From eb980a95d9860ea1555b63bdc965c866b4217d52 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 19 Nov 2022 09:54:34 +0200 Subject: [PATCH] Get SMBIOS from bootloader --- Architecture/amd64/Limine.c | 13 +++++++++++++ include/boot/binfo.h | 2 ++ 2 files changed, 15 insertions(+) diff --git a/Architecture/amd64/Limine.c b/Architecture/amd64/Limine.c index 78dc9d5..acb4b6b 100644 --- a/Architecture/amd64/Limine.c +++ b/Architecture/amd64/Limine.c @@ -38,6 +38,10 @@ static volatile struct limine_module_request ModuleRequest = { .id = LIMINE_MODULE_REQUEST, .revision = 0}; +static volatile struct limine_smbios_request SmbiosRequest = { + .id = LIMINE_SMBIOS_REQUEST, + .revision = 0}; + void init_limine() { struct BootInfo binfo; @@ -60,6 +64,7 @@ void init_limine() struct limine_rsdp_response *RsdpResponse = RsdpRequest.response; struct limine_kernel_file_response *KernelFileResponse = KernelFileRequest.response; struct limine_module_response *ModuleResponse = ModuleRequest.response; + struct limine_smbios_response *SmbiosResponse = SmbiosRequest.response; if (FrameBufferResponse == NULL || FrameBufferResponse->framebuffer_count < 1) { @@ -218,6 +223,14 @@ void init_limine() trace("RSDP: %p(%p) [Signature: %.8s] [OEM: %.6s]", RsdpResponse->address, binfo.RSDP, binfo.RSDP->Signature, binfo.RSDP->OEMID); + debug("SMBIOS: %p %p", SmbiosResponse->entry_32, SmbiosResponse->entry_64); + if (SmbiosResponse->entry_32 != NULL) + binfo.SMBIOSPtr = (void *)((uint64_t)SmbiosResponse->entry_32 - 0xffff800000000000); + else if (SmbiosResponse->entry_64 != NULL) + binfo.SMBIOSPtr = (void *)((uint64_t)SmbiosResponse->entry_64 - 0xffff800000000000); + else + binfo.SMBIOSPtr = NULL; + binfo.Kernel.PhysicalBase = (void *)KernelAddressResponse->physical_base; binfo.Kernel.VirtualBase = (void *)KernelAddressResponse->virtual_base; binfo.Kernel.FileBase = KernelFileResponse->kernel_file->address; diff --git a/include/boot/binfo.h b/include/boot/binfo.h index ffcbc2d..944b7f0 100644 --- a/include/boot/binfo.h +++ b/include/boot/binfo.h @@ -114,6 +114,8 @@ struct BootInfo char Name[256]; char Version[64]; } Bootloader; + + void *SMBIOSPtr; }; #endif // !__FENNIX_KERNEL_BOOT_INFO_H__