]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
plat/common/x86: Re-define ACPI structures
authorSergiu Moga <sergiu.moga@protonmail.com>
Mon, 24 Apr 2023 09:29:05 +0000 (12:29 +0300)
committerUnikraft <monkey@unikraft.io>
Fri, 11 Aug 2023 15:57:48 +0000 (15:57 +0000)
Redefine ACPI structures so that they comply with the coding style
and fix Local SAPIC's wrong definition, as the UID string has at
least 1 byte.

Furthermore, redefine `MADTTypeEntry` as a general System Descriptor
sub-Table, since it is used by almost all of them.

Signed-off-by: Sergiu Moga <sergiu.moga@protonmail.com>
Reviewed-by: Dragos Petre <dragos.petre27@gmail.com>
Reviewed-by: Marco Schlumpp <marco@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #911

plat/common/include/x86/acpi/acpi.h
plat/common/include/x86/acpi/madt.h
plat/common/include/x86/acpi/sdt.h
plat/common/x86/acpi.c
plat/common/x86/lcpu.c

index 8b4b696e0247e5c32cfa7c62fa28b27838402d1a..336b6091a4de7004ef8610191f0809d460819072 100644 (file)
@@ -1,8 +1,9 @@
 /* SPDX-License-Identifier: BSD-3-Clause */
 /*
  * Authors: Cristian Vijelie <cristianvijelie@gmail.com>
+ *          Sergiu Moga <sergiu.moga@protonmail.com>
  *
- * Copyright (c) 2021, University POLITEHNICA of Bucharest. All rights reserved.
+ * Copyright (c) 2023, University POLITEHNICA of Bucharest. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include <x86/acpi/sdt.h>
 #include <x86/acpi/madt.h>
 
-struct RSDPDescriptor {
-       char Signature[8];
-       __u8 Checksum;
-       char OEMID[6];
-       __u8 Revision;
-       __u32 RsdtAddress;
-} __packed;
-
-struct RSDPDescriptor20 {
-       struct RSDPDescriptor v1;
+#define RSDP_SIG               "RSD PTR "
+#define RSDP_SIG_LEN           8
 
-       __u32 Length;
-       __u64 XsdtAddress;
-       __u8 ExtendedChecksum;
-       __u8 Reserved[3];
+struct acpi_rsdp {
+       char sig[RSDP_SIG_LEN];
+       __u8 checksum;
+       char oem_id[ACPI_OEM_ID_LEN];
+       __u8 revision;
+       __u32 rsdt_paddr;
+       __u32 tab_len;
+       __u64 xsdt_paddr;
+       __u8 xchecksum;
+       __u8 reserved[3];
 } __packed;
 
 /**
- * Detect ACPI version and discover ACPI tables.
+ * Detect ACPI version and fetch ACPI tables.
  *
  * @return 0 on success, -errno otherwise.
  */
