]>
Commit | Line | Data |
---|---|---|
04fee52e A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
8be739c0 A |
6 | * The contents of this file constitute Original Code as defined in and |
7 | * are subject to the Apple Public Source License Version 1.1 (the | |
8 | * "License"). You may not use this file except in compliance with the | |
9 | * License. Please obtain a copy of the License at | |
10 | * http://www.apple.com/publicsource and read it before using this file. | |
04fee52e | 11 | * |
8be739c0 A |
12 | * This Original Code and all software distributed under the License are |
13 | * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
04fee52e A |
14 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
15 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
8be739c0 A |
16 | * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the |
17 | * License for the specific language governing rights and limitations | |
18 | * under the License. | |
04fee52e A |
19 | * |
20 | * @APPLE_LICENSE_HEADER_END@ | |
21 | */ | |
22 | /* | |
23 | * sl.h - Headers for configuring the Secondary Loader | |
24 | * | |
95a2ba82 | 25 | * Copyright (c) 1998-2005 Apple Computer, Inc. |
04fee52e A |
26 | * |
27 | * DRI: Josh de Cesare | |
28 | */ | |
29 | ||
30 | #ifndef _BOOTX_SL_H_ | |
31 | #define _BOOTX_SL_H_ | |
32 | ||
8be739c0 | 33 | // i.e. should we put up our failure screen; else back to OF |
04fee52e A |
34 | #define kFailToBoot (1) |
35 | ||
04fee52e A |
36 | /* |
37 | ||
95a2ba82 | 38 | Memory Map: assumed 96 MB (temporarily bumping to 112 MB for 4359362) |
04fee52e A |
39 | |
40 | Physical Address | |
41 | ||
71019aa0 A |
42 | Open Firmware Version 3x, 4x, ... |
43 | 00000000 - 00003FFF : Exception Vectors | |
44 | 00004000 - 057FFFFF : Free Memory | |
95a2ba82 A |
45 | // 05800000 - 05FFFFFF : OF Image (top 8 MB reserved) [96 MB map] |
46 | 06800000 - 06FFFFFF : OF Image (top 8 MB reserved) [112 MB map] | |
04fee52e A |
47 | |
48 | ||
49 | Logical Address | |
50 | ||
95a2ba82 | 51 | // 96 MB map (currently unused - 4363357 tracks re-adoption) |
04fee52e | 52 | 00000000 - 00003FFF : Exception Vectors |
95a2ba82 A |
53 | 00004000 - 03FFFFFF : Kernel Image, Boot Struct and Drivers (~64 MB) |
54 | 04000000 - 04FFFFFF : File Load Area (16 MB) [80 MB] | |
55 | 05000000 - 053FFFFF : FS Cache (4 MB) [84 MB] | |
56 | 05400000 - 055FFFFF : Malloc Zone (2 MB) [86 MB] | |
57 | 05600000 - 057FFFFF : BootX Image (2 MB) [88 MB] | |
58 | 05800000 - 05FFFFFF : Unused/OF (8 MB) [96 MB] | |
59 | ||
60 | // 112 MB map (per 4359362) | |
61 | 00000000 - 00003FFF : Exception Vectors | |
62 | 00004000 - 03FFFFFF : Kernel Image, Boot Struct and Drivers (~64 MB) | |
63 | 04000000 - 05FFFFFF : File Load Area (32 MB) [96 MB] | |
64 | 06000000 - 063FFFFF : FS Cache (4 MB) [100 MB] | |
65 | 06400000 - 065FFFFF : Malloc Zone (2 MB) [102 MB] | |
66 | 06600000 - 067FFFFF : BootX Image (2 MB) [104 MB] | |
67 | 06800000 - 06FFFFFF : Unused/OF (8 MB) [112 MB] | |
04fee52e A |
68 | */ |
69 | ||
70 | #define kVectorAddr (0x00000000) | |
71 | #define kVectorSize (0x00004000) | |
72 | ||
73 | // OF 3.x | |
74 | #define kImageAddr (0x00004000) | |
71019aa0 | 75 | #define kImageSize (0x03FFC000) |
04fee52e A |
76 | |
77 | // OF 1.x 2.x | |
78 | #define kImageAddr0 (0x00004000) | |
79 | #define kImageSize0 (0x002FC000) | |
80 | #define kImageAddr1 (0x00300000) | |
81 | #define kImageSize1 (0x00200000) | |
71019aa0 | 82 | #define kImageAddr1Phys (0x05800000) |
04fee52e | 83 | #define kImageAddr2 (0x00500000) |
71019aa0 | 84 | #define kImageSize2 (0x03B00000) |
04fee52e | 85 | |
71019aa0 | 86 | #define kLoadAddr (0x04000000) |
95a2ba82 A |
87 | #define kLoadSize (0x02000000) // 32 MB @ 64 |
88 | #define kMaxMKextSize (0x01000000) // only allow 16 MB of drivers | |
04fee52e | 89 | |
95a2ba82 A |
90 | #define kFSCacheAddr (0x06000000) |
91 | #define kFSCacheSize (0x00400000) // 4 MB @ 96 | |
71019aa0 | 92 | |
95a2ba82 A |
93 | #define kMallocAddr (0x06400000) |
94 | #define kMallocSize (0x00200000) // 2 MB @ 100 | |
04fee52e | 95 | |
95a2ba82 | 96 | #define kMallocAddr_H (0x06400000) // ditto for hibernate |
8be739c0 | 97 | #define kMallocSize_H (0x00200000) |
95a2ba82 | 98 | #define kImageAddr_H (0x07000000) // fallback for hiberate image buffer |
8be739c0 | 99 | |
04fee52e A |
100 | // Default Output Level |
101 | #define kOutputLevelOff (0) | |
102 | #define kOutputLevelFull (16) | |
103 | ||
104 | // OF versions | |
105 | #define kOFVersion1x (0x01000000) | |
106 | #define kOFVersion2x (0x02000000) | |
107 | #define kOFVersion3x (0x03000000) | |
71019aa0 | 108 | #define kOFVersion4x (0x04000000) |
04fee52e A |
109 | |
110 | // Device Types | |
111 | enum { | |
112 | kUnknownDeviceType = 0, | |
113 | kNetworkDeviceType, | |
114 | kBlockDeviceType | |
115 | }; | |
116 | ||
366defd1 | 117 | // File Permissions and Types |
04fee52e | 118 | enum { |
366defd1 A |
119 | kPermOtherExecute = 1 << 0, |
120 | kPermOtherWrite = 1 << 1, | |
121 | kPermOtherRead = 1 << 2, | |
122 | kPermGroupExecute = 1 << 3, | |
123 | kPermGroupWrite = 1 << 4, | |
124 | kPermGroupRead = 1 << 5, | |
125 | kPermOwnerExecute = 1 << 6, | |
126 | kPermOwnerWrite = 1 << 7, | |
127 | kPermOwnerRead = 1 << 8, | |
128 | kPermMask = 0x1FF, | |
129 | kOwnerNotRoot = 1 << 9, | |
130 | kFileTypeUnknown = 0x0 << 16, | |
131 | kFileTypeFlat = 0x1 << 16, | |
132 | kFileTypeDirectory = 0x2 << 16, | |
133 | kFileTypeLink = 0x3 << 16, | |
134 | kFileTypeMask = 0x3 << 16 | |
04fee52e A |
135 | }; |
136 | ||
137 | // Key Numbers | |
138 | #define kCommandKey (0x200) | |
139 | #define kOptKey (0x201) | |
140 | #define kShiftKey (0x202) | |
141 | #define kControlKey (0x203) | |
8be739c0 | 142 | #define kDeleteKey (0x204) |
04fee52e A |
143 | |
144 | // Mac OS X Booter Signature 'MOSX' | |
145 | #define kMacOSXSignature (0x4D4F5358) | |
146 | ||
366defd1 A |
147 | // Boot Modes |
148 | enum { | |
149 | kBootModeNormal = 0, | |
150 | kBootModeSafe, | |
151 | kBootModeSecure | |
152 | }; | |
04fee52e | 153 | |
366defd1 A |
154 | #include <sys/stat.h> |
155 | #include <sys/types.h> | |
8be739c0 | 156 | #include <stdint.h> |
04fee52e A |
157 | |
158 | #include <ci.h> | |
159 | #include <sl_words.h> | |
160 | #include <libclite.h> | |
161 | #include <fs.h> | |
162 | #include <boot_args.h> | |
163 | ||
8be739c0 A |
164 | // types for plist.c |
165 | typedef enum { | |
166 | kTagTypeNone = 0, | |
167 | kTagTypeDict, | |
168 | kTagTypeKey, | |
169 | kTagTypeString, | |
170 | kTagTypeInteger, | |
171 | kTagTypeData, | |
172 | kTagTypeDate, | |
173 | kTagTypeFalse, | |
174 | kTagTypeTrue, | |
175 | kTagTypeArray | |
176 | } TagType; | |
177 | ||
178 | struct Tag { | |
179 | TagType type; | |
180 | char *string; | |
181 | struct Tag *tag; | |
182 | struct Tag *tagNext; | |
183 | }; | |
184 | typedef struct Tag Tag, *TagPtr; | |
185 | ||
04fee52e A |
186 | // Externs for main.c |
187 | extern char *gVectorSaveAddr; | |
188 | extern long gKernelEntryPoint; | |
189 | extern long gDeviceTreeAddr; | |
190 | extern long gDeviceTreeSize; | |
191 | extern long gBootArgsAddr; | |
192 | extern long gBootArgsSize; | |
193 | extern long gSymbolTableAddr; | |
194 | extern long gSymbolTableSize; | |
195 | ||
366defd1 | 196 | extern long gBootMode; |
04fee52e A |
197 | extern long gBootDeviceType; |
198 | extern long gBootFileType; | |
b1faa321 | 199 | extern char gHaveKernelCache; |
04fee52e A |
200 | extern char gBootDevice[256]; |
201 | extern char gBootFile[256]; | |
8be739c0 | 202 | extern TagPtr gBootDict; |
04fee52e A |
203 | |
204 | extern char gTempStr[4096]; | |
205 | ||
206 | extern long *gDeviceTreeMMTmp; | |
207 | ||
208 | extern long gOFVersion; | |
209 | ||
210 | extern char *gKeyMap; | |
211 | ||
71019aa0 A |
212 | extern long gRootAddrCells; |
213 | extern long gRootSizeCells; | |
214 | ||
04fee52e A |
215 | extern CICell gChosenPH; |
216 | extern CICell gOptionsPH; | |
217 | extern CICell gScreenPH; | |
218 | extern CICell gMemoryMapPH; | |
219 | extern CICell gStdOutPH; | |
220 | ||
221 | extern CICell gMMUIH; | |
222 | extern CICell gMemoryIH; | |
223 | extern CICell gStdOutIH; | |
224 | extern CICell gKeyboardIH; | |
225 | ||
8be739c0 A |
226 | // useful to activate debug logs near when a problem happens |
227 | //extern int gDebugCount; | |
228 | ||
71019aa0 | 229 | extern long ThinFatBinary(void **binary, unsigned long *length); |
04fee52e A |
230 | extern long GetDeviceType(char *devSpec); |
231 | extern long ConvertFileSpec(char *fileSpec, char *devSpec, char **filePath); | |
232 | extern long MatchThis(CICell phandle, char *string); | |
233 | extern void *AllocateBootXMemory(long size); | |
234 | extern long AllocateKernelMemory(long size); | |
235 | extern long AllocateMemoryRange(char *rangeName, long start, long length); | |
8be739c0 | 236 | extern unsigned long Adler32(unsigned char *buffer, long length); |
04fee52e A |
237 | |
238 | // Externs for macho.c | |
71019aa0 A |
239 | extern long ThinFatBinaryMachO(void **binary, unsigned long *length); |
240 | extern long DecodeMachO(void *binary); | |
04fee52e A |
241 | |
242 | // Externs for elf.c | |
71019aa0 A |
243 | extern long ThinFatBinaryElf(void **binary, unsigned long *length); |
244 | extern long DecodeElf(void *binary); | |
04fee52e A |
245 | |
246 | // Externs for device_tree.c | |
247 | extern long FlattenDeviceTree(void); | |
248 | extern CICell SearchForNode(CICell ph, long top, char *prop, char *value); | |
249 | extern CICell SearchForNodeMatching(CICell ph, long top, char *value); | |
250 | ||
251 | // Externs for display.c | |
8be739c0 | 252 | extern long InitDisplays(int fill); |
366defd1 A |
253 | extern long DrawSplashScreen(long stage); |
254 | extern long DrawFailedBootPicture(void); | |
8be739c0 A |
255 | extern void GetMainScreenPH(Boot_Video_Ptr video, int setProperties); |
256 | void SplashPreview(void *src, u_int8_t * saveunder, u_int32_t savelen); | |
257 | void SplashProgress(u_int8_t * saveunder, int32_t firstBlob, int32_t select); | |
258 | ||
259 | // Externs for bmdecompress.c | |
260 | extern int DecompressData(void *srcbase, void *dstbase, | |
261 | int dw, int dh, int bytesPerPixel, int rowbytes); | |
04fee52e A |
262 | |
263 | // Externs for drivers.c | |
264 | extern long LoadDrivers(char *dirPath); | |
265 | ||
266 | // Externs for config.c | |
267 | extern long InitConfig(void); | |
268 | extern long ParseConfigFile(char *addr); | |
269 | ||
b1faa321 A |
270 | // Externs for lzss.c |
271 | extern int decompress_lzss(u_int8_t *dst, u_int8_t *src, u_int32_t srclen); | |
272 | ||
8be739c0 A |
273 | |
274 | // Externs for plist.c | |
275 | #define PLIST_DEBUG 0 // whether report parsing errors, etc | |
276 | ||
277 | extern TagPtr GetProperty(TagPtr dict, char *key); | |
278 | extern long ParseXML(char *buffer, TagPtr *dict); | |
279 | extern void FreeTag(TagPtr tag); | |
280 | #if PLIST_DEBUG | |
281 | extern void DumpTag(TagPtr tag, long depth); | |
282 | #endif | |
283 | ||
284 | ||
285 | // Externs/types for raid.c | |
286 | typedef struct RAIDMember *RAIDDevicePtr; | |
287 | ||
288 | extern int isRAIDPath(char *devSpec); | |
289 | extern int isRAIDDevice(void *ih); | |
290 | extern long LookForRAID(TagPtr bootDict); | |
291 | extern RAIDDevicePtr RAIDOpen(char *devSpec); | |
292 | extern void RAIDClose(RAIDDevicePtr raid); | |
293 | extern long RAIDRead(RAIDDevicePtr raid, long a, long n, long long offset); | |
294 | extern long RAIDSeek(RAIDDevicePtr raid, long long position); | |
295 | ||
296 | ||
04fee52e | 297 | #endif /* ! _BOOTX_SL_H_ */ |