10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51991Sheppo * Common Development and Distribution License (the "License"). 61991Sheppo * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 211991Sheppo 220Sstevel@tonic-gate /* 23*11713SPavel.Tatashin@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate #ifndef _MACH_DESCRIP_H 280Sstevel@tonic-gate #define _MACH_DESCRIP_H 290Sstevel@tonic-gate 300Sstevel@tonic-gate #ifdef __cplusplus 310Sstevel@tonic-gate extern "C" { 320Sstevel@tonic-gate #endif 330Sstevel@tonic-gate 341991Sheppo #include <sys/kstat.h> 351991Sheppo #include <sys/ksynch.h> 361991Sheppo #include <sys/mdesc.h> 371991Sheppo 380Sstevel@tonic-gate /* 391991Sheppo * MD memory operations (memops) are of two types: 401991Sheppo * buf: 411991Sheppo * Buffer allocator routines used to allocate the MD buffer. 421991Sheppo * Allocator must support an alignment argument. 431991Sheppo * 441991Sheppo * meta: 451991Sheppo * Meta allocator routines to allocate meta data strcutures. 461991Sheppo * These allocations are small and don't have alignment 471991Sheppo * requirements. Examples, md_t handles and the machine_descrip_t 481991Sheppo * structure. 490Sstevel@tonic-gate */ 501991Sheppo typedef struct machine_descrip_memops { 511991Sheppo void *(*buf_allocp)(size_t size, size_t align); 521991Sheppo void (*buf_freep)(void *, size_t size); 531991Sheppo void *(*meta_allocp)(size_t size); 541991Sheppo void (*meta_freep)(void *, size_t size); 551991Sheppo } machine_descrip_memops_t; 560Sstevel@tonic-gate 571991Sheppo /* 581991Sheppo * Common structure/list between kernel and mdesc driver enabling 591991Sheppo * the current machine description to be retrieved or updated. 601991Sheppo * 611991Sheppo * Locks: 621991Sheppo * The current global MD is protected by the curr_mach_descrip_lock. 631991Sheppo * Each Machine description has a lock to synchronize its ref count. 641991Sheppo * The Obsolete MD list is protected by the obs_list_lock. 651991Sheppo */ 661991Sheppo typedef struct machine_descrip_s { 671991Sheppo uint64_t gen; /* Generation number for MD */ 681991Sheppo kmutex_t lock; /* synchronize access to MD */ 691991Sheppo void *va; /* virtual address */ 701991Sheppo uint64_t size; /* size of MD */ 711991Sheppo uint64_t space; /* space allocated for MD */ 721991Sheppo int refcnt; /* MD ref count */ 731991Sheppo struct machine_descrip_s *next; /* Next MD in list */ 741991Sheppo machine_descrip_memops_t *memops; /* Memory operations for MD */ 751991Sheppo } machine_descrip_t; 760Sstevel@tonic-gate 771991Sheppo /* 781991Sheppo * Utility wrappers to get/fini a handle to the current MD. 791991Sheppo */ 801991Sheppo extern md_t *md_get_handle(void); 811991Sheppo extern int md_fini_handle(md_t *); 821991Sheppo extern caddr_t md_get_md_raw(md_t *); 831991Sheppo extern int md_alloc_scan_dag(md_t *, mde_cookie_t, char *, char *, 841991Sheppo mde_cookie_t **); 851991Sheppo extern void md_free_scan_dag(md_t *, mde_cookie_t **); 86*11713SPavel.Tatashin@Sun.COM extern uint64_t md_get_current_gen(void); 870Sstevel@tonic-gate 880Sstevel@tonic-gate #ifdef __cplusplus 890Sstevel@tonic-gate } 900Sstevel@tonic-gate #endif 910Sstevel@tonic-gate 920Sstevel@tonic-gate #endif /* _MACH_DESCRIP_H */ 93