index 3a1b14b59709d4bfe4e712f95faade233f9ed69f..615d5d9694f6ea73b3717d952d4652f750398578 100644 (file)
@@ -1,8 +1,9 @@
 /* SPDX-License-Identifier: BSD-3-Clause */
 /*
  * Authors: Cristian Vijelie <cristianvijelie@gmail.com>
+ *          Sergiu Moga <sergiu.moga@protonmail.com>
  *
- * Copyright (c) 2021, University POLITEHNICA of Bucharest. All rights reserved.
+ * Copyright (c) 2023, University POLITEHNICA of Bucharest. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #ifndef __PLAT_CMN_X86_MADT_H__
 #define __PLAT_CMN_X86_MADT_H__
 
-#include <uk/arch/types.h>
 #include <x86/acpi/sdt.h>
-#include <uk/essentials.h>
 
-struct MADT {
-       struct ACPISDTHeader h;
-       __u32 LocalAPICAddress;
-       __u32 Flags;
-       __u8 Entries[];
-} __packed;
-
-#define MADT_FLAGS_PCAT_COMPAT                 0x01
-
-struct MADTEntryHeader {
-       __u8 Type;
-       __u8 Length;
-} __packed;
-
-#define MADT_TYPE_LAPIC                                0x00
-#define MADT_TYPE_IO_APIC                      0x01
-#define MADT_TYPE_INT_SRC_OVERRIDE             0x02
-#define MADT_TYPE_NMI_SOURCE                   0x03
-#define MADT_TYPE_LAPIC_NMI                    0x04
-#define MADT_TYPE_LAPIC_ADDRESS_OVERRIDE       0x05
-#define MADT_TYPE_IO_SAPIC                     0x06
-#define MADT_TYPE_LSAPIC                       0x07
-#define MADT_TYPE_PLATFORM_INT_SOURCES         0x08
-#define MADT_TYPE_LX2APIC                      0x09
-#define MADT_TYPE_LX2APIC_NMI                  0x0a
-#define MADT_TYPE_GICC                         0x0b
-#define MADT_TYPE_GICD                         0x0c
-#define MADT_TYPE_GIC_MSI                      0x0d
-#define MADT_TYPE_GICR                         0x0e
-#define MADT_TYPE_GIC_ITS                      0x0f
-#define MADT_TYPE_MP_WAKEUP                    0x10
+#define ACPI_MADT_SIG                                          "APIC"
+#define ACPI_MADT_FLAGS_PCAT_COMPAT                            0x0001
+struct acpi_madt {
+       struct acpi_sdt_hdr hdr;
+       __u32 lapic_paddr;
+       __u32 flags;
+       __u8 entries[];
+} __packed;
+
+#define ACPI_MADT_LAPIC                                                0x00
+#define ACPI_MADT_IO_APIC                                      0x01
+#define ACPI_MADT_IRQ_SRC_OVRD                                 0x02
+#define ACPI_MADT_NMI_SOURCE                                   0x03
+#define ACPI_MADT_LAPIC_NMI                                    0x04
+#define ACPI_MADT_LAPIC_ADDR_OVRD                              0x05
+#define ACPI_MADT_IO_SAPIC                                     0x06
+#define ACPI_MADT_LSAPIC                                       0x07
+#define ACPI_MADT_PLAT_IRQ_SRCS                                        0x08
+#define ACPI_MADT_LX2APIC                                      0x09
+#define ACPI_MADT_LX2APIC_NMI                                  0x0a
+#define ACPI_MADT_GICC                                         0x0b
+#define ACPI_MADT_GICD                                         0x0c
+#define ACPI_MADT_GIC_MSI                                      0x0d
+#define ACPI_MADT_GICR                                         0x0e
+#define ACPI_MADT_GIC_ITS                                      0x0f
+#define ACPI_MADT_MP_WKP                                       0x10
 
 /*
  * The following structures are declared according to the ACPI
@@ -79,176 +73,174 @@ struct MADTEntryHeader {
  */
 
 /* Processor Local APIC Structure */
