FADT

From OSDev.wiki
Jump to navigation Jump to search

FADT (Fixed ACPI Description Table) 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;
  DWORD FirmwareCtrl;
  DWORD Dsdt;
  BYTE Reserved;  // Was used in ACPI 1.0. Today is not used anymore. Some bioses still use it for compatibility with old os. for more info see the ACPI specification 1.0
  BYTE PreferredPowerManagementProfile;
  WORD SCI_Interrupt;
  DWORD SMI_CommandPort;
  BYTE AcpiEnable;
  BYTE AcpiDisable;
  BYTE S4BIOS_REQ;
  BYTE PSTATE_Control;
  DWORD PM1aEventBlock;
  DWORD PM1bEventBlock;
  DWORD PM1aControlBlock;
  DWORD PM1bControlBlock;
  DWORD PM2ControlBlock;
  DWORD PMTimerBlock;
  DWORD GPE0Block;
  DWORD GPE1Block;
  BYTE PM1EventLength;
  BYTE PM1ControlLength;
  BYTE PM2ControlLength;
  BYTE PMTimerLength;
  BYTE GPE0Length;
  BYTE GPE1Length;
  BYTE GPE1Base;
  BYTE CStateControl;
  WORD WorstC2Latency;
  WORD WorstC3Latency;
  WORD FlushSize;
  WORD FlushStride;
  BYTE DutyOffset;
  BYTE DutyWidth;
  BYTE DayAlarm;
  BYTE MonthAlarm;
  BYTE Century;
  WORD BootArchitectureFlags;
  BYTE Reserved2;
  DWORD Flags;
  GenericAddressStructure ResetRet;  // For details see below. Just know that GenericAddressStructure is made of 12 bytes
  BYTE ResetValue;
  BYTE Reserved3[3];
  
  // 64bit pointers
  QWORD X_FirmwareControl;
  QWORD 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
{
  BYTE AddressSpace;
  BYTE BitWidth;
  BYTE BitOffset;
  BYTE AccessSize;
  QWORD Address;
};

AddressSpace can be one of the following:

  • 0 System Memory
  • 1 System I/O
  • 2 PCI Configuration Space
  • 3 Embedded Controller
  • 4 SMBus
  • 5 to 0x7E Reserved
  • 0x7F Functional Fixed Hardware
  • 0x80 to 0xBF Reserved
  • 0xC0 to 0xFF OEM Defined

BitWidth and BitOffset are required only when accessing a bit field.

AccessSize defines how many bytes at once you can read/write and it must be one of the following:

  • 0 Undefined (legacy reasons)
  • 1 Byte access
  • 2 Word access
  • 3 Dword access
  • 4 QWord access

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

Fields

TODO

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.