Author: stepan Date: 2007-11-03 13:50:26 +0100 (Sat, 03 Nov 2007) New Revision: 2936
Modified: trunk/LinuxBIOSv2/src/arch/i386/boot/acpi.c trunk/LinuxBIOSv2/src/arch/i386/include/arch/acpi.h Log: This patch adds support for MCFG table, which allows OS to find the MMCONFIG for memory mapped PCIe config.
However this patch is not enough to enable it on Linux, Linux do not trust BIOSes too much, so a small patch to kernel to disable the check if this region is e820 reserved.
PCI: BIOS Bug: MCFG area at e0000000 is not E820-reserved PCI: Not using MMCONFIG.
Signed-off-by: Rudolf Marek r.marek@assembler.cz Acked-by: Stefan Reinauer stepan@coresystems.de
Modified: trunk/LinuxBIOSv2/src/arch/i386/boot/acpi.c =================================================================== --- trunk/LinuxBIOSv2/src/arch/i386/boot/acpi.c 2007-11-02 23:27:12 UTC (rev 2935) +++ trunk/LinuxBIOSv2/src/arch/i386/boot/acpi.c 2007-11-03 12:50:26 UTC (rev 2936) @@ -65,7 +65,16 @@ printk_warning("ACPI: could not add ACPI table to RSDT. failed.\n"); }
+int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end) { + mmconfig->base_address = base; + mmconfig->base_reserved = 0; + mmconfig->pci_segment_group_number = seg_nr; + mmconfig->start_bus_number = start; + mmconfig->end_bus_number = end; + return (sizeof(acpi_mcfg_mmconfig_t)); +}
+ int acpi_create_madt_lapic(acpi_madt_lapic_t *lapic, u8 cpu, u8 apic) { lapic->type=0; @@ -146,6 +155,31 @@ header->checksum = acpi_checksum((void *)madt, header->length); }
+void acpi_create_mcfg(acpi_mcfg_t *mcfg) +{ + + acpi_header_t *header=&(mcfg->header); + unsigned long current=(unsigned long)mcfg+sizeof(acpi_mcfg_t); + + memset((void *)mcfg, 0, sizeof(acpi_mcfg_t)); + + /* fill out header fields */ + memcpy(header->signature, MCFG_NAME, 4); + memcpy(header->oem_id, OEM_ID, 6); + memcpy(header->oem_table_id, MCFG_TABLE, 8); + memcpy(header->asl_compiler_id, ASLC, 4); + + header->length = sizeof(acpi_mcfg_t); + header->revision = 1; + + current = acpi_fill_mcfg(current); + + /* recalculate length */ + header->length= current - (unsigned long)mcfg; + + header->checksum = acpi_checksum((void *)mcfg, header->length); +} + int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic) { lapic->type=0;
Modified: trunk/LinuxBIOSv2/src/arch/i386/include/arch/acpi.h =================================================================== --- trunk/LinuxBIOSv2/src/arch/i386/include/arch/acpi.h 2007-11-02 23:27:12 UTC (rev 2935) +++ trunk/LinuxBIOSv2/src/arch/i386/include/arch/acpi.h 2007-11-03 12:50:26 UTC (rev 2936) @@ -26,11 +26,13 @@ #define RSDT_NAME "RSDT" #define HPET_NAME "HPET" #define MADT_NAME "APIC" +#define MCFG_NAME "MCFG" #define SRAT_NAME "SRAT" #define SLIT_NAME "SLIT"
#define RSDT_TABLE "RSDT " #define HPET_TABLE "AMD64 " +#define MCFG_TABLE "MCFG " #define MADT_TABLE "MADT " #define SRAT_TABLE "SRAT " #define SLIT_TABLE "SLIT " @@ -81,7 +83,7 @@ /* RSDT */ typedef struct acpi_rsdt { struct acpi_table_header header; - u32 entry[6+ACPI_SSDTX_NUM+CONFIG_MAX_CPUS]; /* HPET, FADT, SRAT, SLIT, MADT(APIC), SSDT, SSDTX, and SSDT for CPU pstate*/ + u32 entry[7+ACPI_SSDTX_NUM+CONFIG_MAX_CPUS]; /* MCONFIG, HPET, FADT, SRAT, SLIT, MADT(APIC), SSDT, SSDTX, and SSDT for CPU pstate*/ } __attribute__ ((packed)) acpi_rsdt_t;
/* XSDT */ @@ -100,6 +102,22 @@ u8 attributes; } __attribute__ ((packed)) acpi_hpet_t;
+/* MCFG taken from include/linux/acpi.h */ +typedef struct acpi_mcfg { + struct acpi_table_header header; + u8 reserved[8]; +} __attribute__ ((packed)) acpi_mcfg_t; + +typedef struct acpi_mcfg_mmconfig { + u32 base_address; + u32 base_reserved; + u16 pci_segment_group_number; + u8 start_bus_number; + u8 end_bus_number; + u8 reserved[4]; +} __attribute__ ((packed)) acpi_mcfg_mmconfig_t; + + /* SRAT */ typedef struct acpi_srat { struct acpi_table_header header; @@ -273,6 +291,7 @@ /* These are implemented by the target port */ unsigned long write_acpi_tables(unsigned long addr); unsigned long acpi_fill_madt(unsigned long current); +unsigned long acpi_fill_mcfg(unsigned long current); unsigned long acpi_fill_srat(unsigned long current); void acpi_create_fadt(acpi_fadt_t *fadt,acpi_facs_t *facs,void *dsdt);
@@ -294,11 +313,14 @@
int acpi_create_srat_lapic(acpi_srat_lapic_t *lapic, u8 node, u8 apic); int acpi_create_srat_mem(acpi_srat_mem_t *mem, u8 node, u32 basek,u32 sizek, u32 flags); +int acpi_create_mcfg_mmconfig(acpi_mcfg_mmconfig_t *mmconfig, u32 base, u16 seg_nr, u8 start, u8 end); unsigned long acpi_create_srat_lapics(unsigned long current); void acpi_create_srat(acpi_srat_t *srat);
void acpi_create_hpet(acpi_hpet_t *hpet);
+void acpi_create_mcfg(acpi_mcfg_t *mcfg); + void acpi_create_facs(acpi_facs_t *facs);
void acpi_write_rsdt(acpi_rsdt_t *rsdt);