Skip to content

Commit ca65e8c

Browse files
jsun26intelwenlingz
authored andcommitted
HV: refine APIC base address to platform acpi info
The base address of LAPIC and IOAPIC should be parsed from MADT table, so move the definition to platform_acpi_info.h. Tracked-On: #1500 Signed-off-by: Victor Sun <victor.sun@intel.com> Reviewed-by: Junjie Mao <junjie.mao@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
1 parent 8f701b0 commit ca65e8c

File tree

5 files changed

+15
-20
lines changed

5 files changed

+15
-20
lines changed

hypervisor/arch/x86/ioapic.c

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -122,24 +122,17 @@ ioapic_write_reg32(const void *ioapic_base,
122122
spinlock_irqrestore_release(&ioapic_lock, rflags);
123123
}
124124

125+
/**
126+
* @pre apic_id < 2
127+
*/
125128
static inline uint64_t
126129
get_ioapic_base(uint8_t apic_id)
127130
{
128-
uint64_t addr = 0xffffffffffffffffUL;
129-
130-
/* should extract next ioapic from ACPI MADT table */
131-
if (apic_id == 0U) {
132-
addr = DEFAULT_IO_APIC_BASE;
133-
} else if (apic_id == 1U) {
134-
addr = 0xfec3f000UL;
135-
} else if (apic_id == 2U) {
136-
addr = 0xfec7f000UL;
137-
} else {
138-
ASSERT(apic_id <= 2U, "ACPI MADT table missing");
139-
}
140-
return addr;
141-
}
131+
const uint64_t addr[2] = {IOAPIC0_BASE, IOAPIC1_BASE};
142132

133+
/* the ioapic base should be extracted from ACPI MADT table */
134+
return addr[apic_id];
135+
}
143136

144137
static inline void
145138
ioapic_get_rte_entry(void *ioapic_addr,

hypervisor/bsp/include/sbl/platform_acpi_info.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313
#define ACPI_INFO_VALIDATED
1414

1515
/* APIC */
16+
#define LAPIC_BASE 0xFEE00000UL
17+
1618
#define NR_IOAPICS 1U
19+
#define IOAPIC0_BASE 0xFEC00000UL
20+
#define IOAPIC1_BASE 0UL
1721

1822
/* pm sstate data */
1923
#define PM1A_EVT_SPACE_ID SPACE_SYSTEM_IO

hypervisor/bsp/include/uefi/platform_acpi_info.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111
#define PLATFORM_ACPI_INFO_H
1212

1313
/* APIC */
14+
#define LAPIC_BASE 0xFEE00000UL
15+
1416
#define NR_IOAPICS 1U
17+
#define IOAPIC0_BASE 0xFEC00000UL
18+
#define IOAPIC1_BASE 0UL
1519

1620
/* pm sstate data */
1721
#define PM1A_EVT_SPACE_ID SPACE_SYSTEM_IO

hypervisor/include/arch/x86/apicreg.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,9 +350,6 @@ union ioapic_rte {
350350
* I/O APIC defines
351351
*/
352352

353-
/* default physical locations of an IO APIC */
354-
#define DEFAULT_IO_APIC_BASE 0xfec00000UL
355-
356353
/* window register offset */
357354
#define IOAPIC_REGSEL 0x00U
358355
#define IOAPIC_WINDOW 0x10U

hypervisor/include/arch/x86/lapic.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
#define INTR_LAPIC_ICR_ALL_INC_SELF 0x2U
3434
#define INTR_LAPIC_ICR_ALL_EX_SELF 0x3U
3535

36-
/* Default LAPIC base */
37-
#define LAPIC_BASE 0xFEE00000U
38-
3936
/* LAPIC register bit and bitmask definitions */
4037
#define LAPIC_SVR_VECTOR 0x000000FFU
4138
#define LAPIC_SVR_APIC_ENABLE_MASK 0x00000100U

0 commit comments

Comments
 (0)