5 * Copyright (C) 2012 Michael Brown <mbrown@fensystems.co.uk>.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 * Boot application data structures
32 /** A segment:offset address */
38 } __attribute__ (( packed
));
42 /** 8 hex digits, big-endian */
44 /** 2 hex digits, big-endian */
46 /** 2 hex digits, big-endian */
48 /** 2 hex digits, big-endian */
50 /** 12 hex digits, big-endian */
52 } __attribute__ (( packed
));
54 /** Real-mode callback parameters */
55 struct bootapp_callback_params
{
58 /** Interrupt number */
60 /** Segment:offset address of real-mode function */
61 struct segoff function
;
68 } __attribute__ (( packed
));
77 } __attribute__ (( packed
));
86 } __attribute__ (( packed
));
95 } __attribute__ (( packed
));
99 /** Placeholder (for %esp?) */
101 /** Placeholder (for %ebp?) */
113 /** Placeholder (for %cs?) */
117 /** Placeholder (for %ss?) */
127 } __attribute__ (( packed
));
139 /** Real-mode callback function table */
140 struct bootapp_callback_functions
{
142 * Call an arbitrary real-mode interrupt
144 * @v params Parameters
146 void ( * call_interrupt
) ( struct bootapp_callback_params
*params
);
148 * Call an arbitrary real-mode function
150 * @v params Parameters
152 void ( * call_real
) ( struct bootapp_callback_params
*params
);
153 } __attribute__ (( packed
));
155 /** Real-mode callbacks */
156 struct bootapp_callback
{
157 /** Real-mode callback function table */
158 struct bootapp_callback_functions
*fns
;
159 /** Drive number for INT13 calls */
161 } __attribute__ (( packed
));
163 /** Boot application descriptor */
164 struct bootapp_descriptor
{
171 /** COFF machine type */
174 uint32_t reserved_0x14
;
175 /** Loaded PE image base address */
178 uint32_t reserved_0x1c
;
179 /** Length of loaded PE image */
181 /** Offset to memory descriptor */
183 /** Offset to boot application entry descriptor */
187 /** Offset to callback descriptor */
189 /** Offset to pointless descriptor */
192 uint32_t reserved_0x38
;
193 } __attribute__ (( packed
));
195 /** "BOOT APP" magic signature */
196 #define BOOTAPP_SIGNATURE "BOOT APP"
198 /** Boot application descriptor version */
199 #define BOOTAPP_VERSION 2
201 /** i386 architecture */
202 #define BOOTAPP_ARCH_I386 0x014c
204 /** Memory region descriptor */
205 struct bootapp_memory_region
{
206 /** Reserved (for struct list_head?) */
208 /** Start page address */
211 uint8_t reserved_0x10
[8];
212 /** Number of pages */
215 uint8_t reserved_0x20
[4];
218 } __attribute__ (( packed
));
220 /** Memory descriptor */
221 struct bootapp_memory_descriptor
{
224 /** Length of descriptor (excluding region descriptors) */
226 /** Number of regions */
227 uint32_t num_regions
;
228 /** Length of each region descriptor */
230 /** Length of reserved area at start of each region descriptor */
231 uint32_t reserved_len
;
232 } __attribute__ (( packed
));
234 /** Boot application memory descriptor version */
235 #define BOOTAPP_MEMORY_VERSION 1
237 /** Boot application entry descriptor */
238 struct bootapp_entry_descriptor
{
246 uint8_t reserved
[16];
247 } __attribute__ (( packed
));
250 struct bootapp_entry_wtf1_descriptor
{
253 /** Length of descriptor */
255 /** Total length of following descriptors within BTAPENT */
258 uint8_t reserved
[12];
259 } __attribute__ (( packed
));
262 struct bootapp_entry_wtf2_descriptor
{
265 } __attribute__ (( packed
));
268 struct bootapp_entry_wtf3_descriptor
{
272 uint32_t reserved_0x04
;
273 /** Length of descriptor */
276 uint32_t reserved_0x0c
;
277 /** Boot partition offset (in bytes) */
278 uint32_t boot_partition_offset
;
280 uint8_t reserved_0x14
[16];
281 /** MBR signature present? */
284 uint32_t mbr_signature
;
286 uint8_t reserved_0x2c
[26];
287 } __attribute__ (( packed
));
289 /** "BTAPENT" magic signature */
290 #define BOOTAPP_ENTRY_SIGNATURE "BTAPENT\0"
292 /** Boot application entry flags
294 * pxeboot, etftboot, and fatboot all use a value of 0x21; I have no
295 * idea what it means.
297 #define BOOTAPP_ENTRY_FLAGS 0x21
299 /** Boot application callback descriptor */
300 struct bootapp_callback_descriptor
{
301 /** Real-mode callbacks */
302 struct bootapp_callback
*callback
;
305 } __attribute__ (( packed
));
307 /** Boot application pointless descriptor */
308 struct bootapp_pointless_descriptor
{
312 uint8_t reserved
[24];
313 } __attribute__ (( packed
));
315 /** Boot application pointless descriptor version */
316 #define BOOTAPP_POINTLESS_VERSION 1
318 #endif /* _BOOTAPP_H */