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 | #define kEnableC6State␉␉"EnableC6State"␉␉/* acpi_patcher.c */␊ |
165 | #define kEnableC7State␉␉"EnableC7State"␉␉/* acpi_patcher.c */␊ |
166 | ␊ |
167 | /* valv: added these keys */␊ |
168 | #define kbusratio␉␉"busratio"␉␉/* cpu.c */␊ |
169 | #define kDcfg0␉␉␉"display_0"␉␉/* nvidia.c */␊ |
170 | #define kDcfg1␉␉␉"display_1"␉␉/* nvidia.c */␊ |
171 | ␊ |
172 | /* Marchrius: added these keys */␊ |
173 | #define kEnableBacklight␉"EnableBacklight"␉/* nvidia.c */␊ |
174 | ␊ |
175 | /* Kabyl: added these keys */␊ |
176 | #define kAtiConfig␉␉"AtiConfig"␉␉/* ati.c */␊ |
177 | #define kAtiPorts␉␉"AtiPorts"␉␉/* ati.c */␊ |
178 | #define kATYbinimage␉␉"ATYbinimage"␉␉/* ati.c */␊ |
179 | ␊ |
180 | /* cosmo1: added these keys */␊ |
181 | #define kEnableHDMIAudio␉"EnableHDMIAudio"␉/* ati.c && nvidia.c */␊ |
182 | ␊ |
183 | /* cparm: added these keys */␊ |
184 | #define kRebootOnPanic␉␉"RebootOnPanic"␊ |
185 | #define kEnableHiDPI␉␉"EnableHiDPI"␉␉/* enable High resolution display (aka Retina) */␊ |
186 | ␊ |
187 | /* ErmaC: added these keys */␊ |
188 | #define kEnableDualLink␉␉"EnableDualLink"␉/* ati.c && nvidia.c && gma.c*/␊ |
189 | #define kNvidiaGeneric␉␉"NvidiaGeneric"␉␉/* nvidia.c */␊ |
190 | #define kSkipIntelGfx␉␉"SkipIntelGfx"␉␉/* pci_setup.c */␊ |
191 | #define kSkipNvidiaGfx␉␉"SkipNvidiaGfx"␉␉/* pci_setup.c */␊ |
192 | #define kSkipAtiGfx␉␉"SkipAtiGfx"␉␉/* pci_setup.c */␊ |
193 | #define kUsbInject␉␉"USBInject"␉␉/* usb.c */␊ |
194 | #define kIntelCapriFB␉␉"IntelCapriFB"␉␉/* gma.c was HD4K-ig */␊ |
195 | #define kIntelAzulFB␉␉"IntelAzulFB"␉␉/* gma.c was HD5K-ig */␊ |
196 | #define kAAPLCustomIG␉␉"InjectIntel-ig"␉/* gma.c */␊ |
197 | #define kHDAEnabler␉␉"HDAEnabler"␉␉/* pci_setup.c */␊ |
198 | #define kHDEFLayoutID␉␉"HDEFLayoutID"␉␉/* hda.c */␊ |
199 | #define kHDAULayoutID␉␉"HDAULayoutID"␉␉/* hda.c */␊ |
200 | #define kBGRT␉␉␉"BGRT"␉␉␉/* acpi_patcher.c */␊ |
201 | #define kDropBGRT␉␉"DropBGRT"␉␉/* acpi_patcher.c */␊ |
202 | #define kDropMCFG␉␉"DropMCFG"␉␉/* acpi_patcher.c */␊ |
203 | #define kDropAPIC␉␉"DropAPIC"␉␉/* acpi_patcher.c */␊ |
204 | ␊ |
205 | /* Karas: added these keys */␊ |
206 | #define kMemFullInfo␉␉"ForceFullMemInfo"␉/* smbios.c */␊ |
207 | ␊ |
208 | /* Bungo: added these keys */␊ |
209 | // mask private data or no␊ |
210 | #define kPrivateData␉␉"PrivateData"␉␉/* smbios_decode.c */␊ |
211 | ␊ |
212 | /*␊ |
213 | * Flags to the booter or kernel␊ |
214 | */␊ |
215 | #define kVerboseModeFlag␉"-v"␊ |
216 | #define kSafeModeFlag␉␉"-x"␊ |
217 | #define kIgnoreCachesFlag␉"-f"␊ |
218 | #define kIgnoreBootFileFlag␉"-F"␊ |
219 | #define kSingleUserModeFlag␉"-s"␊ |
220 | ␊ |
221 | /*␊ |
222 | * Booter behavior control␊ |
223 | */␊ |
224 | #define kBootTimeout -1␊ |
225 | #define kCDBootTimeout 8␊ |
226 | ␊ |
227 | /*␊ |
228 | * A global set by boot() to record the device that the booter was loaded from.␊ |
229 | */␊ |
230 | #define ROOT_DEVICE_SIZE 512␊ |
231 | extern int gBIOSDev;␊ |
232 | extern long gBootMode;␊ |
233 | extern bool sysConfigValid;␊ |
234 | extern char bootBanner[];␊ |
235 | extern char bootPrompt[];␊ |
236 | extern bool gOverrideKernel;␊ |
237 | extern char *gPlatformName;␊ |
238 | extern char gMKextName[];␊ |
239 | extern char gRootDevice[];␊ |
240 | extern bool gEnableCDROMRescan;␊ |
241 | extern bool gScanSingleDrive;␊ |
242 | extern bool useGUI;␊ |
243 | ␊ |
244 | /*␊ |
245 | * Boot Modes␊ |
246 | */␊ |
247 | enum {␊ |
248 | ␉kBootModeNormal = 0,␊ |
249 | ␉kBootModeSafe = 1,␊ |
250 | ␉kBootModeSecure = 2,␊ |
251 | ␉kBootModeQuiet = 4␊ |
252 | };␊ |
253 | ␊ |
254 | extern void initialize_runtime();␊ |
255 | extern void common_boot(int biosdev);␊ |
256 | ␊ |
257 | /*␊ |
258 | * usb.c␊ |
259 | */␊ |
260 | extern int usb_loop();␊ |
261 | ␊ |
262 | /*␊ |
263 | * graphics.c␊ |
264 | */␊ |
265 | extern void printVBEModeInfo();␊ |
266 | extern void setVideoMode(int mode, int drawgraphics);␊ |
267 | extern int getVideoMode();␊ |
268 | extern void spinActivityIndicator();␊ |
269 | extern void clearActivityIndicator();␊ |
270 | extern void drawColorRectangle(␊ |
271 | unsigned short x,␊ |
272 | unsigned short y,␊ |
273 | unsigned short width,␊ |
274 | unsigned short height,␊ |
275 | unsigned char colorIndex␊ |
276 | );␊ |
277 | extern void drawDataRectangle(␊ |
278 | unsigned short x,␊ |
279 | unsigned short y,␊ |
280 | unsigned short width,␊ |
281 | unsigned short height,␊ |
282 | unsigned char * data␊ |
283 | );␊ |
284 | extern int␊ |
285 | convertImage( unsigned short width,␊ |
286 | unsigned short height,␊ |
287 | const unsigned char *imageData,␊ |
288 | unsigned char **newImageData );␊ |
289 | extern char * decodeRLE( const void * rleData, int rleBlocks, int outBytes );␊ |
290 | extern void drawBootGraphics(void);␊ |
291 | extern void drawPreview(void *src, uint8_t * saveunder);␊ |
292 | extern int getVideoMode(void);␊ |
293 | extern void loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or);␊ |
294 | ␊ |
295 | /*␊ |
296 | * drivers.c␊ |
297 | */␊ |
298 | extern char *gDarwinBuildVerStr; // Bungo␊ |
299 | extern long LoadExtraDrivers(char * dirSpec);␊ |
300 | extern long LoadDrivers(char * dirSpec);␊ |
301 | extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize);␊ |
302 | ␊ |
303 | typedef long (*FileLoadDrivers_t)(char *dirSpec, long plugin);␊ |
304 | /*!␊ |
305 | Hookable function pointer called during the driver loading phase that␊ |
306 | allows other code to cause additional drivers to be loaded.␊ |
307 | */␊ |
308 | extern long (*LoadExtraDrivers_p)(FileLoadDrivers_t FileLoadDrivers_p);␊ |
309 | ␊ |
310 | /*␊ |
311 | * options.c␊ |
312 | */␊ |
313 | extern char gBootUUIDString[];␊ |
314 | ␊ |
315 | extern int getBootOptions(bool firstRun);␊ |
316 | extern int processBootOptions();␊ |
317 | extern int selectAlternateBootDevice(int bootdevice);␊ |
318 | extern bool promptForRescanOption(void);␊ |
319 | ␊ |
320 | void showHelp();␊ |
321 | void showTextFile();␊ |
322 | char *getMemoryInfoString();␊ |
323 | ␊ |
324 | typedef struct {␊ |
325 | ␉char name[80];␊ |
326 | ␉void * param;␊ |
327 | } MenuItem;␊ |
328 | ␊ |
329 | /*␊ |
330 | * lzss.c␊ |
331 | */␊ |
332 | extern int decompress_lzss(u_int8_t *dst, u_int32_t dstlen, u_int8_t *src, u_int32_t srclen);␊ |
333 | extern u_int8_t *compress_lzss(u_int8_t *dst, u_int32_t dstlen, u_int8_t *src, u_int32_t srcLen);␊ |
334 | ␊ |
335 | /*␊ |
336 | * lzvn.c␊ |
337 | */␊ |
338 | extern size_t lzvn_decode(void * dst,␊ |
339 | size_t dst_size,␊ |
340 | const void * src,␊ |
341 | size_t src_size);␊ |
342 | /*␊ |
343 | extern size_t lzvn_encode(void * dst,␊ |
344 | size_t dst_size,␊ |
345 | const void * src,␊ |
346 | size_t src_size,␊ |
347 | void * work);␊ |
348 | */␊ |
349 | ␊ |
350 | struct compressed_kernel_header {␊ |
351 | ␉u_int32_t signature;␊ |
352 | ␉u_int32_t compress_type;␊ |
353 | ␉u_int32_t adler32;␊ |
354 | ␉u_int32_t uncompressed_size;␊ |
355 | ␉u_int32_t compressed_size;␊ |
356 | ␉u_int32_t reserved[11];␊ |
357 | ␉char platform_name[64];␊ |
358 | ␉char root_path[256];␊ |
359 | ␉u_int8_t data[0];␊ |
360 | };␊ |
361 | typedef struct compressed_kernel_header compressed_kernel_header;␊ |
362 | ␊ |
363 | /* resume.c */␊ |
364 | void HibernateBoot(char *boot_device);␊ |
365 | void HibernateBootSnow(char *boot_device);␊ |
366 | ␊ |
367 | /* bmdecompress.c */␊ |
368 | void * DecompressData(void *srcbase, int *dw, int *dh, int *bytesPerPixel);␊ |
369 | ␊ |
370 | bool checkOSVersion(const char * version);␊ |
371 | ␊ |
372 | #endif /* !__BOOT2_BOOT_H */␊ |
373 | |