Max OS 0.3
Loading...
Searching...
No Matches
acpi.h
Go to the documentation of this file.
1
9#ifndef MAXOS_HARDWARECOMMUNICATION_ACPI_H
10#define MAXOS_HARDWARECOMMUNICATION_ACPI_H
11
12#include <cstdint>
13#include <cstddef>
14
15#include <libcommon/string.h>
16#include <libcommon/mem.h>
17#include <libcommon/assert.h>
18
19#include <system/multiboot.h>
21#include <memory/physical.h>
22
23namespace MaxOS::hardwarecommunication {
24
32 typedef struct PACKED RSDPDescriptor {
33 char signature[8];
34 uint8_t checksum;
35 char OEMID[6];
36 uint8_t revision;
37 uint32_t rsdt_address;
38 } rsdp_descriptor_t;
39
47 typedef struct PACKED RSDPDescriptor2 {
49 uint32_t length;
50 uint64_t xsdt_address;
52 uint8_t reserved[3];
53 } rsdp_descriptor2_t;
54
62 typedef struct PACKED ACPISDTHeader {
63 char signature[4];
64 uint32_t length;
65 uint8_t revision;
66 uint8_t checksum;
67 char OEM_id[6];
68 char OEM_table_id[8];
69 uint32_t OEM_revision;
70 uint32_t creator_id;
72 } acpi_sdt_header_t;
73
81 typedef struct RSDT {
83 uint32_t pointers[];
84 } rsdt_t;
85
93 typedef struct XSDT {
95 uint64_t pointers[];
96 } xsdt_t;
97
103 private:
104 bool m_using_new_acpi = false;
105 acpi_sdt_header_t* m_header;
106
107 xsdt_t* m_xsdt;
108 rsdt_t* m_rsdt;
109
110 rsdp_descriptor_t* m_rsdp;
111 rsdp_descriptor2_t* m_rsdp2;
112
113 static bool validate(const char* descriptor, size_t length);
114
115 void map_tables(uint8_t size_of_table);
116 memory::virtual_address_t* map_descriptor(uint64_t physical);
117
118 uint64_t get_rsdt_pointer(size_t index);
119
120 bool valid_checksum();
121
122 public:
125
126 acpi_sdt_header_t* find(const char* signature);
127 };
128
129}
130
131
132#endif // MAXOS_HARDWARECOMMUNICATION_ACPI_H
struct PACKED MaxOS::hardwarecommunication::ACPISDTHeader acpi_sdt_header_t
Alias for ACPISDTHeader struct.
struct PACKED MaxOS::hardwarecommunication::RSDPDescriptor2 rsdp_descriptor2_t
Alias for RSDPDescriptor2 struct.
struct PACKED MaxOS::hardwarecommunication::RSDPDescriptor rsdp_descriptor_t
Alias for RSDPDescriptor struct.
Handles ACPI table parsing and retrieval.
Definition acpi.h:102
acpi_sdt_header_t * find(const char *signature)
Finds a table with the given signature.
Definition acpi.cpp:163
Parses and provides access to Multiboot 2 information.
Definition multiboot.h:518
Defines a MemoryManager class for handling memory allocation and deallocation.
Defines a PhysicalMemoryManager class for managing physical memory allocation and deallocation of pag...
void virtual_address_t
A type representing a virtual address (used for readability)
Definition physical.h:30
Common header for all ACPI System Description Tables (SDTs)
Definition acpi.h:62
uint32_t creator_revision
The revision number of the utility that created the table.
Definition acpi.h:71
uint8_t checksum
This byte added to all bytes in the table must equal zero mod 0x100 for the table to be valid (includ...
Definition acpi.h:66
uint8_t revision
The version of the ACPI specification that is supported (higher means more features and is backwards ...
Definition acpi.h:65
uint32_t OEM_revision
The revision number of the table as supplied by the OEM.
Definition acpi.h:69
uint32_t length
The size of the entire table, including the header, in bytes.
Definition acpi.h:64
uint32_t creator_id
A vendor ID of the utility that created the table.
Definition acpi.h:70
Root System Description Pointer (RSDP) structure for ACPI 2 and above.
Definition acpi.h:47
uint64_t xsdt_address
The physical address of the XSDT.
Definition acpi.h:50
uint8_t extended_checksum
This byte added to all bytes in the table must equal zero for the table to be valid (including the ve...
Definition acpi.h:51
uint32_t length
The total length of the RSDP structure (including the version 1 part)
Definition acpi.h:49
RSDPDescriptor version_1_info
The ACPI 1 RSDP structure (see rsdp_descriptor_t)
Definition acpi.h:48
Root System Description Pointer (RSDP) structure for ACPI 1.
Definition acpi.h:32
uint8_t checksum
This byte added to all bytes in the table must equal zero for the table to be valid.
Definition acpi.h:34
uint32_t rsdt_address
The physical address of the RSDT (.
Definition acpi.h:37
uint8_t revision
The version of the ACPI specification that is supported (higher means more features and is backwards ...
Definition acpi.h:36
Root System Description Table (RSDT) structure for ACPI 1. Contains the header and an array of pointe...
Definition acpi.h:81
ACPISDTHeader header
The common header for all ACPI SDTs (see acpi_sdt_header_t)
Definition acpi.h:82
uint32_t pointers[]
An array of physical addresses pointing to other ACPI SDTs.
Definition acpi.h:83
Extended System Description Table (XSDT) structure for ACPI 2 and above. Contains the header and an a...
Definition acpi.h:93
uint64_t pointers[]
An array of physical addresses pointing to other ACPI SDTs.
Definition acpi.h:95
ACPISDTHeader header
The common header for all ACPI SDTs (see acpi_sdt_header_t)
Definition acpi.h:94