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