aboutsummaryrefslogtreecommitdiffstats
path: root/multiboot.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2024-09-27 20:24:07 -0400
committerClyne Sullivan <clyne@bitgloo.com>2024-09-27 20:24:07 -0400
commit8f9329da623bf0812df44f60867180020283ff3f (patch)
tree08be9ccc06872609a7c0fba400c1adf414e86c60 /multiboot.cpp
parentbd0acf88361a4b73a49d11a45177e72bf32091bc (diff)
acpi detection
Diffstat (limited to 'multiboot.cpp')
-rw-r--r--multiboot.cpp51
1 files changed, 50 insertions, 1 deletions
diff --git a/multiboot.cpp b/multiboot.cpp
index 0c34984..0a30938 100644
--- a/multiboot.cpp
+++ b/multiboot.cpp
@@ -4,11 +4,50 @@
extern TextOutput& term;
+struct multiboot2
+{
+ static constexpr std::uint32_t MAGIC = 0xE85250D6;
+ static constexpr std::uint32_t FLAGS = 0;
+ static constexpr std::uint32_t LENGTH = 16;
+ static constexpr std::uint32_t CHECKSUM = -(MAGIC + FLAGS + LENGTH);
+
+ alignas(8)
+ std::uint32_t magic = MAGIC;
+ std::uint32_t flags = FLAGS;
+ std::uint32_t length = LENGTH;
+ std::uint32_t checksum = CHECKSUM;
+} __attribute__((packed));
+
+struct multiboot2_tag
+{
+ alignas(8)
+ std::uint16_t id;
+ std::uint16_t flags;
+ std::uint32_t length;
+ std::uint32_t data[];
+} __attribute__((packed));
+
+__attribute__((section(".multiboot2")))
+multiboot2 multibootHeader;
+
+__attribute__((section(".multiboot2")))
+multiboot2_tag multibootTagInfoRequest = {
+ 1, 0, sizeof(multiboot2_tag) + sizeof(std::uint32_t),
+ {4}
+};
+
+__attribute__((section(".multiboot2")))
+multiboot2_tag multibootTagEnd = {
+ 0, 0, sizeof(multiboot2_tag), {}
+};
+
std::uint32_t multiboot_magic;
std::uint32_t *multiboot_ptr;
std::uint32_t lowerMem = 0;
std::uint32_t upperMem = 0;
+std::uint32_t *acpiRsdp = nullptr;
+std::uint32_t *acpiRsdpV2 = nullptr;
bool multiboot_initialize()
{
@@ -24,9 +63,19 @@ bool multiboot_initialize()
term.write(ptr[0]);
term.write(", ");
- if (ptr[0] == 4) {
+ switch (ptr[0]) {
+ case 4:
lowerMem = ptr[2] * 1024;
upperMem = ptr[3] * 1024;
+ break;
+ case 14:
+ acpiRsdp = ptr + 2;
+ break;
+ case 15:
+ acpiRsdpV2 = ptr + 2;
+ break;
+ default:
+ break;
}
auto next = reinterpret_cast<std::uintptr_t>(ptr);