[coreboot] Patch set updated for coreboot: 06dfbdf APIC: Add wait_apic() helper function
Sven Schnelle (svens@stackframe.org)
gerrit at coreboot.org
Wed Jun 27 09:45:51 CEST 2012
Sven Schnelle (svens at stackframe.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/1141
-gerrit
commit 06dfbdf601d75da62591219e41bbd4034d114e5d
Author: Sven Schnelle <svens at stackframe.org>
Date: Tue Jun 26 11:29:48 2012 +0200
APIC: Add wait_apic() helper function
Instead of duplicating the code for waiting on the apic, use a
single function.
Change-Id: Iaea5b499787c1393a43e93d4ec37237bdbcfca44
Signed-off-by: Sven Schnelle <svens at stackframe.org>
---
src/cpu/x86/lapic/lapic_cpu_init.c | 49 +++++++++++++----------------------
1 files changed, 18 insertions(+), 31 deletions(-)
diff --git a/src/cpu/x86/lapic/lapic_cpu_init.c b/src/cpu/x86/lapic/lapic_cpu_init.c
index 60cacd5..363dd29 100644
--- a/src/cpu/x86/lapic/lapic_cpu_init.c
+++ b/src/cpu/x86/lapic/lapic_cpu_init.c
@@ -68,10 +68,22 @@ static void copy_secondary_start_to_1m_below(void)
static struct bus *current_cpu_bus;
+static int wait_apic(int timeout)
+{
+ int send_status;
+
+ do {
+ printk(BIOS_SPEW, "+");
+ udelay(100);
+ send_status = lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY;
+ } while (send_status && --timeout);
+
+ return send_status;
+}
+
static int lapic_start_cpus(struct bus *cpu_bus)
{
- int timeout;
- unsigned long send_status, accept_status, start_eip;
+ unsigned long accept_status, start_eip;
int maxlvt;
/*
@@ -88,13 +100,7 @@ static int lapic_start_cpus(struct bus *cpu_bus)
| LAPIC_DM_INIT | LAPIC_DEST_ALLBUT);
printk(BIOS_DEBUG, "Waiting for send to finish...\n");
- timeout = 0;
- do {
- printk(BIOS_SPEW, "+");
- udelay(100);
- send_status = lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY;
- } while (send_status && (timeout++ < 1000));
- if (timeout >= 1000) {
+ if (wait_apic(1000)) {
printk(BIOS_DEBUG, "First apic write timed out. Disabling\n");
// too bad.
printk(BIOS_DEBUG, "ESR is 0x%lx\n", lapic_read(LAPIC_ESR));
@@ -135,13 +141,8 @@ static int lapic_start_cpus(struct bus *cpu_bus)
printk(BIOS_DEBUG, "Startup point 1.\n");
printk(BIOS_DEBUG, "Waiting for send to finish...\n");
- timeout = 0;
- do {
- printk(BIOS_DEBUG, "+");
- udelay(100);
- send_status = lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY;
- } while (send_status && (timeout++ < 1000));
-
+ if (wait_apic(1000))
+ return 1;
/*
* Give the other CPU some time to accept the IPI.
*/
@@ -156,12 +157,8 @@ static int lapic_start_cpus(struct bus *cpu_bus)
accept_status = (lapic_read(LAPIC_ESR) & 0xEF);
printk(BIOS_DEBUG, "After Startup.\n");
- if (send_status)
- printk(BIOS_WARNING, "APIC never delivered???\n");
if (accept_status)
printk(BIOS_WARNING, "APIC delivery error (%lx).\n", accept_status);
- if (send_status || accept_status)
- return 0;
return 1;
}
@@ -174,24 +171,14 @@ extern unsigned char _estack[];
static void stop_all_ap_cpus(void)
{
- unsigned long send_status;
- int timeout;
/* send an LAPIC INIT to all but myself */
lapic_write_around(LAPIC_ICR2, 0);
lapic_write_around(LAPIC_ICR, LAPIC_INT_ASSERT | LAPIC_DM_INIT | LAPIC_DEST_ALLBUT);
/* wait for the ipi send to finish */
printk(BIOS_SPEW, "Waiting for send to finish...\n");
- timeout = 0;
- do {
- printk(BIOS_SPEW, "+");
- udelay(100);
- send_status = lapic_read(LAPIC_ICR) & LAPIC_ICR_BUSY;
- } while (send_status && (timeout++ < 1000));
- if (timeout >= 1000) {
+ if (wait_apic(1000))
printk(BIOS_ERR, "timed out\n");
- }
- mdelay(10);
}
#ifdef __SSE3__
More information about the coreboot
mailing list