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 | /*␊ |
25 | * Copyright 1994 NeXT Computer, Inc.␊ |
26 | * All rights reserved.␊ |
27 | */␊ |
28 | ␊ |
29 | #ifndef __BOOT2_BOOT_H␊ |
30 | #define __BOOT2_BOOT_H␊ |
31 | ␊ |
32 | //Azi:include - keep boot.h free of includes as possible, for now.␊ |
33 | #include "saio_internal.h"␊ |
34 | //#include "libsaio.h"␊ |
35 | //#include "autoresolution.h" // not needed; it's included were it's needed.␊ |
36 | ␊ |
37 | #if DEBUG␊ |
38 | #ifndef AUTORES_DEBUG␊ |
39 | #define AUTORES_DEBUG␊ |
40 | #endif␊ |
41 | #endif␊ |
42 | ␊ |
43 | /*␊ |
44 | * temporary "keys related" stuff␊ |
45 | *␊ |
46 | - deactivated:␊ |
47 | #define kPlatformKey␉␉"platform"␉␉␉␉// options.c, processBootArgument␉␉␉removed, says on comment␊ |
48 | #define kACPIKey␉␉␉"acpi"␉␉␉␉␉//␉␉␉␉␉␉␉␉␉␉␉not in use, afaics␊ |
49 | #define kPCIRootUIDKey␉␉"PCIRootUID"␉␉␉// pci_root.c, getValFK␉␉␉␉␉␉removed by me␊ |
50 | "-pci0"␉␉␉␉␉␉␉␉␉␉␉␉// pci_root.c, getValFK␉␉␉␉␉␉removed by me␊ |
51 | "-pci1"␉␉␉␉␉␉␉␉␉␉␉␉// pci_root.c, getValFK␉␉␉␉␉␉removed by me␊ |
52 | ␊ |
53 | - lost & found:␊ |
54 | "-checkers" gui.c, getValFK; booter flag␊ |
55 | "biosdev" mboot.c, getValFBK␊ |
56 | "timeout" mboot.c, getValFBK␊ |
57 | "partno" mboot.c, getValFBK␊ |
58 | "DumpSPD" spd.c, getBollFK␊ |
59 | ␊ |
60 | - ramdisk specific:␊ |
61 | "Info" // ramdisk.c, getValFK␊ |
62 | "BTAlias" // ramdisk.c, getBollFK␊ |
63 | ␊ |
64 | kNVCAP␉␉nvidia.c, getValFK␊ |
65 | This introduces a new way (to me) to implement key/value;␊ |
66 | key is declared as a "variable", char kNVCAP[12]; on nvidia.c, setup_nvidia_devprop().␊ |
67 | Check: http://efixusers.com/showthread.php?t=644, Update Version 1.1.9 (Asere's booter).␊ |
68 | ␊ |
69 | - Keep just most "useful at boot prompt" stuff on BootHelp; make it a real "boot help", not a user guide.␊ |
70 | - Check who is set to "Yes" by default and if it's really needed! (wake)␊ |
71 | - move keys to the headers of the files they're in, if they have it!?␊ |
72 | */␊ |
73 | ␊ |
74 | /*␊ |
75 | * Default names - these end with "Name" (easier to sort them).␊ |
76 | */␊ |
77 | ␊ |
78 | #define kDefaultKernelName␉␉"mach_kernel"␊ |
79 | #define kDefaultThemeName␉␉"Default"␊ |
80 | /*#define kDefaultBootPlistName␉"com.apple.Boot.plist"␊ |
81 | #define kDefaultDSDTName␉␉"dsdt.aml"␊ |
82 | #define kDefaultSMBIOSName␉␉"smbios.plist"␊ |
83 | #define kDefaultRamdiskName␉␉"Preboot.dmg" ???*/␊ |
84 | ␊ |
85 | /*␊ |
86 | * Keys used in system Boot.plist - these end with "Key".␊ |
87 | *␊ |
88 | * Keys marked with * on the "location" area, are present on BootHelp file.␊ |
89 | * New or temporary keys, since RC4, are marked with # on the "location" area.␊ |
90 | */␊ |
91 | //definition␉␉␉␉␉name␉␉␉␉location/function␉␉␉␉␉␉␉description/comment␊ |
92 | ␊ |
93 | // leave for later...␊ |
94 | #define kTextModeKey␉␉␉"Text Mode"␉␉␉// graphics.c, getNumberArrayFromProperty␉textmode resolution??␊ |
95 | #define kProductVersion␉␉␉"ProductVersion"␉// boot.c, getValFK, internal␉␉␉␉key on SystemVersion.plist␊ |
96 | ␊ |
97 | // First run: keys that make no sense on "override" Boot.plist or typed at boot prompt.␊ |
98 | #define kDefaultPartitionKey␉"Default Partition"␉// sys.c, getValFK␊ |
99 | #define kHidePartitionKey␉␉"Hide Partition"␉// disk.c, getValFK␊ |
100 | #define kRenamePartitionKey␉␉"Rename Partition"␉// disk.c, getStringFK␊ |
101 | #define kTimeoutKey␉␉␉␉"Timeout"␉␉␉// * options.c, getIntFK␊ |
102 | #define kInstantMenuKey␉␉␉"Instant Menu"␉␉// * boot.c, getBollFK␊ |
103 | #define kQuietBootKey␉␉␉"Quiet Boot"␉␉// * boot.c, getBollFK␊ |
104 | #define kThemeNameKey␉␉␉"Theme"␉␉␉␉// gui.c, getValFK␉␉␉␉␉␉␉override default name␊ |
105 | #define kGUIKey␉␉␉␉␉"GUI"␉␉␉␉// * boot.c, getBollFK␊ |
106 | #define kBootBannerKey␉␉␉"Boot Banner"␉␉// * options.c, getBollFK␊ |
107 | #define kDebugInfoKey␉␉␉"DebugInfo"␉␉␉// #gui.c, graphics.c, getBollFK␊ |
108 | #define kGraphicsModeKey␉␉"Graphics Mode"␉␉// * graphics.c, getNumberArrayFromProperty␊ |
109 | #define kCDROMPromptKey␉␉␉"CD-ROM Prompt"␉␉// options.c, getValFK␊ |
110 | #define kCDROMOptionKey␉␉␉"CD-ROM Option Key"␉// options.c, getIntFK & getValFK␊ |
111 | #define kRescanPromptKey␉␉"Rescan Prompt"␉␉// boot.c, getBollFK␉␉␉␉␉␉test this␊ |
112 | #define kRescanKey␉␉␉␉"Rescan"␉␉␉// * boot.c, getBollFK␊ |
113 | #define kScanSingleDriveKey␉␉"Scan Single Drive"␉// * boot.c, getBollFK␊ |
114 | #define kDevicePropertiesKey␉"device-properties"␉// device_inject.c, getValFK␊ |
115 | ␊ |
116 | // Common: firstrun or secondrun␊ |
117 | #define kWaitForKeypressKey␉␉"Wait"␉␉␉␉// * boot.c, getBollFK␉␉␉␉␉␉turn this into flag?␊ |
118 | #define kTestConfigKey␉␉␉"config"␉␉␉// # stringTable.c, getValFK␊ |
119 | #define kKernelNameKey␉␉␉"Kernel"␉␉␉// * options.c, getValFK,␉␉␉␉␉override default name; at boot prompt typing the name is enough.␊ |
120 | #define kKernelCacheKey␉␉␉"Kernel Cache"␉␉// boot.c, getValFK␉␉␉␉␉␉␉test this␊ |
121 | #define kKernelFlagsKey␉␉␉"Kernel Flags"␉␉// * options.c, getValFK␊ |
122 | #define kPatchKernelKey␉␉␉"PatchKernel"␉␉// # stringTable.c, getBollFK␉␉␉␉Meklort␊ |
123 | ␊ |
124 | #define kRootDeviceKey␉␉␉"rd"␉␉␉␉// * options.c, processBootArgument␉␉␉test this,␊ |
125 | #define kBootDeviceKey␉␉␉"Boot Device"␉␉// options.c, getValFK␉␉␉␉␉␉and this??␊ |
126 | ␊ |
127 | #define kBootUUIDKey␉␉␉"boot-uuid"␉␉␉// options.c, processBootArgument␉␉␉test this␊ |
128 | #define kHelperRootUUIDKey␉␉"Root UUID"␉␉␉// options.c, getValFK␉␉␉␉␉␉can't test this␊ |
129 | ␊ |
130 | #define kExtensionsKey␉␉␉"kext"␉␉␉␉// # drivers.c, getValFK␊ |
131 | #define kMKextCacheKey␉␉␉"MKext Cache"␉␉// options.c, getValFK␉␉␉␉␉␉test this␊ |
132 | #define kDSDTKey␉␉␉␉"DSDT"␉␉␉␉// * acpi_patcher.c, getValFK␉␉␉␉override default path/name!?␊ |
133 | #define kDropSSDTKey␉␉␉"DropSSDT"␉␉␉// * acpi_patcher.c, getBollFK␊ |
134 | #define kSMBIOSKey␉␉␉␉"SMBIOS"␉␉␉// * fake_efi.c; getValFK␊ |
135 | #define kSMBIOSdefaultsKey␉␉"SMBIOSdefaults"␉// * smbios_patcher.c, getBollFK␊ |
136 | #define kWakeKey␉␉␉␉"Wake"␉␉␉␉// * boot.c, getBollFK␉␉␉␉␉␉firstrun?␊ |
137 | #define kForceWakeKey␉␉␉"ForceWake"␉␉␉// * boot.c, getBollFK␉␉␉␉␉␉firstrun?␊ |
138 | #define kWakeImageKey␉␉␉"WakeImage"␉␉␉// * boot.c, getValFK␉␉␉␉␉␉firstrun?␊ |
139 | #define kPCIRootUIDKey␉␉␉"PciRoot"␉␉␉// * pci_root.c, getValFK,␊ |
140 | #define kUseAtiROMKey␉␉␉"UseAtiROM"␉␉␉// # ati.c, getBollFK␉␉␉␉␉␉firstrun?␊ |
141 | #define kUseNvidiaROMKey␉␉"UseNvidiaROM"␉␉// # nvidia.c, getBollFK␉␉␉␉␉firstrun?␊ |
142 | #define kVBIOSKey␉␉␉␉"VBIOS"␉␉␉␉// nvidia.c, getBollFK␉␉␉␉␉␉firstrun?␊ |
143 | #define kSystemIDKey␉␉␉"SystemId"␉␉␉// * fake_efi.c, getStringFK␊ |
144 | #define kSystemTypeKey␉␉␉"SystemType"␉␉// * acpi_patcher.c, getStringFK␊ |
145 | #define kEthernetBuiltInKey␉␉"EthernetBuiltIn"␉// * pci_setup.c, getBollFK␊ |
146 | #define kGraphicsEnablerKey␉␉"GraphicsEnabler"␉// * pci_setup.c, getBollFK␊ |
147 | #define kLegacyLogoKey␉␉␉"Legacy Logo"␉␉// * gui.c, getBollFK␊ |
148 | #define kEHCIhardKey␉␉␉"EHCIhard"␉␉␉// usb.c, getBollFK, - rc4␉␉␉␉␉Azi: wtf is this?? internal?␊ |
149 | #define kUSBBusFixKey␉␉␉"USBBusFix"␉␉␉// * pci_setup.c, getBollFK␊ |
150 | #define kEHCIacquireKey␉␉␉"EHCIacquire"␉␉// * pci_setup.c, getBollFK␊ |
151 | #define kUHCIresetKey␉␉␉"UHCIreset"␉␉␉// * pci_setup.c, getBollFK␊ |
152 | #define kForceHPETKey␉␉␉"ForceHPET"␉␉␉// * pci_setup.c, getBollFK␊ |
153 | #define kLegacyOffKey␉␉␉"USBLegacyOff"␉␉// # usb.c, getBoolFK␉␉␉␉␉␉Meklort␊ |
154 | #define kMD0ImageKey␉␉␉"md0"␉␉␉␉// # ramdisk.c, getValFK␉␉␉␉␉␉||␊ |
155 | #define kRestartFixKey␉␉␉"RestartFix"␉␉// # acpi_patcher.c, getBollFK␊ |
156 | #define kUseMemDetectKey␉␉"UseMemDetect"␉␉// # platform.c, getBollFK␊ |
157 | #define kAutoResolutionKey␉␉"AutoResolution"␉// # boot.c, getBollFK␉␉␉␉␉␉don't forget F2 key, to change resolution!␊ |
158 | #define kCanOverrideKey␉␉␉"CanOverride"␉␉// # stringTable.c, getBollFK␉␉␉␉Azi: most probably will be gone␊ |
159 | #define kGeneratePStatesKey␉␉"GeneratePStates"␉// # acpi_patcher.c, getBoolFK␉␉␉␉Mozodojo␊ |
160 | #define kGenerateCStatesKey␉␉"GenerateCStates"␉// # acpi_patcher.c, getBoolFK␉␉␉␉␉||␊ |
161 | #define kEnableC4States␉␉␉"EnableC4State"␉␉// # acpi_patcher.c,␉␉␉␉␉␉␉||␊ |
162 | ␊ |
163 | /*␊ |
164 | * Flags to the booter and/or kernel - these end with "Flag".␊ |
165 | */␊ |
166 | // A summary on next 3 flags:␊ |
167 | // These have no use on machines with cpu "without" 64 bit intructions.␊ |
168 | // Those machines boot i386 arch by "default", Legacy mode!␊ |
169 | // Reworked "arch" key; kind of a fusion between "arch" & "k32BitModeFlag";␊ |
170 | // If this (or something similar) doesn't stick, i vote for arch=i386, it's more educational!␊ |
171 | // 2 keys doing the same thing, just adds confusion!!␊ |
172 | #define kArchI386Flag␉␉␉"32"␉␉␉␉// # boot.c, getValFK␉␉␉␉␉␉␉force i386 ("64 bit Mode" available)␊ |
173 | // Used by the booter to pass i386 arch; used by the kernel to disable "64 bit Mode".␊ |
174 | #define kLegacyModeFlag␉␉␉"-legacy"␉␉␉// # boot.c, fake_efi.c, getValFK;␉␉␉force i386 + disable "64 bit Mode"␊ |
175 | // Just to override i386/-legacy if flagged on Boot.plist.␊ |
176 | #define kArchX86_64Flag␉␉␉"64"␉␉␉␉// # boot.c, getValFK␊ |
177 | //----------␊ |
178 | #define kVerboseModeFlag␉␉"-v"␉␉␉␉// * options.c, getValFK␊ |
179 | #define kSafeModeFlag␉␉␉"-x"␉␉␉␉// * options.c, getValueFBK (5) & getValFK␊ |
180 | #define kSingleUserModeFlag␉␉"-s"␉␉␉␉// * options.c, getValFK␊ |
181 | #define kIgnoreBootFileFlag␉␉"-F"␉␉␉␉// * options.c, getValFBK␊ |
182 | // Can't remember if i ever tried -F; had an idea.. make this point to kTestConfigKey,␊ |
183 | // kind of a -config key.. like if "if you have a messed up config file" use -F to ignore it␊ |
184 | // and use a "safe default one".. investigate␊ |
185 | ␊ |
186 | /*␊ |
187 | * Booter behavior control␊ |
188 | */␊ |
189 | #define kBootTimeout␉␉␉-1␊ |
190 | #define kCDBootTimeout␉␉␉8␊ |
191 | ␊ |
192 | /*␊ |
193 | * A global set by boot() to record the device that the booter␊ |
194 | * was loaded from.␊ |
195 | */␊ |
196 | extern int gBIOSDev;␊ |
197 | extern long gBootMode;␊ |
198 | extern bool sysConfigValid;␊ |
199 | extern char bootBanner[];␊ |
200 | extern char bootPrompt[];␊ |
201 | extern bool gOverrideKernel;␊ |
202 | //extern char *gPlatformName; disabled␊ |
203 | extern char gMKextName[];␊ |
204 | extern char gRootDevice[];␊ |
205 | extern bool gEnableCDROMRescan;␊ |
206 | extern bool gScanSingleDrive;␊ |
207 | extern bool useGUI;␊ |
208 | ␊ |
209 | /*␊ |
210 | * Boot Modes␊ |
211 | */␊ |
212 | enum {␊ |
213 | kBootModeNormal = 0,␊ |
214 | kBootModeSafe = 1,␊ |
215 | kBootModeSecure = 2,␊ |
216 | kBootModeQuiet = 4␊ |
217 | };␊ |
218 | ␊ |
219 | extern void initialize_runtime();␊ |
220 | extern void common_boot(int biosdev);␊ |
221 | ␊ |
222 | /*␊ |
223 | * usb.c␊ |
224 | */␊ |
225 | extern int usb_loop();␊ |
226 | ␊ |
227 | /*␊ |
228 | * graphics.c␊ |
229 | */␊ |
230 | extern void printVBEModeInfo();␊ |
231 | extern void setVideoMode(int mode, int drawgraphics);␊ |
232 | extern int getVideoMode();␊ |
233 | extern void spinActivityIndicator();␊ |
234 | extern void clearActivityIndicator();␊ |
235 | extern void drawColorRectangle( unsigned short x,␊ |
236 | unsigned short y,␊ |
237 | unsigned short width,␊ |
238 | unsigned short height,␊ |
239 | unsigned char colorIndex );␊ |
240 | extern void drawDataRectangle( unsigned short x,␊ |
241 | unsigned short y,␊ |
242 | unsigned short width,␊ |
243 | unsigned short height,␊ |
244 | unsigned char * data );␊ |
245 | extern int␊ |
246 | convertImage( unsigned short width,␊ |
247 | unsigned short height,␊ |
248 | const unsigned char *imageData,␊ |
249 | unsigned char **newImageData );␊ |
250 | extern char * decodeRLE( const void * rleData, int rleBlocks, int outBytes );␊ |
251 | extern void drawBootGraphics(void);␊ |
252 | extern void drawPreview(void *src, uint8_t * saveunder);␊ |
253 | extern int getVideoMode(void);␊ |
254 | extern void loadImageScale (void *input, int iw, int ih, int ip, void *output, int ow, int oh, int op, int or);␊ |
255 | ␊ |
256 | /*␊ |
257 | * drivers.c␊ |
258 | */␊ |
259 | extern long LoadDrivers(char * dirSpec);␊ |
260 | extern long DecodeKernel(void *binary, entry_t *rentry, char **raddr, int *rsize);␊ |
261 | ␊ |
262 | typedef long (*FileLoadDrivers_t)(char *dirSpec, long plugin);␊ |
263 | /*!␊ |
264 | Hookable function pointer called during the driver loading phase that␊ |
265 | allows other code to cause additional drivers to be loaded.␊ |
266 | */␊ |
267 | extern long (*LoadExtraDrivers_p)(FileLoadDrivers_t FileLoadDrivers_p);␊ |
268 | ␊ |
269 | /*␊ |
270 | * options.c␊ |
271 | */␊ |
272 | extern int getBootOptions(bool firstRun);␊ |
273 | extern int processBootOptions();␊ |
274 | extern int selectAlternateBootDevice(int bootdevice);␊ |
275 | extern bool promptForRescanOption(void);␊ |
276 | ␊ |
277 | void showHelp();␊ |
278 | void showTextFile();␊ |
279 | char *getMemoryInfoString();␊ |
280 | ␊ |
281 | typedef struct {␊ |
282 | char name[80];␊ |
283 | void * param;␊ |
284 | } MenuItem;␊ |
285 | ␊ |
286 | /*␊ |
287 | * lzss.c␊ |
288 | */␊ |
289 | extern int decompress_lzss(u_int8_t *dst, u_int8_t *src, u_int32_t srclen);␊ |
290 | ␊ |
291 | struct compressed_kernel_header {␊ |
292 | u_int32_t signature;␊ |
293 | u_int32_t compress_type;␊ |
294 | u_int32_t adler32;␊ |
295 | u_int32_t uncompressed_size;␊ |
296 | u_int32_t compressed_size;␊ |
297 | u_int32_t reserved[11];␊ |
298 | char platform_name[64];␊ |
299 | char root_path[256];␊ |
300 | u_int8_t data[0];␊ |
301 | };␊ |
302 | typedef struct compressed_kernel_header compressed_kernel_header;␊ |
303 | ␊ |
304 | /* resume.c */␊ |
305 | void HibernateBoot(char *boot_device);␊ |
306 | ␊ |
307 | /* bmdecompress.c */␊ |
308 | void * DecompressData(void *srcbase, int *dw, int *dh, int *bytesPerPixel);␊ |
309 | ␊ |
310 | #endif /* !__BOOT2_BOOT_H */␊ |
311 | |