summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2010-08-08 16:43:22 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2010-08-08 16:43:22 +0000
commit857503eac98e97bc4dec50227754949bd94bad18 (patch)
treead0558e8d3d718ba9d617afd728077ed479f18aa
parent0946234057183a7e0e4ac733ceb4983302b53f3d (diff)
Restore the APIC ID to what we set it to at boot (some machines come up
with it incorrect) from mklarkin, ok kettenis
-rw-r--r--sys/arch/amd64/amd64/ioapic.c22
-rw-r--r--sys/arch/i386/i386/ioapic.c22
2 files changed, 40 insertions, 4 deletions
diff --git a/sys/arch/amd64/amd64/ioapic.c b/sys/arch/amd64/amd64/ioapic.c
index 7c43b4bb653..755e77aebd4 100644
--- a/sys/arch/amd64/amd64/ioapic.c
+++ b/sys/arch/amd64/amd64/ioapic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioapic.c,v 1.19 2010/07/22 00:41:29 deraadt Exp $ */
+/* $OpenBSD: ioapic.c,v 1.20 2010/08/08 16:43:21 deraadt Exp $ */
/* $NetBSD: ioapic.c,v 1.6 2003/05/15 13:30:31 fvdl Exp $ */
/*-
@@ -90,6 +90,7 @@
int ioapic_match(struct device *, void *, void *);
void ioapic_attach(struct device *, struct device *, void *);
+int ioapic_activate(struct device *, int);
extern int x86_mem_add_mapping(bus_addr_t, bus_size_t,
int, bus_space_handle_t *); /* XXX XXX */
@@ -232,7 +233,8 @@ ioapic_print_redir(struct ioapic_softc *sc, char *why, int pin)
}
struct cfattach ioapic_ca = {
- sizeof(struct ioapic_softc), ioapic_match, ioapic_attach
+ sizeof(struct ioapic_softc), ioapic_match, ioapic_attach, NULL,
+ ioapic_activate
};
struct cfdriver ioapic_cd = {
@@ -368,6 +370,22 @@ ioapic_attach(struct device *parent, struct device *self, void *aux)
#endif
}
+int
+ioapic_activate(struct device *self, int act)
+{
+ struct ioapic_softc *sc = (struct ioapic_softc *)self;
+
+ switch (act) {
+ case DVACT_RESUME:
+ /* On resume, reset the APIC id, like we do on boot */
+ ioapic_write(sc, IOAPIC_ID,
+ (ioapic_read(sc, IOAPIC_ID) & ~IOAPIC_ID_MASK) |
+ (sc->sc_apicid << IOAPIC_ID_SHIFT));
+ }
+
+ return (0);
+}
+
void
apic_set_redir(struct ioapic_softc *sc, int pin, int idt_vec,
struct cpu_info *ci)
diff --git a/sys/arch/i386/i386/ioapic.c b/sys/arch/i386/i386/ioapic.c
index 47439e2178f..5574d4e5abf 100644
--- a/sys/arch/i386/i386/ioapic.c
+++ b/sys/arch/i386/i386/ioapic.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioapic.c,v 1.23 2010/07/22 00:41:29 deraadt Exp $ */
+/* $OpenBSD: ioapic.c,v 1.24 2010/08/08 16:43:19 deraadt Exp $ */
/* $NetBSD: ioapic.c,v 1.7 2003/07/14 22:32:40 lukem Exp $ */
/*-
@@ -93,6 +93,7 @@
int ioapic_match(struct device *, void *, void *);
void ioapic_attach(struct device *, struct device *, void *);
+int ioapic_activate(struct device *, int);
/* XXX */
extern int bus_mem_add_mapping(bus_addr_t, bus_size_t, int,
@@ -237,7 +238,8 @@ ioapic_print_redir(struct ioapic_softc *sc, char *why, int pin)
}
struct cfattach ioapic_ca = {
- sizeof(struct ioapic_softc), ioapic_match, ioapic_attach
+ sizeof(struct ioapic_softc), ioapic_match, ioapic_attach, NULL,
+ ioapic_activate
};
struct cfdriver ioapic_cd = {
@@ -363,6 +365,22 @@ ioapic_attach(struct device *parent, struct device *self, void *aux)
#endif
}
+int
+ioapic_activate(struct device *self, int act)
+{
+ struct ioapic_softc *sc = (struct ioapic_softc *)self;
+
+ switch (act) {
+ case DVACT_RESUME:
+ /* On resume, reset the APIC id, like we do on boot */
+ ioapic_write(sc, IOAPIC_ID,
+ (ioapic_read(sc, IOAPIC_ID) & ~IOAPIC_ID_MASK) |
+ (sc->sc_apicid << IOAPIC_ID_SHIFT));
+ }
+
+ return (0);
+}
+
/*
* Interrupt mapping.
*