|
ginnOS
The reference: libc, the libraries and the kernel
|
#include "acpi.h"#include "arch/arch.h"#include "arch/x86/cpu/io.h"#include "common/memory.h"#include "common/string.h"#include "drivers/pci/pci.h"#include "kernel/klog/klog.h"#include "kernel/memory/mmio.h"#include "kernel/memory/phys.h"Macros | |
| #define | SDT_HEADER_SIZE 36 |
| the ACPI static tables (ACPI specification, chapter 5.2). | |
| #define | TABLE_MAX_SIZE (256u * 1024u) |
| #define | MADT_LAPIC 0 |
| #define | MADT_IOAPIC 1 |
| #define | MADT_ISO 2 |
| #define | MADT_LAPIC_OVERRIDE 5 |
| #define | MADT_PCAT_COMPAT 0x1u |
| #define | LAPIC_ENABLED 0x1u |
| #define | LAPIC_ONLINE_OK 0x2u |
| #define | FADT_RESET_REG_SUP (1u << 10) |
Functions | |
| bool | acpi_find_s5 (const uint8_t *aml, uint32_t length, uint8_t *type_a, uint8_t *type_b) |
| find the S5 sleep types in DSDT bytes (the AML of "Name (_S5, Package
() {a, b, ...})"), without an AML interpreter. | |
| bool | acpi_init (const boot_info_t *boot) |
| find and read the tables. | |
| const acpi_info_t * | acpi_info (void) |
| what acpi_init found (present is false if it found nothing). | |
| uint32_t | acpi_irq_to_gsi (uint8_t irq, bool *active_low, bool *level) |
| the global system interrupt of a legacy ISA IRQ, after the MADT overrides (for example IRQ 0 is often GSI 2). | |
| void | acpi_power_off (void) |
| turn the machine off: the ACPI S5 state (the _S5 sleep types into the PM1 control registers), then the QEMU and Bochs ports. | |
| void | acpi_reboot (void) |
| restart the machine: the FADT reset register, then the keyboard controller, then a triple fault. | |
| #define SDT_HEADER_SIZE 36 |
the ACPI static tables (ACPI specification, chapter 5.2).
the RSDP points to the RSDT (32-bit table addresses) and, from ACPI 2.0, to the XSDT (64-bit table addresses). each table starts with a 36-byte header with a signature, a length and a checksum (all bytes add up to 0). the tables are in reserved or ACPI memory, which is not always in the direct map, so the kernel maps each table with ioremap.
| #define TABLE_MAX_SIZE (256u * 1024u) |
| #define MADT_LAPIC 0 |
| #define MADT_IOAPIC 1 |
| #define MADT_ISO 2 |
| #define MADT_LAPIC_OVERRIDE 5 |
| #define MADT_PCAT_COMPAT 0x1u |
| #define LAPIC_ENABLED 0x1u |
| #define LAPIC_ONLINE_OK 0x2u |
| #define FADT_RESET_REG_SUP (1u << 10) |
find the S5 sleep types in DSDT bytes (the AML of "Name (_S5, Package () {a, b, ...})"), without an AML interpreter.
| bool acpi_init | ( | const boot_info_t * | boot | ) |
find and read the tables.
the RSDP comes from the bootloader if it gave one, else from a scan of the BIOS areas. call after mmio_init.
| boot | the boot information (rsdp, rsdp_size). |
| const acpi_info_t * acpi_info | ( | void | ) |
what acpi_init found (present is false if it found nothing).
the global system interrupt of a legacy ISA IRQ, after the MADT overrides (for example IRQ 0 is often GSI 2).
| irq | an ISA IRQ, 0 to 15. |
| active_low | receives the polarity (may be NULL). |
| level | receives the trigger mode (may be NULL). |
| void acpi_power_off | ( | void | ) |
turn the machine off: the ACPI S5 state (the _S5 sleep types into the PM1 control registers), then the QEMU and Bochs ports.
if all fail, the CPU halts.
| void acpi_reboot | ( | void | ) |
restart the machine: the FADT reset register, then the keyboard controller, then a triple fault.
does not return.