- make it possible to have ACPI without IOAPIC and/or LAPIC

- make it possible for machine-specific code to provide custom R/W routines
  in its i82093*.h headers
- always initialize sc->sc_pins[pin], even in the !ioapic_cold case.
No objections on port-i386 and port-amd64.
This commit is contained in:
bouyer 2006-09-28 18:01:24 +00:00
parent b12fa3d640
commit e2d271e26c
3 changed files with 38 additions and 17 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ioapic.c,v 1.13 2006/07/04 00:30:23 christos Exp $ */
/* $NetBSD: ioapic.c,v 1.14 2006/09/28 18:01:24 bouyer Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -72,7 +72,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.13 2006/07/04 00:30:23 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: ioapic.c,v 1.14 2006/09/28 18:01:24 bouyer Exp $");
#include "opt_ddb.h"
@ -149,6 +149,7 @@ ioapic_unlock(struct ioapic_softc *sc, u_long flags)
write_psl(flags);
}
#ifndef _IOAPIC_CUSTOM_RW
/*
* Register read/write routines.
*/
@ -170,6 +171,7 @@ ioapic_write_ul(struct ioapic_softc *sc,int regid, u_int32_t val)
*(sc->sc_reg) = regid;
*(sc->sc_data) = val;
}
#endif /* !_IOAPIC_CUSTOM_RW */
static inline u_int32_t
ioapic_read(struct ioapic_softc *sc, int regid)
@ -278,7 +280,6 @@ ioapic_attach(struct device *parent, struct device *self, void *aux)
struct ioapic_softc *sc = (struct ioapic_softc *)self;
struct apic_attach_args *aaa = (struct apic_attach_args *) aux;
int apic_id;
bus_space_handle_t bh;
u_int32_t ver_sz;
int i;
@ -294,8 +295,11 @@ ioapic_attach(struct device *parent, struct device *self, void *aux)
}
ioapic_add(sc);
printf("%s: pa 0x%lx", sc->sc_pic.pic_dev.dv_xname, aaa->apic_address);
#ifndef _IOAPIC_CUSTOM_RW
{
bus_space_handle_t bh;
if (x86_mem_add_mapping(aaa->apic_address, PAGE_SIZE, 0, &bh) != 0) {
printf(": map failed\n");
@ -303,6 +307,9 @@ ioapic_attach(struct device *parent, struct device *self, void *aux)
}
sc->sc_reg = (volatile u_int32_t *)(bh + IOAPIC_REG);
sc->sc_data = (volatile u_int32_t *)(bh + IOAPIC_DATA);
}
#endif
sc->sc_pa = aaa->apic_address;
sc->sc_pic.pic_type = PIC_IOAPIC;
__cpu_simple_lock_init(&sc->sc_pic.pic_lock);
@ -512,11 +519,11 @@ ioapic_addroute(struct pic *pic, struct cpu_info *ci, int pin,
struct ioapic_softc *sc = (struct ioapic_softc *)pic;
struct ioapic_pin *pp;
pp = &sc->sc_pins[pin];
pp->ip_type = type;
pp->ip_vector = idtvec;
pp->ip_cpu = ci;
if (ioapic_cold) {
pp = &sc->sc_pins[pin];
pp->ip_type = type;
pp->ip_vector = idtvec;
pp->ip_cpu = ci;
return;
}
apic_set_redir(sc, pin, idtvec, ci);

View File

@ -1,4 +1,4 @@
/* $NetBSD: mpacpi.c,v 1.40 2006/09/23 17:16:38 fvdl Exp $ */
/* $NetBSD: mpacpi.c,v 1.41 2006/09/28 18:01:24 bouyer Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.40 2006/09/23 17:16:38 fvdl Exp $");
__KERNEL_RCSID(0, "$NetBSD: mpacpi.c,v 1.41 2006/09/28 18:01:24 bouyer Exp $");
#include "acpi.h"
#include "opt_acpi.h"
@ -377,7 +377,7 @@ mpacpi_scan_apics(struct device *self, int *ncpu, int *napic)
mpacpi_ncpu = mpacpi_nintsrc = mpacpi_nioapic = 0;
acpi_madt_walk(mpacpi_count, self);
#if NIOAPIC > 0
#if NLAPIC > 0
lapic_boot_init(mpacpi_lapic_base);
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: mpbios.c,v 1.28 2006/07/04 00:30:23 christos Exp $ */
/* $NetBSD: mpbios.c,v 1.29 2006/09/28 18:01:24 bouyer Exp $ */
/*-
* Copyright (c) 2000 The NetBSD Foundation, Inc.
@ -103,9 +103,11 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mpbios.c,v 1.28 2006/07/04 00:30:23 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: mpbios.c,v 1.29 2006/09/28 18:01:24 bouyer Exp $");
#include "acpi.h"
#include "lapic.h"
#include "ioapic.h"
#include "opt_acpi.h"
#include "opt_mpbios.h"
@ -513,7 +515,6 @@ mpbios_scan(struct device *self, int *ncpu, int *napic)
paddr_t lapic_base;
const struct mpbios_int *iep;
struct mpbios_int ie;
struct ioapic_softc *sc;
printf ("%s: Intel MP Specification ", self->dv_xname);
@ -541,7 +542,9 @@ mpbios_scan(struct device *self, int *ncpu, int *napic)
if (mp_cth != NULL)
lapic_base = (paddr_t)mp_cth->apic_address;
#if NLAPIC > 0
lapic_boot_init(lapic_base);
#endif
#if NACPI > 0
}
#endif
@ -551,7 +554,6 @@ mpbios_scan(struct device *self, int *ncpu, int *napic)
printf("\n%s: MP default configuration %d\n",
self->dv_xname, mp_fps->mpfb1);
#if NACPI > 0
if (mpacpi_ncpu == 0)
#endif
@ -656,11 +658,15 @@ mpbios_scan(struct device *self, int *ncpu, int *napic)
iep = (const struct mpbios_int *)position;
ie = *iep;
if (iep->dst_apic_id == MPS_ALL_APICS) {
#if NIOAPIC > 0
struct ioapic_softc *sc;
for (sc = ioapics ; sc != NULL;
sc = sc->sc_next) {
ie.dst_apic_id = sc->sc_apicid;
mpbios_int((char *)&ie, type,
&mp_intrs[cur_intr++]); }
&mp_intrs[cur_intr++]);
}
#endif
} else {
mpbios_int(position, type,
&mp_intrs[cur_intr++]);
@ -1018,7 +1024,6 @@ mpbios_ioapic(ent, self)
struct device *self;
{
const struct mpbios_ioapic *entry = (const struct mpbios_ioapic *)ent;
struct apic_attach_args aaa;
/* XXX let flags checking happen in ioapic driver.. */
if (!(entry->apic_flags & IOAPICENTRY_FLAG_EN))
@ -1026,6 +1031,9 @@ mpbios_ioapic(ent, self)
mpbios_nioapic++;
#if NIOAPIC > 0
{
struct apic_attach_args aaa;
aaa.aaa_name = "ioapic";
aaa.apic_id = entry->apic_id;
aaa.apic_version = entry->apic_version;
@ -1034,6 +1042,8 @@ mpbios_ioapic(ent, self)
aaa.flags = (mp_fps->mpfb2 & 0x80) ? IOAPIC_PICMODE : IOAPIC_VWIRE;
config_found_sm_loc(self, "cpubus", NULL, &aaa, mp_print, mp_submatch);
}
#endif
}
static const char inttype_fmt[] = "\177\020"
@ -1097,7 +1107,11 @@ mpbios_int(ent, enttype, mpi)
(*mpb->mb_intr_cfg)(entry, &mpi->redir);
if (enttype == MPS_MCT_IOINT) {
#if NIOAPIC > 0
sc = ioapic_find(id);
#else
sc = NULL;
#endif
if (sc == NULL) {
printf("mpbios: can't find ioapic %d\n", id);
return;