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