acpi.h

Go to the documentation of this file.
00001 /*
00002  * coreboot ACPI Support - headers and defines.
00003  * 
00004  * written by Stefan Reinauer <stepan@openbios.org>
00005  * (C) 2004 SUSE LINUX AG
00006  *
00007  * The ACPI table structs are based on the Linux kernel sources.
00008  * 
00009  */
00010 /* ACPI FADT & FACS added by Nick Barker <nick.barker9@btinternet.com>
00011  * those parts (C) 2004 Nick Barker
00012  */
00013 
00014 
00015 #ifndef __ASM_ACPI_H
00016 #define __ASM_ACPI_H
00017 
00018 #if HAVE_ACPI_TABLES==1
00019 
00020 #include <stdint.h>
00021 typedef unsigned long long u64;
00022 
00023 #define RSDP_SIG              "RSD PTR "  /* RSDT Pointer signature */
00024 #define RSDP_NAME             "RSDP"
00025 
00026 #define RSDT_NAME             "RSDT"
00027 #define HPET_NAME             "HPET"
00028 #define MADT_NAME             "APIC"
00029 #define MCFG_NAME             "MCFG"
00030 #define SRAT_NAME             "SRAT"
00031 #define SLIT_NAME             "SLIT"
00032 
00033 #define RSDT_TABLE            "RSDT    "
00034 #define HPET_TABLE            "AMD64   "
00035 #define MCFG_TABLE            "MCFG    "
00036 #define MADT_TABLE            "MADT    "
00037 #define SRAT_TABLE            "SRAT    "
00038 #define SLIT_TABLE            "SLIT    "
00039 
00040 #define OEM_ID                "CORE  "
00041 #define ASLC                  "CORE"
00042 
00043 /* ACPI 2.0 table RSDP */
00044 
00045 typedef struct acpi_rsdp {
00046         char  signature[8];     /* RSDP signature "RSD PTR" */
00047         u8    checksum;         /* checksum of the first 20 bytes */
00048         char  oem_id[6];        /* OEM ID, "LXBIOS" */
00049         u8    revision;         /* 0 for APCI 1.0, 2 for ACPI 2.0 */
00050         u32   rsdt_address;     /* physical address of RSDT */
00051         u32   length;           /* total length of RSDP (including extended part) */
00052         u64   xsdt_address;     /* physical address of XSDT */
00053         u8    ext_checksum;     /* chechsum of whole table */
00054         u8    reserved[3];
00055 } __attribute__((packed)) acpi_rsdp_t;
00056 
00057 /* Generic Address Container */
00058 
00059 typedef struct acpi_gen_regaddr {
00060         u8  space_id;
00061         u8  bit_width;
00062         u8  bit_offset;
00063         u8  resv;
00064         u32 addrl;
00065         u32 addrh;
00066 } __attribute__ ((packed)) acpi_addr_t;
00067 
00068 /* Generic ACPI Header, provided by (almost) all tables */
00069 
00070 typedef struct acpi_table_header         /* ACPI common table header */
00071 {
00072         char signature [4];          /* ACPI signature (4 ASCII characters) */\
00073         u32  length;                 /* Length of table, in bytes, including header */\
00074         u8   revision;               /* ACPI Specification minor version # */\
00075         u8   checksum;               /* To make sum of entire table == 0 */\
00076         char oem_id [6];             /* OEM identification */\
00077         char oem_table_id [8];       /* OEM table identification */\
00078         u32  oem_revision;           /* OEM revision number */\
00079         char asl_compiler_id [4];    /* ASL compiler vendor ID */\
00080         u32  asl_compiler_revision;  /* ASL compiler revision number */
00081 } __attribute__ ((packed)) acpi_header_t;
00082 
00083 /* RSDT */
00084 typedef struct acpi_rsdt {
00085         struct acpi_table_header header;
00086         u32 entry[7+ACPI_SSDTX_NUM+CONFIG_MAX_CPUS]; /* MCONFIG, HPET, FADT, SRAT, SLIT, MADT(APIC), SSDT, SSDTX, and SSDT for CPU pstate*/
00087 } __attribute__ ((packed)) acpi_rsdt_t;
00088 
00089 /* XSDT */
00090 typedef struct acpi_xsdt {
00091         struct acpi_table_header header;
00092         u64 entry[6+ACPI_SSDTX_NUM];
00093 } __attribute__ ((packed)) acpi_xsdt_t;
00094 
00095 /* HPET TIMERS */
00096 typedef struct acpi_hpet {
00097         struct acpi_table_header header;
00098         u32 id;
00099         struct acpi_gen_regaddr addr;
00100         u8 number;
00101         u16 min_tick;
00102         u8 attributes;
00103 } __attribute__ ((packed)) acpi_hpet_t;
00104 
00105 /* MCFG taken from include/linux/acpi.h */
00106 typedef struct acpi_mcfg {
00107         struct acpi_table_header header;
00108         u8 reserved[8];
00109 } __attribute__ ((packed)) acpi_mcfg_t;
00110 
00111 typedef struct acpi_mcfg_mmconfig {
00112         u32 base_address;
00113         u32 base_reserved;
00114         u16 pci_segment_group_number;
00115         u8 start_bus_number;
00116         u8 end_bus_number;
00117         u8 reserved[4];
00118 } __attribute__ ((packed)) acpi_mcfg_mmconfig_t;
00119 
00120 
00121 /* SRAT */
00122 typedef struct acpi_srat {
00123         struct acpi_table_header header;
00124         u32 resv;
00125         u64 resv1;
00126         /* followed by static resource allocation structure[n]*/
00127 } __attribute__ ((packed)) acpi_srat_t;
00128 
00129 
00130 typedef struct acpi_srat_lapic {
00131         u8 type;
00132         u8 length;
00133         u8 proximity_domain_7_0;
00134         u8 apic_id;
00135         u32 flags; /* enable bit 0  = 1, other bits reserved to 0 */
00136         u8 local_sapic_eid;
00137         u8 proximity_domain_31_8[3];
00138         u32 resv;
00139 } __attribute__ ((packed)) acpi_srat_lapic_t;
00140 
00141 typedef struct acpi_srat_mem {
00142         u8 type;
00143         u8 length;
00144         u32 proximity_domain;
00145         u16 resv;
00146         u32 base_address_low;
00147         u32 base_address_high;
00148         u32 length_low;
00149         u32 length_high;
00150         u32 resv1;
00151         u32 flags; /* enable bit 0,  hot pluggable bit 1; Non Volatile bit 2, other bits reserved */
00152         u32 resv2[2];
00153 } __attribute__ ((packed)) acpi_srat_mem_t;
00154 
00155 /* SLIT */
00156 typedef struct acpi_slit {
00157         struct acpi_table_header header;
00158         /* followed by static resource allocation 8+byte[num*num]*/
00159 } __attribute__ ((packed)) acpi_slit_t;
00160 
00161 
00162 /* MADT */
00163 typedef struct acpi_madt {
00164         struct acpi_table_header header;
00165         u32 lapic_addr;
00166         u32 flags;
00167 } __attribute__ ((packed)) acpi_madt_t;
00168 
00169 enum acpi_apic_types {
00170         LocalApic               = 0,
00171         IOApic                  = 1,
00172         IRQSourceOverride       = 2,
00173         NMI                     = 3,
00174         LocalApicNMI            = 4,
00175         LApicAddressOverride    = 5,
00176         IOSApic                 = 6,
00177         LocalSApic              = 7,
00178         PlatformIRQSources      = 8
00179 };
00180 
00181 typedef struct acpi_madt_lapic {
00182         u8 type;
00183         u8 length;
00184         u8 processor_id;
00185         u8 apic_id;
00186         u32 flags;
00187 } __attribute__ ((packed)) acpi_madt_lapic_t;
00188 
00189 typedef struct acpi_madt_lapic_nmi {
00190         u8 type;
00191         u8 length;
00192         u8 processor_id;
00193         u16 flags;
00194         u8 lint;
00195 } __attribute__ ((packed)) acpi_madt_lapic_nmi_t;
00196 
00197 
00198 typedef struct acpi_madt_ioapic {
00199         u8 type;
00200         u8 length;
00201         u8 ioapic_id;
00202         u8 reserved;
00203         u32 ioapic_addr;
00204         u32 gsi_base;
00205 } __attribute__ ((packed)) acpi_madt_ioapic_t;
00206 
00207 typedef struct acpi_madt_irqoverride {
00208         u8 type;
00209         u8 length;
00210         u8 bus;
00211         u8 source;
00212         u32 gsirq;
00213         u16 flags;
00214 } __attribute__ ((packed)) acpi_madt_irqoverride_t;
00215 
00216 /* FADT */
00217 
00218 typedef struct acpi_fadt {
00219         struct acpi_table_header header;
00220         u32 firmware_ctrl;
00221         u32 dsdt;
00222         u8 model;
00223         u8 preferred_pm_profile;
00224         u16 sci_int;
00225         u32 smi_cmd;
00226         u8 acpi_enable;
00227         u8 acpi_disable;
00228         u8 s4bios_req;
00229         u8 pstate_cnt;
00230         u32 pm1a_evt_blk;
00231         u32 pm1b_evt_blk;
00232         u32 pm1a_cnt_blk;
00233         u32 pm1b_cnt_blk;
00234         u32 pm2_cnt_blk;
00235         u32 pm_tmr_blk;
00236         u32 gpe0_blk;
00237         u32 gpe1_blk;
00238         u8 pm1_evt_len;
00239         u8 pm1_cnt_len;
00240         u8 pm2_cnt_len;
00241         u8 pm_tmr_len;
00242         u8 gpe0_blk_len;
00243         u8 gpe1_blk_len;
00244         u8 gpe1_base;
00245         u8 cst_cnt;
00246         u16 p_lvl2_lat;
00247         u16 p_lvl3_lat;
00248         u16 flush_size;
00249         u16 flush_stride;
00250         u8 duty_offset;
00251         u8 duty_width;
00252         u8 day_alrm;
00253         u8 mon_alrm;
00254         u8 century;
00255         u16 iapc_boot_arch;
00256         u8 res2;
00257         u32 flags;
00258         struct acpi_gen_regaddr reset_reg;
00259         u8 reset_value;
00260         u8 res3;
00261         u8 res4;
00262         u8 res5;
00263         u32 x_firmware_ctl_l;
00264         u32 x_firmware_ctl_h;
00265         u32 x_dsdt_l;
00266         u32 x_dsdt_h;
00267         struct acpi_gen_regaddr x_pm1a_evt_blk;
00268         struct acpi_gen_regaddr x_pm1b_evt_blk;
00269         struct acpi_gen_regaddr x_pm1a_cnt_blk;
00270         struct acpi_gen_regaddr x_pm1b_cnt_blk;
00271         struct acpi_gen_regaddr x_pm2_cnt_blk;
00272         struct acpi_gen_regaddr x_pm_tmr_blk;
00273         struct acpi_gen_regaddr x_gpe0_blk;
00274         struct acpi_gen_regaddr x_gpe1_blk;
00275 } __attribute__ ((packed)) acpi_fadt_t;
00276 
00277 /* FACS */
00278 typedef struct acpi_facs {
00279         char signature[4];
00280         u32 length;
00281         u32 hardware_signature;
00282         u32 firmware_waking_vector;
00283         u32 global_lock;
00284         u32 flags;
00285         u32 x_firmware_waking_vector_l;
00286         u32 x_firmware_waking_vector_h;
00287         u8 version;
00288         u8 resv[31];
00289 } __attribute__ ((packed)) acpi_facs_t;
00290 
00291 /* These are implemented by the target port */
00292 unsigned long write_acpi_tables(unsigned long addr);
00293 unsigned long acpi_fill_madt(unsigned long current);
00294 unsigned long acpi_fill_mcfg(unsigned long current);
00295 unsigned long acpi_fill_srat(unsigned long current); 
00296 void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs,void *dsdt);
00297 
00298 /* These can be used by the target port */
00299 u8 acpi_checksum(u8 *table, u32 length);
00300 
00301 void acpi_add_table(acpi_rsdt_t *rsdt, void *table);
00302 
00303 int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic);
00304 int acpi_create_madt_ioapic(acpi_madt_ioapic_t *ioapic, u8 id, u32 addr,u32 gsi_base);
00305 int acpi_create_madt_irqoverride(acpi_madt_irqoverride_t *irqoverride,
00306                 u8 bus, u8 source, u32 gsirq, u16 flags);
00307 int acpi_create_madt_lapic_nmi(acpi_madt_lapic_nmi_t *lapic_nmi, u8 cpu,
00308                 u16 flags, u8 lint);
00309 void acpi_create_madt(acpi_madt_t *madt);
00310 unsigned long acpi_create_madt_lapics(unsigned long current);
00311 unsigned long acpi_create_madt_lapic_nmis(unsigned long current, u16 flags, u8 lint);
00312 
00313 
00314 int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic);
00315 int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek,u32 sizek, u32 flags);
00316 int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end);
00317 unsigned long acpi_create_srat_lapics(unsigned long current);
00318 void acpi_create_srat(acpi_srat_t *srat);
00319 
00320 void acpi_create_slit(acpi_slit_t *slit);
00321 
00322 void acpi_create_hpet(acpi_hpet_t *hpet);
00323 
00324 void acpi_create_mcfg(acpi_mcfg_t *mcfg);
00325 
00326 void acpi_create_facs(acpi_facs_t *facs);
00327 
00328 void acpi_write_rsdt(acpi_rsdt_t *rsdt);
00329 void acpi_write_rsdp(acpi_rsdp_t *rsdp, acpi_rsdt_t *rsdt);
00330 
00331 #define ACPI_WRITE_MADT_IOAPIC(dev,id)                  \
00332 do {                                                    \
00333         struct resource *res;                           \
00334         res = find_resource(dev, PCI_BASE_ADDRESS_0);   \
00335         if (!res) break;                                \
00336         current += acpi_create_madt_ioapic(             \
00337                 (acpi_madt_ioapic_t *)current,          \
00338                 id, res->base, gsi_base);               \
00339         gsi_base+=4;                                    \
00340 } while(0);
00341 
00342 #define IO_APIC_ADDR    0xfec00000UL
00343 
00344 #else // HAVE_ACPI_TABLES
00345 
00346 #define write_acpi_tables(start) (start)
00347 
00348 #endif
00349 
00350 #endif

Generated on Mon Dec 29 10:54:06 2008 for coreboot by  doxygen 1.5.5