vaseboot/include/VasEBoot/i386/linux.h

508 lines
17 KiB
C

/*
* VAS_EBOOT -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2007,2008,2009 Free Software Foundation, Inc.
*
* VAS_EBOOT 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.
*
* VAS_EBOOT 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 VAS_EBOOT. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef VAS_EBOOT_I386_LINUX_HEADER
#define VAS_EBOOT_I386_LINUX_HEADER 1
#include <VasEBoot/types.h>
#define VAS_EBOOT_LINUX_I386_MAGIC_SIGNATURE 0x53726448 /* "HdrS" */
#define VAS_EBOOT_LINUX_DEFAULT_SETUP_SECTS 4
#define VAS_EBOOT_LINUX_INITRD_MAX_ADDRESS 0x37FFFFFF
#define VAS_EBOOT_LINUX_MAX_SETUP_SECTS 64
#define VAS_EBOOT_LINUX_BOOT_LOADER_TYPE 0x72
#define VAS_EBOOT_LINUX_HEAP_END_OFFSET (0x9000 - 0x200)
#define VAS_EBOOT_LINUX_BZIMAGE_ADDR 0x100000
#define VAS_EBOOT_LINUX_ZIMAGE_ADDR 0x10000
#define VAS_EBOOT_LINUX_OLD_REAL_MODE_ADDR 0x90000
#define VAS_EBOOT_LINUX_SETUP_STACK 0x9000
#define VAS_EBOOT_LINUX_FLAG_BIG_KERNEL 0x1
#define VAS_EBOOT_LINUX_FLAG_QUIET 0x20
#define VAS_EBOOT_LINUX_FLAG_CAN_USE_HEAP 0x80
/* Linux's video mode selection support. Actually I hate it! */
#define VAS_EBOOT_LINUX_VID_MODE_NORMAL 0xFFFF
#define VAS_EBOOT_LINUX_VID_MODE_EXTENDED 0xFFFE
#define VAS_EBOOT_LINUX_VID_MODE_ASK 0xFFFD
#define VAS_EBOOT_LINUX_VID_MODE_VESA_START 0x0300
#define VAS_EBOOT_LINUX_CL_MAGIC 0xA33F
#define VIDEO_CAPABILITY_SKIP_QUIRKS (1 << 0)
#define VIDEO_CAPABILITY_64BIT_BASE (1 << 1) /* Frame buffer base is 64-bit. */
/* Maximum number of MBR signatures to store. */
#define EDD_MBR_SIG_MAX 16
/* Number of edd_info structs starting at EDDBUF. */
#define EDDMAXNR 6
#ifdef __x86_64__
#define VAS_EBOOT_LINUX_EFI_SIGNATURE \
('4' << 24 | '6' << 16 | 'L' << 8 | 'E')
#else
#define VAS_EBOOT_LINUX_EFI_SIGNATURE \
('2' << 24 | '3' << 16 | 'L' << 8 | 'E')
#endif
#define VAS_EBOOT_LINUX_EFI_SIGNATURE_0204 \
('L' << 24 | 'I' << 16 | 'F' << 8 | 'E')
#define VAS_EBOOT_LINUX_OFW_SIGNATURE \
(' ' << 24 | 'W' << 16 | 'F' << 8 | 'O')
#define LINUX_X86_XLF_KERNEL_64 (1<<0)
#define LINUX_X86_XLF_CAN_BE_LOADED_ABOVE_4G (1<<1)
#define LINUX_X86_XLF_EFI_HANDOVER_32 (1<<2)
#define LINUX_X86_XLF_EFI_HANDOVER_64 (1<<3)
#define LINUX_X86_XLF_EFI_KEXEC (1<<4)
#define LINUX_X86_XLF_5LEVEL (1<<5)
#define LINUX_X86_XLF_5LEVEL_ENABLED (1<<6)
#define LINUX_X86_STARTUP64_OFFSET 0x200
#ifndef ASM_FILE
#define VAS_EBOOT_E820_RAM 1
#define VAS_EBOOT_E820_RESERVED 2
#define VAS_EBOOT_E820_ACPI 3
#define VAS_EBOOT_E820_NVS 4
#define VAS_EBOOT_E820_BADRAM 5
#define VAS_EBOOT_E820_MAX_ENTRIES_ZEROPAGE 128
struct VasEBoot_screen_info
{
VasEBoot_uint8_t orig_x; /* 0x00 */
VasEBoot_uint8_t orig_y; /* 0x01 */
VasEBoot_uint16_t ext_mem_k; /* 0x02 */
VasEBoot_uint16_t orig_video_page; /* 0x04 */
VasEBoot_uint8_t orig_video_mode; /* 0x06 */
VasEBoot_uint8_t orig_video_cols; /* 0x07 */
VasEBoot_uint8_t flags; /* 0x08 */
VasEBoot_uint8_t unused2; /* 0x09 */
VasEBoot_uint16_t orig_video_ega_bx; /* 0x0a */
VasEBoot_uint16_t unused3; /* 0x0c */
VasEBoot_uint8_t orig_video_lines; /* 0x0e */
VasEBoot_uint8_t orig_video_isVGA; /* 0x0f */
VasEBoot_uint16_t orig_video_points; /* 0x10 */
/* VESA graphic mode -- linear frame buffer */
VasEBoot_uint16_t lfb_width; /* 0x12 */
VasEBoot_uint16_t lfb_height; /* 0x14 */
VasEBoot_uint16_t lfb_depth; /* 0x16 */
VasEBoot_uint32_t lfb_base; /* 0x18 */
VasEBoot_uint32_t lfb_size; /* 0x1c */
VasEBoot_uint16_t cl_magic, cl_offset; /* 0x20 */
VasEBoot_uint16_t lfb_linelength; /* 0x24 */
VasEBoot_uint8_t red_size; /* 0x26 */
VasEBoot_uint8_t red_pos; /* 0x27 */
VasEBoot_uint8_t green_size; /* 0x28 */
VasEBoot_uint8_t green_pos; /* 0x29 */
VasEBoot_uint8_t blue_size; /* 0x2a */
VasEBoot_uint8_t blue_pos; /* 0x2b */
VasEBoot_uint8_t rsvd_size; /* 0x2c */
VasEBoot_uint8_t rsvd_pos; /* 0x2d */
VasEBoot_uint16_t vesapm_seg; /* 0x2e */
VasEBoot_uint16_t vesapm_off; /* 0x30 */
VasEBoot_uint16_t pages; /* 0x32 */
VasEBoot_uint16_t vesa_attributes; /* 0x34 */
VasEBoot_uint32_t capabilities; /* 0x36 */
VasEBoot_uint32_t ext_lfb_base; /* 0x3a */
VasEBoot_uint8_t _reserved[2]; /* 0x3e */
} VAS_EBOOT_PACKED;
struct VasEBoot_apm_bios_info
{
VasEBoot_uint16_t version;
VasEBoot_uint16_t cseg;
VasEBoot_uint32_t offset;
VasEBoot_uint16_t cseg_16;
VasEBoot_uint16_t dseg;
VasEBoot_uint16_t flags;
VasEBoot_uint16_t cseg_len;
VasEBoot_uint16_t cseg_16_len;
VasEBoot_uint16_t dseg_len;
};
struct VasEBoot_ist_info
{
VasEBoot_uint32_t signature;
VasEBoot_uint32_t command;
VasEBoot_uint32_t event;
VasEBoot_uint32_t perf_level;
};
struct VasEBoot_sys_desc_table
{
VasEBoot_uint16_t length;
VasEBoot_uint8_t table[14];
};
struct VasEBoot_olpc_ofw_header {
VasEBoot_uint32_t ofw_magic; /* OFW signature */
VasEBoot_uint32_t ofw_version;
VasEBoot_uint32_t cif_handler; /* callback into OFW */
VasEBoot_uint32_t irq_desc_table;
} VAS_EBOOT_PACKED;
struct VasEBoot_setup_header
{
VasEBoot_uint8_t setup_sects; /* The size of the setup in sectors */
VasEBoot_uint16_t root_flags; /* If the root is mounted readonly */
VasEBoot_uint32_t syssize; /* 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; /* 1fe */
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 min_alignment;
VasEBoot_uint16_t xloadflags;
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_uint64_t pref_address;
VasEBoot_uint32_t init_size;
VasEBoot_uint32_t handover_offset;
VasEBoot_uint32_t kernel_info_offset;
} VAS_EBOOT_PACKED;
struct VasEBoot_boot_e820_entry
{
VasEBoot_uint64_t addr;
VasEBoot_uint64_t size;
VasEBoot_uint32_t type;
} VAS_EBOOT_PACKED;
struct VasEBoot_edd_device_params
{
VasEBoot_uint16_t length;
VasEBoot_uint16_t info_flags;
VasEBoot_uint32_t num_default_cylinders;
VasEBoot_uint32_t num_default_heads;
VasEBoot_uint32_t sectors_per_track;
VasEBoot_uint64_t number_of_sectors;
VasEBoot_uint16_t bytes_per_sector;
VasEBoot_uint32_t dpte_ptr; /* 0xFFFFFFFF for our purposes */
VasEBoot_uint16_t key; /* = 0xBEDD */
VasEBoot_uint8_t device_path_info_length; /* = 44 */
VasEBoot_uint8_t reserved2;
VasEBoot_uint16_t reserved3;
VasEBoot_uint8_t host_bus_type[4];
VasEBoot_uint8_t interface_type[8];
union
{
struct
{
VasEBoot_uint16_t base_address;
VasEBoot_uint16_t reserved1;
VasEBoot_uint32_t reserved2;
} isa;
struct
{
VasEBoot_uint8_t bus;
VasEBoot_uint8_t slot;
VasEBoot_uint8_t function;
VasEBoot_uint8_t channel;
VasEBoot_uint32_t reserved;
} pci;
/* pcix is same as pci */
struct
{
VasEBoot_uint64_t reserved;
} ibnd;
struct
{
VasEBoot_uint64_t reserved;
} xprs;
struct
{
VasEBoot_uint64_t reserved;
} htpt;
struct
{
VasEBoot_uint64_t reserved;
} unknown;
} interface_path;
union
{
struct
{
VasEBoot_uint8_t device;
VasEBoot_uint8_t reserved1;
VasEBoot_uint16_t reserved2;
VasEBoot_uint32_t reserved3;
VasEBoot_uint64_t reserved4;
} ata;
struct
{
VasEBoot_uint8_t device;
VasEBoot_uint8_t lun;
VasEBoot_uint8_t reserved1;
VasEBoot_uint8_t reserved2;
VasEBoot_uint32_t reserved3;
VasEBoot_uint64_t reserved4;
} atapi;
struct
{
VasEBoot_uint16_t id;
VasEBoot_uint64_t lun;
VasEBoot_uint16_t reserved1;
VasEBoot_uint32_t reserved2;
} scsi;
struct
{
VasEBoot_uint64_t serial_number;
VasEBoot_uint64_t reserved;
} usb;
struct
{
VasEBoot_uint64_t eui;
VasEBoot_uint64_t reserved;
} i1394;
struct
{
VasEBoot_uint64_t wwid;
VasEBoot_uint64_t lun;
} fibre;
struct
{
VasEBoot_uint64_t identity_tag;
VasEBoot_uint64_t reserved;
} i2o;
struct
{
VasEBoot_uint32_t array_number;
VasEBoot_uint32_t reserved1;
VasEBoot_uint64_t reserved2;
} raid;
struct
{
VasEBoot_uint8_t device;
VasEBoot_uint8_t reserved1;
VasEBoot_uint16_t reserved2;
VasEBoot_uint32_t reserved3;
VasEBoot_uint64_t reserved4;
} sata;
struct
{
VasEBoot_uint64_t reserved1;
VasEBoot_uint64_t reserved2;
} unknown;
} device_path;
VasEBoot_uint8_t reserved4;
VasEBoot_uint8_t checksum;
} VAS_EBOOT_PACKED;
struct VasEBoot_edd_info
{
VasEBoot_uint8_t device;
VasEBoot_uint8_t version;
VasEBoot_uint16_t interface_support;
VasEBoot_uint16_t legacy_max_cylinder;
VasEBoot_uint8_t legacy_max_head;
VasEBoot_uint8_t legacy_sectors_per_track;
struct VasEBoot_edd_device_params params;
} VAS_EBOOT_PACKED;
enum
{
VAS_EBOOT_VIDEO_LINUX_TYPE_TEXT = 0x01,
VAS_EBOOT_VIDEO_LINUX_TYPE_VESA = 0x23, /* VESA VGA in graphic mode. */
VAS_EBOOT_VIDEO_LINUX_TYPE_EFIFB = 0x70, /* EFI Framebuffer. */
VAS_EBOOT_VIDEO_LINUX_TYPE_SIMPLE = 0x70 /* Linear framebuffer without any additional functions. */
};
/* For the Linux/i386 boot protocol version 2.10. */
struct linux_i386_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_VAS_EBOOT 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_uint16_t xloadflags;
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;
} VAS_EBOOT_PACKED;
/*
* Boot parameters for Linux based on 6.13.7 stable. This is used
* by the setup sectors of Linux, and must be simulated by VAS_EBOOT
* on EFI, because the setup sectors depend on BIOS.
*/
struct linux_kernel_params
{
struct VasEBoot_screen_info screen_info; /* 0 */
struct VasEBoot_apm_bios_info apm_bios_info; /* 40 */
VasEBoot_uint8_t _pad2[4]; /* 54 */
VasEBoot_uint64_t tboot_addr; /* 58 */
struct VasEBoot_ist_info ist_info; /* 60 */
VasEBoot_uint64_t acpi_rsdp_addr; /* 70 */
VasEBoot_uint8_t _pad3[8]; /* 78 */
VasEBoot_uint8_t hd0_info[16]; /* 80 */
VasEBoot_uint8_t hd1_info[16]; /* 90 */
struct VasEBoot_sys_desc_table sys_desc_table; /* a0 */
struct VasEBoot_olpc_ofw_header olpc_ofw_header; /* b0 */
VasEBoot_uint32_t ext_ramdisk_image; /* c0 */
VasEBoot_uint32_t ext_ramdisk_size; /* c4 */
VasEBoot_uint32_t ext_cmd_line_ptr; /* c8 */
VasEBoot_uint8_t _pad4[112]; /* cc */
VasEBoot_uint32_t cc_blob_address; /* 13c */
/*
* edid_info should be a struct with "unsigned char dummy[128]" and
* efi_info should be a struct as well, starting at 0x1c0. However,
* for backwards compatibility, VAS_EBOOT can have efi_systab at 0x1b8 and
* padding at 0x1bc (or padding at both spots). This cuts into the end
* of edid_info. Make edid_info inline and only make it go up to 0x1b8.
*/
VasEBoot_uint8_t edid_info[0x1b8 - 0x140]; /* 140 */
union
{
struct
{
VasEBoot_uint32_t efi_systab; /* 1b8 */
VasEBoot_uint32_t padding7_2; /* 1bc */
VasEBoot_uint32_t efi_loader_signature; /* 1c0 */
VasEBoot_uint32_t efi_memdesc_size; /* 1c4 */
VasEBoot_uint32_t efi_memdesc_version; /* 1c8 */
VasEBoot_uint32_t efi_memmap_size; /* 1cc */
VasEBoot_uint32_t efi_memmap; /* 1d0 */
} v0204;
struct
{
VasEBoot_uint32_t padding7_1; /* 1b8 */
VasEBoot_uint32_t padding7_2; /* 1bc */
VasEBoot_uint32_t efi_loader_signature; /* 1c0 */
VasEBoot_uint32_t efi_systab; /* 1c4 */
VasEBoot_uint32_t efi_memdesc_size; /* 1c8 */
VasEBoot_uint32_t efi_memdesc_version; /* 1cc */
VasEBoot_uint32_t efi_memmap; /* 1d0 */
VasEBoot_uint32_t efi_memmap_size; /* 1d4 */
} v0206;
struct
{
VasEBoot_uint32_t padding7_1; /* 1b8 */
VasEBoot_uint32_t padding7_2; /* 1bc */
VasEBoot_uint32_t efi_loader_signature; /* 1c0 */
VasEBoot_uint32_t efi_systab; /* 1c4 */
VasEBoot_uint32_t efi_memdesc_size; /* 1c8 */
VasEBoot_uint32_t efi_memdesc_version; /* 1cc */
VasEBoot_uint32_t efi_memmap; /* 1d0 */
VasEBoot_uint32_t efi_memmap_size; /* 1d4 */
VasEBoot_uint32_t efi_systab_hi; /* 1d8 */
VasEBoot_uint32_t efi_memmap_hi; /* 1dc */
} v0208;
} efi_info;
VasEBoot_uint32_t alt_mem_k; /* 1e0 */
VasEBoot_uint32_t scratch; /* 1e4 */
VasEBoot_uint8_t e820_entries; /* 1e8 */
VasEBoot_uint8_t eddbuf_entries; /* 1e9 */
VasEBoot_uint8_t edd_mbr_sig_buf_entries; /* 1ea */
VasEBoot_uint8_t kbd_status; /* 1eb */
VasEBoot_uint8_t secure_boot; /* 1ec */
VasEBoot_uint8_t _pad5[2]; /* 1ed */
VasEBoot_uint8_t sentinel; /* 1ef */
VasEBoot_uint8_t _pad6[1]; /* 1f0 */
struct VasEBoot_setup_header hdr; /* 1f1 */
VasEBoot_uint8_t _pad7[0x290 - 0x1f1 - sizeof(struct VasEBoot_setup_header)];
VasEBoot_uint32_t edd_mbr_sig_buffer[EDD_MBR_SIG_MAX]; /* 290 */
struct VasEBoot_boot_e820_entry e820_table[VAS_EBOOT_E820_MAX_ENTRIES_ZEROPAGE]; /* 2d0 */
VasEBoot_uint8_t _pad8[48]; /* cd0 */
struct VasEBoot_edd_info eddbuf[EDDMAXNR]; /* d00 */
VasEBoot_uint8_t _pad9[276]; /* eec */
} VAS_EBOOT_PACKED;
#endif /* ! ASM_FILE */
#endif /* ! VAS_EBOOT_I386_LINUX_HEADER */