]>
Commit | Line | Data |
---|---|---|
1c79356b | 1 | /* |
2d21ac55 | 2 | * Copyright (c) 2000-2007 Apple Inc. All rights reserved. |
1c79356b | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
1c79356b | 5 | * |
2d21ac55 A |
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. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
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 | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
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. | |
8f6c56a5 | 25 | * |
2d21ac55 A |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
27 | */ | |
28 | /* | |
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, | |
32 | * Version 2.0. | |
1c79356b | 33 | */ |
1c79356b | 34 | |
b0d623f7 A |
35 | #ifndef _MACH_KMOD_H_ |
36 | #define _MACH_KMOD_H_ | |
1c79356b A |
37 | |
38 | #include <mach/kern_return.h> | |
b0d623f7 | 39 | #include <mach/mach_types.h> |
1c79356b | 40 | |
91447636 | 41 | #include <sys/cdefs.h> |
9bccf70c | 42 | |
b0d623f7 A |
43 | __BEGIN_DECLS |
44 | ||
45 | #if PRAGMA_MARK | |
46 | #pragma mark Basic macros & typedefs | |
47 | #endif | |
2d21ac55 | 48 | /*********************************************************************** |
b0d623f7 | 49 | * Basic macros & typedefs |
2d21ac55 | 50 | ***********************************************************************/ |
b0d623f7 A |
51 | #define KMOD_MAX_NAME 64 |
52 | ||
53 | #define KMOD_RETURN_SUCCESS KERN_SUCCESS | |
54 | #define KMOD_RETURN_FAILURE KERN_FAILURE | |
1c79356b | 55 | |
1c79356b | 56 | typedef int kmod_t; |
1c79356b | 57 | |
b0d623f7 A |
58 | struct kmod_info; |
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); | |
91447636 | 61 | |
b0d623f7 A |
62 | #if PRAGMA_MARK |
63 | #pragma mark Structure definitions | |
64 | #endif | |
65 | /*********************************************************************** | |
66 | * Structure definitions | |
67 | * | |
68 | * All structures must be #pragma pack(4). | |
69 | ***********************************************************************/ | |
0c530ab8 | 70 | #pragma pack(4) |
9bccf70c | 71 | |
b0d623f7 | 72 | /* Run-time struct only; never saved to a file */ |
1c79356b | 73 | typedef struct kmod_reference { |
b0d623f7 A |
74 | struct kmod_reference * next; |
75 | struct kmod_info * info; | |
1c79356b A |
76 | } kmod_reference_t; |
77 | ||
b0d623f7 A |
78 | /*********************************************************************** |
79 | * Warning: Any changes to the kmod_info structure affect the | |
80 | * KMOD_..._DECL macros below. | |
81 | ***********************************************************************/ | |
91447636 | 82 | |
b0d623f7 A |
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. | |
86 | */ | |
1c79356b | 87 | typedef struct kmod_info { |
b0d623f7 A |
88 | struct kmod_info * next; |
89 | int32_t info_version; // version of this structure | |
90 | uint32_t id; | |
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; | |
1c79356b A |
100 | } kmod_info_t; |
101 | ||
b0d623f7 A |
102 | /* A compatibility definition of kmod_info_t for 32-bit kexts. |
103 | */ | |
104 | typedef struct kmod_info_32_v1 { | |
105 | uint32_t next_addr; | |
106 | int32_t info_version; | |
107 | uint32_t id; | |
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; | |
112 | uint32_t address; | |
113 | uint32_t size; | |
114 | uint32_t hdr_size; | |
115 | uint32_t start_addr; | |
116 | uint32_t stop_addr; | |
117 | } kmod_info_32_v1_t; | |
118 | ||
119 | /* A compatibility definition of kmod_info_t for 64-bit kexts. | |
120 | */ | |
121 | typedef struct kmod_info_64_v1 { | |
122 | uint64_t next_addr; | |
123 | int32_t info_version; | |
124 | uint32_t id; | |
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; | |
129 | uint64_t address; | |
130 | uint64_t size; | |
131 | uint64_t hdr_size; | |
132 | uint64_t start_addr; | |
133 | uint64_t stop_addr; | |
134 | } kmod_info_64_v1_t; | |
1c79356b | 135 | |
b0d623f7 | 136 | #pragma pack() |
91447636 | 137 | |
b0d623f7 A |
138 | #if PRAGMA_MARK |
139 | #pragma mark Kmod structure declaration macros | |
140 | #endif | |
141 | /*********************************************************************** | |
142 | * Kmod structure declaration macros | |
143 | ***********************************************************************/ | |
144 | #define KMOD_INFO_NAME kmod_info | |
145 | #define KMOD_INFO_VERSION 1 | |
146 | ||
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 }; | |
154 | ||
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, \ | |
158 | start, stop }; | |
159 | ||
160 | #if PRAGMA_MARK | |
161 | #pragma mark Kernel private declarations | |
162 | #endif | |
163 | /*********************************************************************** | |
164 | * Kernel private declarations. | |
165 | ***********************************************************************/ | |
166 | #ifdef KERNEL_PRIVATE | |
91447636 | 167 | |
b0d623f7 A |
168 | /* Implementation now in libkern/OSKextLib.cpp. */ |
169 | extern void kmod_panic_dump(vm_offset_t * addr, unsigned int dump_cnt); | |
9bccf70c | 170 | |
b0d623f7 | 171 | #endif /* KERNEL_PRIVATE */ |
1c79356b | 172 | |
1c79356b | 173 | |
b0d623f7 A |
174 | #if PRAGMA_MARK |
175 | #pragma mark Obsolete kmod stuff | |
176 | #endif | |
177 | /*********************************************************************** | |
178 | * These 3 should be dropped but they're referenced by MIG declarations. | |
179 | ***********************************************************************/ | |
180 | typedef void * kmod_args_t; | |
181 | typedef int kmod_control_flavor_t; | |
182 | typedef kmod_info_t * kmod_info_array_t; | |
c910b4d9 | 183 | |
91447636 | 184 | __END_DECLS |
9bccf70c | 185 | |
b0d623f7 | 186 | #endif /* _MACH_KMOD_H_ */ |