2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
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
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.
23 * @APPLE_LICENSE_HEADER_END@
25 #ifndef _PEXPERT_I386_BOOT_H
26 #define _PEXPERT_I386_BOOT_H
29 * What the booter leaves behind for the kernel.
33 * Maximum number of boot drivers that can be loaded.
38 * Types of boot driver that may be loaded by the booter.
41 kBootDriverTypeInvalid
= 0,
42 kBootDriverTypeKEXT
= 1,
43 kBootDriverTypeMKEXT
= 2
47 unsigned long address
; // address where driver was loaded
48 unsigned long size
; // number of bytes
49 unsigned long type
; // driver type
53 * APM BIOS information.
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
;
66 unsigned long mode_16
:1;
67 unsigned long mode_32
:1;
68 unsigned long idle_slows_cpu
:1;
69 unsigned long reserved
:29;
73 unsigned long connected
;
77 * PCI bus information.
79 typedef struct _PCI_bus_info_t
{
82 unsigned char configMethod1
:1;
83 unsigned char configMethod2
:1;
85 unsigned char specialCycle1
:1;
86 unsigned char specialCycle2
:1;
90 unsigned char maxBusNum
;
91 unsigned char majorVersion
;
92 unsigned char minorVersion
;
93 unsigned char BIOSPresent
;
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
108 typedef struct boot_video boot_video
;
110 #define GRAPHICS_MODE 1
115 * INT15, E820h - Query System Address Map.
117 * Documented in ACPI Specification Rev 2.0,
118 * Chapter 15 (System Address Map Interfaces).
122 * ACPI defined memory range types.
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)
130 /* Undefined types should be treated as kMemoryRangeReserved */
134 * Memory range descriptor.
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
;
143 #define kMemoryMapCountMax 40
146 * BIOS drive information.
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
;
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
));
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
;
190 #define MAX_BIOS_DEVICES 8
192 #define OLD_BOOT_STRING_LEN 160
193 #define BOOT_STRING_LEN 1024
194 #define CONFIG_SIZE (12 * 4096)
196 /* Old structure for compatibility */
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];
218 PCI_bus_info_t pciInfo
;
219 APM_config_t apmConfig
;
220 char config
[CONFIG_SIZE
];
223 #define KERNSTRUCT_ADDR ((KERNBOOTSTRUCT *) 0x11000)
224 #define KERNBOOTMAGIC 0xa7a7a7a7
226 #define BOOT_LINE_LENGTH 256
229 * Video information..
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 */
241 typedef struct Boot_Video Boot_Video
;
243 /* DRAM Bank definitions - describes physical memory layout.
245 #define kMaxDRAMBanks 26 /* maximum number of DRAM banks */
249 unsigned long base
; /* physical base of DRAM bank */
250 unsigned long size
; /* size of bank */
252 typedef struct DRAMBank DRAMBank
;
255 /* Boot argument structure - passed into Mach kernel at boot time.
257 #define kBootArgsVersion 1
258 #define kBootArgsRevision 1
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 */
272 extern boot_args passed_args
;
277 #define KERNEL_BOOT_MAGIC 0xa5b6d7e8
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
];
302 PCI_bus_info_t pciInfo
;
303 APM_config_t apmConfig
;
304 char config
[CONFIG_SIZE
];
308 #endif /* _PEXPERT_I386_BOOT_H */