80d6adde1a492cc0582eb0d8d1bd3d524691114c
[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 /* The config table has room for 13 drivers if their config files
30 * are the maximum size allowed.
31 */
32 #define CONFIG_SIZE (13 * 4096)
33
34 /* Maximum number of boot drivers supported, assuming their
35 * config files fit in the bootstruct.
36 */
37 #define NDRIVERS 64
38
39 typedef struct {
40 char *address; // address where driver was loaded
41 int size; // entry point for driver
42 } driver_config_t;
43
44 typedef struct {
45 unsigned short major_vers; // == 0 if not present
46 unsigned short minor_vers;
47 unsigned long cs32_base;
48 unsigned long cs16_base;
49 unsigned long ds_base;
50 unsigned long cs_length;
51 unsigned long ds_length;
52 unsigned long entry_offset;
53 union {
54 struct {
55 unsigned long mode_16 :1;
56 unsigned long mode_32 :1;
57 unsigned long idle_slows_cpu :1;
58 unsigned long reserved :29;
59 } f;
60 unsigned long data;
61 } flags;
62 unsigned long connected;
63 } APM_config_t;
64
65 typedef struct _EISA_slot_info_t {
66 union {
67 struct {
68 unsigned char duplicateID :4;
69 unsigned char slotType :1;
70 unsigned char prodIDPresent :1;
71 unsigned char dupIDPresent :1;
72 } s;
73 unsigned char d;
74 } u_ID;
75 unsigned char configMajor;
76 unsigned char configMinor;
77 unsigned short checksum;
78 unsigned char numFunctions;
79 union {
80 struct {
81 unsigned char fnTypesPresent :1;
82 unsigned char memoryPresent :1;
83 unsigned char irqPresent :1;
84 unsigned char dmaPresent :1;
85 unsigned char portRangePresent:1;
86 unsigned char portInitPresent :1;
87 unsigned char freeFormPresent :1;
88 unsigned char reserved:1;
89 } s;
90 unsigned char d;
91 } u_resources;
92 unsigned char id[8];
93 } EISA_slot_info_t;
94
95 typedef struct _EISA_func_info_t {
96 unsigned char slot;
97 unsigned char function;
98 unsigned char reserved[2];
99 unsigned char data[320];
100 } EISA_func_info_t;
101
102 #define NUM_EISA_SLOTS 64
103
104 typedef struct _PCI_bus_info_t {
105 union {
106 struct {
107 unsigned char configMethod1 :1;
108 unsigned char configMethod2 :1;
109 unsigned char :2;
110 unsigned char specialCycle1 :1;
111 unsigned char specialCycle2 :1;
112 } s;
113 unsigned char d;
114 } u_bus;
115 unsigned char maxBusNum;
116 unsigned char majorVersion;
117 unsigned char minorVersion;
118 unsigned char BIOSPresent;
119 } PCI_bus_info_t;
120
121 /*
122 * Video information..
123 */
124
125 struct boot_video {
126 unsigned long v_baseAddr; /* Base address of video memory */
127 unsigned long v_display; /* Display Code (if Applicable */
128 unsigned long v_rowBytes; /* Number of bytes per pixel row */
129 unsigned long v_width; /* Width */
130 unsigned long v_height; /* Height */
131 unsigned long v_depth; /* Pixel Depth */
132 };
133
134 typedef struct boot_video boot_video;
135
136 #define BOOT_STRING_LEN 160
137
138 typedef struct {
139 short version;
140 char bootString[BOOT_STRING_LEN];// string we booted with
141 int magicCookie; // KERNBOOTMAGIC if struct valid
142 int numIDEs; // how many IDE drives
143 int rootdev; // booters guess as to rootdev
144 int convmem; // conventional memory
145 int extmem; // extended memory
146 char boot_file[128]; // name of the kernel we booted
147 int first_addr0; // first address for kern convmem
148 int diskInfo[4]; // bios info for bios dev 80-83
149 int graphicsMode; // did we boot in graphics mode?
150 int kernDev; // device kernel was fetched from
151 int numBootDrivers; // number of drivers loaded by booter
152 char *configEnd; // pointer to end of config files
153 int kaddr; // kernel load address
154 int ksize; // size of kernel
155 void *rld_entry; // entry point for standalone rld
156
157 driver_config_t driverConfig[NDRIVERS];
158 APM_config_t apm_config;
159
160 char _reserved[7500];
161
162 boot_video video;
163
164 PCI_bus_info_t pciInfo;
165
166 int eisaConfigFunctions;
167 EISA_slot_info_t eisaSlotInfo[NUM_EISA_SLOTS];// EISA slot information
168
169 char config[CONFIG_SIZE]; // the config file contents
170 } KERNBOOTSTRUCT;
171
172 #define GRAPHICS_MODE 1
173 #define TEXT_MODE 0
174
175 #define KERNSTRUCT_ADDR ((KERNBOOTSTRUCT *)0x11000)
176 #define KERNBOOTMAGIC 0xa7a7a7a7
177
178 #ifndef EISA_CONFIG_ADDR
179 #define EISA_CONFIG_ADDR 0x20000
180 #define EISA_CONFIG_LEN 0x10000
181 #endif
182
183 #ifndef KERNEL
184 extern KERNBOOTSTRUCT *kernBootStruct;
185 #endif
186
187 #define BOOT_LINE_LENGTH 256
188
189 /*
190 * Video information..
191 */
192
193 struct Boot_Video {
194 unsigned long v_baseAddr; /* Base address of video memory */
195 unsigned long v_display; /* Display Code (if Applicable */
196 unsigned long v_rowBytes; /* Number of bytes per pixel row */
197 unsigned long v_width; /* Width */
198 unsigned long v_height; /* Height */
199 unsigned long v_depth; /* Pixel Depth */
200 };
201
202 typedef struct Boot_Video Boot_Video;
203
204 /* DRAM Bank definitions - describes physical memory layout.
205 */
206 #define kMaxDRAMBanks 26 /* maximum number of DRAM banks */
207
208 struct DRAMBank
209 {
210 unsigned long base; /* physical base of DRAM bank */
211 unsigned long size; /* size of bank */
212 };
213 typedef struct DRAMBank DRAMBank;
214
215
216 /* Boot argument structure - passed into Mach kernel at boot time.
217 */
218 #define kBootArgsVersion 1
219 #define kBootArgsRevision 1
220
221 typedef struct boot_args {
222 unsigned short Revision; /* Revision of boot_args structure */
223 unsigned short Version; /* Version of boot_args structure */
224 char CommandLine[BOOT_LINE_LENGTH]; /* Passed in command line */
225 DRAMBank PhysicalDRAM[kMaxDRAMBanks]; /* base and range pairs for the 26 DRAM banks */
226 Boot_Video Video; /* Video Information */
227 unsigned long machineType; /* Machine Type (gestalt) */
228 void *deviceTreeP; /* Base of flattened device tree */
229 unsigned long deviceTreeLength;/* Length of flattened tree */
230 unsigned long topOfKernelData;/* Highest address used in kernel data area */
231 } boot_args;
232
233 extern boot_args passed_args;
234
235 #endif /* _PEXPERT_I386_BOOT_H */
236