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