FADT

From OSDev Wiki
Jump to navigation Jump to search
ACPI
Fixed Tables
Differentiated Tables
Tools/Libs

This page is about the ACPI FADT(Fixed ACPI Description Table) It contains information about ACPI fixed registers, DSDT pointer, etc.

FADT is a data structure used in the ACPI programming interface. This table contains information about fixed register blocks pertaining to power management.

Finding the FADT

The FADT is pointed to by an entry in the RSDT. The signature is 'FACP'. Even if the pointer was found in another ACPI valid structure, you should anyway do the checksum to check that the table is valid.

Structure

The FADT is a complex structure and contains a lot of data. Here it is:

struct FADT
{
    struct   ACPISDTHeader h;
    uint32_t FirmwareCtrl;
    uint32_t Dsdt;

    // field used in ACPI 1.0; no longer in use, for compatibility only
    uint8_t  Reserved;

    uint8_t  PreferredPowerManagementProfile;
    uint16_t SCI_Interrupt;
    uint32_t SMI_CommandPort;
    uint8_t  AcpiEnable;
    uint8_t  AcpiDisable;
    uint8_t  S4BIOS_REQ;
    uint8_t  PSTATE_Control;
    uint32_t PM1aEventBlock;
    uint32_t PM1bEventBlock;
    uint32_t PM1aControlBlock;
    uint32_t PM1bControlBlock;
    uint32_t PM2ControlBlock;
    uint32_t PMTimerBlock;
    uint32_t GPE0Block;
    uint32_t GPE1Block;
    uint8_t  PM1EventLength;
    uint8_t  PM1ControlLength;
    uint8_t  PM2ControlLength;
    uint8_t  PMTimerLength;
    uint8_t  GPE0Length;
    uint8_t  GPE1Length;
    uint8_t  GPE1Base;
    uint8_t  CStateControl;
    uint16_t WorstC2Latency;
    uint16_t WorstC3Latency;
    uint16_t FlushSize;
    uint16_t FlushStride;
    uint8_t  DutyOffset;
    uint8_t  DutyWidth;
    uint8_t  DayAlarm;
    uint8_t  MonthAlarm;
    uint8_t  Century;

    // reserved in ACPI 1.0; used since ACPI 2.0+
    uint16_t BootArchitectureFlags;

    uint8_t  Reserved2;
    uint32_t Flags;

    // 12 byte structure; see below for details
    GenericAddressStructure ResetReg;

    uint8_t  ResetValue;
    uint8_t  Reserved3[3];
  
    // 64bit pointers - Available on ACPI 2.0+
    uint64_t                X_FirmwareControl;
    uint64_t                X_Dsdt;

    GenericAddressStructure X_PM1aEventBlock;
    GenericAddressStructure X_PM1bEventBlock;
    GenericAddressStructure X_PM1aControlBlock;
    GenericAddressStructure X_PM1bControlBlock;
    GenericAddressStructure X_PM2ControlBlock;
    GenericAddressStructure X_PMTimerBlock;
    GenericAddressStructure X_GPE0Block;
    GenericAddressStructure X_GPE1Block;
};

GenericAddressStructure

Before going to far, keep in mind that the GAS is a structure used by ACPI to describe the position of registers. Its structure is:

struct GenericAddressStructure
{
  uint8_t AddressSpace;
  uint8_t BitWidth;
  uint8_t BitOffset;
  uint8_t AccessSize;
  uint64_t Address;
};
Possible values of AddressSpace
Value Address Space
0 System Memory
1 System I/O
2 PCI Configuration Space
3 Embedded Controller
4 System Management Bus
5 System CMOS
6 PCI Device BAR Target
7 Intelligent Platform Management Infrastructure
8 General Purpose I/O
9 Generic Serial Bus
0x0A Platform Communication Channel
0x0B to 0x7F Reserved
0x80 to 0xFF OEM Defined

BitWidth and BitOffset are required only when accessing a bit field, and I guess you know how to use them.

AccessSize defines how many bytes at once you can read/write.

Possible values of AccessSize
Value Access size
0 Undefined (legacy reasons)
1 Byte access
2 16-bit (word) access
3 32-bit (dword) access
4 64-bit (qword) access

Address is a 64-bit pointer in the defined address space to the data structure.

Fields

FirmwareCtrl

This is a 32-bit pointer to the FACS. Since ACPI 2.0 a new field has been added to the table, X_FirmwareControl of type GAS, which is 64-bits wide. Only one of the two fields is used, the other contains 0. According to the Specs, the X_ field is used only when the FACS is placed above the 4th GB.

Dsdt

A 32-bit pointer to the DSDT. This has a X_Dsdt brother too.

PreferredPowerManagementProfile

This field contains a value which should address you to a power management profile. For example if it contains 2, the computer is a laptop and you should configure power management in power saving mode.

Values for PreferredPowerManagementProfile
Value Meaning
0 Unspecified
1 Desktop
2 Mobile
3 Workstation
4 Enterprise Server
5 SOHO Server
6 Aplliance PC
7 Performance Server
>7 Reserved

SCI_Interrupt

The System Control Interrupt is used by ACPI to notify the OS about fixed events, such as for example, pressing the power button, or for General Purpose Events (GPEs), which are firmware specific. This member in the FADT structure indicates the PIC or IOAPIC interrupt pin for it. To know if it's a PIC IRQ, check if the dual 8259 interrupt controllers are present via the MADT. Otherwise, it's a GSI. If you are using the IOAPIC and the PIC is present, remember to check the Interrupt Source Overrides first to get the GSI associated with the IRQ source.

SMI_CommandPort

This is an I/O Port. This is where the OS writes AcpiEnable or AcpiDisable to get or release the ownership over the ACPI registers. This is 0 on systems where the System Management Mode is not supported.

What's next?

You should preserve the pointer to the FACS (in FirmwareControl (if < 4GB) or in X_FirmwareControl (if >= 4GB)). Then you should parse the DSDT.