diff --git a/include/io/acpi.h b/include/io/acpi.h index 9b2d087..3228584 100644 --- a/include/io/acpi.h +++ b/include/io/acpi.h @@ -31,7 +31,25 @@ //----------------------------------------------------------------------------// +// +// ACPI 2.0 Legacy descriptor +// +struct RSDPDescriptor { + char signature[8]; + uchar checksum; + char OEMID[6]; + uchar revision; + uint rsdtAddress; + uint length; + ulong xsdtAddress; + uchar extendedChecksum; + uchar reserved[3]; +} __attribute__ ((packed)); + +//----------------------------------------------------------------------------// + void IoTestAcpi(void); +RSDPDescriptor *IoFindRSDP(void); //----------------------------------------------------------------------------// diff --git a/include/kernel.h b/include/kernel.h index 8000b3d..3c02075 100644 --- a/include/kernel.h +++ b/include/kernel.h @@ -56,6 +56,8 @@ typedef struct IdtPtr_t IdtPtr_t; typedef struct ISRList_t ISRList_t; typedef struct ISRFrame_t ISRFrame_t; +typedef struct RSDPDescriptor RSDPDescriptor; + typedef struct MemoryMap_t MemoryMap_t; typedef struct MapEntry_t MapEntry_t; typedef struct GdtEntry_t GdtEntry_t; diff --git a/kaleid/kernel/init/init.c b/kaleid/kernel/init/init.c index fb5841d..5855162 100644 --- a/kaleid/kernel/init/init.c +++ b/kaleid/kernel/init/init.c @@ -64,6 +64,9 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg) // Sanity checks BtDoSanityChecks(mbMagic); + // ACPI + IoTestAcpi(); + // Memory MmInitMemoryMap(); MmInitGdt(); @@ -83,9 +86,6 @@ noreturn void BtStartKern(multiboot_info_t *mbInfo, uint mbMagic, void *codeSeg) KeGetCpuInfos(); IoEnableKeyb(); - // ACPI - IoTestAcpi(); - // Scheduler PsInitSched(); diff --git a/kaleid/kernel/io/acpi.c b/kaleid/kernel/io/acpi.c index b5fdd6a..df1f3fb 100644 --- a/kaleid/kernel/io/acpi.c +++ b/kaleid/kernel/io/acpi.c @@ -24,6 +24,7 @@ #include #include +#include void IoTestAcpi(void) { @@ -34,6 +35,57 @@ void IoTestAcpi(void) if (BtFirmwareInfo.apmValid) KernLog("\tApm Table is valid at %p\n", BtFirmwareInfo.apmTable); + RSDPDescriptor *rsdp = IoFindRSDP(); + if (!rsdp) + return; + + KernLog("\tFound ACPI RSDP (%s) version %d at %p\n", + rsdp->OEMID, (uint)rsdp->revision, rsdp + ); return; } + +RSDPDescriptor *IoFindRSDP() +{ + char *rsdp = NULL; + + + // Search in EBDA + for (rsdp = (char *)0x00080000; // EBDA address + (ulong)rsdp < (ulong)0x0009FFFF; // EBDA end + rsdp++) { + + if (rsdp[0] == 'R' && + rsdp[1] == 'S' && + rsdp[2] == 'D' && + rsdp[3] == ' ' && + rsdp[4] == 'P' && + rsdp[5] == 'T' && + rsdp[6] == 'R' && + rsdp[7] == ' ' + ) { + return (RSDPDescriptor *)rsdp; + } + } + + // Search in BDA + for (rsdp = (char *)0x000E0000; // BDA address + (ulong)rsdp < (ulong)0x000FFFFF; // BDA end + rsdp++) { + + if (rsdp[0] == 'R' && + rsdp[1] == 'S' && + rsdp[2] == 'D' && + rsdp[3] == ' ' && + rsdp[4] == 'P' && + rsdp[5] == 'T' && + rsdp[6] == 'R' && + rsdp[7] == ' ' + ) { + return (RSDPDescriptor *)rsdp; + } + } + + return NULL; +} diff --git a/kaleid/kernel/sh/testcmds.c b/kaleid/kernel/sh/testcmds.c index 1f7c376..cc322a7 100644 --- a/kaleid/kernel/sh/testcmds.c +++ b/kaleid/kernel/sh/testcmds.c @@ -143,7 +143,6 @@ error_t CmdDumpMem(int argc, char **argv, char *cmdline) x += step; } - KernLog("\n\n"); return EOK; }