17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*1ae08745Sheppo * Common Development and Distribution License (the "License"). 6*1ae08745Sheppo * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 21*1ae08745Sheppo 227c478bd9Sstevel@tonic-gate /* 23*1ae08745Sheppo * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 277c478bd9Sstevel@tonic-gate #ifndef _MACH_DESCRIP_H 287c478bd9Sstevel@tonic-gate #define _MACH_DESCRIP_H 297c478bd9Sstevel@tonic-gate 307c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 36*1ae08745Sheppo #include <sys/kstat.h> 37*1ae08745Sheppo #include <sys/ksynch.h> 38*1ae08745Sheppo #include <sys/mdesc.h> 39*1ae08745Sheppo 407c478bd9Sstevel@tonic-gate /* 41*1ae08745Sheppo * MD memory operations (memops) are of two types: 42*1ae08745Sheppo * buf: 43*1ae08745Sheppo * Buffer allocator routines used to allocate the MD buffer. 44*1ae08745Sheppo * Allocator must support an alignment argument. 45*1ae08745Sheppo * 46*1ae08745Sheppo * meta: 47*1ae08745Sheppo * Meta allocator routines to allocate meta data strcutures. 48*1ae08745Sheppo * These allocations are small and don't have alignment 49*1ae08745Sheppo * requirements. Examples, md_t handles and the machine_descrip_t 50*1ae08745Sheppo * structure. 517c478bd9Sstevel@tonic-gate */ 52*1ae08745Sheppo typedef struct machine_descrip_memops { 53*1ae08745Sheppo void *(*buf_allocp)(size_t size, size_t align); 54*1ae08745Sheppo void (*buf_freep)(void *, size_t size); 55*1ae08745Sheppo void *(*meta_allocp)(size_t size); 56*1ae08745Sheppo void (*meta_freep)(void *, size_t size); 57*1ae08745Sheppo } machine_descrip_memops_t; 587c478bd9Sstevel@tonic-gate 59*1ae08745Sheppo /* 60*1ae08745Sheppo * Common structure/list between kernel and mdesc driver enabling 61*1ae08745Sheppo * the current machine description to be retrieved or updated. 62*1ae08745Sheppo * 63*1ae08745Sheppo * Locks: 64*1ae08745Sheppo * The current global MD is protected by the curr_mach_descrip_lock. 65*1ae08745Sheppo * Each Machine description has a lock to synchronize its ref count. 66*1ae08745Sheppo * The Obsolete MD list is protected by the obs_list_lock. 67*1ae08745Sheppo */ 68*1ae08745Sheppo typedef struct machine_descrip_s { 69*1ae08745Sheppo uint64_t gen; /* Generation number for MD */ 70*1ae08745Sheppo kmutex_t lock; /* synchronize access to MD */ 71*1ae08745Sheppo void *va; /* virtual address */ 72*1ae08745Sheppo uint64_t size; /* size of MD */ 73*1ae08745Sheppo uint64_t space; /* space allocated for MD */ 74*1ae08745Sheppo int refcnt; /* MD ref count */ 75*1ae08745Sheppo struct machine_descrip_s *next; /* Next MD in list */ 76*1ae08745Sheppo machine_descrip_memops_t *memops; /* Memory operations for MD */ 77*1ae08745Sheppo } machine_descrip_t; 787c478bd9Sstevel@tonic-gate 79*1ae08745Sheppo /* 80*1ae08745Sheppo * Utility wrappers to get/fini a handle to the current MD. 81*1ae08745Sheppo */ 82*1ae08745Sheppo extern md_t *md_get_handle(void); 83*1ae08745Sheppo extern int md_fini_handle(md_t *); 84*1ae08745Sheppo extern caddr_t md_get_md_raw(md_t *); 85*1ae08745Sheppo extern int md_alloc_scan_dag(md_t *, mde_cookie_t, char *, char *, 86*1ae08745Sheppo mde_cookie_t **); 87*1ae08745Sheppo extern void md_free_scan_dag(md_t *, mde_cookie_t **); 887c478bd9Sstevel@tonic-gate 897c478bd9Sstevel@tonic-gate #ifdef __cplusplus 907c478bd9Sstevel@tonic-gate } 917c478bd9Sstevel@tonic-gate #endif 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate #endif /* _MACH_DESCRIP_H */ 94