xref: /titanic_41/usr/src/uts/sun4v/sys/mach_descrip.h (revision 661b8ac7d0f039c645db17e87130c2c1eebeda1c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _MACH_DESCRIP_H
28 #define	_MACH_DESCRIP_H
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/kstat.h>
35 #include <sys/ksynch.h>
36 #include <sys/mdesc.h>
37 
38 /*
39  * MD memory operations (memops) are of two types:
40  * buf:
41  * 	Buffer allocator routines used to allocate the MD buffer.
42  *	Allocator must support an alignment argument.
43  *
44  * meta:
45  *	Meta allocator routines to allocate meta data strcutures.
46  *	These allocations are small and don't have alignment
47  *	requirements. Examples, md_t handles and the machine_descrip_t
48  *	structure.
49  */
50 typedef struct machine_descrip_memops {
51 	void 		*(*buf_allocp)(size_t size, size_t align);
52 	void 		(*buf_freep)(void *, size_t size);
53 	void 		*(*meta_allocp)(size_t size);
54 	void 		(*meta_freep)(void *, size_t size);
55 } machine_descrip_memops_t;
56 
57 /*
58  * Common structure/list between kernel and mdesc driver enabling
59  * the current machine description to be retrieved or updated.
60  *
61  * Locks:
62  * The current global MD is protected by the curr_mach_descrip_lock.
63  * Each Machine description has a lock to synchronize its ref count.
64  * The Obsolete MD list is protected by the obs_list_lock.
65  */
66 typedef struct machine_descrip_s {
67 	uint64_t	gen;		/* Generation number for MD */
68 	kmutex_t	lock;		/* synchronize access to MD */
69 	void		*va;		/* virtual address */
70 	uint64_t	size;		/* size of MD */
71 	uint64_t	space;		/* space allocated for MD */
72 	int		refcnt;		/* MD ref count */
73 	struct machine_descrip_s *next;	/* Next MD in list */
74 	machine_descrip_memops_t *memops; /* Memory operations for MD */
75 } machine_descrip_t;
76 
77 /*
78  * Utility wrappers to get/fini a handle to the current MD.
79  */
80 extern md_t *md_get_handle(void);
81 extern int md_fini_handle(md_t *);
82 extern caddr_t md_get_md_raw(md_t *);
83 extern int md_alloc_scan_dag(md_t *, mde_cookie_t, char *, char *,
84 	    mde_cookie_t **);
85 extern void md_free_scan_dag(md_t *, mde_cookie_t **);
86 extern uint64_t md_get_current_gen(void);
87 
88 #ifdef __cplusplus
89 }
90 #endif
91 
92 #endif	/* _MACH_DESCRIP_H */
93