Misc cleanup

This commit is contained in:
Adrien Bourmault 2020-02-04 00:41:41 +01:00
parent 898c05588a
commit 51292364ce
2 changed files with 42 additions and 36 deletions

View File

@ -26,6 +26,9 @@ set timeout=0
set default=0 #Set the default menu entry
insmod vbe
insmod vga
menuentry "OS/K (pre-pre-alpha 0.0.1)" {
multiboot /boot/kaleid # The multiboot command replaces the kernel command
boot

View File

@ -31,6 +31,7 @@ SDTHeader *AcpiSDT = NULL;
SDTHeader *AcpiFADT = NULL;
char IoACPIVersion = 1;
int tableCount = 1;
//
// Returns the checksum of the given structure
@ -94,6 +95,42 @@ static inline RSDPDescriptor *IoFindRSDP()
return NULL;
}
//
// RSDP Exploration
//
static inline void IoInitRSDP(void)
{
char checksum = 1;
RSDPDescriptor *rsdp = IoFindRSDP();
if (!rsdp)
KeStartPanic("ACPI RSDP not found in memory");
// Checksum calculation
checksum = DoChecksum(rsdp, (size_t)sizeof(RSDPDescriptor),
(size_t)sizeof(struct RSDPLegacy),
!rsdp->legacy.revision
);
if (checksum)
KeStartPanic("Invalid RSDP checksum : %d vs 0", checksum);
if (rsdp->legacy.revision == 1 || rsdp->legacy.revision >= 3)
KeStartPanic("Invalid ACPI Revision : %d", rsdp->legacy.revision);
KernLog("\tACPI Revision %d (OEM %s)\n",
(uint)rsdp->legacy.revision,
rsdp->legacy.OEMID
);
AcpiSDT = (void *)(ulong)rsdp->legacy.rsdtAddress;
if (rsdp->legacy.revision) {
AcpiSDT = (void *)rsdp->xsdtAddress;
IoACPIVersion = 2;
}
}
//
// R/XSDT Exploration
//
@ -136,42 +173,6 @@ static inline void IoInitRXSDT(void)
}
}
//
// RSDP Exploration
//
static inline void IoInitRSDP(void)
{
char checksum = 1;
RSDPDescriptor *rsdp = IoFindRSDP();
if (!rsdp)
KeStartPanic("ACPI RSDP not found in memory");
// Checksum calculation
checksum = DoChecksum(rsdp, (size_t)sizeof(RSDPDescriptor),
(size_t)sizeof(struct RSDPLegacy),
!rsdp->legacy.revision
);
if (checksum)
KeStartPanic("Invalid RSDP checksum : %d vs 0", checksum);
if (rsdp->legacy.revision == 1 || rsdp->legacy.revision >= 3)
KeStartPanic("Invalid ACPI Revision : %d", rsdp->legacy.revision);
KernLog("\tACPI Revision %d (OEM %s)\n",
(uint)rsdp->legacy.revision,
rsdp->legacy.OEMID
);
AcpiSDT = (void *)(ulong)rsdp->legacy.rsdtAddress;
if (rsdp->legacy.revision) {
AcpiSDT = (void *)rsdp->xsdtAddress;
IoACPIVersion = 2;
}
}
//
// Explore all ACPI Tables
//
@ -181,6 +182,8 @@ static inline void IoSearchAcpiTables(void)
}
// -------------------------------------------------------------------------- //
//
// Initialise the ACPI by finding tables
//