]>
git.saurik.com Git - apple/xnu.git/blob - osfmk/mach/kmod.h
2 * Copyright (c) 2000-2007 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 * NOTICE: This file was modified by SPARTA, Inc. in 2005 to introduce
30 * support for mandatory and extensible security protections. This notice
31 * is included in support of clause 2.2 (b) of the Apple Public License,
38 #include <mach/kern_return.h>
39 #include <mach/mach_types.h>
41 #include <sys/cdefs.h>
46 #pragma mark Basic macros & typedefs
48 /***********************************************************************
49 * Basic macros & typedefs
50 ***********************************************************************/
51 #define KMOD_MAX_NAME 64
53 #define KMOD_RETURN_SUCCESS KERN_SUCCESS
54 #define KMOD_RETURN_FAILURE KERN_FAILURE
59 typedef kern_return_t
kmod_start_func_t(struct kmod_info
* ki
, void * data
);
60 typedef kern_return_t
kmod_stop_func_t(struct kmod_info
* ki
, void * data
);
63 #pragma mark Structure definitions
65 /***********************************************************************
66 * Structure definitions
68 * All structures must be #pragma pack(4).
69 ***********************************************************************/
72 /* Run-time struct only; never saved to a file */
73 typedef struct kmod_reference
{
74 struct kmod_reference
* next
;
75 struct kmod_info
* info
;
78 /***********************************************************************
79 * Warning: Any changes to the kmod_info structure affect the
80 * KMOD_..._DECL macros below.
81 ***********************************************************************/
83 /* The kmod_info_t structure is only safe to use inside the running
84 * kernel. If you need to work with a kmod_info_t structure outside
85 * the kernel, please use the compatibility definitions below.
87 typedef struct kmod_info
{
88 struct kmod_info
* next
;
89 int32_t info_version
; // version of this structure
91 char name
[KMOD_MAX_NAME
];
92 char version
[KMOD_MAX_NAME
];
93 int32_t reference_count
; // # linkage refs to this
94 kmod_reference_t
* reference_list
; // who this refs (links on)
95 vm_address_t address
; // starting address
96 vm_size_t size
; // total size
97 vm_size_t hdr_size
; // unwired hdr size
98 kmod_start_func_t
* start
;
99 kmod_stop_func_t
* stop
;
102 /* A compatibility definition of kmod_info_t for 32-bit kexts.
104 typedef struct kmod_info_32_v1
{
106 int32_t info_version
;
108 uint8_t name
[KMOD_MAX_NAME
];
109 uint8_t version
[KMOD_MAX_NAME
];
110 int32_t reference_count
;
111 uint32_t reference_list_addr
;
119 /* A compatibility definition of kmod_info_t for 64-bit kexts.
121 typedef struct kmod_info_64_v1
{
123 int32_t info_version
;
125 uint8_t name
[KMOD_MAX_NAME
];
126 uint8_t version
[KMOD_MAX_NAME
];
127 int32_t reference_count
;
128 uint64_t reference_list_addr
;
139 #pragma mark Kmod structure declaration macros
141 /***********************************************************************
142 * Kmod structure declaration macros
143 ***********************************************************************/
144 #define KMOD_INFO_NAME kmod_info
145 #define KMOD_INFO_VERSION 1
147 #define KMOD_DECL(name, version) \
148 static kmod_start_func_t name ## _module_start; \
149 static kmod_stop_func_t name ## _module_stop; \
150 kmod_info_t KMOD_INFO_NAME = { 0, KMOD_INFO_VERSION, -1U, \
151 { #name }, { version }, -1, 0, 0, 0, 0, \
152 name ## _module_start, \
153 name ## _module_stop };
155 #define KMOD_EXPLICIT_DECL(name, version, start, stop) \
156 kmod_info_t KMOD_INFO_NAME = { 0, KMOD_INFO_VERSION, -1U, \
157 { #name }, { version }, -1, 0, 0, 0, 0, \
161 #pragma mark Kernel private declarations
163 /***********************************************************************
164 * Kernel private declarations.
165 ***********************************************************************/
166 #ifdef KERNEL_PRIVATE
168 /* Implementation now in libkern/OSKextLib.cpp. */
169 extern void kmod_panic_dump(vm_offset_t
* addr
, unsigned int dump_cnt
);
173 * DTrace can take a flag indicating whether it should instrument
174 * probes immediately based on kernel symbols. This per kext
175 * flag overrides system mode in dtrace_modload().
177 #define KMOD_DTRACE_FORCE_INIT 0x01
178 #endif /* CONFIG_DTRACE */
180 #endif /* KERNEL_PRIVATE */
184 #pragma mark Obsolete kmod stuff
186 /***********************************************************************
187 * These 3 should be dropped but they're referenced by MIG declarations.
188 ***********************************************************************/
189 typedef void * kmod_args_t
;
190 typedef int kmod_control_flavor_t
;
191 typedef kmod_info_t
* kmod_info_array_t
;
195 #endif /* _MACH_KMOD_H_ */