1 | /*␊ |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
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.␊ |
14 | * ␊ |
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␊ |
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.␊ |
25 | * ␊ |
26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@␊ |
27 | */␊ |
28 | #ifndef _PEXPERT_I386_BOOT_H␊ |
29 | #define _PEXPERT_I386_BOOT_H␊ |
30 | ␊ |
31 | #include <stdint.h>␊ |
32 | ␊ |
33 | /*␊ |
34 | * What the booter leaves behind for the kernel.␊ |
35 | */␊ |
36 | ␊ |
37 | /*␊ |
38 | * Types of boot driver that may be loaded by the booter.␊ |
39 | */␊ |
40 | enum {␊ |
41 | kBootDriverTypeInvalid = 0,␊ |
42 | kBootDriverTypeKEXT = 1,␊ |
43 | kBootDriverTypeMKEXT = 2␊ |
44 | };␊ |
45 | ␊ |
46 | enum {␊ |
47 | kEfiReservedMemoryType␉= 0,␊ |
48 | kEfiLoaderCode␉␉= 1,␊ |
49 | kEfiLoaderData␉␉= 2,␊ |
50 | kEfiBootServicesCode␉= 3,␊ |
51 | kEfiBootServicesData␉= 4,␊ |
52 | kEfiRuntimeServicesCode␉= 5,␊ |
53 | kEfiRuntimeServicesData␉= 6,␊ |
54 | kEfiConventionalMemory␉= 7,␊ |
55 | kEfiUnusableMemory␉␉= 8,␊ |
56 | kEfiACPIReclaimMemory␉= 9,␊ |
57 | kEfiACPIMemoryNVS␉␉= 10,␊ |
58 | kEfiMemoryMappedIO␉␉= 11,␊ |
59 | kEfiMemoryMappedIOPortSpace = 12,␊ |
60 | kEfiPalCode␉␉␉= 13,␊ |
61 | kEfiMaxMemoryType␉␉= 14␊ |
62 | };␊ |
63 | ␊ |
64 | /*␊ |
65 | * Memory range descriptor.␊ |
66 | */␊ |
67 | typedef struct EfiMemoryRange {␊ |
68 | uint32_t Type;␊ |
69 | uint32_t Pad;␊ |
70 | uint64_t PhysicalStart;␊ |
71 | uint64_t VirtualStart;␊ |
72 | uint64_t NumberOfPages;␊ |
73 | uint64_t Attribute;␊ |
74 | } EfiMemoryRange;␊ |
75 | ␊ |
76 | #define BOOT_LINE_LENGTH 1024␊ |
77 | #define BOOT_STRING_LEN BOOT_LINE_LENGTH␊ |
78 | ␊ |
79 | /*␊ |
80 | * Video information.. ␊ |
81 | */␊ |
82 | ␊ |
83 | struct Boot_VideoV1 {␊ |
84 | ␉uint32_t␉v_baseAddr;␉/* Base address of video memory */␊ |
85 | ␉uint32_t␉v_display;␉/* Display Code (if Applicable */␊ |
86 | ␉uint32_t␉v_rowBytes;␉/* Number of bytes per pixel row */␊ |
87 | ␉uint32_t␉v_width;␉/* Width */␊ |
88 | ␉uint32_t␉v_height;␉/* Height */␊ |
89 | ␉uint32_t␉v_depth;␉/* Pixel Depth */␊ |
90 | };␊ |
91 | typedef struct Boot_VideoV1␉Boot_VideoV1;␊ |
92 | ␊ |
93 | struct Boot_Video␊ |
94 | {␊ |
95 | ␉uint32_t␉v_display;␉␉// Display Code (if Applicable).␊ |
96 | ␉uint32_t␉v_rowBytes;␉␉// Number of bytes per pixel row.␊ |
97 | ␉uint32_t␉v_width;␉␉// Width.␊ |
98 | ␉uint32_t␉v_height;␉␉// Height.␊ |
99 | ␉uint32_t␉v_depth;␉␉// Pixel Depth.␊ |
100 | ␉uint32_t␉v_resv[7];␉␉// Reserved.␊ |
101 | ␉uint64_t␉v_baseAddr;␉␉// Base address (64-bit) of video memory.␊ |
102 | };␊ |
103 | typedef struct Boot_Video␉Boot_Video;␊ |
104 | ␊ |
105 | /* Values for v_display */␊ |
106 | ␊ |
107 | #define GRAPHICS_MODE␉␉␉1␊ |
108 | #define FB_TEXT_MODE␉␉␉2␊ |
109 | ␊ |
110 | ␊ |
111 | /* Struct describing an image passed in by the booter */␊ |
112 | struct boot_icon_element {␊ |
113 | unsigned int width;␊ |
114 | unsigned int height;␊ |
115 | int y_offset_from_center;␊ |
116 | unsigned int data_size;␊ |
117 | unsigned int __reserved1[4];␊ |
118 | unsigned char data[0];␊ |
119 | };␊ |
120 | typedef struct boot_icon_element boot_icon_element;␊ |
121 | ␊ |
122 | /* Boot argument structure - passed into Mach kernel at boot time.␊ |
123 | * "Revision" can be incremented for compatible changes␊ |
124 | */␊ |
125 | // Lion␊ |
126 | #define kBootArgsRevision␉␉0␊ |
127 | #define kBootArgsVersion␉␉2␊ |
128 | ␊ |
129 | // Snow Leopard and older␊ |
130 | #define kBootArgsLegacyVersion␉␉1␊ |
131 | #define kBootArgsLegacyRevision␉␉6␊ |
132 | ␊ |
133 | /* Snapshot constants of previous revisions that are supported */␊ |
134 | #define kBootArgsVersion1␉␉1␊ |
135 | #define kBootArgsVersion2␉␉2␊ |
136 | #define kBootArgsRevision2_0␉␉0␊ |
137 | ␊ |
138 | #define kBootArgsEfiMode32 32␊ |
139 | #define kBootArgsEfiMode64 64␊ |
140 | ␊ |
141 | /* Bitfields for boot_args->flags */␊ |
142 | #define kBootArgsFlagRebootOnPanic␉(1 << 0)␊ |
143 | #define kBootArgsFlagHiDPI␉␉(1 << 1)␊ |
144 | #define kBootArgsFlagBlack␉␉(1 << 2)␊ |
145 | #define kBootArgsFlagCSRActiveConfig␉(1 << 3)␊ |
146 | #define kBootArgsFlagCSRConfigMode␉(1 << 4)␊ |
147 | #define kBootArgsFlagCSRBoot␉␉(1 << 5)␊ |
148 | #define kBootArgsFlagBlackBg␉␉(1 << 6)␊ |
149 | #define kBootArgsFlagLoginUI␉␉(1 << 7)␊ |
150 | #define kBootArgsFlagInstallUI␉␉(1 << 8)␊ |
151 | #define kBootArgsFlagUnknownHS␉␉(1 << 9)␉// 512 (High Sierra only)␊ |
152 | ␊ |
153 | /* Rootless configuration flags */␊ |
154 | // http://www.idelta.info/archives/kext-to-check-sip-rootless-status-on-el-capitan/␊ |
155 | #define CSR_ALLOW_UNTRUSTED_KEXTS␉␉(1 << 0) /* Allow untrusted kexts */␊ |
156 | #define CSR_ALLOW_UNRESTRICTED_FS␉␉(1 << 1) /* Allow unrestricted file system. */␊ |
157 | #define CSR_ALLOW_TASK_FOR_PID␉␉␉(1 << 2) /* Allow test_for_pid() */␊ |
158 | #define CSR_ALLOW_KERNEL_DEBUGGER␉␉(1 << 3)␊ |
159 | #define CSR_ALLOW_APPLE_INTERNAL␉␉(1 << 4)␊ |
160 | #define CSR_ALLOW_UNRESTRICTED_DTRACE␉␉(1 << 5) /* Allow unrestricted dtrace */␊ |
161 | #define CSR_ALLOW_UNRESTRICTED_NVRAM␉␉(1 << 6) /* Allow unrestricted NVRAM */␊ |
162 | #define CSR_ALLOW_DEVICE_CONFIGURATION␉␉(1 << 7) /* Allow device configuration */␊ |
163 | #define CSR_ALLOW_ANY_RECOVERY_OS␉␉(1 << 8)␊ |
164 | #define CSR_ALLOW_UNAPPROVED_KEXTS␉␉(1 << 9)␊ |
165 | ␊ |
166 | #define CSR_VALID_FLAGS (CSR_ALLOW_UNTRUSTED_KEXTS | \␊ |
167 | ␉␉CSR_ALLOW_UNRESTRICTED_FS | \␊ |
168 | ␉␉CSR_ALLOW_TASK_FOR_PID | \␊ |
169 | ␉␉CSR_ALLOW_KERNEL_DEBUGGER | \␊ |
170 | ␉␉CSR_ALLOW_APPLE_INTERNAL | \␊ |
171 | ␉␉CSR_ALLOW_UNRESTRICTED_DTRACE | \␊ |
172 | ␉␉CSR_ALLOW_UNRESTRICTED_NVRAM | \␊ |
173 | ␉␉CSR_ALLOW_DEVICE_CONFIGURATION | \␊ |
174 | ␉␉CSR_ALLOW_ANY_RECOVERY_OS | \␊ |
175 | ␉␉CSR_ALLOW_UNAPPROVED_KEXTS)␊ |
176 | ␊ |
177 | /* CSR capabilities that a booter can give to the system */␊ |
178 | #define CSR_CAPABILITY_UNLIMITED␉␉␉(1 << 0)␊ |
179 | #define CSR_CAPABILITY_CONFIG␉␉␉␉(1 << 1)␊ |
180 | #define CSR_CAPABILITY_APPLE_INTERNAL␉␉␉(1 << 2)␊ |
181 | ␊ |
182 | #define CSR_VALID_CAPABILITIES (CSR_CAPABILITY_UNLIMITED | CSR_CAPABILITY_CONFIG | CSR_CAPABILITY_APPLE_INTERNAL)␊ |
183 | ␊ |
184 | typedef struct boot_args␊ |
185 | {␊ |
186 | uint16_t Revision;␉/* Revision of boot_args structure */␊ |
187 | uint16_t Version;␉/* Version of boot_args structure */␊ |
188 | ␊ |
189 | uint8_t efiMode; /* 32 means 32-bit mode, 64 means 64-bit mode */␊ |
190 | uint8_t debugMode; /* Bit field with behavior changes */␊ |
191 | uint16_t flags;␊ |
192 | ␊ |
193 | char CommandLine[BOOT_LINE_LENGTH];␉/* Passed in command line */␊ |
194 | ␊ |
195 | uint32_t MemoryMap; /* Physical address of memory map */␊ |
196 | uint32_t MemoryMapSize;␊ |
197 | uint32_t MemoryMapDescriptorSize;␊ |
198 | uint32_t MemoryMapDescriptorVersion;␊ |
199 | ␊ |
200 | Boot_VideoV1␉VideoV1;␉␉/* Video Information */␊ |
201 | ␊ |
202 | uint32_t deviceTreeP;␉ /* Physical address of flattened device tree */␊ |
203 | uint32_t deviceTreeLength; /* Length of flattened tree */␊ |
204 | ␊ |
205 | uint32_t kaddr; /* Physical address of beginning of kernel text */␊ |
206 | uint32_t ksize; /* Size of combined kernel text+data+efi */␊ |
207 | ␊ |
208 | uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */␊ |
209 | uint32_t efiRuntimeServicesPageCount;␊ |
210 | uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */␊ |
211 | ␊ |
212 | uint32_t efiSystemTable; /* physical address of system table in runtime area */␊ |
213 | uint32_t kslide;␊ |
214 | ␊ |
215 | uint32_t performanceDataStart; /* physical address of log */␊ |
216 | uint32_t performanceDataSize;␊ |
217 | ␊ |
218 | uint32_t keyStoreDataStart; /* physical address of key store data */␊ |
219 | uint32_t keyStoreDataSize;␊ |
220 | uint64_t␉bootMemStart;␊ |
221 | uint64_t␉bootMemSize;␊ |
222 | uint64_t PhysicalMemorySize;␊ |
223 | uint64_t FSBFrequency;␊ |
224 | ␊ |
225 | uint64_t pciConfigSpaceBaseAddress;␊ |
226 | uint32_t pciConfigSpaceStartBusNumber;␊ |
227 | uint32_t pciConfigSpaceEndBusNumber;␊ |
228 | ␊ |
229 | uint32_t csrActiveConfig;␊ |
230 | uint32_t csrCapabilities;␊ |
231 | uint32_t boot_SMC_plimit;␊ |
232 | uint16_t␉bootProgressMeterStart;␊ |
233 | uint16_t␉bootProgressMeterEnd;␊ |
234 | ␊ |
235 | Boot_Video Video; /* Video Information */␊ |
236 | ␊ |
237 | uint32_t␉apfsDataStart;␉␉␉␉␉␉// Physical address of apfs volume key structure.␊ |
238 | uint32_t␉apfsDataSize;␊ |
239 | ␊ |
240 | uint32_t __reserved4[710];␊ |
241 | ␊ |
242 | } boot_args;␊ |
243 | ␊ |
244 | typedef struct boot_args_legacy␊ |
245 | {␊ |
246 | uint16_t Revision;␉/* Revision of boot_args structure */␊ |
247 | uint16_t Version;␉/* Version of boot_args structure */␊ |
248 | ␊ |
249 | char CommandLine[BOOT_LINE_LENGTH];␉/* Passed in command line */␊ |
250 | ␊ |
251 | uint32_t MemoryMap; /* Physical address of memory map */␊ |
252 | uint32_t MemoryMapSize;␊ |
253 | uint32_t MemoryMapDescriptorSize;␊ |
254 | uint32_t MemoryMapDescriptorVersion;␊ |
255 | ␊ |
256 | Boot_VideoV1␉Video;␉␉/* Video Information */␊ |
257 | ␊ |
258 | uint32_t deviceTreeP;␉ /* Physical address of flattened device tree */␊ |
259 | uint32_t deviceTreeLength; /* Length of flattened tree */␊ |
260 | ␊ |
261 | uint32_t kaddr; /* Physical address of beginning of kernel text */␊ |
262 | uint32_t ksize; /* Size of combined kernel text+data+efi */␊ |
263 | ␊ |
264 | uint32_t efiRuntimeServicesPageStart; /* physical address of defragmented runtime pages */␊ |
265 | uint32_t efiRuntimeServicesPageCount;␊ |
266 | ␊ |
267 | uint32_t efiSystemTable; /* physical address of system table in runtime area */␊ |
268 | ␊ |
269 | uint8_t efiMode; /* 32 means 32-bit mode, 64 means 64-bit mode */␊ |
270 | uint8_t __reserved1[3];␊ |
271 | uint32_t __reserved2[1];␊ |
272 | uint32_t performanceDataStart; /* physical address of log */␊ |
273 | uint32_t performanceDataSize;␊ |
274 | uint64_t efiRuntimeServicesVirtualPageStart; /* virtual address of defragmented runtime pages */␊ |
275 | uint32_t __reserved3[2];␊ |
276 | ␊ |
277 | } boot_args_legacy;␊ |
278 | ␊ |
279 | #endif /* _PEXPERT_I386_BOOT_H */␊ |
280 | |