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