154 lines
3.7 KiB
C
154 lines
3.7 KiB
C
|
|
#ifndef MULTIBOOT_H
|
|
#define MULTIBOOT_H
|
|
|
|
#include "hos_types.h"
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* 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
|
|
|
|
#define MB_MMAP_TYPE_RAM 1
|
|
|
|
/* The Multiboot header. */
|
|
typedef struct
|
|
{
|
|
u32_t magic;
|
|
u32_t flags;
|
|
u32_t checksum;
|
|
u32_t header_addr; // if flags[16]
|
|
u32_t load_addr; // if flags[16]
|
|
u32_t load_end_addr; // if flags[16]
|
|
u32_t bss_end_addr; // if flags[16]
|
|
u32_t entry_addr; // if flags[16]
|
|
u32_t mode_type; // if flags[2]
|
|
u32_t width; // if flags[2]
|
|
u32_t height; // if flags[2]
|
|
u32_t depth; // if flags[2]
|
|
} 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; // 3
|
|
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; // 6
|
|
u32_t drives_length; // 7
|
|
u32_t drives_addr; // 7
|
|
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; // 11
|
|
u16_t vbe_mode; // 11
|
|
u16_t vbe_interface_seg; // 11
|
|
u16_t vbe_interface_off; // 11
|
|
u16_t vbe_interface_len; // 11
|
|
} 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;
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif
|