]> git.saurik.com Git - apple/xnu.git/blob - pexpert/pexpert/i386/boot.h
7cccc0f0738011b786d140cea394e6e061e9fbc6
[apple/xnu.git] / pexpert / pexpert / i386 / boot.h
1 /*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
14 * agreement.
15 *
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
18 * file.
19 *
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
27 *
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
29 */
30 #ifndef _PEXPERT_I386_BOOT_H
31 #define _PEXPERT_I386_BOOT_H
32
33 /*
34 * What the booter leaves behind for the kernel.
35 */
36
37 /*
38 * Maximum number of boot drivers that can be loaded.
39 */
40 #define NDRIVERS 500
41
42 /*
43 * Types of boot driver that may be loaded by the booter.
44 */
45 enum {
46 kBootDriverTypeInvalid = 0,
47 kBootDriverTypeKEXT = 1,
48 kBootDriverTypeMKEXT = 2
49 };
50
51 typedef struct {
52 unsigned long address; // address where driver was loaded
53 unsigned long size; // number of bytes
54 unsigned long type; // driver type
55 } driver_config_t;
56
57 /*
58 * APM BIOS information.
59 */
60 typedef struct {
61 unsigned short major_vers; // == 0 if not present
62 unsigned short minor_vers;
63 unsigned long cs32_base;
64 unsigned long cs16_base;
65 unsigned long ds_base;
66 unsigned long cs_length;
67 unsigned long ds_length;
68 unsigned long entry_offset;
69 union {
70 struct {
71 unsigned long mode_16 :1;
72 unsigned long mode_32 :1;
73 unsigned long idle_slows_cpu :1;
74 unsigned long reserved :29;
75 } f;
76 unsigned long data;
77 } flags;
78 unsigned long connected;
79 } APM_config_t;
80
81 /*
82 * PCI bus information.
83 */
84 typedef struct _PCI_bus_info_t {
85 union {
86 struct {
87 unsigned char configMethod1 :1;
88 unsigned char configMethod2 :1;
89 unsigned char :2;
90 unsigned char specialCycle1 :1;
91 unsigned char specialCycle2 :1;
92 } s;
93 unsigned char d;
94 } u_bus;
95 unsigned char maxBusNum;
96 unsigned char majorVersion;
97 unsigned char minorVersion;
98 unsigned char BIOSPresent;
99 } PCI_bus_info_t;
100
101 /*
102 * Video information.
103 */
104 struct boot_video {
105 unsigned long v_baseAddr; // Base address of video memory
106 unsigned long v_display; // Display Code (if Applicable
107 unsigned long v_rowBytes; // Number of bytes per pixel row
108 unsigned long v_width; // Width
109 unsigned long v_height; // Height
110 unsigned long v_depth; // Pixel Depth
111 };
112
113 typedef struct boot_video boot_video;
114
115 #define GRAPHICS_MODE 1
116 #define TEXT_MODE 0
117
118
119 /*
120 * INT15, E820h - Query System Address Map.
121 *
122 * Documented in ACPI Specification Rev 2.0,
123 * Chapter 15 (System Address Map Interfaces).
124 */
125
126 /*
127 * ACPI defined memory range types.
128 */
129 enum {
130 kMemoryRangeUsable = 1, // RAM usable by the OS.
131 kMemoryRangeReserved = 2, // Reserved. (Do not use)
132 kMemoryRangeACPI = 3, // ACPI tables. Can be reclaimed.
133 kMemoryRangeNVS = 4, // ACPI NVS memory. (Do not use)
134
135 /* Undefined types should be treated as kMemoryRangeReserved */
136 };
137
138 /*
139 * Memory range descriptor.
140 */
141 typedef struct MemoryRange {
142 unsigned long long base; // 64-bit base address
143 unsigned long long length; // 64-bit length in bytes
144 unsigned long type; // type of memory range
145 unsigned long reserved;
146 } MemoryRange;
147
148 #define kMemoryMapCountMax 40
149
150 /*
151 * BIOS drive information.
152 */
153 struct boot_drive_info {
154 struct drive_params {
155 unsigned short buf_size;
156 unsigned short info_flags;
157 unsigned long phys_cyls;
158 unsigned long phys_heads;
159 unsigned long phys_spt;
160 unsigned long long phys_sectors;
161 unsigned short phys_nbps;
162 unsigned short dpte_offset;
163 unsigned short dpte_segment;
164 unsigned short key;
165 unsigned char path_len;
166 unsigned char reserved1;
167 unsigned short reserved2;
168 unsigned char bus_type[4];
169 unsigned char interface_type[8];
170 unsigned char interface_path[8];
171 unsigned char dev_path[8];
172 unsigned char reserved3;
173 unsigned char checksum;
174 } params __attribute__((packed));
175 struct drive_dpte {
176 unsigned short io_port_base;
177 unsigned short control_port_base;
178 unsigned char head_flags;
179 unsigned char vendor_info;
180 unsigned char irq : 4;
181 unsigned char irq_unused : 4;
182 unsigned char block_count;
183 unsigned char dma_channel : 4;
184 unsigned char dma_type : 4;
185 unsigned char pio_type : 4;
186 unsigned char pio_unused : 4;
187 unsigned short option_flags;
188 unsigned short reserved;
189 unsigned char revision;
190 unsigned char checksum;
191 } dpte __attribute__((packed));
192 } __attribute__((packed));
193 typedef struct boot_drive_info boot_drive_info_t;
194
195 #define MAX_BIOS_DEVICES 8
196
197 #define OLD_BOOT_STRING_LEN 160
198 #define BOOT_STRING_LEN 1024
199 #define CONFIG_SIZE (12 * 4096)
200
201 /* Old structure for compatibility */
202
203 typedef struct {
204 short version;
205 char bootString[OLD_BOOT_STRING_LEN]; // boot arguments
206 int magicCookie; // KERNBOOTMAGIC
207 int numIDEs; // number of IDE drives
208 int rootdev; // root device
209 int convmem; // conventional memory
210 int extmem; // extended memory
211 char bootFile[128]; // kernel file name
212 int firstAddr0; // first address for kern convmem
213 int diskInfo[4]; // info for bios dev 80-83
214 int graphicsMode; // booted in graphics mode?
215 int kernDev; // device kernel was fetched from
216 int numBootDrivers; // number of drivers loaded
217 char * configEnd; // pointer to end of config files
218 int kaddr; // kernel load address
219 int ksize; // size of kernel
220 driver_config_t driverConfig[NDRIVERS];
221 char _reserved[2052];
222 boot_video video;
223 PCI_bus_info_t pciInfo;
224 APM_config_t apmConfig;
225 char config[CONFIG_SIZE];
226 } KERNBOOTSTRUCT;
227
228 #define KERNSTRUCT_ADDR ((KERNBOOTSTRUCT *) 0x11000)
229 #define KERNBOOTMAGIC 0xa7a7a7a7
230
231 #define BOOT_LINE_LENGTH 256
232
233 /*
234 * Video information..
235 */
236
237 struct Boot_Video {
238 unsigned long v_baseAddr; /* Base address of video memory */
239 unsigned long v_display; /* Display Code (if Applicable */
240 unsigned long v_rowBytes; /* Number of bytes per pixel row */
241 unsigned long v_width; /* Width */
242 unsigned long v_height; /* Height */
243 unsigned long v_depth; /* Pixel Depth */
244 };
245
246 typedef struct Boot_Video Boot_Video;
247
248 /* DRAM Bank definitions - describes physical memory layout.
249 */
250 #define kMaxDRAMBanks 26 /* maximum number of DRAM banks */
251
252 struct DRAMBank
253 {
254 unsigned long base; /* physical base of DRAM bank */
255 unsigned long size; /* size of bank */
256 };
257 typedef struct DRAMBank DRAMBank;
258
259
260 /* Boot argument structure - passed into Mach kernel at boot time.
261 */
262 #define kBootArgsVersion 1
263 #define kBootArgsRevision 1
264
265 typedef struct boot_args {
266 unsigned short Revision; /* Revision of boot_args structure */
267 unsigned short Version; /* Version of boot_args structure */
268 char CommandLine[BOOT_LINE_LENGTH]; /* Passed in command line */
269 DRAMBank PhysicalDRAM[kMaxDRAMBanks]; /* base and range pairs for the 26 DRAM banks */
270 Boot_Video Video; /* Video Information */
271 unsigned long machineType; /* Machine Type (gestalt) */
272 void *deviceTreeP; /* Base of flattened device tree */
273 unsigned long deviceTreeLength;/* Length of flattened tree */
274 unsigned long topOfKernelData;/* Highest address used in kernel data area */
275 } boot_args;
276
277 extern boot_args passed_args;
278
279 /* New structures */
280
281
282 #define KERNEL_BOOT_MAGIC 0xa5b6d7e8
283
284 typedef struct KernelBootArgs {
285 unsigned int magicCookie; // KERNEL_BOOT_MAGIC
286 unsigned short version;
287 unsigned short revision;
288 unsigned int size; // size of KernelBootArgs structure
289 int numDrives; // number of BIOS drives
290 int rootdev; // root device
291 int convmem; // conventional memory
292 int extmem; // extended memory
293 unsigned int firstAddr0; // first address for kern convmem
294 int graphicsMode; // booted in graphics mode?
295 int kernDev; // device kernel was fetched from
296 int numBootDrivers; // number of drivers loaded
297 char * configEnd; // pointer to end of config files
298 unsigned int kaddr; // kernel load address
299 unsigned int ksize; // size of kernel
300 char bootFile[128]; // kernel file name
301 char bootString[BOOT_STRING_LEN]; // boot arguments
302 driver_config_t driverConfig[NDRIVERS];
303 unsigned long memoryMapCount;
304 MemoryRange memoryMap[kMemoryMapCountMax];
305 boot_drive_info_t driveInfo[MAX_BIOS_DEVICES];
306 boot_video video;
307 PCI_bus_info_t pciInfo;
308 APM_config_t apmConfig;
309 char config[CONFIG_SIZE];
310 } KernelBootArgs_t;
311
312
313 #endif /* _PEXPERT_I386_BOOT_H */
314