133 lines
2.9 KiB
C
133 lines
2.9 KiB
C
#ifndef CRASHPOWEROS_ACPI_H
|
|
#define CRASHPOWEROS_ACPI_H
|
|
|
|
#include <stdint.h>
|
|
|
|
typedef struct RSDPDescriptor RSDPDescriptor;
|
|
typedef struct GenericAddressStructure GenericAddressStructure;
|
|
|
|
struct RSDPDescriptor {
|
|
char Signature[8];
|
|
uint8_t Checksum;
|
|
char OEMID[6];
|
|
uint8_t Revision;
|
|
uint32_t RsdtAddress;
|
|
} __attribute__ ((packed));
|
|
|
|
struct RSDPDescriptor20 {
|
|
struct RSDPDescriptor firstPart;
|
|
|
|
uint32_t Length;
|
|
uint64_t XsdtAddress;
|
|
uint8_t ExtendedChecksum;
|
|
uint8_t reserved[3];
|
|
} __attribute__ ((packed));
|
|
|
|
struct ACPISDTHeader {
|
|
char Signature[4];
|
|
uint32_t Length;
|
|
uint8_t Revision;
|
|
uint8_t Checksum;
|
|
char OEMID[6];
|
|
char OEMTableID[8];
|
|
uint32_t OEMRevision;
|
|
uint32_t CreatorID;
|
|
uint32_t CreatorRevision;
|
|
};
|
|
|
|
struct RSDT {
|
|
struct ACPISDTHeader h;
|
|
uint32_t PointerToOtherSDT;
|
|
};
|
|
|
|
struct XSDT {
|
|
struct ACPISDTHeader h;
|
|
uint64_t PointerToOtherSDT;
|
|
};
|
|
|
|
struct GenericAddressStructure {
|
|
uint8_t AddressSpace;
|
|
uint8_t BitWidth;
|
|
uint8_t BitOffset;
|
|
uint8_t AccessSize;
|
|
uint64_t Address;
|
|
};
|
|
|
|
struct FADT {
|
|
struct ACPISDTHeader h;
|
|
uint32_t FirmwareCtrl;
|
|
uint32_t Dsdt;
|
|
|
|
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;
|
|
|
|
uint16_t BootArchitectureFlags;
|
|
|
|
uint8_t Reserved2;
|
|
uint32_t Flags;
|
|
|
|
GenericAddressStructure ResetReg;
|
|
|
|
uint8_t ResetValue;
|
|
uint8_t Reserved3[3];
|
|
|
|
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;
|
|
};
|
|
|
|
struct DSDT_vals {
|
|
int length;
|
|
void *S5_object;
|
|
};
|
|
|
|
void *findRSDP();
|
|
int acpi_check_hdr(uint8_t *table, const char *sig, int n);
|
|
void parse_dsdt();
|
|
void parse_acpi(void *mem);
|
|
void parse_acpi20(void *mem);
|
|
void acpi_enable();
|
|
void init_acpi();
|
|
|
|
#endif //CRASHPOWEROS_ACPI_H
|