The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
acpi.h File Reference

the ACPI tables: RSDP, RSDT/XSDT, MADT, FADT, HPET and MCFG. More...

Go to the source code of this file.

Data Structures

struct  acpi_ioapic_t
 one I/O APIC from the MADT. More...
struct  acpi_iso_t
 an interrupt source override from the MADT: ISA IRQ source is global system interrupt gsi, with the given polarity and trigger mode. More...
struct  acpi_info_t
 what the kernel takes from the ACPI tables. More...

Macros

#define ACPI_MAX_CPUS   64
#define ACPI_MAX_IOAPICS   4
#define ACPI_MAX_ISOS   16

Functions

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_reboot (void) __attribute__((noreturn))
 restart the machine: the FADT reset register, then the keyboard controller, then a triple fault.
void acpi_power_off (void) __attribute__((noreturn))
 turn the machine off: the ACPI S5 state (the _S5 sleep types into the PM1 control registers), then the QEMU and Bochs ports.
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.

Detailed Description

the ACPI tables: RSDP, RSDT/XSDT, MADT, FADT, HPET and MCFG.

the kernel reads the static tables only. it has no AML interpreter, so it cannot run the DSDT: no device enumeration through ACPI. power-off reads only the _S5 package from the DSDT bytes. reboot uses the FADT reset register.

Macro Definition Documentation

◆ ACPI_MAX_CPUS

#define ACPI_MAX_CPUS   64

◆ ACPI_MAX_IOAPICS

#define ACPI_MAX_IOAPICS   4

◆ ACPI_MAX_ISOS

#define ACPI_MAX_ISOS   16

Function Documentation

◆ acpi_init()

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.

Parameters
bootthe boot information (rsdp, rsdp_size).
Returns
true if the tables were found.

◆ acpi_info()

const acpi_info_t * acpi_info ( void )

what acpi_init found (present is false if it found nothing).

◆ acpi_irq_to_gsi()

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).

Parameters
irqan ISA IRQ, 0 to 15.
active_lowreceives the polarity (may be NULL).
levelreceives the trigger mode (may be NULL).

◆ acpi_reboot()

void acpi_reboot ( void )

restart the machine: the FADT reset register, then the keyboard controller, then a triple fault.

does not return.

◆ acpi_power_off()

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.

◆ acpi_find_s5()

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.

Returns
false if there is no such package.