Unify local_apic.c for x86 archs,

This commit is contained in:
Alexander Motin 2010-05-23 17:45:01 +00:00
parent f87d5cdcbc
commit fa1ed4bd1a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=208452
5 changed files with 25 additions and 1433 deletions

File diff suppressed because it is too large Load Diff

View File

@ -107,7 +107,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/mca.c standard

View File

@ -272,7 +272,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

View File

@ -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/mca.c standard
i386/i386/mem.c optional mem

View File

@ -34,7 +34,6 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include "opt_atpic.h"
#include "opt_hwpmc_hooks.h"
#include "opt_kdtrace.h"
@ -69,6 +68,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];
@ -213,8 +222,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();
@ -223,12 +232,10 @@ 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 */
}
@ -982,8 +989,8 @@ apic_enable_vector(u_int apic_id, u_int vector)
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
@ -998,8 +1005,7 @@ apic_disable_vector(u_int apic_id, u_int vector)
* 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
}
@ -1196,7 +1202,9 @@ 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. */
@ -1229,6 +1237,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
@ -1240,6 +1249,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();
@ -1290,7 +1300,7 @@ SYSINIT(apic_setup_io, SI_SUB_INTR, SI_ORDER_SECOND, apic_setup_io, NULL);
#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