Move SDTHeader to separate file

This commit is contained in:
apio 2022-09-06 11:46:26 +02:00
parent 78fe37ddb3
commit f7f8c1068a
4 changed files with 31 additions and 24 deletions

View File

@ -1,21 +1,8 @@
#pragma once #pragma once
#include <stdint.h> #include "acpi/SDT.h"
namespace ACPI namespace ACPI
{ {
struct SDTHeader
{
char Signature[4];
uint32_t Length;
uint8_t Revision;
uint8_t Checksum;
char OEMID[6];
char OEMTableID[8];
uint32_t OEMRevision;
uint32_t CreatorID;
uint32_t CreatorRevision;
};
struct XSDT struct XSDT
{ {
SDTHeader header; SDTHeader header;
@ -29,7 +16,6 @@ namespace ACPI
}; };
SDTHeader* GetRSDTOrXSDT(); SDTHeader* GetRSDTOrXSDT();
bool ValidateSDTHeader(SDTHeader* header);
void* FindTable(SDTHeader* rootSDT, const char* signature); void* FindTable(SDTHeader* rootSDT, const char* signature);
} }

20
kernel/include/acpi/SDT.h Normal file
View File

@ -0,0 +1,20 @@
#pragma once
#include <stdint.h>
namespace ACPI
{
struct SDTHeader
{
char Signature[4];
uint32_t Length;
uint8_t Revision;
uint8_t Checksum;
char OEMID[6];
char OEMTableID[8];
uint32_t OEMRevision;
uint32_t CreatorID;
uint32_t CreatorRevision;
};
bool ValidateSDTHeader(SDTHeader* header);
}

View File

@ -10,15 +10,6 @@ ACPI::SDTHeader* ACPI::GetRSDTOrXSDT()
return (SDTHeader*)bootboot.arch.x86_64.acpi_ptr; return (SDTHeader*)bootboot.arch.x86_64.acpi_ptr;
} }
bool ACPI::ValidateSDTHeader(ACPI::SDTHeader* header)
{
uint8_t sum = 0;
for (uint32_t i = 0; i < header->Length; i++) { sum += ((char*)header)[i]; }
return sum == 0;
}
void* ACPI::FindTable(ACPI::SDTHeader* rootSDT, const char* signature) void* ACPI::FindTable(ACPI::SDTHeader* rootSDT, const char* signature)
{ {
bool isXSDT = strncmp(rootSDT->Signature, "XSDT", 4); bool isXSDT = strncmp(rootSDT->Signature, "XSDT", 4);

10
kernel/src/acpi/SDT.cpp Normal file
View File

@ -0,0 +1,10 @@
#include "acpi/SDT.h"
bool ACPI::ValidateSDTHeader(ACPI::SDTHeader* header)
{
uint8_t sum = 0;
for (uint32_t i = 0; i < header->Length; i++) { sum += ((char*)header)[i]; }
return sum == 0;
}