svn commit: r215047 - in stable/8/sys: amd64/amd64 conf i386/i386
x86/x86
Alexander Motin
mav at FreeBSD.org
Tue Nov 9 19:29:30 UTC 2010
Author: mav
Date: Tue Nov 9 19:29:29 2010
New Revision: 215047
URL: http://svn.freebsd.org/changeset/base/215047
Log:
MFC r208452, r208479:
Unify local_apic.c for x86 archs,
Added:
stable/8/sys/x86/x86/local_apic.c
- copied, changed from r215045, stable/8/sys/i386/i386/local_apic.c
Deleted:
stable/8/sys/amd64/amd64/local_apic.c
stable/8/sys/i386/i386/local_apic.c
Modified:
stable/8/sys/conf/files.amd64
stable/8/sys/conf/files.i386
stable/8/sys/conf/files.pc98
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
stable/8/sys/dev/xen/xenpci/ (props changed)
Modified: stable/8/sys/conf/files.amd64
==============================================================================
--- stable/8/sys/conf/files.amd64 Tue Nov 9 19:28:06 2010 (r215046)
+++ stable/8/sys/conf/files.amd64 Tue Nov 9 19:29:29 2010 (r215047)
@@ -116,7 +116,7 @@ amd64/amd64/intr_machdep.c standard
amd64/amd64/io.c optional io
amd64/amd64/io_apic.c standard
amd64/amd64/legacy.c standard
-amd64/amd64/local_apic.c standard
+x86/x86/local_apic.c standard
amd64/amd64/locore.S standard no-obj
amd64/amd64/machdep.c standard
amd64/amd64/mem.c optional mem
Modified: stable/8/sys/conf/files.i386
==============================================================================
--- stable/8/sys/conf/files.i386 Tue Nov 9 19:28:06 2010 (r215046)
+++ stable/8/sys/conf/files.i386 Tue Nov 9 19:29:29 2010 (r215047)
@@ -276,7 +276,7 @@ i386/i386/io.c optional io
i386/i386/io_apic.c optional apic
i386/i386/k6_mem.c optional mem
i386/i386/legacy.c optional native
-i386/i386/local_apic.c optional apic
+x86/x86/local_apic.c optional apic
i386/i386/locore.s optional native no-obj
i386/xen/locore.s optional xen no-obj
i386/i386/longrun.c optional cpu_enable_longrun
Modified: stable/8/sys/conf/files.pc98
==============================================================================
--- stable/8/sys/conf/files.pc98 Tue Nov 9 19:28:06 2010 (r215046)
+++ stable/8/sys/conf/files.pc98 Tue Nov 9 19:29:29 2010 (r215047)
@@ -151,7 +151,7 @@ i386/i386/io.c optional io
i386/i386/io_apic.c optional apic
i386/i386/k6_mem.c optional mem
i386/i386/legacy.c standard
-i386/i386/local_apic.c optional apic
+x86/x86/local_apic.c optional apic
i386/i386/locore.s standard no-obj
i386/i386/mem.c optional mem
i386/i386/minidump_machdep.c standard
Copied and modified: stable/8/sys/x86/x86/local_apic.c (from r215045, stable/8/sys/i386/i386/local_apic.c)
==============================================================================
--- stable/8/sys/i386/i386/local_apic.c Tue Nov 9 18:46:44 2010 (r215045, copy source)
+++ stable/8/sys/x86/x86/local_apic.c Tue Nov 9 19:29:29 2010 (r215047)
@@ -34,7 +34,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include "opt_atpic.h"
#include "opt_hwpmc_hooks.h"
#include "opt_kdtrace.h"
@@ -70,6 +69,16 @@ __FBSDID("$FreeBSD$");
#include <ddb/ddb.h>
#endif
+#ifdef __amd64__
+#define SDT_APIC SDT_SYSIGT
+#define SDT_APICT SDT_SYSIGT
+#define GSEL_APIC 0
+#else
+#define SDT_APIC SDT_SYS386IGT
+#define SDT_APICT SDT_SYS386TGT
+#define GSEL_APIC GSEL(GCODE_SEL, SEL_KPL)
+#endif
+
#ifdef KDTRACE_HOOKS
#include <sys/dtrace_bsd.h>
cyclic_clock_func_t cyclic_clock_func[MAXCPU];
@@ -215,8 +224,8 @@ lapic_init(vm_paddr_t addr)
("local APIC not aligned on a page boundary"));
lapic = pmap_mapdev(addr, sizeof(lapic_t));
lapic_paddr = addr;
- setidt(APIC_SPURIOUS_INT, IDTVEC(spuriousint), SDT_SYS386IGT, SEL_KPL,
- GSEL(GCODE_SEL, SEL_KPL));
+ setidt(APIC_SPURIOUS_INT, IDTVEC(spuriousint), SDT_APIC, SEL_KPL,
+ GSEL_APIC);
/* Perform basic initialization of the BSP's local APIC. */
lapic_enable();
@@ -225,17 +234,15 @@ lapic_init(vm_paddr_t addr)
PCPU_SET(apic_id, lapic_id());
/* Local APIC timer interrupt. */
- setidt(APIC_TIMER_INT, IDTVEC(timerint), SDT_SYS386IGT, SEL_KPL,
- GSEL(GCODE_SEL, SEL_KPL));
+ setidt(APIC_TIMER_INT, IDTVEC(timerint), SDT_APIC, SEL_KPL, GSEL_APIC);
/* Local APIC error interrupt. */
- setidt(APIC_ERROR_INT, IDTVEC(errorint), SDT_SYS386IGT, SEL_KPL,
- GSEL(GCODE_SEL, SEL_KPL));
+ setidt(APIC_ERROR_INT, IDTVEC(errorint), SDT_APIC, SEL_KPL, GSEL_APIC);
/* XXX: Thermal interrupt */
/* Local APIC CMCI. */
- setidt(APIC_CMC_INT, IDTVEC(cmcint), SDT_SYS386TGT, SEL_KPL,
+ setidt(APIC_CMC_INT, IDTVEC(cmcint), SDT_APICT, SEL_KPL,
GSEL(GCODE_SEL, SEL_KPL));
}
@@ -1021,8 +1028,8 @@ apic_enable_vector(u_int apic_id, u_int
KASSERT(vector != IDT_SYSCALL, ("Attempt to overwrite syscall entry"));
KASSERT(ioint_handlers[vector / 32] != NULL,
("No ISR handler for vector %u", vector));
- setidt(vector, ioint_handlers[vector / 32], SDT_SYS386IGT, SEL_KPL,
- GSEL(GCODE_SEL, SEL_KPL));
+ setidt(vector, ioint_handlers[vector / 32], SDT_APIC, SEL_KPL,
+ GSEL_APIC);
}
void
@@ -1037,8 +1044,7 @@ apic_disable_vector(u_int apic_id, u_int
* We can not currently clear the idt entry because other cpus
* may have a valid vector at this offset.
*/
- setidt(vector, &IDTVEC(rsvd), SDT_SYS386TGT, SEL_KPL,
- GSEL(GCODE_SEL, SEL_KPL));
+ setidt(vector, &IDTVEC(rsvd), SDT_APICT, SEL_KPL, GSEL_APIC);
#endif
}
@@ -1228,14 +1234,17 @@ apic_register_enumerator(struct apic_enu
}
/*
- * Probe the APIC enumerators, enumerate CPUs, and initialize the
- * local APIC.
+ * We have to look for CPU's very, very early because certain subsystems
+ * want to know how many CPU's we have extremely early on in the boot
+ * process.
*/
static void
apic_init(void *dummy __unused)
{
struct apic_enumerator *enumerator;
+#ifndef __amd64__
uint64_t apic_base;
+#endif
int retval, best;
/* We only support built in local APICs. */
@@ -1268,6 +1277,7 @@ apic_init(void *dummy __unused)
printf("APIC: Using the %s enumerator.\n",
best_enum->apic_name);
+#ifndef __amd64__
/*
* To work around an errata, we disable the local APIC on some
* CPUs during early startup. We need to turn the local APIC back
@@ -1279,6 +1289,7 @@ apic_init(void *dummy __unused)
apic_base |= APICBASE_ENABLED;
wrmsr(MSR_APICBASE, apic_base);
}
+#endif
/* Second, probe the CPU's in the system. */
retval = best_enum->apic_probe_cpus();
@@ -1286,13 +1297,34 @@ apic_init(void *dummy __unused)
printf("%s: Failed to probe CPUs: returned %d\n",
best_enum->apic_name, retval);
+#ifdef __amd64__
+}
+SYSINIT(apic_init, SI_SUB_TUNABLES - 1, SI_ORDER_SECOND, apic_init, NULL);
+
+/*
+ * Setup the local APIC. We have to do this prior to starting up the APs
+ * in the SMP case.
+ */
+static void
+apic_setup_local(void *dummy __unused)
+{
+ int retval;
+
+ if (best_enum == NULL)
+ return;
+#endif
/* Third, initialize the local APIC. */
retval = best_enum->apic_setup_local();
if (retval != 0)
printf("%s: Failed to setup the local APIC: returned %d\n",
best_enum->apic_name, retval);
}
+#ifdef __amd64__
+SYSINIT(apic_setup_local, SI_SUB_CPU, SI_ORDER_SECOND, apic_setup_local,
+ NULL);
+#else
SYSINIT(apic_init, SI_SUB_CPU, SI_ORDER_SECOND, apic_init, NULL);
+#endif
/*
* Setup the I/O APICs.
@@ -1329,7 +1361,7 @@ SYSINIT(apic_setup_io, SI_SUB_INTR, SI_O
#ifdef SMP
/*
* Inter Processor Interrupt functions. The lapic_ipi_*() functions are
- * private to the sys/i386 code. The public interface for the rest of the
+ * private to the MD code. The public interface for the rest of the
* kernel is defined in mp_machdep.c.
*/
int
More information about the svn-src-stable
mailing list