]> git.saurik.com Git - apple/bootx.git/blob - bootx.tproj/include.subproj/sl.h
952ff4cc9adc5fb0deb3c77f2dffbc4483d7caed
[apple/bootx.git] / bootx.tproj / include.subproj / sl.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25 /*
26 * sl.h - Headers for configuring the Secondary Loader
27 *
28 * Copyright (c) 1998-2003 Apple Computer, Inc.
29 *
30 * DRI: Josh de Cesare
31 */
32
33 #ifndef _BOOTX_SL_H_
34 #define _BOOTX_SL_H_
35
36 #define kFailToBoot (1)
37
38 /*
39
40 Memory Map: assumes 96 MB
41
42 Physical Address
43
44 Open Firmware Version 3x, 4x, ...
45 00000000 - 00003FFF : Exception Vectors
46 00004000 - 057FFFFF : Free Memory
47 05800000 - 05FFFFFF : OF Image
48
49
50 Logical Address
51
52 00000000 - 00003FFF : Exception Vectors
53 00004000 - 03FFFFFF : Kernel Image, Boot Struct and Drivers
54 04000000 - 04FFFFFF : File Load Area
55 05000000 - 053FFFFF : FS Cache
56 05400000 - 055FFFFF : Malloc Zone
57 05600000 - 057FFFFF : BootX Image
58 05800000 - 05FFFFFF : Unused
59
60 */
61
62 #define kVectorAddr (0x00000000)
63 #define kVectorSize (0x00004000)
64
65 // OF 3.x
66 #define kImageAddr (0x00004000)
67 #define kImageSize (0x03FFC000)
68
69 // OF 1.x 2.x
70 #define kImageAddr0 (0x00004000)
71 #define kImageSize0 (0x002FC000)
72 #define kImageAddr1 (0x00300000)
73 #define kImageSize1 (0x00200000)
74 #define kImageAddr1Phys (0x05800000)
75 #define kImageAddr2 (0x00500000)
76 #define kImageSize2 (0x03B00000)
77
78 #define kLoadAddr (0x04000000)
79 #define kLoadSize (0x01000000)
80
81 #define kFSCacheAddr (0x05000000)
82 #define kFSCacheSize (0x00400000)
83
84 #define kMallocAddr (0x05400000)
85 #define kMallocSize (0x00200000)
86
87 // Default Output Level
88 #define kOutputLevelOff (0)
89 #define kOutputLevelFull (16)
90
91 // OF versions
92 #define kOFVersion1x (0x01000000)
93 #define kOFVersion2x (0x02000000)
94 #define kOFVersion3x (0x03000000)
95 #define kOFVersion4x (0x04000000)
96
97 // Device Types
98 enum {
99 kUnknownDeviceType = 0,
100 kNetworkDeviceType,
101 kBlockDeviceType
102 };
103
104 // File Permissions and Types
105 enum {
106 kPermOtherExecute = 1 << 0,
107 kPermOtherWrite = 1 << 1,
108 kPermOtherRead = 1 << 2,
109 kPermGroupExecute = 1 << 3,
110 kPermGroupWrite = 1 << 4,
111 kPermGroupRead = 1 << 5,
112 kPermOwnerExecute = 1 << 6,
113 kPermOwnerWrite = 1 << 7,
114 kPermOwnerRead = 1 << 8,
115 kPermMask = 0x1FF,
116 kOwnerNotRoot = 1 << 9,
117 kFileTypeUnknown = 0x0 << 16,
118 kFileTypeFlat = 0x1 << 16,
119 kFileTypeDirectory = 0x2 << 16,
120 kFileTypeLink = 0x3 << 16,
121 kFileTypeMask = 0x3 << 16
122 };
123
124 // Key Numbers
125 #define kCommandKey (0x200)
126 #define kOptKey (0x201)
127 #define kShiftKey (0x202)
128 #define kControlKey (0x203)
129
130 // Mac OS X Booter Signature 'MOSX'
131 #define kMacOSXSignature (0x4D4F5358)
132
133 // Boot Modes
134 enum {
135 kBootModeNormal = 0,
136 kBootModeSafe,
137 kBootModeSecure
138 };
139
140 #include <sys/stat.h>
141 #include <sys/types.h>
142
143 #include <ci.h>
144 #include <sl_words.h>
145 #include <libclite.h>
146 #include <fs.h>
147 #include <boot_args.h>
148
149 // Externs for main.c
150 extern char *gVectorSaveAddr;
151 extern long gKernelEntryPoint;
152 extern long gDeviceTreeAddr;
153 extern long gDeviceTreeSize;
154 extern long gBootArgsAddr;
155 extern long gBootArgsSize;
156 extern long gSymbolTableAddr;
157 extern long gSymbolTableSize;
158
159 extern long gBootMode;
160 extern long gBootDeviceType;
161 extern long gBootFileType;
162 extern char gBootDevice[256];
163 extern char gBootFile[256];
164 extern char gRootDir[256];
165
166 extern char gTempStr[4096];
167
168 extern long *gDeviceTreeMMTmp;
169
170 extern long gOFVersion;
171
172 extern char *gKeyMap;
173
174 extern long gRootAddrCells;
175 extern long gRootSizeCells;
176
177 extern CICell gChosenPH;
178 extern CICell gOptionsPH;
179 extern CICell gScreenPH;
180 extern CICell gMemoryMapPH;
181 extern CICell gStdOutPH;
182
183 extern CICell gMMUIH;
184 extern CICell gMemoryIH;
185 extern CICell gStdOutIH;
186 extern CICell gKeyboardIH;
187
188 extern long ThinFatBinary(void **binary, unsigned long *length);
189 extern long GetDeviceType(char *devSpec);
190 extern long ConvertFileSpec(char *fileSpec, char *devSpec, char **filePath);
191 extern long MatchThis(CICell phandle, char *string);
192 extern void *AllocateBootXMemory(long size);
193 extern long AllocateKernelMemory(long size);
194 extern long AllocateMemoryRange(char *rangeName, long start, long length);
195 extern unsigned long Alder32(unsigned char *buffer, long length);
196
197 // Externs for macho.c
198 extern long ThinFatBinaryMachO(void **binary, unsigned long *length);
199 extern long DecodeMachO(void *binary);
200
201 // Externs for elf.c
202 extern long ThinFatBinaryElf(void **binary, unsigned long *length);
203 extern long DecodeElf(void *binary);
204
205 // Externs for device_tree.c
206 extern long FlattenDeviceTree(void);
207 extern CICell SearchForNode(CICell ph, long top, char *prop, char *value);
208 extern CICell SearchForNodeMatching(CICell ph, long top, char *value);
209
210 // Externs for display.c
211 extern long InitDisplays(void);
212 extern long DrawSplashScreen(long stage);
213 extern long DrawFailedBootPicture(void);
214 extern void GetMainScreenPH(Boot_Video_Ptr video);
215
216 // Externs for drivers.c
217 extern long LoadDrivers(char *dirPath);
218
219 // Externs for config.c
220 extern long InitConfig(void);
221 extern long ParseConfigFile(char *addr);
222
223 #endif /* ! _BOOTX_SL_H_ */