diff options
| author | TheSoeren <imhofabian@gmail.com> | 2024-09-29 09:26:17 +0000 |
|---|---|---|
| committer | TheSoeren <imhofabian@gmail.com> | 2024-09-29 09:26:17 +0000 |
| commit | 8f91d0ef50e01440f7e6e9f4afa5887f6afefea1 (patch) | |
| tree | 179cd8a2809cde6d2add5d7f9f940686a575a527 /arch/x86_64 | |
| parent | eeee7967c17704fee443a3b5b02d53a580f18b73 (diff) | |
| download | teachos-8f91d0ef50e01440f7e6e9f4afa5887f6afefea1.tar.xz teachos-8f91d0ef50e01440f7e6e9f4afa5887f6afefea1.zip | |
read basic mem info
Diffstat (limited to 'arch/x86_64')
| -rw-r--r-- | arch/x86_64/include/arch/boot/multiboot.hpp | 38 | ||||
| -rw-r--r-- | arch/x86_64/src/kernel/main.cpp | 34 |
2 files changed, 62 insertions, 10 deletions
diff --git a/arch/x86_64/include/arch/boot/multiboot.hpp b/arch/x86_64/include/arch/boot/multiboot.hpp index c6fed55..9a0757e 100644 --- a/arch/x86_64/include/arch/boot/multiboot.hpp +++ b/arch/x86_64/include/arch/boot/multiboot.hpp @@ -10,5 +10,39 @@ struct multiboot_info { uint32_t total_size; uint32_t reserved; - struct multiboot_tag tags[1]; // TODO: Size 0 -};
\ No newline at end of file + /* + * field "tags" is an array of multiboot_tags, however the array is never + * being accessed by index and using an array definition with size 0 produces a compiler + * error. + */ + struct multiboot_tag tags; +}; + +/* + * Define all multiboot tag types to ther respective values + * The gnu boot information format is defined here: + * https://www.gnu.org/software/grub/manual/multiboot2/multiboot.html#Boot-information-format + */ +#define MULTIBOOT_TAG_ALIGN 8 +#define MULTIBOOT_TAG_TYPE_END 0 +#define MULTIBOOT_TAG_TYPE_CMDLINE 1 +#define MULTIBOOT_TAG_TYPE_BOOT_LOADER_NAME 2 +#define MULTIBOOT_TAG_TYPE_MODULE 3 +#define MULTIBOOT_TAG_TYPE_BASIC_MEMINFO 4 +#define MULTIBOOT_TAG_TYPE_BOOTDEV 5 +#define MULTIBOOT_TAG_TYPE_MMAP 6 +#define MULTIBOOT_TAG_TYPE_VBE 7 +#define MULTIBOOT_TAG_TYPE_FRAMEBUFFER 8 +#define MULTIBOOT_TAG_TYPE_ELF_SECTIONS 9 +#define MULTIBOOT_TAG_TYPE_APM 10 +#define MULTIBOOT_TAG_TYPE_EFI32 11 +#define MULTIBOOT_TAG_TYPE_EFI64 12 +#define MULTIBOOT_TAG_TYPE_SMBIOS 13 +#define MULTIBOOT_TAG_TYPE_ACPI_OLD 14 +#define MULTIBOOT_TAG_TYPE_ACPI_NEW 15 +#define MULTIBOOT_TAG_TYPE_NETWORK 16 +#define MULTIBOOT_TAG_TYPE_EFI_MMAP 17 +#define MULTIBOOT_TAG_TYPE_EFI_BS 18 +#define MULTIBOOT_TAG_TYPE_EFI32_IH 19 +#define MULTIBOOT_TAG_TYPE_EFI64_IH 20 +#define MULTIBOOT_TAG_TYPE_LOAD_BASE_ADDR 21 diff --git a/arch/x86_64/src/kernel/main.cpp b/arch/x86_64/src/kernel/main.cpp index e77818e..8ca577a 100644 --- a/arch/x86_64/src/kernel/main.cpp +++ b/arch/x86_64/src/kernel/main.cpp @@ -10,16 +10,34 @@ namespace teachos::arch::kernel { using namespace video::vga; - auto t = arch::boot::multiboot_information_pointer; - // auto multiboot_tag = (struct multiboot_tag *) ((uint8_t) t + 8); - // for (auto tag = multiboot_tag; tag->type != ) - - if (t == 300) - { - } - text::clear(); text::cursor(false); text::write("TeachOS is starting up...", text::common_attributes::green_on_black); + + auto mip = arch::boot::multiboot_information_pointer; + + // Address of the first multiboot tag + auto multiboot_tag = (struct multiboot_tag *)((uint8_t *)mip + 8); + + /* + * Loop over the multiboot2 tags to access the information needed. + * Tags are defined in the header. + */ + for (auto tag = multiboot_tag; tag->type != MULTIBOOT_TAG_TYPE_END; + tag = (struct multiboot_tag *)((uint8_t *)tag + ((tag->size + 7) & ~7))) + { + switch (tag->type) + { + case MULTIBOOT_TAG_TYPE_BASIC_MEMINFO: + uint32_t size = tag->size; + uint32_t mem_lower = *(uint32_t *)(&size + 32); + uint32_t mem_upper = *(uint32_t *)(&size + 64); + if (mem_lower > mem_upper) + { + } + text::write("BUFFER IS HERE", text::common_attributes::green_on_black); + break; + } + } } } // namespace teachos::arch::kernel |
