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