-struct MADTType0Entry {
-       struct MADTEntryHeader eh;
-       __u8 ACPIProcessorUID;
-       __u8 APICID;
-       __u32 Flags;
+#define ACPI_MADT_LAPIC_FLAGS_EN                               0x01
+#define ACPI_MADT_LAPIC_FLAGS_ON_CAP                           0x02
+struct acpi_madt_lapic {
+       struct acpi_subsdt_hdr hdr;
+       __u8 cpu_id;
+       __u8 lapic_id;
+       __u32 flags;
 } __packed;
 
-#define MADT_T0_FLAGS_ENABLED                  0x01
-#define MADT_T0_FLAGS_ONLINE_CAPABLE           0x02
-
 /* I/O APIC Structure */
-struct MADTType1Entry {
-       struct MADTEntryHeader eh;
-       __u8 IOAPICID;
-       __u8 Reserved;
-       __u32 IOAPICAddress;
-       __u32 GlobalSystemInterruptBase;
+struct acpi_madt_ioapic {
+       struct acpi_subsdt_hdr hdr;
+       __u8 ioapic_id;
+       __u8 reserved;
+       __u32 ioapic_paddr;
+       __u32 gsi_base;
 } __packed;
 
 /* Interrupt Source Override Structure */
-struct MADTType2Entry {
-       struct MADTEntryHeader eh;
-       __u8 BusSource;
-       __u8 IRQSource;
-       __u32 GlobalSystemInterrupt;
-       __u16 Flags;
+struct acpi_madt_irq_src_ovrd {
+       struct acpi_subsdt_hdr hdr;
+       __u8 bus;
+       __u8 src_irq;
+       __u32 gsi;
+       __u16 flags;
 } __packed;
 
 /* Non-Maskable Interrupt (NMI) Source Structure */
-struct MADTType3Entry {
-       struct MADTEntryHeader eh;
-       __u16 Flags;
-       __u32 GlobalSystemInterrupt;
+struct acpi_madt_nmi_src {
+       struct acpi_subsdt_hdr hdr;
+       __u16 flags;
+       __u32 gsi;
 } __packed;
 
 /* Local APIC NMI Structure */
-struct MADTType4Entry {
-       struct MADTEntryHeader eh;
-       __u8 ACPIProcessorID;
-       __u16 Flags;
-       __u8 LINT;
+struct acpi_madt_lapic_nmi {
+       struct acpi_subsdt_hdr hdr;
+       __u8 cpu_id;
+       __u16 flags;
+       __u8 lint;
 } __packed;
 
 /* Local APIC Address Override Structure */
-struct MADTType5Entry {
-       struct MADTEntryHeader eh;
-       __u16 Reserved;
-       __u64 LAPICOverride;
+struct acpi_madt_lapic_addr_ovrd {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u64 lapic_paddr;
 } __packed;
 
 /* I/O SAPIC Structure */
-struct MADTType6Entry {
-       struct MADTEntryHeader eh;
-       __u8 IOAPICID;
-       __u8 Reserved;
-       __u32 GlobalSystemInterruptBase;
-       __u64 IOSAPICAddress;
+struct acpi_madt_iosapic {
+       struct acpi_subsdt_hdr hdr;
+       __u8 iosapic_id;
+       __u8 reserved;
+       __u32 gsi_base;
+       __u64 iosapic_paddr;
 } __packed;
 
 /* Local SAPIC Structure */
-struct MADTType7Entry {
-       struct MADTEntryHeader eh;
-       __u8 ACPIProcessorID;
-       __u8 LocalSAPICID;
-       __u8 LocalSAPICEID;
-       __u8 Reserved[3];
-       __u32 Flags;
-       __u32 ACPIProcessorUIDValue;
-       __u32 ACPIProcessorUIDString[];
+struct acpi_madt_lsapic {
+       struct acpi_subsdt_hdr hdr;
+       __u8 cpu_id;
+       __u8 lsapic_id;
+       __u8 lsapic_eid;
+       __u8 reserved[3];
+       __u32 flags;
+       __u32 uid;
+       char uid_string[1];
 } __packed;
 
 /* Platform Interrupt Source Structure */
-struct MADTType8Entry {
-       struct MADTEntryHeader eh;
-       __u16 Flags;
-       __u8 InterruptType;
-       __u8 ProcessorID;
-       __u8 ProcessorEID;
-       __u8 IOSAPICVector;
-       __u32 GlobalSystemInterrupt;
-       __u32 PlatformInterruptSourceFlags;
+struct acpi_madt_irq_src {
+       struct acpi_subsdt_hdr hdr;
+       __u16 mps_inti_flags;
+       __u8 irq_type;
+       __u8 cpu_id;
+       __u8 cpu_eid;
+       __u8 io_sapic_vector;
+       __u32 gsi;
+       __u32 flags;
 } __packed;
 
 /* Processor Local x2APIC Structure */
-struct MADTType9Entry {
-       struct MADTEntryHeader eh;
-       __u16 Reserved;
-       __u32 X2APICID;
-       __u32 Flags;
-       __u32 ACPIProcessorUID;
+#define ACPI_MADT_X2APIC_FLAGS_EN                              0x01
+#define ACPI_MADT_X2APIC_FLAGS_ON_CAP                          0x02
+struct acpi_madt_x2apic {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u32 lapic_id;
+       __u32 flags;
+       __u32 uid;
 } __packed;
 
-#define MADT_T9_FLAGS_ENABLED                  0x01
-#define MADT_T9_FLAGS_ONLINE_CAPABLE           0x02
-
 /* Local x2APIC NMI Structure */
-struct MADTTypeAEntry {
-       struct MADTEntryHeader eh;
-       __u16 Flags;
-       __u32 ACPIProcessorUID;
-       __u8 Localx2APICLINTNr;
-       __u8 Reserved[3];
+struct acpi_madt_x2apic_nmi {
+       struct acpi_subsdt_hdr hdr;
+       __u16 mps_inti_flags;
+       __u32 uid;
+       __u8 lint;
+       __u8 reserved[3];
 } __packed;
 
 /* GIC CPU Interface (GICC) Structure */
-struct MADTTypeBEntry {
-       struct MADTEntryHeader eh;
-       __u16 Reserved;
-       __u32 CPUInterfaceNumber;
-       __u32 ACPIProcessorUID;
-       __u32 Flags;
-       __u32 ParkingProtocolVersion;
-       __u32 PerformanceInterruptGSIV;
-       __u64 ParkedAddress;
-       __u64 PhysicalBaseAddress;
-       __u64 GICV;
-       __u64 GICH;
-       __u32 VGICMaintenanceInterrupt;
-       __u64 GICRBaseAddress;
-       __u64 MPIDR;
-       __u8 ProcessorPowerEfficiencyClass;
-       __u8 Reserved2;
-       __u16 SPEOverflowInterrupt;
+struct acpi_madt_gicc {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u32 cpu_if;
+       __u32 uid;
+       __u32 flags;
+       __u32 parking_version;
+       __u32 perf_mon_gsiv;
+       __u64 parked_paddr;
+       __u64 paddr;
+       __u64 gicv;
+       __u64 gich;
+       __u32 vgic_maintenance_gsiv;
+       __u64 gicr_paddr;
+       __u64 mpidr;
+       __u8 power_efficiency;
+       __u8 reserved2;
+       __u16 spe_gsiv;
 } __packed;
 
 /* GIC Distributor (GICD) Structure */
-struct MADTTypeCEntry {
-       struct MADTEntryHeader eh;
-       __u16 Reserved;
-       __u32 GICID;
-       __u64 PhysicalBaseAddress;
-       __u32 SystemVectorBase;
-       __u8 GICVersion;
-       __u8 Reserved2[3];
+struct acpi_madt_gicd {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u32 gic_id;
+       __u64 paddr;
+       __u32 gsi_base;
+       __u8 version;
+       __u8 reserved2[3];
 } __packed;
 
 /* GIC MSI Frame Structure */
-struct MADTTypeDEntry {
-       struct MADTEntryHeader eh;
-       __u16 Reserved;
-       __u32 GICMSIFrameID;
-       __u64 PhysicalBaseAddress;
-       __u32 Flags;
-       __u16 SPICount;
-       __u16 SPIBase;
+struct acpi_madt_gic_msi_frame {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u32 msi_frame_id;
+       __u64 paddr;
+       __u32 flags;
+       __u16 spi_count;
+       __u16 spi_base;
 } __packed;
 
 /* GIC Redistributor (GICR) Structure */
-struct MADTTypeEEntry {
-       struct MADTEntryHeader eh;
-       __u16 Reserved;
-       __u64 DiscoveryRangeBaseAddress;
-       __u64 DiscoveryRangeLength;
+struct acpi_madt_gicr {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u64 paddr;
+       __u32 len;
 } __packed;
 
 /* GIC Interrupt Translation Service (ITS) Structure */
-struct MADTTypeFEntry {
-       struct MADTEntryHeader eh;
-       __u16 Reserved;
-       __u32 GICITSID;
-       __u64 PhysicalBaseAddress;
-       __u32 Reserved2;
+struct acpi_madt_gic_its {
+       struct acpi_subsdt_hdr hdr;
+       __u16 reserved;
+       __u32 id;
+       __u64 paddr;
+       __u32 reserved2;
 } __packed;
 
 /* Multiprocessor Wakeup Structure */
-struct MADTType10Entry {
-       struct MADTEntryHeader eh;
-       __u16 MailBoxVersion;
-       __u32 Reserved;
-       __u64 MailBoxAddress;
+struct acpi_madt_mp_wkp_src {
+       struct acpi_subsdt_hdr hdr;
+       __u16 mbox_version;
+       __u32 reserved;
+       __u64 mbox_paddr;
 } __packed;
 
 /**
@@ -257,6 +249,6 @@ struct MADTType10Entry {
  *
  * @return Pointer to MADT.
  */
-struct MADT *acpi_get_madt(void);
+struct acpi_madt *acpi_get_madt(void);
 
 #endif /* __PLAT_CMN_X86_MADT_H__ */
index 4e322423e664505d10160996f0e4d4dbb82cc039..d738fb0418205d7ed89efe233d71098ef6b543a9 100644 (file)
@@ -1,8 +1,9 @@
 /* SPDX-License-Identifier: BSD-3-Clause */
 /*
  * Authors: Cristian Vijelie <cristianvijelie@gmail.com>
+ *          Sergiu Moga <sergiu.moga@protonmail.com>
  *
- * Copyright (c) 2021, University POLITEHNICA of Bucharest. All rights reserved.
+ * Copyright (c) 2023, University POLITEHNICA of Bucharest. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include <uk/arch/types.h>
 #include <uk/essentials.h>
 
-struct ACPISDTHeader {
-       char Signature[4];
-       __u32 Length;
-       __u8 Revision;
-       __u8 Checksum;
-       char OEMID[6];
-       char OEMTableID[8];
-       __u32 OEMRevision;
-       __u32 CreatorID;
-       __u32 CreatorRevision;
+#define ACPI_OEM_ID_LEN                                        6
+#define ACPI_OEM_TAB_ID_LEN                            8
+#define ACPI_SDT_SIG_LEN                               4
+#define ACPI_SDT_CREATOR_ID_LEN                                4
+
+struct acpi_sdt_hdr {
+       char sig[ACPI_SDT_SIG_LEN];
+       __u32 tab_len;
+       __u8 revision;
+       __u8 checksum;
+       char oem_id[ACPI_OEM_ID_LEN];
+       char oem_table_id[ACPI_OEM_TAB_ID_LEN];
+       __u32 oem_revision;
+       char creator_id[ACPI_SDT_CREATOR_ID_LEN];
+       __u32 creator_revision;
+} __packed;
+
+struct acpi_subsdt_hdr {
+       __u8 type;
+       __u8 len;
 } __packed;
 
-struct RSDT {
-       struct ACPISDTHeader h;
-       __u32 Entry[];
+#define ACPI_RSDT_SIG                                  "RSDT"
+struct acpi_rsdt {
+       struct acpi_sdt_hdr hdr;
+       __u32 entry[];
 } __packed;
 
-struct XSDT {
-       struct ACPISDTHeader h;
-       __u64 Entry[];
+#define ACPI_XSDT_SIG                                  "XSDT"
+struct acpi_xsdt {
+       struct acpi_sdt_hdr hdr;
+       __u64 entry[];
 } __packed;
 
 #endif /* __PLAT_CMN_X86_SDT_H__ */
index 7d8079e11a3f013c5a17445c56066c158228dea9..8f1c0a223ca3614ef51b6a12d2cf42967fda4fb6 100644 (file)
 #include <uk/print.h>
 #include <uk/assert.h>
 #include <x86/acpi/acpi.h>
-#include <x86/acpi/madt.h>
 
 #include <string.h>
 #include <errno.h>
 
-#define RSDT_ENTRIES(rsdt) (((rsdt)->h.Length - sizeof((rsdt)->h)) / 4)
+#define RSDT_ENTRIES(rsdt) (((rsdt)->hdr.tab_len - sizeof((rsdt)->hdr)) / 4)
 
 static __u8 acpi_version;
-static struct RSDPDescriptor *acpi_rsdp;
-static struct RSDT *acpi_rsdt;
-static struct MADT *acpi_madt;
+static struct acpi_rsdp *acpi_rsdp;
+static struct acpi_rsdt *acpi_rsdt;
+static struct acpi_madt *acpi_madt;
 
 /*
  * Compute checksum for ACPI RSDP table.
  */
 
-static inline int verify_rsdp_checksum(struct RSDPDescriptor *rsdp)
+static inline int verify_rsdp_checksum(struct acpi_rsdp *rsdp)
 {
        __u8 checksum = 0;
        __u8 *ptr = (__u8 *)rsdp;
@@ -65,12 +64,12 @@ static inline int verify_rsdp_checksum(struct RSDPDescriptor *rsdp)
  * Compute checksum for any ACPI table, except RSDP.
  */
 
-static inline int verify_acpi_checksum(struct ACPISDTHeader *h)
+static inline int verify_acpi_checksum(struct acpi_sdt_hdr *h)
 {
        __u8 checksum = 0;
        __u32 i;
 
-       for (i = 0; i < h->Length; i++)
+       for (i = 0; i < h->tab_len; i++)
                checksum += ((__u8 *)h)[i];
 
        return checksum == 0 ? 0 : -1;
@@ -95,7 +94,7 @@ static int detect_acpi_version(void)
 
        for (ptr = start_addr; ptr < end_addr; ptr += 16) {
                if (!memcmp(ptr, "RSD PTR ", 8)) {
-                       acpi_rsdp = (struct RSDPDescriptor *)ptr;
+                       acpi_rsdp = (struct acpi_rsdp *)ptr;
                        uk_pr_debug("ACPI RSDP present at %p\n", ptr);
                        break;
                }
@@ -114,7 +113,7 @@ static int detect_acpi_version(void)
        }
 
        uk_pr_info("ACPI version detected: ");
-       if (acpi_rsdp->Revision == 0) {
+       if (acpi_rsdp->revision == 0) {
                uk_pr_info("1.0\n");
 
                acpi_version = 1;
@@ -141,10 +140,10 @@ static int acpi10_find_rsdt(void)
        UK_ASSERT(acpi_version == 1);
        UK_ASSERT(acpi_rsdp);
 
-       acpi_rsdt = (struct RSDT *)((__uptr)acpi_rsdp->RsdtAddress);
+       acpi_rsdt = (struct acpi_rsdt *)((__uptr)acpi_rsdp->rsdt_paddr);
        uk_pr_debug("ACPI RSDT present at %p\n", acpi_rsdt);
 
-       if (unlikely(verify_acpi_checksum(&acpi_rsdt->h) != 0)) {
+       if (unlikely(verify_acpi_checksum(&acpi_rsdt->hdr) != 0)) {
                uk_pr_err("ACPI RSDT corrupted\n");
 
                acpi_rsdt = NULL;
@@ -163,7 +162,7 @@ static int acpi10_find_rsdt(void)
 static int acpi10_find_madt(void)
 {
        int entries, i;
-       struct ACPISDTHeader *h;
+       struct acpi_sdt_hdr *h;
 
        UK_ASSERT(acpi_version == 1);
        UK_ASSERT(acpi_rsdt);
@@ -172,9 +171,9 @@ static int acpi10_find_madt(void)
        entries = RSDT_ENTRIES(acpi_rsdt);
 
        for (i = 0; i < entries; i++) {
-               h = (struct ACPISDTHeader *)((__uptr)acpi_rsdt->Entry[i]);
+               h = (struct acpi_sdt_hdr *)((__uptr)acpi_rsdt->entry[i]);
 
-               if (memcmp(h->Signature, "APIC", 4) != 0)
+               if (memcmp(h->sig, "APIC", 4) != 0)
                        continue; /* Not an APIC entry */
 
                uk_pr_debug("ACPI MADT present at %p\n", h);
@@ -184,7 +183,7 @@ static int acpi10_find_madt(void)
                        return -ENOENT;
                }
 
-               acpi_madt = (struct MADT *)h;
+               acpi_madt = (struct acpi_madt *)h;
                return 0;
        }
 
@@ -200,7 +199,7 @@ static int acpi10_find_madt(void)
 static void acpi10_list_tables(void)
 {
        int entries, i;
-       struct ACPISDTHeader *h;
+       struct acpi_sdt_hdr *h;
 
        UK_ASSERT(acpi_version == 1);
        UK_ASSERT(acpi_rsdt);
@@ -210,8 +209,8 @@ static void acpi10_list_tables(void)
        uk_pr_debug("%d ACPI tables found\n", entries);
 
        for (i = 0; i < entries; i++) {
-               h = (struct ACPISDTHeader *)((__uptr)acpi_rsdt->Entry[i]);
-               uk_pr_debug("%p: %.4s\n", h, h->Signature);
+               h = (struct acpi_sdt_hdr *)((__uptr)acpi_rsdt->entry[i]);
+               uk_pr_debug("%p: %.4s\n", h, h->sig);
        }
 }
 #endif /* UK_DEBUG */
@@ -281,7 +280,7 @@ int acpi_get_version(void)
  * Return the Multiple APIC Descriptor Table (MADT).
  */
 
-struct MADT *acpi_get_madt(void)
+struct acpi_madt *acpi_get_madt(void)
 {
        UK_ASSERT(acpi_version);
        UK_ASSERT(acpi_madt);
index 574b20d08143a3830453dd923c823bb9270033cf..f2f921b5e0f66079636c5df6c11accad0e69315f 100644 (file)
@@ -150,44 +150,43 @@ static void uk_reloc_mp_init(void) { }
 
 int lcpu_arch_mp_init(void *arg __unused)
 {
-       struct MADT *madt;
+       __lcpuid bsp_cpu_id = lcpu_get(0)->id;
        union {
-               struct MADTEntryHeader *h;
-               struct MADTType0Entry *e0;
-               struct MADTType9Entry *e9;
+               struct acpi_madt_x2apic *x2apic;
+               struct acpi_madt_lapic *lapic;
+               struct acpi_subsdt_hdr *h;
        } m;
-       __sz off, len;
+       int bsp_found __maybe_unused = 0;
+       struct acpi_madt *madt;
        struct lcpu *lcpu;
        __lcpuid cpu_id;
-       __lcpuid bsp_cpu_id = lcpu_get(0)->id;
-       int bsp_found __maybe_unused = 0;
+       __sz off, len;
 
-       uk_pr_info("Bootstrapping processor has the ID %ld\n",
-                  bsp_cpu_id);
+       uk_pr_info("Bootstrapping processor has the ID %ld\n", bsp_cpu_id);
 
        /* Enumerate all other CPUs */
        madt = acpi_get_madt();
        UK_ASSERT(madt);
 
-       len = madt->h.Length - sizeof(struct MADT);
-       for (off = 0; off < len; off += m.h->Length) {
-               m.h = (struct MADTEntryHeader *)(madt->Entries + off);
+       len = madt->hdr.tab_len - sizeof(*madt);
+       for (off = 0; off < len; off += m.h->len) {
+               m.h = (struct acpi_subsdt_hdr *)(madt->entries + off);
 
-               switch (m.h->Type) {
-               case MADT_TYPE_LAPIC:
-                       if (!(m.e0->Flags & MADT_T0_FLAGS_ENABLED) &&
-                           !(m.e0->Flags & MADT_T0_FLAGS_ONLINE_CAPABLE))
+               switch (m.h->type) {
+               case ACPI_MADT_LAPIC:
+                       if (!(m.lapic->flags & ACPI_MADT_LAPIC_FLAGS_EN) &&
+                           !(m.lapic->flags & ACPI_MADT_LAPIC_FLAGS_ON_CAP))
                                continue; /* goto next MADT entry */
 
-                       cpu_id = m.e0->APICID;
+                       cpu_id = m.lapic->lapic_id;
                        break;
 
-               case MADT_TYPE_LX2APIC:
-                       if (!(m.e9->Flags & MADT_T9_FLAGS_ENABLED) &&
-                           !(m.e9->Flags & MADT_T9_FLAGS_ONLINE_CAPABLE))
+               case ACPI_MADT_LX2APIC:
+                       if (!(m.x2apic->flags & ACPI_MADT_X2APIC_FLAGS_EN) &&
+                           !(m.x2apic->flags & ACPI_MADT_X2APIC_FLAGS_ON_CAP))
                                continue; /* goto next MADT entry */
 
-                       cpu_id = m.e9->X2APICID;
+                       cpu_id = m.x2apic->lapic_id;
                        break;
 
                default:
@@ -215,8 +214,7 @@ int lcpu_arch_mp_init(void *arg __unused)
 
        /* Copy AP startup code to target address in first 1MiB */
        UK_ASSERT(x86_start16_addr < 0x100000);
-       memcpy((void *)x86_start16_addr, &x86_start16_begin,
-              X86_START16_SIZE);
+       memcpy((void *)x86_start16_addr, &x86_start16_begin, X86_START16_SIZE);
 
        uk_reloc_mp_init();