Module Name: src Committed By: cegger Date: Sat Jan 9 20:56:17 UTC 2010
Modified Files: src/sys/arch/x86/include: cpu.h mpconfig.h src/sys/arch/x86/x86: mpacpi.c Log Message: add x2apic support. patch presented on current-users@, port-i386@ and port-amd64@ on 2009-12-22 No comments. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/x86/include/cpu.h cvs rdiff -u -r1.11 -r1.12 src/sys/arch/x86/include/mpconfig.h cvs rdiff -u -r1.83 -r1.84 src/sys/arch/x86/x86/mpacpi.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/x86/include/cpu.h diff -u src/sys/arch/x86/include/cpu.h:1.18 src/sys/arch/x86/include/cpu.h:1.19 --- src/sys/arch/x86/include/cpu.h:1.18 Sat Nov 21 03:11:01 2009 +++ src/sys/arch/x86/include/cpu.h Sat Jan 9 20:56:17 2010 @@ -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 */ Index: src/sys/arch/x86/include/mpconfig.h diff -u src/sys/arch/x86/include/mpconfig.h:1.11 src/sys/arch/x86/include/mpconfig.h:1.12 --- src/sys/arch/x86/include/mpconfig.h:1.11 Fri Apr 17 21:07:58 2009 +++ src/sys/arch/x86/include/mpconfig.h Sat Jan 9 20:56:17 2010 @@ -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; Index: src/sys/arch/x86/x86/mpacpi.c diff -u src/sys/arch/x86/x86/mpacpi.c:1.83 src/sys/arch/x86/x86/mpacpi.c:1.84 --- src/sys/arch/x86/x86/mpacpi.c:1.83 Tue Jan 5 17:23:18 2010 +++ src/sys/arch/x86/x86/mpacpi.c Sat Jan 9 20:56:17 2010 @@ -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; }