1 | /*␊ |
2 | * Copyright (c) 1999-2003 Apple Computer, Inc. All rights reserved.␊ |
3 | *␊ |
4 | * @APPLE_LICENSE_HEADER_START@␊ |
5 | * ␊ |
6 | * Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights␊ |
7 | * Reserved. This file contains Original Code and/or Modifications of␊ |
8 | * Original Code as defined in and that are subject to the Apple Public␊ |
9 | * Source License Version 2.0 (the "License"). You may not use this file␊ |
10 | * except in compliance with the License. Please obtain a copy of the␊ |
11 | * License at http://www.apple.com/publicsource and read it before using␊ |
12 | * this file.␊ |
13 | * ␊ |
14 | * The Original Code and all software distributed under the License are␊ |
15 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER␊ |
16 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,␊ |
17 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,␊ |
18 | * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the␊ |
19 | * License for the specific language governing rights and limitations␊ |
20 | * under the License.␊ |
21 | * ␊ |
22 | * @APPLE_LICENSE_HEADER_END@␊ |
23 | *␊ |
24 | * Copyright 1994 NeXT Computer, Inc. All rights reserved.␊ |
25 | */␊ |
26 | ␊ |
27 | #ifndef __BOOT2_BOOT_H␊ |
28 | #define __BOOT2_BOOT_H␊ |
29 | ␊ |
30 | #include "libsaio.h"␊ |
31 | ␊ |
32 | // OS X Versions␊ |
33 | #define ELCAPITAN checkOSVersion("10.11") // El Capitan␊ |
34 | #define YOSEMITE checkOSVersion("10.10") // Yosemite␊ |
35 | #define MAVERICKS checkOSVersion("10.9") // Mavericks␊ |
36 | #define MOUNTAIN_LION checkOSVersion("10.8") // Mountain Lion␊ |
37 | #define LION checkOSVersion("10.7") // Lion␊ |
38 | #define SNOW_LEOPARD checkOSVersion("10.6") // Snow Leopard␊ |
39 | #define LEOPARD checkOSVersion("10.5") // Leopard␊ |
40 | #define TIGER checkOSVersion("10.4") // Tiger␊ |
41 | ␊ |
42 | /*␊ |
43 | * Paths used by chameleon␊ |
44 | */␊ |
45 | ␊ |
46 | // kernel cache␊ |
47 | #define kDefaultCachePathLeo␉␉"/System/Library/Caches/com.apple.kernelcaches/"␊ |
48 | #define kDefaultCachePathSnow␉␉"/System/Library/Caches/com.apple.kext.caches/Startup/"␊ |
49 | ␊ |
50 | // Lion installer␊ |
51 | #define kLionInstallerDataFolder␉"/Mac OS X Install Data/"␊ |
52 | #define kLionInstallerPlist␉␉kLionInstallerDataFolder "com.apple.Boot.plist"␊ |
53 | ␊ |
54 | // Mountain Lion installer␊ |
55 | #define kMLionInstallerDataFolder␉"/OS X Install Data/"␊ |
56 | #define kMLionInstallerPlist␉␉kMLionInstallerDataFolder "com.apple.Boot.plist"␊ |
57 | ␊ |
58 | //kernel path␊ |
59 | #define kDefaultKernelPathPreYos␉"/"␊ |
60 | #define kDefaultKernelPathForYos␉"/System/Library/Kernels/" //for Yosemite and El Capitan␊ |
61 | ␊ |
62 | /*␊ |
63 | * Keys used in system Boot.plist␊ |
64 | */␊ |
65 | #define kGraphicsModeKey␉␉"Graphics Mode"␊ |
66 | #define kTextModeKey␉␉␉"Text Mode"␊ |
67 | #define kQuietBootKey␉␉␉"Quiet Boot"␊ |
68 | #define kKernelFlagsKey␉␉␉"Kernel Flags"␊ |
69 | #define kKernelArchKey␉␉␉"Kernel Architecture"␊ |
70 | #define kMKextCacheKey␉␉␉"MKext Cache"␊ |
71 | #define kKernelNameKey␉␉␉"Kernel"␊ |
72 | #define kKernelCacheKey␉␉␉"Kernel Cache"␊ |
73 | #define kUseKernelCache␉␉␉"UseKernelCache"␉/* boot.c */␊ |
74 | #define kBootDeviceKey␉␉␉"Boot Device"␊ |
75 | #define kTimeoutKey␉␉␉"Timeout"␊ |
76 | #define kRootDeviceKey␉␉␉"rd"␊ |
77 | #define kBootUUIDKey␉␉␉"boot-uuid"␊ |
78 | #define kHelperRootUUIDKey␉␉"Root UUID"␊ |
79 | #define kPlatformKey␉␉␉"platform"␊ |
80 | #define kACPIKey␉␉␉"acpi"␊ |
81 | #define kCDROMPromptKey␉␉␉"CD-ROM Prompt"␊ |
82 | #define kCDROMOptionKey␉␉␉"CD-ROM Option Key"␊ |
83 | #define kRescanPromptKey␉␉"Rescan Prompt"␊ |
84 | #define kRescanKey␉␉␉"Rescan"␊ |
85 | #define kScanSingleDriveKey␉␉"Scan Single Drive"␊ |
86 | #define kInstantMenuKey␉␉␉"Instant Menu"␊ |
87 | #define kDefaultKernel␉␉␉"mach_kernel"␊ |
88 | #define kOSXKernel␉␉␉"kernel"␉␉// Yosemite+␊ |
89 | #define kGUIKey␉␉␉␉"GUI"␊ |
90 | #define kBootBannerKey␉␉␉"Boot Banner"␊ |
91 | #define kShowInfoKey␉␉␉"ShowInfo"␉␉// gui.c␊ |
92 | #define kWaitForKeypressKey␉␉"Wait"␊ |
93 | ␊ |
94 | /* AsereBLN: added these keys */␊ |
95 | #define kUseAtiROM␉␉␉"UseAtiROM"␉␉/* ati.c */␊ |
96 | #define kWake␉␉␉␉"Wake"␉␉␉/* boot.c */␊ |
97 | #define kForceWake␉␉␉"ForceWake"␉␉/* boot.c */␊ |
98 | #define kWakeImage␉␉␉"WakeImage"␉␉/* boot.c */␊ |
99 | #define kProductVersion␉␉␉"ProductVersion"␉/* boot.c */␊ |
100 | #define karch␉␉␉␉"arch"␉␉␉/* boot.c */␊ |
101 | #define kDSDT␉␉␉␉"DSDT"␉␉␉/* acpi_patcher.c */␊ |
102 | #define kDropSSDT␉␉␉"DropSSDT"␉␉/* acpi_patcher.c */␊ |
103 | #define kDeviceProperties␉␉"device-properties"␉/* device_inject.c */␊ |
104 | #define kHidePartition␉␉␉"Hide Partition"␉/* disk.c */␊ |
105 | #define kRenamePartition␉␉"Rename Partition"␉/* disk.c */␊ |
106 | #define kSMBIOSKey␉␉␉"SMBIOS"␉␉/* fake_efi.c */␊ |
107 | //#define kSystemID␉␉␉"SystemId"␉␉/* fake_efi.c */␊ |
108 | #define kSystemType␉␉␉"SystemType"␉␉/* fake_efi.c */␊ |
109 | #define kUseNvidiaROM␉␉␉"UseNvidiaROM"␉␉/* nvidia.c */␊ |
110 | #define kVBIOS␉␉␉␉"VBIOS"␉␉␉/* nvidia.c && ati.c */␊ |
111 | #define kPCIRootUID␉␉␉"PCIRootUID"␉␉/* pci_root.c */␊ |
112 | #define kEthernetBuiltIn␉␉"EthernetBuiltIn"␉/* networking.c */␊ |
113 | #define kGraphicsEnabler␉␉"GraphicsEnabler"␉/* pci_setup.c */␊ |
114 | #define kForceHPET␉␉␉"ForceHPET"␉␉/* pci_setup.c */␊ |
115 | #define kUseMemDetect␉␉␉"UseMemDetect"␉␉/* platform.c */␊ |
116 | #define kSMBIOSdefaults␉␉␉"SMBIOSdefaults"␉/* smbios_patcher.c */␊ |
117 | #define kUSBBusFix␉␉␉"USBBusFix"␉␉/* usb.c */␊ |
118 | #define kEHCIacquire␉␉␉"EHCIacquire"␉␉/* usb.c */␊ |
119 | #define kUHCIreset␉␉␉"UHCIreset"␉␉/* usb.c */␊ |
120 | #define kEHCIhard␉␉␉"EHCIhard"␉␉/* usb.c */␊ |
121 | #define kDefaultPartition␉␉"Default Partition"␉/* sys.c */␊ |
122 | ␊ |
123 | /* Zenith432: added this key */␊ |
124 | #define kXHCILegacyOff␉␉␉"XHCILegacyOff"␉␉/* usb.c */␊ |
125 | ␊ |
126 | /* Duvel300: added this key */␊ |
127 | #define kRestartFix␉␉␉"RestartFix"␉␉/* acpi_patcher.c */␊ |
128 | ␊ |
129 | /* Slice: added these keys */␊ |
130 | #define kPS2RestartFix␉␉␉"PS2RestartFix"␉␉/* acpi_patcher.c */␊ |
131 | #define kUseIntelHDMI␉␉␉"UseIntelHDMI"␉␉/* ati.c && nvidia.c && gma.c */␊ |
132 | #define kNvidiaSingle␉␉␉"NvidiaSingle"␉␉/* nvidia.c */␊ |
133 | ␊ |
134 | /* Signal64: added this key */␊ |
135 | #define kLegacyOff␉␉␉"USBLegacyOff"␉␉/* usb.c */␊ |
136 | ␊ |
137 | /* Lebidou: added this key */␊ |
138 | ␊ |
139 | /* Meklort: added these keys */␊ |
140 | #define kMD0Image␉␉␉"md0"␉␉␉/* ramdisk.h */␊ |
141 | #define kEnableWifi␉␉␉"EnableWifi"␉␉/* networking.c */␊ |
142 | ␊ |
143 | /* Andyvand: added these keys */␊ |
144 | //#define kSSDT␉␉␉␉"SSDT"␉␉␉/* acpi_patcher.c */␊ |
145 | #define kHPET␉␉␉␉"HPET"␉␉␉/* acpi_patcher.c */␊ |
146 | #define kSBST␉␉␉␉"SBST"␉␉␉/* acpi_patcher.c */␊ |
147 | #define kECDT␉␉␉␉"ECDT"␉␉␉/* acpi_patcher.c */␊ |
148 | #define kASFT␉␉␉␉"ASFT"␉␉␉/* acpi_patcher.c */␊ |
149 | #define kDMAR␉␉␉␉"DMAR"␉␉␉/* acpi_patcher.c */␊ |
150 | #define kFADT␉␉␉␉"FADT"␉␉␉/* acpi_patcher.c */␊ |
151 | #define kAPIC␉␉␉␉"APIC"␉␉␉/* acpi_patcher.c */␊ |
152 | #define kMCFG␉␉␉␉"MCFG"␉␉␉/* acpi_patcher.c */␊ |
153 | #define kDropHPET␉␉␉"DropHPET"␉␉/* acpi_patcher.c */␊ |
154 | #define kDropSLIC␉␉␉"DropSLIC"␉␉/* acpi_patcher.c */␊ |
155 | #define kDropSBST␉␉␉"DropSBST"␉␉/* acpi_patcher.c */␊ |
156 | #define kDropECDT␉␉␉"DropECDT"␉␉/* acpi_patcher.c */␊ |
157 | #define kDropASFT␉␉␉"DropASFT"␉␉/* acpi_patcher.c */␊ |
158 | #define kDropDMAR␉␉␉"DropDMAR"␉␉/* acpi_patcher.c */␊ |
159 | ␊ |
160 | /* Mojodojo: added these keys */␊ |
161 | #define kGeneratePStates␉␉"GeneratePStates"␉␉/* acpi_patcher.c */␊ |
162 | #define kGenerateCStates␉␉"GenerateCStates"␉␉/* acpi_patcher.c */␊ |
163 | #define kCSTUsingSystemIO␉␉"CSTUsingSystemIO"␉␉/* acpi_patcher.c */␊ |
164 | #define kEnableC2State␉␉␉"EnableC2State"␉␉␉/* acpi_patcher.c */␊ |
165 | #define kEnableC3State␉␉␉"EnableC3State"␉␉␉/* acpi_patcher.c */␊ |
166 | #define kEnableC4State␉␉␉"EnableC4State"␉␉␉/* acpi_patcher.c */␊ |
167 | #define kEnableC6State␉␉␉"EnableC6State"␉␉␉/* acpi_patcher.c */␊ |
168 | #define kEnableC7State␉␉␉"EnableC7State"␉␉␉/* acpi_patcher.c */␊ |
169 | ␊ |
170 | /* valv: added these keys */␊ |
171 | #define kbusratio␉␉␉"busratio"␉␉␉/* cpu.c */␊ |
172 | #define kDcfg0␉␉␉␉"display_0"␉␉␉/* nvidia.c */␊ |
173 | #define kDcfg1␉␉␉␉"display_1"␉␉␉/* nvidia.c */␊ |
174 | ␊ |
175 | /* Marchrius: added this key */␊ |
176 | #define kEnableBacklight␉␉"EnableBacklight"␉␉/* nvidia.c */␊ |
177 | ␊ |
178 | /* Kabyl: added these keys */␊ |
179 | #define kAtiConfig␉␉␉"AtiConfig"␉␉␉/* ati.c */␊ |
180 | #define kAtiPorts␉␉␉"AtiPorts"␉␉␉/* ati.c */␊ |
181 | #define kATYbinimage␉␉␉"ATYbinimage"␉␉␉/* ati.c */␊ |
182 | ␊ |
183 | /* cosmo1: added these keys */␊ |
184 | #define kEnableHDMIAudio␉␉"EnableHDMIAudio"␉␉/* ati.c && nvidia.c */␊ |
185 | ␊ |
186 | /* cparm: added these keys */␊ |
187 | ␊ |
188 | /* ErmaC: added these keys */␊ |
189 | #define kEnableDualLink␉␉␉"EnableDualLink"␉␉/* ati.c && nvidia.c && gma.c*/␊ |
190 | #define kNvidiaGeneric␉␉␉"NvidiaGeneric"␉␉␉/* nvidia.c */␊ |
191 | #define kSkipIntelGfx␉␉␉"SkipIntelGfx"␉␉␉/* pci_setup.c */␊ |
192 | #define kSkipNvidiaGfx␉␉␉"SkipNvidiaGfx"␉␉␉/* pci_setup.c */␊ |
193 | #define kSkipAtiGfx␉␉␉"SkipAtiGfx"␉␉␉/* pci_setup.c */␊ |
194 | #define kIntelCapriFB␉␉␉"IntelCapriFB"␉␉␉/* gma.c was HD4K-ig */␊ |
195 | #define kIntelAzulFB␉␉␉"IntelAzulFB"␉␉␉/* gma.c was HD5K-ig */␊ |
196 | #define kIntelBdwFB␉␉␉"IntelBdwFB"␉␉␉/* gma.c */␊ |
197 | #define kAAPLCustomIG␉␉␉"InjectIntel-ig"␉␉/* gma.c */␊ |
198 | #define kHDAEnabler␉␉␉"HDAEnabler"␉␉␉/* pci_setup.c */␊ |
199 | #define kHDEFLayoutID␉␉␉"HDEFLayoutID"␉␉␉/* hda.c */␊ |
200 | #define kHDAULayoutID␉␉␉"HDAULayoutID"␉␉␉/* hda.c */␊ |
201 | #define kBGRT␉␉␉␉"BGRT"␉␉␉␉/* acpi_patcher.c */␊ |
202 | #define kDropBGRT␉␉␉"DropBGRT"␉␉␉/* acpi_patcher.c */␊ |
203 | #define kDropMCFG␉␉␉"DropMCFG"␉␉␉/* acpi_patcher.c */␊ |
204 | #define kDropAPIC␉␉␉"DropAPIC"␉␉␉/* acpi_patcher.c */␊ |
205 | ␊ |
206 | /* Karas: added this key */␊ |
207 | #define kMemFullInfo␉␉␉"ForceFullMemInfo"␉␉/* smbios.c */␊ |
208 | ␊ |
209 | /* Bungo: added this key */␊ |
210 | #define kPrivateData␉␉␉"PrivateData"␉␉␉/* smbios_decode.c */␊ |
211 | ␊ |
212 | ␊ |
213 | /*␊ |
214 | * Flags to the booter or kernel␊ |
215 | */␊ |
216 | #define kVerboseModeFlag␉␉"-v"␊ |
217 | #define kSafeModeFlag␉␉␉"-x"␊ |
218 | #define kIgnoreCachesFlag␉␉"-f"␊ |
219 | #define kIgnoreBootFileFlag␉␉"-F"␊ |
220 | #define kSingleUserModeFlag␉␉"-s"␊ |
221 | ␊ |
222 | /*␊ |
223 | * Booter behavior control␊ |
224 | */␊ |
225 | #define kBootTimeout␉␉␉-1␊ |
226 | #define kCDBootTimeout␉␉␉8␊ |
227 | ␊ |
228 | /*␊ |
229 | * A global set by boot() to record the device that the booter was loaded from.␊ |
230 | */␊ |
231 | #define ROOT_DEVICE_SIZE 512␊ |
232 | extern int gBIOSDev;␊ |
233 | extern long gBootMode;␊ |
234 | extern bool sysConfigValid;␊ |
235 | extern char bootBanner[];␊ |
236 | extern char bootPrompt[];␊ |
237 | extern bool gOverrideKernel;␊ |
238 | extern char *gPlatformName;␊ |
239 | extern char gMKextName[];␊ |
240 | extern char gRootDevice[];␊ |
241 | extern bool gEnableCDROMRescan;␊ |
242 | extern bool gScanSingleDrive;␊ |
243 | extern bool useGUI;␊ |
244 | ␊ |
245 | /*␊ |
246 | * Boot Modes␊ |
247 | */␊ |
248 | enum {␊ |
249 | ␉kBootModeNormal = 0,␊ |
250 | ␉kBootModeSafe = 1,␊ |
251 | ␉kBootModeSecure = 2,␊ |
252 | ␉kBootModeQuiet = 4␊ |
253 | };␊ |
254 | ␊ |
255 | extern void initialize_runtime();␊ |
256 | extern void common_boot(int biosdev);␊ |
257 | extern bool checkOSVersion(const char * version);␊ |
258 | extern uint32_t getMacOSVerCurrent();␊ |
259 | ␊ |
260 | /*␊ |
261 | * usb.c␊ |
262 | */␊ |
263 | extern int usb_loop();␊ |
264 | ␊ |
265 | /*␊ |
266 | * graphics.c␊ |
267 | */␊ |
268 | extern void printVBEModeInfo();␊ |
269 | extern void setVideoMode(int mode);␊ |
270 | extern int getVideoMode();␊ |
271 | extern void spinActivityIndicator();␊ |
272 | extern void clearActivityIndicator();␊ |
273 | extern void setBackgroundColor( uint32_t color );␊ |
274 | extern void drawDataRectangle(␊ |
275 | unsigned short x,␊ |
276 | unsigned short y,␊ |
277 | unsigned short width,␊ |
278 | unsigned short height,␊ |
279 | unsigned char *data␊ |
280 | );␊ |
281 | extern int␊ |
282 | convertImage( unsigned short width,␊ |
283 | unsigned short height,␊ |
284 | const unsigned char *imageData,␊ |
285 | unsigned char **newImageData );␊ |
286 | extern char *decodeRLE( const void *rleData, int rleBlocks, int outBytes );␊ |
287 | extern void drawBootGraphics(void);␊ |
288 | extern void drawPreview(void *src, uint8_t *saveunder);␊ |
289 | extern int getVideoMode(void);␊ |
290 | extern void loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or);␊ |
291 | ␊ |
292 | /*␊ |
293 | * drivers.c␊ |
294 | */␊ |
295 | extern long LoadExtraDrivers(char * dirSpec);␊ |
296 | extern long LoadDrivers(char * dirSpec);␊ |
297 | extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize);␊ |
298 | typedef long (*FileLoadDrivers_t)(char *dirSpec, long plugin);␊ |
299 | // Bungo:␊ |
300 | extern char gDarwinBuildVerStr[256];␊ |
301 | ␊ |
302 | /*!␊ |
303 | Hookable function pointer called during the driver loading phase that␊ |
304 | allows other code to cause additional drivers to be loaded.␊ |
305 | */␊ |
306 | extern long (*LoadExtraDrivers_p)(FileLoadDrivers_t FileLoadDrivers_p);␊ |
307 | ␊ |
308 | /*␊ |
309 | * options.c␊ |
310 | */␊ |
311 | extern char gBootUUIDString[];␊ |
312 | extern int getBootOptions(bool firstRun);␊ |
313 | extern int processBootOptions();␊ |
314 | extern int selectAlternateBootDevice(int bootdevice);␊ |
315 | extern bool promptForRescanOption(void);␊ |
316 | ␊ |
317 | void showHelp();␊ |
318 | void showTextFile();␊ |
319 | char *getMemoryInfoString();␊ |
320 | ␊ |
321 | typedef struct {␊ |
322 | ␉char name[80];␊ |
323 | ␉void * param;␊ |
324 | } MenuItem;␊ |
325 | ␊ |
326 | /*␊ |
327 | * lzss.c␊ |
328 | */␊ |
329 | extern int decompress_lzss(u_int8_t *dst, u_int32_t dstlen, u_int8_t *src, u_int32_t srclen);␊ |
330 | extern u_int8_t *compress_lzss(u_int8_t *dst, u_int32_t dstlen, u_int8_t *src, u_int32_t srcLen);␊ |
331 | ␊ |
332 | /*␊ |
333 | * lzvn.c␊ |
334 | */␊ |
335 | extern size_t lzvn_decode(void␉␉*dst,␊ |
336 | size_t␉dst_size,␊ |
337 | const void␉*src,␊ |
338 | size_t␉src_size);␊ |
339 | /*␊ |
340 | extern size_t lzvn_encode(void␉␉*dst,␊ |
341 | size_t␉dst_size,␊ |
342 | const void␉*src,␊ |
343 | size_t␉src_size,␊ |
344 | void␉␉*work);␊ |
345 | */␊ |
346 | ␊ |
347 | struct compressed_kernel_header {␊ |
348 | ␉u_int32_t signature;␊ |
349 | ␉u_int32_t compress_type;␊ |
350 | ␉u_int32_t adler32;␊ |
351 | ␉u_int32_t uncompressed_size;␊ |
352 | ␉u_int32_t compressed_size;␊ |
353 | ␉u_int32_t reserved[11];␊ |
354 | ␉char platform_name[64];␊ |
355 | ␉char root_path[256];␊ |
356 | ␉u_int8_t data[0];␊ |
357 | };␊ |
358 | typedef struct compressed_kernel_header compressed_kernel_header;␊ |
359 | ␊ |
360 | /* resume.c */␊ |
361 | void HibernateBoot(char *boot_device);␊ |
362 | void HibernateBootSnow(char *boot_device);␊ |
363 | ␊ |
364 | /* bmdecompress.c */␊ |
365 | void *DecompressData(void *srcbase, int *dw, int *dh, int *bytesPerPixel);␊ |
366 | ␊ |
367 | #endif /* !__BOOT2_BOOT_H */␊ |
368 | |