123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450 |
- #pragma once
- #include "stdint.h"
- #include "stdbool.h"
- #include "../../common/boot_info.h"
- extern unsigned int multiboot2_magic;
- static const unsigned int MULTIBOOT_SEARCH = 32768;
- static const unsigned int MULTIBOOT_HEADER_ALIGN = 8;
- static const unsigned int MULTIBOOT2_HEADER_MAGIC = 0xe85250d6;
- static const unsigned int MULTIBOOT2_BOOTLOADER_MAGIC = 0x36d76289;
- static const unsigned int MULTIBOOT_MOD_ALIGN = 0x00001000;
- static const unsigned int MULTIBOOT_INFO_ALIGN = 0x00000008;
- static const unsigned int MULTIBOOT_TAG_ALIGN = 8;
- static const unsigned int MULTIBOOT_TAG_TYPE_END = 0;
- static const unsigned int MULTIBOOT_TAG_TYPE_CMDLINE = 1;
- static const unsigned int MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME = 2;
- static const unsigned int MULTIBOOT_TAG_TYPE_MODULE = 3;
- static const unsigned int MULTIBOOT_TAG_TYPE_BASIC_MEMINFO = 4;
- static const unsigned int MULTIBOOT_TAG_TYPE_BOOTDEV = 5;
- static const unsigned int MULTIBOOT_TAG_TYPE_MMAP = 6;
- static const unsigned int MULTIBOOT_TAG_TYPE_VBE = 7;
- static const unsigned int MULTIBOOT_TAG_TYPE_FRAMEBUFFER = 8;
- static const unsigned int MULTIBOOT_TAG_TYPE_ELF_SECTIONS = 9;
- static const unsigned int MULTIBOOT_TAG_TYPE_APM = 10;
- static const unsigned int MULTIBOOT_TAG_TYPE_EFI32 = 11;
- static const unsigned int MULTIBOOT_TAG_TYPE_EFI64 = 12;
- static const unsigned int MULTIBOOT_TAG_TYPE_SMBIOS = 13;
- static const unsigned int MULTIBOOT_TAG_TYPE_ACPI_OLD = 14;
- static const unsigned int MULTIBOOT_TAG_TYPE_ACPI_NEW = 15;
- static const unsigned int MULTIBOOT_TAG_TYPE_NETWORK = 16;
- static const unsigned int MULTIBOOT_TAG_TYPE_EFI_MMAP = 17;
- static const unsigned int MULTIBOOT_TAG_TYPE_EFI_BS = 18;
- static const unsigned int MULTIBOOT_TAG_TYPE_EFI32_IH = 19;
- static const unsigned int MULTIBOOT_TAG_TYPE_EFI64_IH = 20;
- static const unsigned int MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR = 21;
- static const unsigned int MULTIBOOT_HEADER_TAG_END = 0;
- static const unsigned int MULTIBOOT_HEADER_TAG_INFORMATION_REQUEST =
- 1;
- static const unsigned int MULTIBOOT_HEADER_TAG_ADDRESS = 2;
- static const unsigned int MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS = 3;
- static const unsigned int MULTIBOOT_HEADER_TAG_CONSOLE_FLAGS = 4;
- static const unsigned int MULTIBOOT_HEADER_TAG_FRAMEBUFFER = 5;
- static const unsigned int MULTIBOOT_HEADER_TAG_MODULE_ALIGN = 6;
- static const unsigned int MULTIBOOT_HEADER_TAG_EFI_BS = 7;
- static const unsigned int MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI32 =
- 8;
- static const unsigned int MULTIBOOT_HEADER_TAG_ENTRY_ADDRESS_EFI64 =
- 9;
- static const unsigned int MULTIBOOT_HEADER_TAG_RELOCATABLE = 10;
- static const unsigned int MULTIBOOT_ARCHITECTURE_I386 = 0;
- static const unsigned int MULTIBOOT_ARCHITECTURE_MIPS32 = 4;
- static const unsigned int MULTIBOOT_HEADER_TAG_OPTIONAL = 1;
- static const unsigned int MULTIBOOT_LOAD_PREFERENCE_NONE = 0;
- static const unsigned int MULTIBOOT_LOAD_PREFERENCE_LOW = 1;
- static const unsigned int MULTIBOOT_LOAD_PREFERENCE_HIGH = 2;
- static const unsigned int MULTIBOOT_CONSOLE_FLAGS_CONSOLE_REQUIRED =
- 1;
- static const unsigned int MULTIBOOT_CONSOLE_FLAGS_EGA_TEXT_SUPPORTED =
- 2;
- static const unsigned int MULTIBOOT_MEMORY_AVAILABLE = 1;
- static const unsigned int MULTIBOOT_MEMORY_RESERVED = 2;
- static const unsigned int MULTIBOOT_MEMORY_ACPI_RECLAIMABLE = 3;
- static const unsigned int MULTIBOOT_MEMORY_NVS = 4;
- static const unsigned int MULTIBOOT_MEMORY_BADRAM = 5;
- struct multiboot_header_t
- {
-
- unsigned int magic;
-
- unsigned int architecture;
-
- unsigned int header_length;
-
- unsigned int checksum;
- };
- struct multiboot_header_tag_t
- {
- uint16_t type;
- uint16_t flags;
- unsigned int size;
- };
- struct multiboot_header_tag_information_request_t
- {
- uint16_t type;
- uint16_t flags;
- unsigned int size;
- unsigned int requests[0];
- };
- struct multiboot_header_tag_address_t
- {
- uint16_t type;
- uint16_t flags;
- unsigned int size;
- unsigned int header_addr;
- unsigned int load_addr;
- unsigned int load_end_addr;
- unsigned int bss_end_addr;
- };
- struct multiboot_header_tag_entry_address_t
- {
- uint16_t type;
- uint16_t flags;
- unsigned int size;
- unsigned int entry_addr;
- };
- struct multiboot_header_tag_console_flags_t
- {
- uint16_t type;
- uint16_t flags;
- unsigned int size;
- unsigned int console_flags;
- };
- struct multiboot_header_tag_framebuffer_t
- {
- uint16_t type;
- uint16_t flags;
- unsigned int size;
- unsigned int width;
- unsigned int height;
- unsigned int depth;
- };
- struct multiboot_header_tag_module_align_t
- {
- uint16_t type;
- uint16_t flags;
- unsigned int size;
- };
- struct multiboot_header_tag_relocatable_t
- {
- uint16_t type;
- uint16_t flags;
- unsigned int size;
- unsigned int min_addr;
- unsigned int max_addr;
- unsigned int align;
- unsigned int preference;
- };
- struct multiboot_color_t
- {
- uint8_t red;
- uint8_t green;
- uint8_t blue;
- };
- struct multiboot_mmap_entry_t
- {
- uint64_t addr;
- uint64_t len;
- unsigned int type;
- unsigned int reserved;
- };
- struct multiboot_tag_t
- {
- unsigned int type;
- unsigned int size;
- };
- struct multiboot_tag_string_t
- {
- struct multiboot_tag_t tag_t;
- char string[0];
- };
- struct multiboot_tag_module_t
- {
- struct multiboot_tag_t tag_t;
- unsigned int mod_start;
- unsigned int mod_end;
- char cmdline[0];
- };
- struct multiboot_tag_basic_meminfo_t
- {
- struct multiboot_tag_t tag_t;
- unsigned int mem_lower;
- unsigned int mem_upper;
- };
- struct multiboot_tag_bootdev_t
- {
- struct multiboot_tag_t tag_t;
- unsigned int biosdev;
- unsigned int slice;
- unsigned int part;
- };
- struct multiboot_tag_mmap_t
- {
- struct multiboot_tag_t tag_t;
- unsigned int entry_size;
- unsigned int entry_version;
- struct multiboot_mmap_entry_t entries[0];
- };
- struct multiboot_vbe_info_block_t
- {
- uint8_t external_specification[512];
- };
- struct multiboot_vbe_mode_info_block_t
- {
- uint8_t external_specification[256];
- };
- struct multiboot_tag_vbe_t
- {
- struct multiboot_tag_t tag_t;
- uint16_t vbe_mode;
- uint16_t vbe_interface_seg;
- uint16_t vbe_interface_off;
- uint16_t vbe_interface_len;
-
-
- struct multiboot_vbe_info_block_t vbe_control_info;
- struct multiboot_vbe_mode_info_block_t vbe_mode_info;
- };
- struct multiboot_tag_framebuffer_info_t
- {
- struct multiboot_tag_t tag_t;
- uint64_t framebuffer_addr;
- uint32_t framebuffer_pitch;
-
-
- uint32_t framebuffer_width;
- uint32_t framebuffer_height;
-
- uint8_t framebuffer_bpp;
-
- uint8_t framebuffer_type;
- uint8_t reserved;
- };
- struct multiboot_tag_framebuffer_info_type0_t
- {
- struct multiboot_tag_framebuffer_info_t;
- uint32_t framebuffer_palette_num_colors;
- struct multiboot_color_t color_desc;
- };
- struct multiboot_tag_framebuffer_info_type1_t
- {
- struct multiboot_tag_framebuffer_info_t;
- uint8_t framebuffer_red_field_position;
- uint8_t framebuffer_red_mask_size;
- uint8_t framebuffer_green_field_position;
- uint8_t framebuffer_green_mask_size;
- uint8_t framebuffer_blue_field_position;
- uint8_t framebuffer_blue_mask_size;
- };
- struct multiboot_tag_elf_sections_t
- {
- struct multiboot_tag_t tag_t;
- unsigned int num;
- unsigned int entsize;
-
- unsigned int shndx;
- char sections[0];
- };
- struct multiboot_tag_apm_t
- {
- struct multiboot_tag_t tag_t;
- uint16_t version;
- uint16_t cseg;
- unsigned int offset;
- uint16_t cseg_16;
- uint16_t dseg;
- uint16_t flags;
- uint16_t cseg_len;
- uint16_t cseg_16_len;
- uint16_t dseg_len;
- };
- struct multiboot_tag_efi32_t
- {
- struct multiboot_tag_t tag_t;
- unsigned int pointer;
- };
- struct multiboot_tag_efi64_t
- {
- struct multiboot_tag_t tag_t;
- uint64_t pointer;
- };
- struct multiboot_tag_smbios_t
- {
- struct multiboot_tag_t tag_t;
- uint8_t major;
- uint8_t minor;
- uint8_t reserved[6];
- uint8_t tables[0];
- };
- struct multiboot_tag_old_acpi_t
- {
- struct multiboot_tag_t tag_t;
- uint8_t rsdp[0];
- };
- struct multiboot_tag_new_acpi_t
- {
- struct multiboot_tag_t tag_t;
- uint8_t rsdp[0];
- };
- struct multiboot_tag_network_t
- {
- struct multiboot_tag_t tag_t;
- uint8_t dhcpack[0];
- };
- struct multiboot_tag_efi_mmap_t
- {
- struct multiboot_tag_t tag_t;
- unsigned int descr_size;
- unsigned int descr_vers;
- uint8_t efi_mmap[0];
- };
- struct multiboot_tag_efi32_ih_t
- {
- struct multiboot_tag_t tag_t;
- unsigned int pointer;
- };
- struct multiboot_tag_efi64_ih_t
- {
- struct multiboot_tag_t tag_t;
- uint64_t pointer;
- };
- struct multiboot_tag_load_base_addr_t
- {
- struct multiboot_tag_t tag_t;
- unsigned int load_base_addr;
- };
- struct iter_data_t
- {
- unsigned int type;
- unsigned int size;
- };
- static bool multiboot2_init(void);
- void multiboot2_iter(bool (*_fun)(const struct iter_data_t *, void *, unsigned int *),
- void *_data, unsigned int *count);
- bool multiboot2_get_memory(const struct iter_data_t *_iter_data, void *_data, unsigned int *count);
- bool multiboot2_get_VBE_info(const struct iter_data_t *_iter_data, void *_data, unsigned int *reserved);
- bool multiboot2_get_Framebuffer_info(const struct iter_data_t *_iter_data, void *_data, unsigned int *reserved);
|