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␊ |
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 | /* Duvel300: added this */␊ |
123 | #define kRestartFix␉␉"RestartFix"␉␉/* acpi_patcher.c */␊ |
124 | ␊ |
125 | /* Slice: added this */␊ |
126 | #define kPS2RestartFix␉␉"PS2RestartFix"␉␉/* acpi_patcher.c */␊ |
127 | #define kInjectEDID␉␉"InjectEDID"␉␉/* ati.c*/␊ |
128 | #define kCustomEDID␉␉"CustomEDID"␉␉/* ati.c*/␊ |
129 | ␊ |
130 | /* Signal64: added this key */␊ |
131 | #define kLegacyOff␉␉"USBLegacyOff"␉␉/* usb.c */␊ |
132 | ␊ |
133 | /* Lebidou: added this key */␊ |
134 | ␊ |
135 | /* Meklort: added this key */␊ |
136 | #define kMD0Image␉␉"md0"␉␉␉/* ramdisk.h */␊ |
137 | #define kEnableWifi␉␉"EnableWifi"␉␉/* pci_setup.c */␊ |
138 | ␊ |
139 | /* Andyvand: added these keys */␊ |
140 | //#define kSSDT␉␉␉"SSDT"␉␉␉/* acpi_patcher.c */␊ |
141 | #define kHPET␉␉␉"HPET"␉␉␉/* acpi_patcher.c */␊ |
142 | #define kSBST␉␉␉"SBST"␉␉␉/* acpi_patcher.c */␊ |
143 | #define kECDT␉␉␉"ECDT"␉␉␉/* acpi_patcher.c */␊ |
144 | #define kASFT␉␉␉"ASFT"␉␉␉/* acpi_patcher.c */␊ |
145 | #define kDMAR␉␉␉"DMAR"␉␉␉/* acpi_patcher.c */␊ |
146 | #define kFADT␉␉␉"FADT"␉␉␉/* acpi_patcher.c */␊ |
147 | #define kAPIC␉␉␉"APIC"␉␉␉/* acpi_patcher.c */␊ |
148 | #define kMCFG␉␉␉"MCFG"␉␉␉/* acpi_patcher.c */␊ |
149 | #define kDropHPET␉␉"DropHPET"␉␉/* acpi_patcher.c */␊ |
150 | #define kDropSLIC␉␉"DropSLIC"␉␉/* acpi_patcher.c */␊ |
151 | #define kDropSBST␉␉"DropSBST"␉␉/* acpi_patcher.c */␊ |
152 | #define kDropECDT␉␉"DropECDT"␉␉/* acpi_patcher.c */␊ |
153 | #define kDropASFT␉␉"DropASFT"␉␉/* acpi_patcher.c */␊ |
154 | #define kDropDMAR␉␉"DropDMAR"␉␉/* acpi_patcher.c */␊ |
155 | #define kUpdateACPI␉␉"UpdateACPI"␉␉/* acpi_patcher.c */␊ |
156 | ␊ |
157 | /* Mojodojo: added these keys */␊ |
158 | #define kGeneratePStates␉"GeneratePStates"␉/* acpi_patcher.c */␊ |
159 | #define kGenerateCStates␉"GenerateCStates"␉/* acpi_patcher.c */␊ |
160 | #define kCSTUsingSystemIO␉"CSTUsingSystemIO"␉/* acpi_patcher.c */␊ |
161 | #define kEnableC2State␉␉"EnableC2State"␉␉/* acpi_patcher.c */␊ |
162 | #define kEnableC3State␉␉"EnableC3State"␉␉/* acpi_patcher.c */␊ |
163 | #define kEnableC4State␉␉"EnableC4State"␉␉/* acpi_patcher.c */␊ |
164 | ␊ |
165 | /* valv: added these keys */␊ |
166 | #define kbusratio␉␉"busratio"␉␉/* cpu.c */␊ |
167 | #define kDcfg0␉␉␉"display_0"␉␉/* nvidia.c */␊ |
168 | #define kDcfg1␉␉␉"display_1"␉␉/* nvidia.c */␊ |
169 | ␊ |
170 | /* Marchrius: added these keys */␊ |
171 | #define kEnableBacklight␉"EnableBacklight"␉/* nvidia.c */␊ |
172 | ␊ |
173 | /* Kabyl: added these keys */␊ |
174 | #define kAtiConfig␉␉"AtiConfig"␉␉/* ati.c */␊ |
175 | #define kAtiPorts␉␉"AtiPorts"␉␉/* ati.c */␊ |
176 | #define kATYbinimage␉␉"ATYbinimage"␉␉/* ati.c */␊ |
177 | ␊ |
178 | /* cosmo1: added these keys */␊ |
179 | #define kEnableHDMIAudio␉"EnableHDMIAudio"␉/* ati.c && nvidia.c */␊ |
180 | ␊ |
181 | /* cparm: added these keys */␊ |
182 | #define kRebootOnPanic␉␉"RebootOnPanic"␊ |
183 | #define kEnableHiDPI␉␉"EnableHiDPI"␉␉/* enable High resolution display (aka Retina) */␊ |
184 | ␊ |
185 | /* ErmaC: added these keys */␊ |
186 | #define kEnableDualLink␉␉"EnableDualLink"␉/* ati.c && nvidia.c && gma.c*/␊ |
187 | #define kNvidiaGeneric␉␉"NvidiaGeneric"␉␉/* nvidia.c */␊ |
188 | #define kSkipIntelGfx␉␉"SkipIntelGfx"␉␉/* pci_setup.c */␊ |
189 | #define kSkipNvidiaGfx␉␉"SkipNvidiaGfx"␉␉/* pci_setup.c */␊ |
190 | #define kSkipAtiGfx␉␉"SkipAtiGfx"␉␉/* pci_setup.c */␊ |
191 | #define kUsbInject␉␉"USBInject"␉␉/* usb.c */␊ |
192 | #define kIntelCapriFB␉␉"IntelCapriFB"␉␉/* gma.c was HD4K-ig */␊ |
193 | #define kIntelAzulFB␉␉"IntelAzulFB"␉␉/* gma.c was HD5K-ig */␊ |
194 | #define kAAPLCustomIG␉␉"InjectIntel-ig"␉/* gma.c */␊ |
195 | #define kHDAEnabler␉␉"HDAEnabler"␉␉/* pci_setup.c */␊ |
196 | #define kHDEFLayoutID␉␉"HDEFLayoutID"␉␉/* hda.c */␊ |
197 | #define kHDAULayoutID␉␉"HDAULayoutID"␉␉/* hda.c */␊ |
198 | #define kBGRT␉␉␉"BGRT"␉␉␉/* acpi_patcher.c */␊ |
199 | #define kDropBGRT␉␉"DropBGRT"␉␉/* acpi_patcher.c */␊ |
200 | #define kDropMCFG␉␉"DropMCFG"␉␉/* acpi_patcher.c */␊ |
201 | #define kDropAPIC␉␉"DropAPIC"␉␉/* acpi_patcher.c */␊ |
202 | ␊ |
203 | /* Karas: added these keys */␊ |
204 | #define kMemFullInfo␉␉"ForceFullMemInfo"␉/* smbios.c */␊ |
205 | ␊ |
206 | /* Bungo: added these keys */␊ |
207 | // mask private data or no␊ |
208 | #define kPrivateData␉␉"PrivateData"␉␉/* smbios_decode.c */␊ |
209 | ␊ |
210 | /*␊ |
211 | * Flags to the booter or kernel␊ |
212 | */␊ |
213 | #define kVerboseModeFlag␉"-v"␊ |
214 | #define kSafeModeFlag␉␉"-x"␊ |
215 | #define kIgnoreCachesFlag␉"-f"␊ |
216 | #define kIgnoreBootFileFlag␉"-F"␊ |
217 | #define kSingleUserModeFlag␉"-s"␊ |
218 | ␊ |
219 | /*␊ |
220 | * Booter behavior control␊ |
221 | */␊ |
222 | #define kBootTimeout -1␊ |
223 | #define kCDBootTimeout 8␊ |
224 | ␊ |
225 | /*␊ |
226 | * A global set by boot() to record the device that the booter was loaded from.␊ |
227 | */␊ |
228 | #define ROOT_DEVICE_SIZE 512␊ |
229 | extern int gBIOSDev;␊ |
230 | extern long gBootMode;␊ |
231 | extern bool sysConfigValid;␊ |
232 | extern char bootBanner[];␊ |
233 | extern char bootPrompt[];␊ |
234 | extern bool gOverrideKernel;␊ |
235 | extern char *gPlatformName;␊ |
236 | extern char gMKextName[];␊ |
237 | extern char gRootDevice[];␊ |
238 | extern bool gEnableCDROMRescan;␊ |
239 | extern bool gScanSingleDrive;␊ |
240 | extern bool useGUI;␊ |
241 | ␊ |
242 | /*␊ |
243 | * Boot Modes␊ |
244 | */␊ |
245 | enum {␊ |
246 | ␉kBootModeNormal = 0,␊ |
247 | ␉kBootModeSafe = 1,␊ |
248 | ␉kBootModeSecure = 2,␊ |
249 | ␉kBootModeQuiet = 4␊ |
250 | };␊ |
251 | ␊ |
252 | extern void initialize_runtime();␊ |
253 | extern void common_boot(int biosdev);␊ |
254 | ␊ |
255 | /*␊ |
256 | * usb.c␊ |
257 | */␊ |
258 | extern int usb_loop();␊ |
259 | ␊ |
260 | /*␊ |
261 | * graphics.c␊ |
262 | */␊ |
263 | extern void printVBEModeInfo();␊ |
264 | extern void setVideoMode(int mode, int drawgraphics);␊ |
265 | extern int getVideoMode();␊ |
266 | extern void spinActivityIndicator();␊ |
267 | extern void clearActivityIndicator();␊ |
268 | extern void drawColorRectangle(␊ |
269 | unsigned short x,␊ |
270 | unsigned short y,␊ |
271 | unsigned short width,␊ |
272 | unsigned short height,␊ |
273 | unsigned char colorIndex␊ |
274 | );␊ |
275 | extern void drawDataRectangle(␊ |
276 | unsigned short x,␊ |
277 | unsigned short y,␊ |
278 | unsigned short width,␊ |
279 | unsigned short height,␊ |
280 | unsigned char * data␊ |
281 | );␊ |
282 | extern int␊ |
283 | convertImage( unsigned short width,␊ |
284 | unsigned short height,␊ |
285 | const unsigned char *imageData,␊ |
286 | unsigned char **newImageData );␊ |
287 | extern char * decodeRLE( const void * rleData, int rleBlocks, int outBytes );␊ |
288 | extern void drawBootGraphics(void);␊ |
289 | extern void drawPreview(void *src, uint8_t * saveunder);␊ |
290 | extern int getVideoMode(void);␊ |
291 | extern void loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or);␊ |
292 | ␊ |
293 | /*␊ |
294 | * drivers.c␊ |
295 | */␊ |
296 | extern char *gDarwinBuildVerStr; // Bungo␊ |
297 | extern long LoadExtraDrivers(char * dirSpec);␊ |
298 | extern long LoadDrivers(char * dirSpec);␊ |
299 | extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize);␊ |
300 | ␊ |
301 | typedef long (*FileLoadDrivers_t)(char *dirSpec, long plugin);␊ |
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 | ␊ |
313 | extern int getBootOptions(bool firstRun);␊ |
314 | extern int processBootOptions();␊ |
315 | extern int selectAlternateBootDevice(int bootdevice);␊ |
316 | extern bool promptForRescanOption(void);␊ |
317 | ␊ |
318 | void showHelp();␊ |
319 | void showTextFile();␊ |
320 | char *getMemoryInfoString();␊ |
321 | ␊ |
322 | typedef struct {␊ |
323 | ␉char name[80];␊ |
324 | ␉void * param;␊ |
325 | } MenuItem;␊ |
326 | ␊ |
327 | /*␊ |
328 | * lzss.c␊ |
329 | */␊ |
330 | extern int decompress_lzss(u_int8_t *dst, u_int32_t dstlen, u_int8_t *src, u_int32_t srclen);␊ |
331 | extern u_int8_t *compress_lzss(u_int8_t *dst, u_int32_t dstlen, u_int8_t *src, u_int32_t srcLen);␊ |
332 | ␊ |
333 | /*␊ |
334 | * lzvn.c␊ |
335 | */␊ |
336 | extern size_t lzvn_decode(void * dst,␊ |
337 | size_t dst_size,␊ |
338 | const void * src,␊ |
339 | size_t src_size);␊ |
340 | /*␊ |
341 | extern size_t lzvn_encode(void * dst,␊ |
342 | size_t dst_size,␊ |
343 | const void * src,␊ |
344 | size_t src_size,␊ |
345 | void * work);␊ |
346 | */␊ |
347 | ␊ |
348 | struct compressed_kernel_header {␊ |
349 | ␉u_int32_t signature;␊ |
350 | ␉u_int32_t compress_type;␊ |
351 | ␉u_int32_t adler32;␊ |
352 | ␉u_int32_t uncompressed_size;␊ |
353 | ␉u_int32_t compressed_size;␊ |
354 | ␉u_int32_t reserved[11];␊ |
355 | ␉char platform_name[64];␊ |
356 | ␉char root_path[256];␊ |
357 | ␉u_int8_t data[0];␊ |
358 | };␊ |
359 | typedef struct compressed_kernel_header compressed_kernel_header;␊ |
360 | ␊ |
361 | /* resume.c */␊ |
362 | void HibernateBoot(char *boot_device);␊ |
363 | void HibernateBootSnow(char *boot_device);␊ |
364 | ␊ |
365 | /* bmdecompress.c */␊ |
366 | void * DecompressData(void *srcbase, int *dw, int *dh, int *bytesPerPixel);␊ |
367 | ␊ |
368 | bool checkOSVersion(const char * version);␊ |
369 | ␊ |
370 | #endif /* !__BOOT2_BOOT_H */␊ |
371 | |