vaseboot/include/VasEBoot/i386/linux.h

317 lines
12 KiB
C

/*
* VasEBoot -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2007,2008,2009 Free Software Foundation, Inc.
*
* VasEBoot is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* VasEBoot is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with VasEBoot. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VasEBoot_LINUX_MACHINE_HEADER
#define VasEBoot_LINUX_MACHINE_HEADER 1
#define VasEBoot_LINUX_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */
#define VasEBoot_LINUX_DEFAULT_SETUP_SECTS 4
#define VasEBoot_LINUX_INITRD_MAX_ADDRESS 0x37FFFFFF
#define VasEBoot_LINUX_MAX_SETUP_SECTS 64
#define VasEBoot_LINUX_BOOT_LOADER_TYPE 0x72
#define VasEBoot_LINUX_HEAP_END_OFFSET (0x9000 - 0x200)
#define VasEBoot_LINUX_BZIMAGE_ADDR 0x100000
#define VasEBoot_LINUX_ZIMAGE_ADDR 0x10000
#define VasEBoot_LINUX_OLD_REAL_MODE_ADDR 0x90000
#define VasEBoot_LINUX_SETUP_STACK 0x9000
#define VasEBoot_LINUX_FLAG_BIG_KERNEL 0x1
#define VasEBoot_LINUX_FLAG_QUIET 0x20
#define VasEBoot_LINUX_FLAG_CAN_USE_HEAP 0x80
/* Linux's video mode selection support. Actually I hate it! */
#define VasEBoot_LINUX_VID_MODE_NORMAL 0xFFFF
#define VasEBoot_LINUX_VID_MODE_EXTENDED 0xFFFE
#define VasEBoot_LINUX_VID_MODE_ASK 0xFFFD
#define VasEBoot_LINUX_VID_MODE_VESA_START 0x0300
#define VasEBoot_LINUX_CL_MAGIC 0xA33F
#ifdef __x86_64__
#define VasEBoot_LINUX_EFI_SIGNATURE \
('4' << 24 | '6' << 16 | 'L' << 8 | 'E')
#else
#define VasEBoot_LINUX_EFI_SIGNATURE \
('2' << 24 | '3' << 16 | 'L' << 8 | 'E')
#endif
#define VasEBoot_LINUX_EFI_SIGNATURE_0204 \
('L' << 24 | 'I' << 16 | 'F' << 8 | 'E')
#define VasEBoot_LINUX_OFW_SIGNATURE \
(' ' << 24 | 'W' << 16 | 'F' << 8 | 'O')
#ifndef ASM_FILE
#define VasEBoot_E820_RAM 1
#define VasEBoot_E820_RESERVED 2
#define VasEBoot_E820_ACPI 3
#define VasEBoot_E820_NVS 4
#define VasEBoot_E820_BADRAM 5
struct VasEBoot_e820_mmap
{
VasEBoot_uint64_t addr;
VasEBoot_uint64_t size;
VasEBoot_uint32_t type;
} VasEBoot_PACKED;
enum
{
VasEBoot_VIDEO_LINUX_TYPE_TEXT = 0x01,
VasEBoot_VIDEO_LINUX_TYPE_VESA = 0x23, /* VESA VGA in graphic mode. */
VasEBoot_VIDEO_LINUX_TYPE_EFIFB = 0x70, /* EFI Framebuffer. */
VasEBoot_VIDEO_LINUX_TYPE_SIMPLE = 0x70 /* Linear framebuffer without any additional functions. */
};
/* For the Linux/i386 boot protocol version 2.10. */
struct linux_kernel_header
{
VasEBoot_uint8_t code1[0x0020];
VasEBoot_uint16_t cl_magic; /* Magic number 0xA33F */
VasEBoot_uint16_t cl_offset; /* The offset of command line */
VasEBoot_uint8_t code2[0x01F1 - 0x0020 - 2 - 2];
VasEBoot_uint8_t setup_sects; /* The size of the setup in sectors */
VasEBoot_uint16_t root_flags; /* If the root is mounted readonly */
VasEBoot_uint16_t syssize; /* obsolete */
VasEBoot_uint16_t swap_dev; /* obsolete */
VasEBoot_uint16_t ram_size; /* obsolete */
VasEBoot_uint16_t vid_mode; /* Video mode control */
VasEBoot_uint16_t root_dev; /* Default root device number */
VasEBoot_uint16_t boot_flag; /* 0xAA55 magic number */
VasEBoot_uint16_t jump; /* Jump instruction */
VasEBoot_uint32_t header; /* Magic signature "HdrS" */
VasEBoot_uint16_t version; /* Boot protocol version supported */
VasEBoot_uint32_t realmode_swtch; /* Boot loader hook */
VasEBoot_uint16_t start_sys; /* The load-low segment (obsolete) */
VasEBoot_uint16_t kernel_version; /* Points to kernel version string */
VasEBoot_uint8_t type_of_loader; /* Boot loader identifier */
#define LINUX_LOADER_ID_LILO 0x0
#define LINUX_LOADER_ID_LOADLIN 0x1
#define LINUX_LOADER_ID_BOOTSECT 0x2
#define LINUX_LOADER_ID_SYSLINUX 0x3
#define LINUX_LOADER_ID_ETHERBOOT 0x4
#define LINUX_LOADER_ID_ELILO 0x5
#define LINUX_LOADER_ID_VasEBoot 0x7
#define LINUX_LOADER_ID_UBOOT 0x8
#define LINUX_LOADER_ID_XEN 0x9
#define LINUX_LOADER_ID_GUJIN 0xa
#define LINUX_LOADER_ID_QEMU 0xb
VasEBoot_uint8_t loadflags; /* Boot protocol option flags */
VasEBoot_uint16_t setup_move_size; /* Move to high memory size */
VasEBoot_uint32_t code32_start; /* Boot loader hook */
VasEBoot_uint32_t ramdisk_image; /* initrd load address */
VasEBoot_uint32_t ramdisk_size; /* initrd size */
VasEBoot_uint32_t bootsect_kludge; /* obsolete */
VasEBoot_uint16_t heap_end_ptr; /* Free memory after setup end */
VasEBoot_uint16_t pad1; /* Unused */
VasEBoot_uint32_t cmd_line_ptr; /* Points to the kernel command line */
VasEBoot_uint32_t initrd_addr_max; /* Highest address for initrd */
VasEBoot_uint32_t kernel_alignment;
VasEBoot_uint8_t relocatable;
VasEBoot_uint8_t min_alignment;
VasEBoot_uint8_t pad[2];
VasEBoot_uint32_t cmdline_size;
VasEBoot_uint32_t hardware_subarch;
VasEBoot_uint64_t hardware_subarch_data;
VasEBoot_uint32_t payload_offset;
VasEBoot_uint32_t payload_length;
VasEBoot_uint64_t setup_data;
VasEBoot_uint64_t pref_address;
VasEBoot_uint32_t init_size;
VasEBoot_uint32_t handover_offset;
} VasEBoot_PACKED;
/* Boot parameters for Linux based on 2.6.12. This is used by the setup
sectors of Linux, and must be simulated by VasEBoot on EFI, because
the setup sectors depend on BIOS. */
struct linux_kernel_params
{
VasEBoot_uint8_t video_cursor_x; /* 0 */
VasEBoot_uint8_t video_cursor_y;
VasEBoot_uint16_t ext_mem; /* 2 */
VasEBoot_uint16_t video_page; /* 4 */
VasEBoot_uint8_t video_mode; /* 6 */
VasEBoot_uint8_t video_width; /* 7 */
VasEBoot_uint8_t padding1[0xa - 0x8];
VasEBoot_uint16_t video_ega_bx; /* a */
VasEBoot_uint8_t padding2[0xe - 0xc];
VasEBoot_uint8_t video_height; /* e */
VasEBoot_uint8_t have_vga; /* f */
VasEBoot_uint16_t font_size; /* 10 */
VasEBoot_uint16_t lfb_width; /* 12 */
VasEBoot_uint16_t lfb_height; /* 14 */
VasEBoot_uint16_t lfb_depth; /* 16 */
VasEBoot_uint32_t lfb_base; /* 18 */
VasEBoot_uint32_t lfb_size; /* 1c */
VasEBoot_uint16_t cl_magic; /* 20 */
VasEBoot_uint16_t cl_offset;
VasEBoot_uint16_t lfb_line_len; /* 24 */
VasEBoot_uint8_t red_mask_size; /* 26 */
VasEBoot_uint8_t red_field_pos;
VasEBoot_uint8_t green_mask_size;
VasEBoot_uint8_t green_field_pos;
VasEBoot_uint8_t blue_mask_size;
VasEBoot_uint8_t blue_field_pos;
VasEBoot_uint8_t reserved_mask_size;
VasEBoot_uint8_t reserved_field_pos;
VasEBoot_uint16_t vesapm_segment; /* 2e */
VasEBoot_uint16_t vesapm_offset; /* 30 */
VasEBoot_uint16_t lfb_pages; /* 32 */
VasEBoot_uint16_t vesa_attrib; /* 34 */
VasEBoot_uint32_t capabilities; /* 36 */
VasEBoot_uint8_t padding3[0x40 - 0x3a];
VasEBoot_uint16_t apm_version; /* 40 */
VasEBoot_uint16_t apm_code_segment; /* 42 */
VasEBoot_uint32_t apm_entry; /* 44 */
VasEBoot_uint16_t apm_16bit_code_segment; /* 48 */
VasEBoot_uint16_t apm_data_segment; /* 4a */
VasEBoot_uint16_t apm_flags; /* 4c */
VasEBoot_uint32_t apm_code_len; /* 4e */
VasEBoot_uint16_t apm_data_len; /* 52 */
VasEBoot_uint8_t padding4[0x60 - 0x54];
VasEBoot_uint32_t ist_signature; /* 60 */
VasEBoot_uint32_t ist_command; /* 64 */
VasEBoot_uint32_t ist_event; /* 68 */
VasEBoot_uint32_t ist_perf_level; /* 6c */
VasEBoot_uint8_t padding5[0x80 - 0x70];
VasEBoot_uint8_t hd0_drive_info[0x10]; /* 80 */
VasEBoot_uint8_t hd1_drive_info[0x10]; /* 90 */
VasEBoot_uint16_t rom_config_len; /* a0 */
VasEBoot_uint8_t padding6[0xb0 - 0xa2];
VasEBoot_uint32_t ofw_signature; /* b0 */
VasEBoot_uint32_t ofw_num_items; /* b4 */
VasEBoot_uint32_t ofw_cif_handler; /* b8 */
VasEBoot_uint32_t ofw_idt; /* bc */
VasEBoot_uint8_t padding7[0x1b8 - 0xc0];
union
{
struct
{
VasEBoot_uint32_t efi_system_table; /* 1b8 */
VasEBoot_uint32_t padding7_1; /* 1bc */
VasEBoot_uint32_t efi_signature; /* 1c0 */
VasEBoot_uint32_t efi_mem_desc_size; /* 1c4 */
VasEBoot_uint32_t efi_mem_desc_version; /* 1c8 */
VasEBoot_uint32_t efi_mmap_size; /* 1cc */
VasEBoot_uint32_t efi_mmap; /* 1d0 */
} v0204;
struct
{
VasEBoot_uint32_t padding7_1; /* 1b8 */
VasEBoot_uint32_t padding7_2; /* 1bc */
VasEBoot_uint32_t efi_signature; /* 1c0 */
VasEBoot_uint32_t efi_system_table; /* 1c4 */
VasEBoot_uint32_t efi_mem_desc_size; /* 1c8 */
VasEBoot_uint32_t efi_mem_desc_version; /* 1cc */
VasEBoot_uint32_t efi_mmap; /* 1d0 */
VasEBoot_uint32_t efi_mmap_size; /* 1d4 */
} v0206;
struct
{
VasEBoot_uint32_t padding7_1; /* 1b8 */
VasEBoot_uint32_t padding7_2; /* 1bc */
VasEBoot_uint32_t efi_signature; /* 1c0 */
VasEBoot_uint32_t efi_system_table; /* 1c4 */
VasEBoot_uint32_t efi_mem_desc_size; /* 1c8 */
VasEBoot_uint32_t efi_mem_desc_version; /* 1cc */
VasEBoot_uint32_t efi_mmap; /* 1d0 */
VasEBoot_uint32_t efi_mmap_size; /* 1d4 */
VasEBoot_uint32_t efi_system_table_hi; /* 1d8 */
VasEBoot_uint32_t efi_mmap_hi; /* 1dc */
} v0208;
};
VasEBoot_uint32_t alt_mem; /* 1e0 */
VasEBoot_uint8_t padding8[0x1e8 - 0x1e4];
VasEBoot_uint8_t mmap_size; /* 1e8 */
VasEBoot_uint8_t padding9[0x1f1 - 0x1e9];
VasEBoot_uint8_t setup_sects; /* The size of the setup in sectors */
VasEBoot_uint16_t root_flags; /* If the root is mounted readonly */
VasEBoot_uint16_t syssize; /* obsolete */
VasEBoot_uint16_t swap_dev; /* obsolete */
VasEBoot_uint16_t ram_size; /* obsolete */
VasEBoot_uint16_t vid_mode; /* Video mode control */
VasEBoot_uint16_t root_dev; /* Default root device number */
VasEBoot_uint8_t padding10; /* 1fe */
VasEBoot_uint8_t ps_mouse; /* 1ff */
VasEBoot_uint16_t jump; /* Jump instruction */
VasEBoot_uint32_t header; /* Magic signature "HdrS" */
VasEBoot_uint16_t version; /* Boot protocol version supported */
VasEBoot_uint32_t realmode_swtch; /* Boot loader hook */
VasEBoot_uint16_t start_sys; /* The load-low segment (obsolete) */
VasEBoot_uint16_t kernel_version; /* Points to kernel version string */
VasEBoot_uint8_t type_of_loader; /* Boot loader identifier */
VasEBoot_uint8_t loadflags; /* Boot protocol option flags */
VasEBoot_uint16_t setup_move_size; /* Move to high memory size */
VasEBoot_uint32_t code32_start; /* Boot loader hook */
VasEBoot_uint32_t ramdisk_image; /* initrd load address */
VasEBoot_uint32_t ramdisk_size; /* initrd size */
VasEBoot_uint32_t bootsect_kludge; /* obsolete */
VasEBoot_uint16_t heap_end_ptr; /* Free memory after setup end */
VasEBoot_uint8_t ext_loader_ver; /* Extended loader version */
VasEBoot_uint8_t ext_loader_type; /* Extended loader type */
VasEBoot_uint32_t cmd_line_ptr; /* Points to the kernel command line */
VasEBoot_uint32_t initrd_addr_max; /* Maximum initrd address */
VasEBoot_uint32_t kernel_alignment; /* Alignment of the kernel */
VasEBoot_uint8_t relocatable_kernel; /* Is the kernel relocatable */
VasEBoot_uint8_t pad1[3];
VasEBoot_uint32_t cmdline_size; /* Size of the kernel command line */
VasEBoot_uint32_t hardware_subarch;
VasEBoot_uint64_t hardware_subarch_data;
VasEBoot_uint32_t payload_offset;
VasEBoot_uint32_t payload_length;
VasEBoot_uint64_t setup_data;
VasEBoot_uint8_t pad2[120]; /* 258 */
struct VasEBoot_e820_mmap e820_map[(0x400 - 0x2d0) / 20]; /* 2d0 */
} VasEBoot_PACKED;
#endif /* ! ASM_FILE */
#endif /* ! VasEBoot_LINUX_MACHINE_HEADER */