xref: /titanic_44/usr/src/uts/sun4v/sys/mach_descrip.h (revision a38ddfee9c8c6b6c5a2947ff52fd2338362a4444)
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 2006 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/kstat.h>
37 #include <sys/ksynch.h>
38 #include <sys/mdesc.h>
39 
40 /*
41  * MD memory operations (memops) are of two types:
42  * buf:
43  * 	Buffer allocator routines used to allocate the MD buffer.
44  *	Allocator must support an alignment argument.
45  *
46  * meta:
47  *	Meta allocator routines to allocate meta data strcutures.
48  *	These allocations are small and don't have alignment
49  *	requirements. Examples, md_t handles and the machine_descrip_t
50  *	structure.
51  */
52 typedef struct machine_descrip_memops {
53 	void 		*(*buf_allocp)(size_t size, size_t align);
54 	void 		(*buf_freep)(void *, size_t size);
55 	void 		*(*meta_allocp)(size_t size);
56 	void 		(*meta_freep)(void *, size_t size);
57 } machine_descrip_memops_t;
58 
59 /*
60  * Common structure/list between kernel and mdesc driver enabling
61  * the current machine description to be retrieved or updated.
62  *
63  * Locks:
64  * The current global MD is protected by the curr_mach_descrip_lock.
65  * Each Machine description has a lock to synchronize its ref count.
66  * The Obsolete MD list is protected by the obs_list_lock.
67  */
68 typedef struct machine_descrip_s {
69 	uint64_t	gen;		/* Generation number for MD */
70 	kmutex_t	lock;		/* synchronize access to MD */
71 	void		*va;		/* virtual address */
72 	uint64_t	size;		/* size of MD */
73 	uint64_t	space;		/* space allocated for MD */
74 	int		refcnt;		/* MD ref count */
75 	struct machine_descrip_s *next;	/* Next MD in list */
76 	machine_descrip_memops_t *memops; /* Memory operations for MD */
77 } machine_descrip_t;
78 
79 /*
80  * Utility wrappers to get/fini a handle to the current MD.
81  */
82 extern md_t *md_get_handle(void);
83 extern int md_fini_handle(md_t *);
84 extern caddr_t md_get_md_raw(md_t *);
85 extern int md_alloc_scan_dag(md_t *, mde_cookie_t, char *, char *,
86 	    mde_cookie_t **);
87 extern void md_free_scan_dag(md_t *, mde_cookie_t **);
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif	/* _MACH_DESCRIP_H */
94