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