diff options
Diffstat (limited to 'kernel/mboot')
-rw-r--r-- | kernel/mboot/mboot.c | 6 | ||||
-rw-r--r-- | kernel/mboot/mboot.h | 82 | ||||
-rw-r--r-- | kernel/mboot/mmap.c | 23 | ||||
-rw-r--r-- | kernel/mboot/rsdp.c | 23 |
4 files changed, 45 insertions, 89 deletions
diff --git a/kernel/mboot/mboot.c b/kernel/mboot/mboot.c index ce74cc1..e10f33c 100644 --- a/kernel/mboot/mboot.c +++ b/kernel/mboot/mboot.c @@ -7,20 +7,20 @@ static volatile void *mboot; void mboot_init(long magic, volatile void *ptr) { - if (magic != MBOOT_HEADER_MAGIC) + if (magic != MULTIBOOT2_BOOTLOADER_MAGIC) panic("invalid multiboot magic"); mboot = ptr; } void *locate_mboot_table(uint32_t type) { - struct mboot_info *info = (struct mboot_info *)mboot; + struct multiboot *info = (struct multiboot *)mboot; const char *mboot_end = ((char *)info) + info->total_size; char *tag_ptr = info->tags; while (tag_ptr < mboot_end) { - struct mboot_tag *tag = (struct mboot_tag *)tag_ptr; + struct multiboot_tag *tag = (struct multiboot_tag *)tag_ptr; if (tag->type == type) return tag; diff --git a/kernel/mboot/mboot.h b/kernel/mboot/mboot.h index 7e8c09a..8887aec 100644 --- a/kernel/mboot/mboot.h +++ b/kernel/mboot/mboot.h @@ -11,93 +11,17 @@ #include <lib.h> -#define MBOOT_HEADER_MAGIC 0x36D76289 +#define MULTIBOOT2_BOOTLOADER_MAGIC 0x36D76289 -#define MBOOT_CMDLINE 1 -#define MBOOT_MEMORY_MAP 6 -#define MBOOT_FRAMEBUFFER 8 -#define MBOOT_ELF_SYMBOLS 9 -#define MBOOT_OLD_RSDP 14 -#define MBOOT_NEW_RSDP 15 - -struct mboot_info { +struct multiboot { uint32_t total_size; uint32_t reserved; char tags[]; }; -struct mboot_tag { - uint32_t type; - uint32_t size; - char data[]; -}; - -struct mboot_tag_elf_sections { - uint32_t type; - uint32_t size; - uint16_t num; - uint16_t entsize; - uint16_t shndx; - uint16_t reserved; - char sections[]; -}; - -struct mboot_tag_elf_sections_entry { - uint32_t sh_name; - uint32_t sh_type; - uint64_t sh_flags; - uint64_t sh_addr; - uint64_t sh_offset; - uint64_t sh_size; - uint32_t sh_link; - uint32_t sh_info; - uint64_t sh_addralign; - uint64_t sh_entsize; -}; - -struct mboot_mmap_entry { - uint64_t addr; - uint64_t len; - uint32_t type; - uint32_t zero; -}; - -struct mboot_tag_mmap { - uint32_t type; - uint32_t size; - uint32_t entry_size; - uint32_t entry_version; - struct mboot_mmap_entry entries[]; -}; - -struct mboot_tag_old_rsdp { - uint32_t type; - uint32_t size; - char rsdp[]; -}; - -struct mboot_tag_new_rsdp { - uint32_t type; - uint32_t size; - char rsdp[]; -}; - -struct mboot_tag_cmdline { - uint32_t type; - uint32_t size; - uint8_t cmdline[]; -}; - -struct mboot_tag_framebuffer { +struct multiboot_tag { uint32_t type; uint32_t size; - uint64_t framebuffer_addr; - uint32_t framebuffer_pitch; - uint32_t framebuffer_width; - uint32_t framebuffer_height; - uint8_t framebuffer_bpp; - uint8_t framebuffer_type; - uint16_t reserved; }; void *locate_mboot_table(uint32_t type); diff --git a/kernel/mboot/mmap.c b/kernel/mboot/mmap.c index f319395..e93421d 100644 --- a/kernel/mboot/mmap.c +++ b/kernel/mboot/mmap.c @@ -3,6 +3,23 @@ #include "mboot.h" +#define MULTIBOOT_TAG_TYPE_MMAP 6 + +struct multiboot_mmap_entry { + uint64_t addr; + uint64_t len; + uint32_t type; + uint32_t zero; +}; + +struct multiboot_tag_mmap { + uint32_t type; + uint32_t size; + uint32_t entry_size; + uint32_t entry_version; + struct multiboot_mmap_entry entries[]; +}; + static const char *segment_type[] = { "Reserved", "Free", "Reserved", "ACPI Reserved", "Hibernation", "Defective", @@ -10,11 +27,11 @@ static const char *segment_type[] = { "Reserved", "Free", int mboot_get_mmap(struct memory_map *res) { - void *tag = locate_mboot_table(MBOOT_MEMORY_MAP); + void *tag = locate_mboot_table(MULTIBOOT_TAG_TYPE_MMAP); if (tag == NULL) return 1; - struct mboot_tag_mmap *mmap = (struct mboot_tag_mmap *)tag; + struct multiboot_tag_mmap *mmap = (struct multiboot_tag_mmap *)tag; int idx = 0; uintptr_t i = (uintptr_t)mmap->entries; @@ -22,7 +39,7 @@ int mboot_get_mmap(struct memory_map *res) char buf[20]; for (; i < (uintptr_t)mmap->entries + mmap->size; i += mmap->entry_size, idx++) { - struct mboot_mmap_entry *seg = (struct mboot_mmap_entry *)i; + struct multiboot_mmap_entry *seg = (struct multiboot_mmap_entry *)i; const char *type = NULL; if (seg->type > 6) type = segment_type[6]; diff --git a/kernel/mboot/rsdp.c b/kernel/mboot/rsdp.c index 48afff3..f20d986 100644 --- a/kernel/mboot/rsdp.c +++ b/kernel/mboot/rsdp.c @@ -3,21 +3,36 @@ #include "mboot.h" +#define MULTIBOOT_TAG_TYPE_ACPI_OLD 14 +#define MULTIBOOT_TAG_TYPE_ACPI_NEW 15 + +struct multiboot_tag_old_acpi { + uint32_t type; + uint32_t size; + uint8_t rsdp[]; +}; + +struct multiboot_tag_new_acpi { + uint32_t type; + uint32_t size; + uint8_t rsdp[]; +}; + void *mboot_get_rsdp(void) { void *tag; // acpi 2.0 - tag = locate_mboot_table(MBOOT_NEW_RSDP); + tag = locate_mboot_table(MULTIBOOT_TAG_TYPE_ACPI_NEW); if (tag != NULL) { - struct mboot_tag_new_rsdp *rsdp = (struct mboot_tag_new_rsdp *)tag; + struct multiboot_tag_new_acpi *rsdp = (struct multiboot_tag_new_acpi *)tag; return rsdp->rsdp; } // acpi 1.0 - tag = locate_mboot_table(MBOOT_OLD_RSDP); + tag = locate_mboot_table(MULTIBOOT_TAG_TYPE_ACPI_OLD); if (tag != NULL) { - struct mboot_tag_old_rsdp *rsdp = (struct mboot_tag_old_rsdp *)tag; + struct multiboot_tag_old_acpi *rsdp = (struct multiboot_tag_old_acpi *)tag; return rsdp->rsdp; } |