]> xenbits.xensource.com Git - seabios.git/commitdiff
Move fw/acpi.h to std/acpi.h.
authorKevin O'Connor <kevin@koconnor.net>
Sun, 15 Sep 2013 02:54:44 +0000 (22:54 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 19 Sep 2013 00:48:34 +0000 (20:48 -0400)
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
13 files changed:
src/apm.c
src/byteorder.h
src/fw/acpi.c
src/fw/acpi.h [deleted file]
src/fw/biostables.c
src/fw/coreboot.c
src/fw/csm.c
src/fw/paravirt.c
src/fw/pciinit.c
src/fw/xen.c
src/resume.c
src/std/acpi.h [new file with mode: 0644]
src/util.h

index b4b9ed96bc3c2fae3b9ecf4415289224756701b1..7f400fbada249809a5b1ca301a123c8434679c27 100644 (file)
--- a/src/apm.c
+++ b/src/apm.c
@@ -9,7 +9,6 @@
 #include "biosvar.h" // GET_GLOBAL
 #include "bregs.h" // struct bregs
 #include "config.h" // CONFIG_*
-#include "fw/acpi.h" // acpi_pm_ctl
 #include "fw/paravirt.h" // runningOnQEMU
 #include "ioport.h" // outb
 #include "output.h" // dprintf
index 7362aeb71af249a83d552988665fcbd0d141fe39..928c1b807e240d49c95dcc261111f04dfe965f76 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __BYTEORDER_H
 #define __BYTEORDER_H
 
+#include "types.h" // u32
+
 static inline u16 __swab16_constant(u16 val) {
     return (val<<8) | (val>>8);
 }
index cba3f68223a988f210660f4f8775ab468f59642c..8f99b34fa8d3c4a63e7b54c4a7f1fd1e74ea7476 100644 (file)
@@ -5,7 +5,6 @@
 //
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
-#include "acpi.h" // struct rsdp_descriptor
 #include "byteorder.h" // cpu_to_le16
 #include "config.h" // CONFIG_*
 #include "dev-q35.h"
@@ -17,6 +16,7 @@
 #include "output.h" // dprintf
 #include "paravirt.h" // RamSize
 #include "romfile.h" // romfile_loadint
+#include "std/acpi.h" // struct rsdp_descriptor
 #include "string.h" // memset
 #include "util.h" // MaxCountCPUs
 #include "x86.h" // readl
@@ -756,6 +756,8 @@ find_acpi_features(void)
 static struct acpi_20_generic_address acpi_reset_reg;
 static u8 acpi_reset_val;
 
+#define acpi_ga_to_bdf(addr) pci_to_bdf(0, (addr >> 32) & 0xffff, (addr >> 16) & 0xffff)
+
 void
 acpi_reboot(void)
 {
diff --git a/src/fw/acpi.h b/src/fw/acpi.h
deleted file mode 100644 (file)
index f0d24d4..0000000
+++ /dev/null
@@ -1,282 +0,0 @@
-#ifndef __ACPI_H
-#define __ACPI_H
-
-#include "types.h" // u32
-
-/*
- * ACPI 2.0 Generic Address Space definition.
- */
-struct acpi_20_generic_address {
-    u8  address_space_id;
-    u8  register_bit_width;
-    u8  register_bit_offset;
-    u8  reserved;
-    u64 address;
-} PACKED;
-#define acpi_ga_to_bdf(addr) pci_to_bdf(0, (addr >> 32) & 0xffff, (addr >> 16) & 0xffff)
-
-void acpi_setup(void);
-u32 find_resume_vector(void);
-void find_acpi_features(void);
-void acpi_set_reset_reg(struct acpi_20_generic_address *reg, u8 val);
-void acpi_reboot(void);
-
-#define RSDP_SIGNATURE 0x2052545020445352LL // "RSD PTR "
-
-struct rsdp_descriptor {        /* Root System Descriptor Pointer */
-    u64 signature;              /* ACPI signature, contains "RSD PTR " */
-    u8  checksum;               /* To make sum of struct == 0 */
-    u8  oem_id [6];             /* OEM identification */
-    u8  revision;               /* Must be 0 for 1.0, 2 for 2.0 */
-    u32 rsdt_physical_address;  /* 32-bit physical address of RSDT */
-    u32 length;                 /* XSDT Length in bytes including hdr */
-    u64 xsdt_physical_address;  /* 64-bit physical address of XSDT */
-    u8  extended_checksum;      /* Checksum of entire table */
-    u8  reserved [3];           /* Reserved field must be 0 */
-};
-
-extern struct rsdp_descriptor *RsdpAddr;
-extern u32 acpi_pm1a_cnt;
-
-/* Table structure from Linux kernel (the ACPI tables are under the
-   BSD license) */
-
-#define ACPI_TABLE_HEADER_DEF   /* ACPI common table header */ \
-    u32 signature;          /* ACPI signature (4 ASCII characters) */ \
-    u32 length;                 /* Length of table, in bytes, including header */ \
-    u8  revision;               /* ACPI Specification minor version # */ \
-    u8  checksum;               /* To make sum of entire table == 0 */ \
-    u8  oem_id [6];             /* OEM identification */ \
-    u8  oem_table_id [8];       /* OEM table identification */ \
-    u32 oem_revision;           /* OEM revision number */ \
-    u8  asl_compiler_id [4];    /* ASL compiler vendor ID */ \
-    u32 asl_compiler_revision;  /* ASL compiler revision number */
-
-
-/*
- * ACPI 1.0 Fixed ACPI Description Table (FADT)
- */
-#define FACP_SIGNATURE 0x50434146 // FACP
-struct fadt_descriptor_rev1
-{
-    ACPI_TABLE_HEADER_DEF     /* ACPI common table header */
-    u32 firmware_ctrl;          /* Physical address of FACS */
-    u32 dsdt;                   /* Physical address of DSDT */
-    u8  model;                  /* System Interrupt Model */
-    u8  reserved1;              /* Reserved */
-    u16 sci_int;                /* System vector of SCI interrupt */
-    u32 smi_cmd;                /* Port address of SMI command port */
-    u8  acpi_enable;            /* Value to write to smi_cmd to enable ACPI */
-    u8  acpi_disable;           /* Value to write to smi_cmd to disable ACPI */
-    u8  S4bios_req;             /* Value to write to SMI CMD to enter S4BIOS state */
-    u8  reserved2;              /* Reserved - must be zero */
-    u32 pm1a_evt_blk;           /* Port address of Power Mgt 1a acpi_event Reg Blk */
-    u32 pm1b_evt_blk;           /* Port address of Power Mgt 1b acpi_event Reg Blk */
-    u32 pm1a_cnt_blk;           /* Port address of Power Mgt 1a Control Reg Blk */
-    u32 pm1b_cnt_blk;           /* Port address of Power Mgt 1b Control Reg Blk */
-    u32 pm2_cnt_blk;            /* Port address of Power Mgt 2 Control Reg Blk */
-    u32 pm_tmr_blk;             /* Port address of Power Mgt Timer Ctrl Reg Blk */
-    u32 gpe0_blk;               /* Port addr of General Purpose acpi_event 0 Reg Blk */
-    u32 gpe1_blk;               /* Port addr of General Purpose acpi_event 1 Reg Blk */
-    u8  pm1_evt_len;            /* Byte length of ports at pm1_x_evt_blk */
-    u8  pm1_cnt_len;            /* Byte length of ports at pm1_x_cnt_blk */
-    u8  pm2_cnt_len;            /* Byte Length of ports at pm2_cnt_blk */
-    u8  pm_tmr_len;             /* Byte Length of ports at pm_tm_blk */
-    u8  gpe0_blk_len;           /* Byte Length of ports at gpe0_blk */
-    u8  gpe1_blk_len;           /* Byte Length of ports at gpe1_blk */
-    u8  gpe1_base;              /* Offset in gpe model where gpe1 events start */
-    u8  reserved3;              /* Reserved */
-    u16 plvl2_lat;              /* Worst case HW latency to enter/exit C2 state */
-    u16 plvl3_lat;              /* Worst case HW latency to enter/exit C3 state */
-    u16 flush_size;             /* Size of area read to flush caches */
-    u16 flush_stride;           /* Stride used in flushing caches */
-    u8  duty_offset;            /* Bit location of duty cycle field in p_cnt reg */
-    u8  duty_width;             /* Bit width of duty cycle field in p_cnt reg */
-    u8  day_alrm;               /* Index to day-of-month alarm in RTC CMOS RAM */
-    u8  mon_alrm;               /* Index to month-of-year alarm in RTC CMOS RAM */
-    u8  century;                /* Index to century in RTC CMOS RAM */
-    u8  reserved4;              /* Reserved */
-    u8  reserved4a;             /* Reserved */
-    u8  reserved4b;             /* Reserved */
-    u32 flags;
-} PACKED;
-
-struct acpi_table_header         /* ACPI common table header */
-{
-    ACPI_TABLE_HEADER_DEF
-} PACKED;
-
-/*
- * ACPI 1.0 Root System Description Table (RSDT)
- */
-#define RSDT_SIGNATURE 0x54445352 // RSDT
-struct rsdt_descriptor_rev1
-{
-    ACPI_TABLE_HEADER_DEF       /* ACPI common table header */
-    u32 table_offset_entry[0];  /* Array of pointers to other */
-    /* ACPI tables */
-} PACKED;
-
-/*
- * ACPI 1.0 Firmware ACPI Control Structure (FACS)
- */
-#define FACS_SIGNATURE 0x53434146 // FACS
-struct facs_descriptor_rev1
-{
-    u32 signature;           /* ACPI Signature */
-    u32 length;                 /* Length of structure, in bytes */
-    u32 hardware_signature;     /* Hardware configuration signature */
-    u32 firmware_waking_vector; /* ACPI OS waking vector */
-    u32 global_lock;            /* Global Lock */
-    u32 flags;
-    u8  resverved3 [40];        /* Reserved - must be zero */
-} PACKED;
-
-/*
- * Differentiated System Description Table (DSDT)
- */
-#define DSDT_SIGNATURE 0x54445344 // DSDT
-
-/*
- * MADT values and structures
- */
-
-/* Values for MADT PCATCompat */
-
-#define DUAL_PIC                0
-#define MULTIPLE_APIC           1
-
-/* Master MADT */
-
-#define APIC_SIGNATURE 0x43495041 // APIC
-struct multiple_apic_table
-{
-    ACPI_TABLE_HEADER_DEF     /* ACPI common table header */
-    u32 local_apic_address;     /* Physical address of local APIC */
-    u32 flags;
-} PACKED;
-
-/* Values for Type in APIC sub-headers */
-
-#define APIC_PROCESSOR          0
-#define APIC_IO                 1
-#define APIC_XRUPT_OVERRIDE     2
-#define APIC_NMI                3
-#define APIC_LOCAL_NMI          4
-#define APIC_ADDRESS_OVERRIDE   5
-#define APIC_IO_SAPIC           6
-#define APIC_LOCAL_SAPIC        7
-#define APIC_XRUPT_SOURCE       8
-#define APIC_RESERVED           9           /* 9 and greater are reserved */
-
-/*
- * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE)
- */
-#define ACPI_SUB_HEADER_DEF   /* Common ACPI sub-structure header */\
-    u8  type;                               \
-    u8  length;
-
-/* Sub-structures for MADT */
-
-struct madt_processor_apic
-{
-    ACPI_SUB_HEADER_DEF
-    u8  processor_id;           /* ACPI processor id */
-    u8  local_apic_id;          /* Processor's local APIC id */
-    u32 flags;
-} PACKED;
-
-struct madt_io_apic
-{
-    ACPI_SUB_HEADER_DEF
-    u8  io_apic_id;             /* I/O APIC ID */
-    u8  reserved;               /* Reserved - must be zero */
-    u32 address;                /* APIC physical address */
-    u32 interrupt;              /* Global system interrupt where INTI
-                                 * lines start */
-} PACKED;
-
-struct madt_intsrcovr {
-    ACPI_SUB_HEADER_DEF
-    u8  bus;
-    u8  source;
-    u32 gsi;
-    u16 flags;
-} PACKED;
-
-struct madt_local_nmi {
-    ACPI_SUB_HEADER_DEF
-    u8  processor_id;           /* ACPI processor id */
-    u16 flags;                  /* MPS INTI flags */
-    u8  lint;                   /* Local APIC LINT# */
-} PACKED;
-
-/*
- * HPET Description Table
- */
-#define HPET_SIGNATURE 0x54455048 // HPET
-struct acpi_20_hpet {
-    ACPI_TABLE_HEADER_DEF                    /* ACPI common table header */
-    u32           timer_block_id;
-    struct acpi_20_generic_address addr;
-    u8            hpet_number;
-    u16           min_tick;
-    u8            page_protect;
-} PACKED;
-
-/*
- * SRAT (NUMA topology description) table
- */
-
-#define SRAT_SIGNATURE 0x54415253 // SRAT
-struct system_resource_affinity_table
-{
-    ACPI_TABLE_HEADER_DEF
-    u32    reserved1;
-    u32    reserved2[2];
-} PACKED;
-
-#define SRAT_PROCESSOR          0
-#define SRAT_MEMORY             1
-
-struct srat_processor_affinity
-{
-    ACPI_SUB_HEADER_DEF
-    u8     proximity_lo;
-    u8     local_apic_id;
-    u32    flags;
-    u8     local_sapic_eid;
-    u8     proximity_hi[3];
-    u32    reserved;
-} PACKED;
-
-struct srat_memory_affinity
-{
-    ACPI_SUB_HEADER_DEF
-    u8     proximity[4];
-    u16    reserved1;
-    u64    base_addr;
-    u64    range_length;
-    u32    reserved2;
-    u32    flags;
-    u32    reserved3[2];
-} PACKED;
-
-/* PCI fw r3.0 MCFG table. */
-/* Subtable */
-struct acpi_mcfg_allocation {
-    u64 address;                /* Base address, processor-relative */
-    u16 pci_segment;            /* PCI segment group number */
-    u8 start_bus_number;       /* Starting PCI Bus number */
-    u8 end_bus_number;         /* Final PCI Bus number */
-    u32 reserved;
-} PACKED;
-
-#define MCFG_SIGNATURE 0x4746434d       // MCFG
-struct acpi_table_mcfg {
-    ACPI_TABLE_HEADER_DEF;
-    u8 reserved[8];
-    struct acpi_mcfg_allocation allocation[0];
-} PACKED;
-
-#endif // acpi.h
index fea7511e107b0fe5e021af6e46bf250bc856abbb..a3ee827fc7f854cead4cf6efbd6fa9eed00d3a28 100644 (file)
@@ -4,10 +4,10 @@
 //
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
-#include "acpi.h" // struct rsdp_descriptor
 #include "config.h" // CONFIG_*
 #include "malloc.h" // malloc_fseg
 #include "output.h" // dprintf
+#include "std/acpi.h" // struct rsdp_descriptor
 #include "std/mptable.h" // MPTABLE_SIGNATURE
 #include "std/pirtable.h" // struct pir_header
 #include "std/smbios.h" // struct smbios_entry_point
index 5daed866f981c0740b09b76f2b36285c55fa9360..e9874e249f1fce35bccbcb5c0884009982957e9f 100644 (file)
@@ -4,7 +4,6 @@
 //
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
-#include "acpi.h" // find_acpi_features
 #include "boot.h" // boot_add_cbfs
 #include "byteorder.h" // be32_to_cpu
 #include "config.h" // CONFIG_*
index eca97a7780d0a605c7e8d9aceeab5b28a13c17d4..dda6af4a749c2e17399ae7d4bc22b531e9587116 100644 (file)
@@ -4,7 +4,6 @@
 //
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
-#include "acpi.h"
 #include "biosvar.h"
 #include "boot.h"
 #include "bregs.h"
@@ -16,6 +15,7 @@
 #include "output.h" // dprintf
 #include "post.h"
 #include "stacks.h" // wait_threads
+#include "std/acpi.h" // RSDP_SIGNATURE
 #include "std/optionrom.h" // struct rom_header
 #include "util.h" // copy_smbios
 
index 573511c207d83e822d0fb8e661d6046ba3f43c0b..2524b7bfd1ca4c7f8b96b678f7eef67cfd315f2c 100644 (file)
@@ -8,7 +8,6 @@
 //
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
-#include "acpi.h" // acpi_setup
 #include "byteorder.h" // be32_to_cpu
 #include "config.h" // CONFIG_QEMU
 #include "hw/cmos.h" // CMOS_*
index 834847b70a041dee8573e2b530113ed98b69534d..b29db99d5d61f0f8406b2485b7ace3384b30642a 100644 (file)
@@ -5,7 +5,6 @@
 //
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
-#include "acpi.h" // acpi_pm1a_cnt
 #include "config.h" // CONFIG_*
 #include "dev-q35.h" // Q35_HOST_BRIDGE_PCIEXBAR_ADDR
 #include "hw/pci.h" // pci_config_readl
index 92527211e0142e7853114d9a51e437d53589c573..9b0003041d59808c787fa4c78d29d1502b7827b8 100644 (file)
@@ -4,7 +4,6 @@
 //
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
-#include "acpi.h" // find_acpi_features
 #include "config.h"
 #include "malloc.h" // memalign_high
 #include "memmap.h" // add_e820
index 31643a701ea9d188c6aa3451aa2ad981f69f33e8..96c63d5b4ffbc1a1c289fb01e45da6ece9fd61f9 100644 (file)
@@ -6,7 +6,6 @@
 
 #include "biosvar.h" // struct bios_data_area_s
 #include "bregs.h" // struct bregs
-#include "fw/acpi.h" // find_resume_vector
 #include "hw/cmos.h" // inb_cmos
 #include "hw/pci.h" // pci_reboot
 #include "hw/pic.h" // pic_eoi2
diff --git a/src/std/acpi.h b/src/std/acpi.h
new file mode 100644 (file)
index 0000000..fad6ac2
--- /dev/null
@@ -0,0 +1,272 @@
+#ifndef __ACPI_H
+#define __ACPI_H
+
+#include "types.h" // u32
+
+/*
+ * ACPI 2.0 Generic Address Space definition.
+ */
+struct acpi_20_generic_address {
+    u8  address_space_id;
+    u8  register_bit_width;
+    u8  register_bit_offset;
+    u8  reserved;
+    u64 address;
+} PACKED;
+
+#define RSDP_SIGNATURE 0x2052545020445352LL // "RSD PTR "
+
+struct rsdp_descriptor {        /* Root System Descriptor Pointer */
+    u64 signature;              /* ACPI signature, contains "RSD PTR " */
+    u8  checksum;               /* To make sum of struct == 0 */
+    u8  oem_id [6];             /* OEM identification */
+    u8  revision;               /* Must be 0 for 1.0, 2 for 2.0 */
+    u32 rsdt_physical_address;  /* 32-bit physical address of RSDT */
+    u32 length;                 /* XSDT Length in bytes including hdr */
+    u64 xsdt_physical_address;  /* 64-bit physical address of XSDT */
+    u8  extended_checksum;      /* Checksum of entire table */
+    u8  reserved [3];           /* Reserved field must be 0 */
+};
+
+/* Table structure from Linux kernel (the ACPI tables are under the
+   BSD license) */
+
+#define ACPI_TABLE_HEADER_DEF   /* ACPI common table header */ \
+    u32 signature;          /* ACPI signature (4 ASCII characters) */ \
+    u32 length;                 /* Length of table, in bytes, including header */ \
+    u8  revision;               /* ACPI Specification minor version # */ \
+    u8  checksum;               /* To make sum of entire table == 0 */ \
+    u8  oem_id [6];             /* OEM identification */ \
+    u8  oem_table_id [8];       /* OEM table identification */ \
+    u32 oem_revision;           /* OEM revision number */ \
+    u8  asl_compiler_id [4];    /* ASL compiler vendor ID */ \
+    u32 asl_compiler_revision;  /* ASL compiler revision number */
+
+
+/*
+ * ACPI 1.0 Fixed ACPI Description Table (FADT)
+ */
+#define FACP_SIGNATURE 0x50434146 // FACP
+struct fadt_descriptor_rev1
+{
+    ACPI_TABLE_HEADER_DEF     /* ACPI common table header */
+    u32 firmware_ctrl;          /* Physical address of FACS */
+    u32 dsdt;                   /* Physical address of DSDT */
+    u8  model;                  /* System Interrupt Model */
+    u8  reserved1;              /* Reserved */
+    u16 sci_int;                /* System vector of SCI interrupt */
+    u32 smi_cmd;                /* Port address of SMI command port */
+    u8  acpi_enable;            /* Value to write to smi_cmd to enable ACPI */
+    u8  acpi_disable;           /* Value to write to smi_cmd to disable ACPI */
+    u8  S4bios_req;             /* Value to write to SMI CMD to enter S4BIOS state */
+    u8  reserved2;              /* Reserved - must be zero */
+    u32 pm1a_evt_blk;           /* Port address of Power Mgt 1a acpi_event Reg Blk */
+    u32 pm1b_evt_blk;           /* Port address of Power Mgt 1b acpi_event Reg Blk */
+    u32 pm1a_cnt_blk;           /* Port address of Power Mgt 1a Control Reg Blk */
+    u32 pm1b_cnt_blk;           /* Port address of Power Mgt 1b Control Reg Blk */
+    u32 pm2_cnt_blk;            /* Port address of Power Mgt 2 Control Reg Blk */
+    u32 pm_tmr_blk;             /* Port address of Power Mgt Timer Ctrl Reg Blk */
+    u32 gpe0_blk;               /* Port addr of General Purpose acpi_event 0 Reg Blk */
+    u32 gpe1_blk;               /* Port addr of General Purpose acpi_event 1 Reg Blk */
+    u8  pm1_evt_len;            /* Byte length of ports at pm1_x_evt_blk */
+    u8  pm1_cnt_len;            /* Byte length of ports at pm1_x_cnt_blk */
+    u8  pm2_cnt_len;            /* Byte Length of ports at pm2_cnt_blk */
+    u8  pm_tmr_len;             /* Byte Length of ports at pm_tm_blk */
+    u8  gpe0_blk_len;           /* Byte Length of ports at gpe0_blk */
+    u8  gpe1_blk_len;           /* Byte Length of ports at gpe1_blk */
+    u8  gpe1_base;              /* Offset in gpe model where gpe1 events start */
+    u8  reserved3;              /* Reserved */
+    u16 plvl2_lat;              /* Worst case HW latency to enter/exit C2 state */
+    u16 plvl3_lat;              /* Worst case HW latency to enter/exit C3 state */
+    u16 flush_size;             /* Size of area read to flush caches */
+    u16 flush_stride;           /* Stride used in flushing caches */
+    u8  duty_offset;            /* Bit location of duty cycle field in p_cnt reg */
+    u8  duty_width;             /* Bit width of duty cycle field in p_cnt reg */
+    u8  day_alrm;               /* Index to day-of-month alarm in RTC CMOS RAM */
+    u8  mon_alrm;               /* Index to month-of-year alarm in RTC CMOS RAM */
+    u8  century;                /* Index to century in RTC CMOS RAM */
+    u8  reserved4;              /* Reserved */
+    u8  reserved4a;             /* Reserved */
+    u8  reserved4b;             /* Reserved */
+    u32 flags;
+} PACKED;
+
+struct acpi_table_header         /* ACPI common table header */
+{
+    ACPI_TABLE_HEADER_DEF
+} PACKED;
+
+/*
+ * ACPI 1.0 Root System Description Table (RSDT)
+ */
+#define RSDT_SIGNATURE 0x54445352 // RSDT
+struct rsdt_descriptor_rev1
+{
+    ACPI_TABLE_HEADER_DEF       /* ACPI common table header */
+    u32 table_offset_entry[0];  /* Array of pointers to other */
+    /* ACPI tables */
+} PACKED;
+
+/*
+ * ACPI 1.0 Firmware ACPI Control Structure (FACS)
+ */
+#define FACS_SIGNATURE 0x53434146 // FACS
+struct facs_descriptor_rev1
+{
+    u32 signature;           /* ACPI Signature */
+    u32 length;                 /* Length of structure, in bytes */
+    u32 hardware_signature;     /* Hardware configuration signature */
+    u32 firmware_waking_vector; /* ACPI OS waking vector */
+    u32 global_lock;            /* Global Lock */
+    u32 flags;
+    u8  resverved3 [40];        /* Reserved - must be zero */
+} PACKED;
+
+/*
+ * Differentiated System Description Table (DSDT)
+ */
+#define DSDT_SIGNATURE 0x54445344 // DSDT
+
+/*
+ * MADT values and structures
+ */
+
+/* Values for MADT PCATCompat */
+
+#define DUAL_PIC                0
+#define MULTIPLE_APIC           1
+
+/* Master MADT */
+
+#define APIC_SIGNATURE 0x43495041 // APIC
+struct multiple_apic_table
+{
+    ACPI_TABLE_HEADER_DEF     /* ACPI common table header */
+    u32 local_apic_address;     /* Physical address of local APIC */
+    u32 flags;
+} PACKED;
+
+/* Values for Type in APIC sub-headers */
+
+#define APIC_PROCESSOR          0
+#define APIC_IO                 1
+#define APIC_XRUPT_OVERRIDE     2
+#define APIC_NMI                3
+#define APIC_LOCAL_NMI          4
+#define APIC_ADDRESS_OVERRIDE   5
+#define APIC_IO_SAPIC           6
+#define APIC_LOCAL_SAPIC        7
+#define APIC_XRUPT_SOURCE       8
+#define APIC_RESERVED           9           /* 9 and greater are reserved */
+
+/*
+ * MADT sub-structures (Follow MULTIPLE_APIC_DESCRIPTION_TABLE)
+ */
+#define ACPI_SUB_HEADER_DEF   /* Common ACPI sub-structure header */\
+    u8  type;                               \
+    u8  length;
+
+/* Sub-structures for MADT */
+
+struct madt_processor_apic
+{
+    ACPI_SUB_HEADER_DEF
+    u8  processor_id;           /* ACPI processor id */
+    u8  local_apic_id;          /* Processor's local APIC id */
+    u32 flags;
+} PACKED;
+
+struct madt_io_apic
+{
+    ACPI_SUB_HEADER_DEF
+    u8  io_apic_id;             /* I/O APIC ID */
+    u8  reserved;               /* Reserved - must be zero */
+    u32 address;                /* APIC physical address */
+    u32 interrupt;              /* Global system interrupt where INTI
+                                 * lines start */
+} PACKED;
+
+struct madt_intsrcovr {
+    ACPI_SUB_HEADER_DEF
+    u8  bus;
+    u8  source;
+    u32 gsi;
+    u16 flags;
+} PACKED;
+
+struct madt_local_nmi {
+    ACPI_SUB_HEADER_DEF
+    u8  processor_id;           /* ACPI processor id */
+    u16 flags;                  /* MPS INTI flags */
+    u8  lint;                   /* Local APIC LINT# */
+} PACKED;
+
+/*
+ * HPET Description Table
+ */
+#define HPET_SIGNATURE 0x54455048 // HPET
+struct acpi_20_hpet {
+    ACPI_TABLE_HEADER_DEF                    /* ACPI common table header */
+    u32           timer_block_id;
+    struct acpi_20_generic_address addr;
+    u8            hpet_number;
+    u16           min_tick;
+    u8            page_protect;
+} PACKED;
+
+/*
+ * SRAT (NUMA topology description) table
+ */
+
+#define SRAT_SIGNATURE 0x54415253 // SRAT
+struct system_resource_affinity_table
+{
+    ACPI_TABLE_HEADER_DEF
+    u32    reserved1;
+    u32    reserved2[2];
+} PACKED;
+
+#define SRAT_PROCESSOR          0
+#define SRAT_MEMORY             1
+
+struct srat_processor_affinity
+{
+    ACPI_SUB_HEADER_DEF
+    u8     proximity_lo;
+    u8     local_apic_id;
+    u32    flags;
+    u8     local_sapic_eid;
+    u8     proximity_hi[3];
+    u32    reserved;
+} PACKED;
+
+struct srat_memory_affinity
+{
+    ACPI_SUB_HEADER_DEF
+    u8     proximity[4];
+    u16    reserved1;
+    u64    base_addr;
+    u64    range_length;
+    u32    reserved2;
+    u32    flags;
+    u32    reserved3[2];
+} PACKED;
+
+/* PCI fw r3.0 MCFG table. */
+/* Subtable */
+struct acpi_mcfg_allocation {
+    u64 address;                /* Base address, processor-relative */
+    u16 pci_segment;            /* PCI segment group number */
+    u8 start_bus_number;       /* Starting PCI Bus number */
+    u8 end_bus_number;         /* Final PCI Bus number */
+    u32 reserved;
+} PACKED;
+
+#define MCFG_SIGNATURE 0x4746434d       // MCFG
+struct acpi_table_mcfg {
+    ACPI_TABLE_HEADER_DEF;
+    u8 reserved[8];
+    struct acpi_mcfg_allocation allocation[0];
+} PACKED;
+
+#endif // acpi.h
index ab45ac67aaf6802eb00c0b6ee9a7c2f0ef1327c8..95be57f5870999ce1bfe8445b2a356e5f61e9110 100644 (file)
@@ -55,6 +55,16 @@ void callrom(struct rom_header *rom, u16 bdf);
 void handle_1ab1(struct bregs *regs);
 void bios32_init(void);
 
+// fw/acpi.c
+extern struct rsdp_descriptor *RsdpAddr;
+extern u32 acpi_pm1a_cnt;
+void acpi_setup(void);
+u32 find_resume_vector(void);
+void find_acpi_features(void);
+struct acpi_20_generic_address;
+void acpi_set_reset_reg(struct acpi_20_generic_address *reg, u8 val);
+void acpi_reboot(void);
+
 // fw/csm.c
 struct pci_device;
 int csm_bootprio_fdc(struct pci_device *pci, int port, int fdid);