12using namespace MaxOS::hardwarecommunication;
13using namespace MaxOS::system;
14using namespace MaxOS::memory;
15using namespace MaxOS::common;
32 m_using_new_acpi =
multiboot->old_acpi() ==
nullptr;
33 Logger::DEBUG() <<
"CPU Supports " << (m_using_new_acpi ?
"New" :
"Old") <<
" ACPI\n";
41 uint64_t physical_address = m_using_new_acpi ? m_rsdp2->xsdt_address : m_rsdp->rsdt_address;
42 void* virtual_address = map_descriptor(physical_address);
43 ASSERT(virtual_address !=
nullptr,
"Failed to map ACPI table");
44 Logger::DEBUG() <<
"XSDT/RSDT: physical: 0x" << physical_address <<
", virtual: 0x" << (
uint64_t) virtual_address
49 m_xsdt = (
XSDT*) virtual_address;
51 m_rsdt = (
RSDT*) virtual_address;
58 ASSERT(valid_checksum(),
"ACPI: Invalid checksum!");
61AdvancedConfigurationAndPowerInterface::~AdvancedConfigurationAndPowerInterface() =
default;
71 for(
uint32_t i = 0; i < entries; i++) {
74 auto address = (
uint64_t) (m_using_new_acpi ? m_xsdt->
pointers[i] : get_rsdt_pointer(i));
124uint64_t AdvancedConfigurationAndPowerInterface::get_rsdt_pointer(
size_t index) {
129 ASSERT(offset +
sizeof(
uint32_t) <= m_header->length,
"RSDT index out of bounds");
144bool AdvancedConfigurationAndPowerInterface::validate(
const char*
descriptor,
size_t length) {
150 for(
uint32_t i = 0; i < length; i++)
154 return ((
sum & 0xFF) == 0);
170 for(
size_t i = 0; i < entries; ++i) {
179 if(
strncmp(header->signature, signature, 4))
192bool AdvancedConfigurationAndPowerInterface::valid_checksum() {
195 char*
check = m_using_new_acpi ? (
char*) m_rsdp2 : (
char*) m_rsdp;
200 for(
uint32_t i = 0; i < length; i++)
Defines an Advanced Configuration And Power Interface (ACPI class for handling ACPI table parsing and...
static Logger DEBUG()
Gets active logger set to DEBUG level.
static Logger INFO()
Gets active logger set to info level.
Stores the left, top, width and height of a rectangle.
acpi_sdt_header_t * find(const char *signature)
Finds a table with the given signature.
AdvancedConfigurationAndPowerInterface(system::Multiboot *multiboot)
Construct a new Advanced Configuration And Power Interface object. Maps the ACPI headers and tables i...
static size_t align_direct_to_page(size_t size)
Aligns a address to the page size.
static void * to_io_region(uintptr_t physical_address)
Converts a physical address to an IO region address if it is in the lower region using the higher hal...
static PhysicalMemoryManager * s_current_manager
The current physical memory manager in use.
Parses and provides access to Multiboot 2 information.
Defines a Logger class for logging messages with different severity levels to multiple output streams...
#define ASSERT(condition, format,...)
If the specified condition is not met then the kernel will crash with the specified message.
void * memcpy(void *destination, const void *source, uint64_t num)
Copies a block of memory from one location to another.
constexpr uint64_t PAGE_SIZE
The size of a page (4KB)
bool strncmp(char const *str1, char const *str2, int length)
Checks if one string pointer is equal to another string pointer up to a specified length (each must b...
Root System Description Pointer (RSDP) structure for ACPI 2 and above.
Root System Description Pointer (RSDP) structure for ACPI 1.
Root System Description Table (RSDT) structure for ACPI 1. Contains the header and an array of pointe...
Extended System Description Table (XSDT) structure for ACPI 2 and above. Contains the header and an a...
uint64_t pointers[]
An array of physical addresses pointing to other ACPI SDTs.