2020-03-26 03:37:56 +03:00
|
|
|
|
#ifndef __LIB__ACPI_H__
|
|
|
|
|
#define __LIB__ACPI_H__
|
|
|
|
|
|
2020-09-17 13:06:35 +03:00
|
|
|
|
#include <stdint.h>
|
|
|
|
|
#include <stddef.h>
|
2022-07-01 16:04:57 +03:00
|
|
|
|
#include <sys/cpu.h>
|
2020-09-17 13:06:35 +03:00
|
|
|
|
|
2022-07-01 16:04:57 +03:00
|
|
|
|
#define EBDA (ebda_get())
|
|
|
|
|
|
2022-09-02 03:29:12 +03:00
|
|
|
|
#if defined (BIOS)
|
2022-07-01 16:04:57 +03:00
|
|
|
|
static inline uintptr_t ebda_get(void) {
|
|
|
|
|
uintptr_t ebda = (uintptr_t)mminw(0x40e) << 4;
|
|
|
|
|
|
|
|
|
|
// Sanity checks
|
|
|
|
|
if (ebda < 0x80000 || ebda >= 0xa0000) {
|
|
|
|
|
ebda = 0x80000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return ebda;
|
|
|
|
|
}
|
2022-08-18 18:32:54 +03:00
|
|
|
|
#endif
|
2020-09-17 13:06:35 +03:00
|
|
|
|
|
|
|
|
|
struct sdt {
|
|
|
|
|
char signature[4];
|
|
|
|
|
uint32_t length;
|
|
|
|
|
uint8_t rev;
|
|
|
|
|
uint8_t checksum;
|
|
|
|
|
char oem_id[6];
|
|
|
|
|
char oem_table_id[8];
|
|
|
|
|
uint32_t oem_rev;
|
2021-08-20 02:13:20 +03:00
|
|
|
|
char creator_id[4];
|
2020-09-17 13:06:35 +03:00
|
|
|
|
uint32_t creator_rev;
|
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
|
|
struct rsdp {
|
|
|
|
|
char signature[8];
|
|
|
|
|
uint8_t checksum;
|
|
|
|
|
char oem_id[6];
|
|
|
|
|
uint8_t rev;
|
|
|
|
|
uint32_t rsdt_addr;
|
2021-10-08 04:52:22 +03:00
|
|
|
|
// Revision 2 only after this comment
|
2020-09-17 13:06:35 +03:00
|
|
|
|
uint32_t length;
|
|
|
|
|
uint64_t xsdt_addr;
|
|
|
|
|
uint8_t ext_checksum;
|
|
|
|
|
uint8_t reserved[3];
|
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
|
|
struct rsdt {
|
2021-05-28 17:05:42 +03:00
|
|
|
|
struct sdt header;
|
2020-09-17 15:37:22 +03:00
|
|
|
|
char ptrs_start[];
|
2020-09-17 13:06:35 +03:00
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
2021-10-08 04:52:22 +03:00
|
|
|
|
struct smbios_entry_point_32 {
|
|
|
|
|
char anchor_str[4];
|
|
|
|
|
/// This value summed with all the values of the table.
|
|
|
|
|
uint8_t checksum;
|
|
|
|
|
/// Length of the entry point table.
|
|
|
|
|
uint8_t length;
|
|
|
|
|
/// Major version of SMBIOS.
|
|
|
|
|
uint8_t major_version;
|
|
|
|
|
/// Minor version of SMBIOS.
|
|
|
|
|
uint8_t minor_version;
|
|
|
|
|
/// Size of the largest SMBIOS structure, in bytes, and encompasses the
|
|
|
|
|
/// structure’s formatted area and text strings
|
|
|
|
|
uint16_t max_structure_size;
|
|
|
|
|
uint8_t entry_point_revision;
|
|
|
|
|
char formatted_area[5];
|
|
|
|
|
|
|
|
|
|
char intermediate_anchor_str[5];
|
2022-01-26 05:58:28 +03:00
|
|
|
|
/// Checksum for values from intermediate anchor str to the
|
2021-10-08 04:52:22 +03:00
|
|
|
|
/// end of table.
|
|
|
|
|
uint8_t intermediate_checksum;
|
|
|
|
|
/// Total length of SMBIOS Structure Table, pointed to by the structure
|
|
|
|
|
/// table address, in bytes.
|
|
|
|
|
uint16_t table_length;
|
|
|
|
|
/// 32-bit physical starting address of the read-only SMBIOS Structure
|
|
|
|
|
/// Table.
|
|
|
|
|
uint32_t table_address;
|
|
|
|
|
/// Total number of structures present in the SMBIOS Structure Table.
|
|
|
|
|
uint16_t number_of_structures;
|
|
|
|
|
/// Indicates compliance with a revision of this specification.
|
|
|
|
|
uint8_t bcd_revision;
|
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
|
|
struct smbios_entry_point_64 {
|
|
|
|
|
char anchor_str[5];
|
|
|
|
|
/// This value summed with all the values of the table.
|
|
|
|
|
uint8_t checksum;
|
|
|
|
|
/// Length of the entry point table.
|
|
|
|
|
uint8_t length;
|
|
|
|
|
/// Major version of SMBIOS.
|
|
|
|
|
uint8_t major_version;
|
|
|
|
|
/// Minor version of SMBIOS.
|
|
|
|
|
uint8_t minor_version;
|
|
|
|
|
uint8_t docrev;
|
|
|
|
|
uint8_t entry_point_revision;
|
|
|
|
|
uint8_t reserved;
|
|
|
|
|
/// Size of the largest SMBIOS structure, in bytes, and encompasses the
|
|
|
|
|
/// structure’s formatted area and text strings
|
|
|
|
|
uint16_t max_structure_size;
|
|
|
|
|
/// 64-bit physical starting address of the read-only SMBIOS Structure
|
|
|
|
|
/// Table.
|
|
|
|
|
uint64_t table_address;
|
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
2020-09-17 13:06:35 +03:00
|
|
|
|
uint8_t acpi_checksum(void *ptr, size_t size);
|
|
|
|
|
void *acpi_get_rsdp(void);
|
2021-10-05 04:07:52 +03:00
|
|
|
|
|
|
|
|
|
void *acpi_get_rsdp_v1(void);
|
|
|
|
|
void *acpi_get_rsdp_v2(void);
|
|
|
|
|
|
2020-09-17 15:37:22 +03:00
|
|
|
|
void *acpi_get_table(const char *signature, int index);
|
2021-04-28 21:15:24 +03:00
|
|
|
|
void acpi_get_smbios(void **smbios32, void **smbios64);
|
2020-03-26 03:37:56 +03:00
|
|
|
|
|
|
|
|
|
#endif
|