Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/x86 add x2apic support.
details: https://anonhg.NetBSD.org/src/rev/40fccbb298cb
branches: trunk
changeset: 750659:40fccbb298cb
user: cegger <cegger%NetBSD.org@localhost>
date: Sat Jan 09 20:56:17 2010 +0000
description:
add x2apic support.
patch presented on current-users@, port-i386@ and port-amd64@ on 2009-12-22
No comments.
diffstat:
sys/arch/x86/include/cpu.h | 9 +++--
sys/arch/x86/include/mpconfig.h | 4 +-
sys/arch/x86/x86/mpacpi.c | 65 +++++++++++++++++++++++++++++++++++-----
3 files changed, 64 insertions(+), 14 deletions(-)
diffs (191 lines):
diff -r 91b58a16071a -r 40fccbb298cb sys/arch/x86/include/cpu.h
--- a/sys/arch/x86/include/cpu.h Sat Jan 09 20:50:11 2010 +0000
+++ b/sys/arch/x86/include/cpu.h Sat Jan 09 20:56:17 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu.h,v 1.18 2009/11/21 03:11:01 rmind Exp $ */
+/* $NetBSD: cpu.h,v 1.19 2010/01/09 20:56:17 cegger Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -59,6 +59,7 @@
#include <sys/cpu_data.h>
#include <sys/evcnt.h>
+#include <sys/device_if.h> /* for device_t */
struct intrsource;
struct pmap;
@@ -76,7 +77,7 @@
*/
struct cpu_info {
- struct device *ci_dev; /* pointer to our device */
+ device_t ci_dev; /* pointer to our device */
struct cpu_info *ci_self; /* self-pointer */
volatile struct vcpu_info *ci_vcpu; /* for XEN */
void *ci_tlog_base; /* Trap log base */
@@ -93,7 +94,7 @@
int ci_fpused; /* XEN: FPU was used by curlwp */
cpuid_t ci_cpuid; /* our CPU ID */
int ci_cpumask; /* (1 << CPU ID) */
- uint8_t ci_initapicid; /* our intitial APIC ID */
+ uint32_t ci_initapicid; /* our intitial APIC ID */
uint8_t ci_packageid;
uint8_t ci_coreid;
uint8_t ci_smtid;
@@ -137,7 +138,7 @@
uint32_t ci_flags; /* flags; see below */
uint32_t ci_ipis; /* interprocessor interrupts pending */
- int sc_apic_version; /* local APIC version */
+ uint32_t sc_apic_version; /* local APIC version */
uint32_t ci_signature; /* X86 cpuid type */
uint32_t ci_feature_flags;/* X86 %edx CPUID feature bits */
diff -r 91b58a16071a -r 40fccbb298cb sys/arch/x86/include/mpconfig.h
--- a/sys/arch/x86/include/mpconfig.h Sat Jan 09 20:50:11 2010 +0000
+++ b/sys/arch/x86/include/mpconfig.h Sat Jan 09 20:56:17 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mpconfig.h,v 1.11 2009/04/17 21:07:58 dyoung Exp $ */
+/* $NetBSD: mpconfig.h,v 1.12 2010/01/09 20:56:17 cegger Exp $ */
/*
* Definitions originally from the mpbios code, but now used for ACPI
@@ -59,7 +59,7 @@
int type; /* from mp spec intr record */
int flags; /* from mp spec intr record */
uint32_t redir;
- int cpu_id;
+ uint32_t cpu_id;
int global_int; /* ACPI global interrupt number */
int sflags; /* other, software flags (see below) */
void *linkdev;
diff -r 91b58a16071a -r 40fccbb298cb sys/arch/x86/x86/mpacpi.c
--- a/sys/arch/x86/x86/mpacpi.c Sat Jan 09 20:50:11 2010 +0000
+++ b/sys/arch/x86/x86/mpacpi.c Sat Jan 09 20:56:17 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mpacpi.c,v 1.83 2010/01/05 17:23:18 jruoho Exp $ */
+/* $NetBSD: mpacpi.c,v 1.84 2010/01/09 20:56:17 cegger Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.83 2010/01/05 17:23:18 jruoho Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.84 2010/01/09 20:56:17 cegger Exp $");
#include "acpica.h"
#include "opt_acpi.h"
@@ -181,6 +181,7 @@
ACPI_MADT_NMI_SOURCE *ioapic_nmi;
ACPI_MADT_LOCAL_APIC_NMI *lapic_nmi;
ACPI_MADT_INTERRUPT_OVERRIDE *isa_ovr;
+ ACPI_MADT_LOCAL_X2APIC_NMI *x2apic_nmi;
struct pic *pic;
extern struct acpi_softc *acpi_softc; /* XXX */
@@ -308,6 +309,22 @@
mpacpi_sci_override = mpi;
break;
+
+ case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI:
+ x2apic_nmi = (ACPI_MADT_LOCAL_X2APIC_NMI *)hdrp;
+
+ mpi = &mp_intrs[*index];
+ (*index)++;
+ mpi->next = NULL;
+ mpi->bus = NULL;
+ mpi->ioapic = NULL;
+ mpi->type = MPS_INTTYPE_NMI;
+ mpi->ioapic_pin = x2apic_nmi->Lint;
+ mpi->cpu_id = x2apic_nmi->Uid;
+ mpi->redir = (IOAPIC_REDLO_DEL_NMI<<IOAPIC_REDLO_DEL_SHIFT);
+ mpi->global_int = -1;
+ break;
+
default:
break;
}
@@ -325,6 +342,7 @@
switch (hdrp->Type) {
case ACPI_MADT_TYPE_LOCAL_APIC:
+ case ACPI_MADT_TYPE_LOCAL_X2APIC:
mpacpi_ncpu++;
break;
case ACPI_MADT_TYPE_IO_APIC:
@@ -332,6 +350,7 @@
break;
case ACPI_MADT_TYPE_NMI_SOURCE:
case ACPI_MADT_TYPE_LOCAL_APIC_NMI:
+ case ACPI_MADT_TYPE_LOCAL_X2APIC_NMI:
mpacpi_nintsrc++;
break;
case ACPI_MADT_TYPE_LOCAL_APIC_OVERRIDE:
@@ -347,7 +366,8 @@
mpacpi_config_cpu(ACPI_SUBTABLE_HEADER *hdrp, void *aux)
{
device_t parent = aux;
- ACPI_MADT_LOCAL_APIC *p;
+ ACPI_MADT_LOCAL_APIC *lapic;
+ ACPI_MADT_LOCAL_X2APIC *x2apic;
struct cpu_attach_args caa;
int cpunum = 0;
int locs[CPUBUSCF_NLOCS];
@@ -357,19 +377,48 @@
cpunum = lapic_cpu_number();
#endif
- if (hdrp->Type == ACPI_MADT_TYPE_LOCAL_APIC) {
- p = (ACPI_MADT_LOCAL_APIC *)hdrp;
- if (p->LapicFlags & ACPI_MADT_ENABLED) {
- if (p->Id != cpunum)
+ switch (hdrp->Type) {
+ case ACPI_MADT_TYPE_LOCAL_APIC:
+ lapic = (ACPI_MADT_LOCAL_APIC *)hdrp;
+ if (lapic->LapicFlags & ACPI_MADT_ENABLED) {
+ if (lapic->Id != cpunum)
caa.cpu_role = CPU_ROLE_AP;
else
caa.cpu_role = CPU_ROLE_BP;
- caa.cpu_number = p->Id;
+ caa.cpu_number = lapic->Id;
caa.cpu_func = &mp_cpu_funcs;
locs[CPUBUSCF_APID] = caa.cpu_number;
config_found_sm_loc(parent, "cpubus", locs,
&caa, mpacpi_cpuprint, config_stdsubmatch);
}
+ break;
+
+ case ACPI_MADT_TYPE_LOCAL_X2APIC:
+ x2apic = (ACPI_MADT_LOCAL_X2APIC *)hdrp;
+
+ /* ACPI spec: "Logical processors with APIC ID values
+ * less than 255 must use the Processor Local APIC
+ * structure to convey their APIC information to OSPM."
+ */
+ if (x2apic->LocalApicId <= 0xff) {
+ printf("bogus MADT X2APIC entry (id = 0x%"PRIx32")\n",
+ x2apic->LocalApicId);
+ break;
+ }
+
+ if (x2apic->LapicFlags & ACPI_MADT_ENABLED) {
+ if (x2apic->LocalApicId != cpunum)
+ caa.cpu_role = CPU_ROLE_AP;
+ else
+ caa.cpu_role = CPU_ROLE_BP;
+ caa.cpu_number = x2apic->LocalApicId;
+ caa.cpu_func = &mp_cpu_funcs;
+ locs[CPUBUSCF_APID] = caa.cpu_number;
+ config_found_sm_loc(parent, "cpubus", locs,
+ &caa, mpacpi_cpuprint, config_stdsubmatch);
+ }
+ break;
+
}
return AE_OK;
}
Home |
Main Index |
Thread Index |
Old Index