diff --git a/kernel/include/multiboot.h b/kernel/include/multiboot.h new file mode 100644 index 0000000..d45779f --- /dev/null +++ b/kernel/include/multiboot.h @@ -0,0 +1,139 @@ + +#ifndef MULTIBOOT_H +#define MULTIBOOT_H + +#include "hos_types.h" + +/* The magic number for the Multiboot header. */ +#define MB_HEADER_MAGIC 0x1BADB002 + +#define MB_HEADER_ALIGN_MODULES (1 << 0) +#define MB_HEADER_MEM_INFO (1 << 1) +#define MB_HEADER_VIDEO_INFO (1 << 2) +#define MB_HEADER_KLUDGE_OFFSETS (1 << 16) + +/* The magic number passed by a Multiboot-compliant boot loader. */ +#define MB_BOOTLOADER_MAGIC 0x2BADB002 + +#define MB_BOOTLOADER_MEM_INFO (1 << 0) +#define MB_BOOTLOADER_BOOT_DEVICE (1 << 1) +#define MB_BOOTLOADER_COMMAND_LINE (1 << 2) +#define MB_BOOTLOADER_MODS (1 << 3) +#define MB_BOOTLOADER_AOUT (1 << 4) +#define MB_BOOTLOADER_ELF (1 << 5) +#define MB_BOOTLOADER_MMAP (1 << 6) +#define MB_BOOTLOADER_DRIVES (1 << 7) +#define MB_BOOTLOADER_CONFIG (1 << 8) +#define MB_BOOTLOADER_APM (1 << 9) +#define MB_BOOTLOADER_GRAPHICS (1 << 10) + +#define MB_DRIVE_MODE_CHS 0 +#define MB_DRIVE_MODE_LBA 1 + +/* The Multiboot header. */ +typedef struct +{ + u32_t magic; + u32_t flags; + u32_t checksum; + u32_t header_addr; + u32_t load_addr; + u32_t load_end_addr; + u32_t bss_end_addr; + u32_t entry_addr; +} mb_header_t; + +/* The symbol table for a.out. */ +typedef struct +{ + u32_t tabsize; + u32_t strsize; + u32_t addr; + u32_t reserved; +} mb_aout_symbol_table_t; + +/* The section header table for ELF. */ +typedef struct +{ + u32_t num; + u32_t size; + u32_t addr; + u32_t shndx; +} mb_elf_section_header_table_t; + +/* The Multiboot information. */ +typedef struct +{ + u32_t flags; + u32_t mem_lower; // present if flags[0] is set + u32_t mem_upper; + u32_t boot_device; // 1 + u32_t cmdline; // 2 + u32_t mods_count; // 3 + u32_t mods_addr; + union + { + mb_aout_symbol_table_t aout_sym; // 4 + mb_elf_section_header_table_t elf_sec; // 5 + }; + u32_t mmap_length; // 6 + u32_t mmap_addr; + u32_t drives_length; // 7 + u32_t drives_addr; + u32_t config_table; // 8 + u32_t bootloader_name; // 9 + u32_t apm_table; // 10 + + u32_t vbe_control_info; // 11 + u32_t vbe_mode_info; + u16_t vbe_mode; + u16_t vbe_interface_seg; + u16_t vbe_interface_off; + u16_t vbe_interface_len; +} mb_info_t; + +/* The module structure. */ +typedef struct +{ + u32_t mod_start; + u32_t mod_end; + u32_t string; + u32_t reserved; +} mb_module_t; + +/* The memory map. Be careful that the offset 0 is base_addr_low, not size. */ +typedef struct +{ + u32_t size; // offset -4 + u64_t base; // offset 0 + u64_t length; + u32_t type; +} mb_mmap_t; + +/* The drive structure */ +typedef struct +{ + u32_t size; + u8_t drive_number; + u8_t drive_mode; + u8_t drive_cylinders; + u8_t drive_heads; + u8_t drive_sectors; + u16_t drive_ports[1]; +} mb_drive_t; + +/* APM table structure */ +typedef struct +{ + u16_t version; + u16_t cseg; + u32_t offset; + u16_t cseg_16; + u16_t dseg; + u16_t flags; + u16_t cseg_len; + u16_t cseg_16_len; + u16_t dseg_len; +} mb_apm_t; + +#endif