mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Search for SMBIOS & RSDP if the bootloader doesn't provide them
This commit is contained in:
parent
a452b9acd1
commit
fcf1e7528e
@ -162,19 +162,11 @@ namespace Memory
|
||||
debug("Reserving RSDT...");
|
||||
this->ReservePages((void *)bInfo.RSDP, TO_PAGES(sizeof(BootInfo::RSDPInfo)));
|
||||
|
||||
#if defined(a64)
|
||||
if ((uintptr_t)ACPIPtr > 0x7FE00000) /* FIXME */
|
||||
if (!Memory::Virtual().Check(ACPIPtr))
|
||||
{
|
||||
error("ACPI table is located above 0x7FE00000, which is not mapped.");
|
||||
error("ACPI table is located in an unmapped region.");
|
||||
return;
|
||||
}
|
||||
#elif defined(a32)
|
||||
if ((uintptr_t)ACPIPtr > 0x2800000) /* FIXME */
|
||||
{
|
||||
error("ACPI table is located above 0x2800000, which is not mapped.");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
size_t TableSize = ((ACPIPtr->Length - sizeof(ACPI::ACPI::ACPIHeader)) /
|
||||
(XSDT ? 8 : 4));
|
||||
|
@ -30,6 +30,7 @@ namespace SMBIOS
|
||||
debug("SMBIOS is available (%#lx).", bInfo.SMBIOSPtr);
|
||||
return true;
|
||||
}
|
||||
|
||||
debug("SMBIOS is not available. (%#lx)", bInfo.SMBIOSPtr);
|
||||
return false;
|
||||
}
|
||||
|
56
Kernel.cpp
56
Kernel.cpp
@ -155,6 +155,10 @@ bool DebuggerIsAttached = false;
|
||||
* - SMBIOS:
|
||||
* https://www.dmtf.org/dsp/DSP0134
|
||||
* https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_3.6.0.pdf
|
||||
* https://wiki.osdev.org/System_Management_BIOS
|
||||
*
|
||||
* - EDBA:
|
||||
* https://wiki.osdev.org/Memory_Map_(x86)
|
||||
*
|
||||
* - UMIP, SMAP and SMEP:
|
||||
* https://en.wikipedia.org/wiki/Control_register
|
||||
@ -599,6 +603,58 @@ EXTERNC __no_stack_protector NIF void Entry(BootInfo *Info)
|
||||
for (CallPtr *func = __init_array_start; func != __init_array_end; func++)
|
||||
(*func)();
|
||||
|
||||
#ifdef a86
|
||||
if (!bInfo.SMBIOSPtr)
|
||||
{
|
||||
trace("SMBIOS was not provided by the bootloader. Trying to find it manually.");
|
||||
for (uintptr_t i = 0xF0000; i < 0x100000; i += 16)
|
||||
{
|
||||
if (memcmp((void *)i, "_SM_", 4) == 0 || memcmp((void *)i, "_SM3_", 5) == 0)
|
||||
{
|
||||
bInfo.SMBIOSPtr = (void *)i;
|
||||
trace("Found SMBIOS at %#lx", i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!bInfo.RSDP)
|
||||
{
|
||||
trace("RSDP was not provided by the bootloader. Trying to find it manually.");
|
||||
/* FIXME: Not always shifting by 4 will work. */
|
||||
uintptr_t EBDABase = (uintptr_t)mminw((void *)0x40E) << 4;
|
||||
|
||||
for (uintptr_t ptr = EBDABase;
|
||||
ptr < 0x100000; /* 1MB */
|
||||
ptr += 16)
|
||||
{
|
||||
if (unlikely(ptr == EBDABase + 0x400))
|
||||
{
|
||||
trace("EBDA is full. Trying to find RSDP in the BIOS area.");
|
||||
break;
|
||||
}
|
||||
|
||||
BootInfo::RSDPInfo *rsdp = (BootInfo::RSDPInfo *)ptr;
|
||||
if (memcmp(rsdp->Signature, "RSD PTR ", 8) == 0)
|
||||
{
|
||||
bInfo.RSDP = (BootInfo::RSDPInfo *)rsdp;
|
||||
trace("Found RSDP at %#lx", rsdp);
|
||||
}
|
||||
}
|
||||
|
||||
for (uintptr_t ptr = 0xE0000;
|
||||
ptr < 0x100000; /* 1MB */
|
||||
ptr += 16)
|
||||
{
|
||||
BootInfo::RSDPInfo *rsdp = (BootInfo::RSDPInfo *)ptr;
|
||||
if (memcmp(rsdp->Signature, "RSD PTR ", 8) == 0)
|
||||
{
|
||||
bInfo.RSDP = (BootInfo::RSDPInfo *)rsdp;
|
||||
trace("Found RSDP at %#lx", rsdp);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
InitializeMemoryManagement();
|
||||
|
||||
void *KernelStackAddress = KernelAllocator.RequestPages(TO_PAGES(STACK_SIZE));
|
||||
|
Loading…
x
Reference in New Issue
Block a user