Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/i386/pnpbios deal with bios that just say end tag w...
details: https://anonhg.NetBSD.org/src/rev/788b97e7b1ef
branches: trunk
changeset: 482823:788b97e7b1ef
user: chopps <chopps%NetBSD.org@localhost>
date: Tue Feb 22 15:49:17 2000 +0000
description:
deal with bios that just say end tag with no end dep
add a lot of skeletal work to pnpbios.
option to handle events from pnpbios in a thread (e.g., hot-doc)
add calls for the other pnpbios functions (e.g., send message etc..)
add most defintions from the pnp doc to new reg file
diffstat:
sys/arch/i386/pnpbios/pnpbios.c | 811 ++++++++++++++++++++++++++----------
sys/arch/i386/pnpbios/pnpbiosreg.h | 231 ++++++++++
2 files changed, 819 insertions(+), 223 deletions(-)
diffs (truncated from 1450 to 300 lines):
diff -r 21766ee02c44 -r 788b97e7b1ef sys/arch/i386/pnpbios/pnpbios.c
--- a/sys/arch/i386/pnpbios/pnpbios.c Tue Feb 22 15:43:54 2000 +0000
+++ b/sys/arch/i386/pnpbios/pnpbios.c Tue Feb 22 15:49:17 2000 +0000
@@ -1,5 +1,6 @@
-/* $NetBSD: pnpbios.c,v 1.10 2000/02/20 21:42:26 soren Exp $ */
+/* $NetBSD: pnpbios.c,v 1.11 2000/02/22 15:49:17 chopps Exp $ */
/*
+ * Copyright (c) 2000 Christian E. Hopps. All rights reserved.
* Copyright (c) 1999
* Matthias Drochner. All rights reserved.
*
@@ -31,44 +32,115 @@
* http://www.microsoft.com/hwdev/download/respec/pnpbios.zip
* http://www.microsoft.com/hwdev/download/respec/biosclar.zip
* http://www.microsoft.com/hwdev/download/respec/devids.txt
+ *
+ * PNPBIOSEVENTS is unfinished. After coding what I did I discovered
+ * I had no platforms to test on so someone else will need to finish
+ * it. I didn't want to toss the code though
*/
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/malloc.h>
-#include <dev/isa/isareg.h>
-#include <machine/isa_machdep.h>
-#include <machine/segments.h>
+#include <sys/kernel.h>
+#include <sys/kthread.h>
+
#include <vm/vm.h>
#include <vm/vm_kern.h>
+#include <machine/isa_machdep.h>
+#include <machine/segments.h>
+
+#include <dev/isa/isareg.h>
+#include <dev/isapnp/isapnpreg.h>
+
#include <arch/i386/pnpbios/pnpbiosvar.h>
+#include <arch/i386/pnpbios/pnpbiosreg.h>
#include "opt_pnpbiosverbose.h"
#include "isadma.h"
#include "locators.h"
+#ifdef PNPBIOSDEBUG
+#define DPRINTF(x) printf x
+#else
+#define DPRINTF(x)
+#endif
+
struct pnpbios_softc {
- struct device sc_dev;
- isa_chipset_tag_t sc_ic;
+ struct device sc_dev;
+ isa_chipset_tag_t sc_ic;
+ struct proc *sc_evthread;
+
+ u_int8_t *sc_evaddr;
+ int sc_version;
+ int sc_control;
+ int sc_threadrun;
};
-static caddr_t pnpbios_find __P((void));
-static int pnpbios_match __P((struct device *, struct cfdata *, void *));
-static void pnpbios_attach __P((struct device *, struct device *, void *));
-static void pnpbios_printres __P((struct pnpresources *));
-static int pnpbios_print __P((void *, const char *));
-static int pnpbios_getnumnodes __P((int *, size_t *));
-static int pnpbios_getnode __P((int, int *, unsigned char *, size_t));
-static void eisaid_to_string __P((unsigned char *, char *));
-static void pnpbios_attachnode __P((struct pnpbios_softc *, int,
- unsigned char *, size_t));
-static int pnp_scan __P((unsigned char **, size_t, struct pnpresources *, int));
+#define PNPGET4(p) ((p)[0] + ((p)[1] << 8) + \
+ ((p)[2] << 16) + ((p)[3] << 24))
+
+/* bios calls */
+int pnpbios_getapmtable __P((u_char *, size_t *));
+int pnpbios_getdockinfo __P((struct pnpdockinfo *));
+int pnpbios_getnode __P((int, int *, u_int8_t *, size_t));
+int pnpbios_getnumnodes __P((int *, size_t *));
+int pnpbios_getevent __P((u_int16_t *event));
+int pnpbios_sendmessage __P((int));
+int pnpbios_setnode __P((int, int, const u_int8_t *, size_t));
+
+void pnpbios_create_event_thread __P((void *));
+void pnpbios_event_thread __P((void *));
+
+/* configuration stuff */
+caddr_t pnpbios_mapit __P((u_long, u_long, int));
+caddr_t pnpbios_find __P((void));
+int pnpbios_match __P((struct device *, struct cfdata *, void *));
+void pnpbios_attach __P((struct device *, struct device *, void *));
+void pnpbios_printres __P((struct pnpresources *));
+int pnpbios_print __P((void *, const char *));
+void pnpbios_id_to_string __P((u_int32_t, char *));
+void pnpbios_attachnode __P((struct pnpbios_softc *, int, const u_int8_t *,
+ size_t));
+int pnp_scan __P((const u_int8_t **, size_t,struct pnpresources *, int));
+int pnpbios_submatch __P((struct device *, struct cfdata *, void *));
+extern int pnpbioscall __P((int));
-static int pnpbios_submatch __P((struct device *, struct cfdata *, void *));
+/* scanning functions */
+int pnp_compatid __P((struct pnpresources *, const void *, size_t));
+int pnp_newirq __P((struct pnpresources *, const void *, size_t));
+int pnp_newdma __P((struct pnpresources *, const void *, size_t));
+int pnp_newioport __P((struct pnpresources *, const void *, size_t));
+int pnp_newfixedioport __P((struct pnpresources *, const void *, size_t));
+#ifdef PNPBIOSDEBUG
+int pnp_debugdump __P((struct pnpresources *, const void *, size_t));
+#endif
-extern int pnpbioscall __P((int));
+/*
+ * small ressource types (beginning with 1)
+ */
+static struct{
+ int (*handler) __P((struct pnpresources *, const void *, size_t));
+ int minlen, maxlen;
+} smallrescs[] = {
+ {0, 2, 2}, /* PnP version number */
+ {0, 5, 6}, /* logical device id */
+ {pnp_compatid, 4, 4}, /* compatible device id */
+ {pnp_newirq, 2, 3}, /* irq descriptor */
+ {pnp_newdma, 2, 2}, /* dma descriptor */
+ {0, 0, 1}, /* start dep */
+ {0, 0, 0}, /* end dep */
+ {pnp_newioport, 7, 7}, /* io descriptor */
+ {pnp_newfixedioport, 3, 3}, /* fixed io descriptor */
+ {0, -1, -1}, /* reserved */
+ {0, -1, -1},
+ {0, -1, -1},
+ {0, -1, -1},
+ {0, 1, 7}, /* vendor defined */
+ {0, 1, 1} /* end */
+};
+
struct cfattach pnpbios_ca = {
sizeof(struct pnpbios_softc), pnpbios_match, pnpbios_attach
@@ -92,11 +164,11 @@
#define PNPBIOS_SIGNATURE ('$' | ('P' << 8) | ('n' << 16) | ('P' << 24))
-static caddr_t
+caddr_t
pnpbios_find()
{
caddr_t p, c;
- unsigned char cksum;
+ u_int8_t cksum;
size_t structlen;
for (p = (caddr_t)ISA_HOLE_VADDR(0xf0000);
@@ -104,14 +176,14 @@
p += 16) {
if (*(int *)p != PNPBIOS_SIGNATURE)
continue;
- structlen = *(unsigned char *)(p + 5);
+ structlen = *(u_int8_t *)(p + 5);
if ((structlen < 0x21) ||
((p + structlen - 1) > (caddr_t)ISA_HOLE_VADDR(0xfffff)))
continue;
cksum = 0;
for (c = p; c < p + structlen; c++)
- cksum += *(unsigned char *)c;
+ cksum += *(u_int8_t *)c;
if (cksum != 0)
continue;
@@ -133,7 +205,7 @@
return (pnpbios_find() != 0);
}
-static int
+int
pnpbios_match(parent, match, aux)
struct device *parent;
struct cfdata *match;
@@ -152,10 +224,8 @@
return (pnpbios_enabled);
}
-static caddr_t mapit __P((u_long, u_long, int));
-
-static caddr_t
-mapit(addr, len, prot)
+caddr_t
+pnpbios_mapit(addr, len, prot)
u_long addr, len;
int prot;
{
@@ -174,19 +244,26 @@
return ((caddr_t)(startva + (addr - startpa)));
}
-static void
+void
pnpbios_attach(parent, self, aux)
struct device *parent, *self;
void *aux;
{
struct pnpbios_softc *sc = (struct pnpbios_softc *)self;
struct pnpbios_attach_args *paa = aux;
+ struct pnpdevnode *dn;
caddr_t p;
- unsigned int codepbase, datapbase;
+ unsigned int codepbase, datapbase, evaddrp;
caddr_t codeva, datava;
extern char pnpbiostramp[], epnpbiostramp[];
int res, num, i, size, idx;
- unsigned char *buf;
+#ifdef PNPBIOSVERBOSE
+ struct pnpdockinfo di;
+#endif
+#ifdef PNPBIOSEVENTS
+ int evtype;
+#endif
+ u_int8_t *buf;
pnpbios_softc = sc;
sc->sc_ic = paa->paa_ic;
@@ -199,18 +276,35 @@
if (!p)
panic("pnpbios_attach: disappeared");
- codepbase = *(unsigned int *)(p + 0x13);
- datapbase = *(unsigned int *)(p + 0x1d);
- pnpbios_entry = *(unsigned short *)(p + 0x11);
+ sc->sc_version = *(u_int8_t *)(p + 0x04);
+ sc->sc_control = *(u_int8_t *)(p + 0x06);
+ evaddrp = *(u_int32_t *)(p + 0x09);
+ codepbase = *(u_int32_t *)(p + 0x13);
+ datapbase = *(u_int32_t *)(p + 0x1d);
+ pnpbios_entry = *(u_int16_t *)(p + 0x11);
+#ifdef PNPBIOSEVENTS
+ /* if we have an event mechnism queue a thread to deal with them */
+ evtype = (sc->sc_control & PNP_IC_CONTORL_EVENT_MASK);
+ if (evtype == PNP_IC_CONTROL_EVENT_POLL) {
+ sc->sc_evaddr = pnpbios_mapit(evaddrp, NBPG,
+ VM_PROT_READ | VM_PROT_WRITE);
+ if (!sc->sc_evaddr)
+ printf("pnpbios: couldn't map event flag 0x%08x\n",
+ evaddrp);
+ DPRINTF(("pnpbios: event flag vaddr 0x%08x\n",
+ (int)sc->sc_evaddr));
+ }
+#endif
#ifdef PNPBIOSVERBOSE
- printf(": code %x, data %x, entry %x\n%s",
- codepbase, datapbase, pnpbios_entry, self->dv_xname);
+ printf(": code %x, data %x, entry %x, control %x eventp %x\n%s",
+ codepbase, datapbase, pnpbios_entry, sc->sc_control,
+ (int)evaddrp, self->dv_xname);
#endif
- codeva = mapit(codepbase, 0x10000,
+ codeva = pnpbios_mapit(codepbase, 0x10000,
VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE);
- datava = mapit(datapbase, 0x10000,
+ datava = pnpbios_mapit(datapbase, 0x10000,
VM_PROT_READ | VM_PROT_WRITE);
if (codeva == 0 || datava == 0) {
printf("no vm for mapping\n");
@@ -235,7 +329,7 @@
return;
}
- printf(": %d nodes, max len %d\n", num, size);
+ printf(": nodes %d, max len %d\n", num, size);
buf = malloc(size, M_DEVBUF, M_NOWAIT);
idx = 0;
@@ -246,9 +340,11 @@
printf("pnpbios_getnode: error %d\n", res);
continue;
}
- if (buf[2] != node)
- printf("node idx: called %d, got %d\n", node, buf[2]);
- pnpbios_attachnode(sc, node, buf, buf[0] + (buf[1] << 8));
+ dn = (struct pnpdevnode *)buf;
+ if (dn->dn_handle != node)
+ printf("node idx: called %d, got %d\n", node,
+ dn->dn_handle);
+ pnpbios_attachnode(sc, node, buf, dn->dn_size);
}
if (i != num)
printf("got only %d nodes\n", i);
@@ -256,9 +352,34 @@
printf("last idx=%x\n", idx);
free(buf, M_DEVBUF);
+
Home |
Main Index |
Thread Index |
Old Index