Furquan Shaikh has uploaded this change for review.

View Change

cpu: Add a helper function cpu_get_lapic_addr

This change adds a helper function cpu_get_lapic_addr() that returns
LOCAL_APIC_ADDR for x86. It also adds a weak default implementation
which returns 0 if platform does not support LAPIC. This is being
done in preparation to move all ACPI table support in coreboot out of
arch/x86.

BUG=b:155428745

Change-Id: I2ad0c47472eb4cc2bcd9fdd11ca49abf318a5444
Signed-off-by: Furquan Shaikh <furquan@google.com>
---
M src/arch/x86/acpi.c
M src/arch/x86/cpu.c
M src/include/cpu/cpu.h
3 files changed, 16 insertions(+), 2 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/40934/1
diff --git a/src/arch/x86/acpi.c b/src/arch/x86/acpi.c
index 5c15a5e..8e7b51d 100644
--- a/src/arch/x86/acpi.c
+++ b/src/arch/x86/acpi.c
@@ -22,7 +22,6 @@
#include <device/pci.h>
#include <cbmem.h>
#include <commonlib/helpers.h>
-#include <cpu/x86/lapic_def.h>
#include <cpu/cpu.h>
#include <cbfs.h>
#include <version.h>
@@ -222,6 +221,15 @@
return lapic_nmi->length;
}

+__weak uintptr_t cpu_get_lapic_addr(void)
+{
+ /*
+ * If an architecture does not support LAPIC, this weak implementation returns LAPIC
+ * addr as 0.
+ */
+ return 0;
+}
+
void acpi_create_madt(acpi_madt_t *madt)
{
acpi_header_t *header = &(madt->header);
@@ -242,7 +250,7 @@
header->length = sizeof(acpi_madt_t);
header->revision = get_acpi_table_revision(MADT);

- madt->lapic_addr = LOCAL_APIC_ADDR;
+ madt->lapic_addr = cpu_get_lapic_addr();
if (CONFIG(ACPI_HAVE_PCAT_8259))
madt->flags |= 1;

diff --git a/src/arch/x86/cpu.c b/src/arch/x86/cpu.c
index 1ee8fb3..b523768 100644
--- a/src/arch/x86/cpu.c
+++ b/src/arch/x86/cpu.c
@@ -354,3 +354,8 @@
}
return -1;
}
+
+uintptr_t cpu_get_lapic_addr(void)
+{
+ return LOCAL_APIC_ADDR;
+}
diff --git a/src/include/cpu/cpu.h b/src/include/cpu/cpu.h
index cdb6817..db324b6 100644
--- a/src/include/cpu/cpu.h
+++ b/src/include/cpu/cpu.h
@@ -6,6 +6,7 @@
void cpu_initialize(unsigned int cpu_index);
/* Returns default APIC id based on logical_cpu number or < 0 on failure. */
int cpu_get_apic_id(int logical_cpu);
+uintptr_t cpu_get_lapic_addr(void);
/* Function to keep track of cpu default apic_id */
void cpu_add_map_entry(unsigned int index);
struct bus;

To view, visit change 40934. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: master
Gerrit-Change-Id: I2ad0c47472eb4cc2bcd9fdd11ca49abf318a5444
Gerrit-Change-Number: 40934
Gerrit-PatchSet: 1
Gerrit-Owner: Furquan Shaikh <furquan@google.com>
Gerrit-MessageType: newchange