summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2004-12-30 21:26:18 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2004-12-30 21:26:18 +0000
commitd80952da09e939a8d77e0c52c8ad1a08fafb6462 (patch)
treef0afe746ab250ba17fb70a83aec74a8ada4e6910
parent829235c5016fbb5316a407f461e24f03a6fde9b1 (diff)
Kill the EIOMAPSIZE and instead, dynamically size the external I/O map,
based on the DIO-II space probing results. This does not win much for now, but this will be very useful for SGC bus support (coming soon).
-rw-r--r--sys/arch/hp300/hp300/autoconf.c6
-rw-r--r--sys/arch/hp300/hp300/locore.s87
-rw-r--r--sys/arch/hp300/hp300/machdep.c5
-rw-r--r--sys/arch/hp300/hp300/mem.c5
-rw-r--r--sys/arch/hp300/hp300/pmap_bootstrap.c5
-rw-r--r--sys/arch/hp300/include/vmparam.h12
6 files changed, 100 insertions, 20 deletions
diff --git a/sys/arch/hp300/hp300/autoconf.c b/sys/arch/hp300/hp300/autoconf.c
index 7c57c118bde..832e266fe94 100644
--- a/sys/arch/hp300/hp300/autoconf.c
+++ b/sys/arch/hp300/hp300/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.27 2004/12/25 23:02:24 miod Exp $ */
+/* $OpenBSD: autoconf.c,v 1.28 2004/12/30 21:26:14 miod Exp $ */
/* $NetBSD: autoconf.c,v 1.45 1999/04/10 17:31:02 kleink Exp $ */
/*
@@ -1243,9 +1243,11 @@ iounmap(kva, size)
int error;
#ifdef DEBUG
+ extern int eiomapsize;
+
if (((int)kva & PGOFSET) || (size & PGOFSET))
panic("iounmap: unaligned");
- if (kva < extiobase || kva >= extiobase + ctob(EIOMAPSIZE))
+ if (kva < extiobase || kva >= extiobase + ctob(eiomapsize))
panic("iounmap: bad address");
#endif
diff --git a/sys/arch/hp300/hp300/locore.s b/sys/arch/hp300/hp300/locore.s
index db8bc017829..c8820504608 100644
--- a/sys/arch/hp300/hp300/locore.s
+++ b/sys/arch/hp300/hp300/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.43 2004/12/24 22:50:29 miod Exp $ */
+/* $OpenBSD: locore.s,v 1.44 2004/12/30 21:26:14 miod Exp $ */
/* $NetBSD: locore.s,v 1.91 1998/11/11 06:41:25 thorpej Exp $ */
/*
@@ -71,6 +71,7 @@
#ifdef USELEDS
#include <hp300/hp300/leds.h>
#endif
+#include <hp300/dev/dioreg.h>
#define MMUADDR(ar) movl _C_LABEL(MMUbase),ar
#define CLKADDR(ar) movl _C_LABEL(CLKbase),ar
@@ -318,6 +319,51 @@ Lis320:
Lstart1:
/*
+ * Now we need to know how much space the external I/O map has to be.
+ * This has to be done before pmap_bootstrap() is invoked, but since
+ * we are not running in virtual mode and will cause several bus
+ * errors while probing, it is easier to do this before setting up
+ * our own vectors table.
+ * Be careful, a1 is reserved at this point.
+ */
+ clrl d3
+
+ /*
+ * Don't probe the DIO-I space. Since cards may claim memory outside
+ * their range (frame buffers, for example), assume the whole 0-31
+ * select code range is taken, i.e. 32 boards.
+ */
+ addl #(DIO_DEVSIZE * 32), d3
+
+ /*
+ * Probe for DIO-II devices, select codes 132 to 255.
+ */
+ RELOC(machineid,a0)
+ cmpl #HP_320,a0@
+ jeq eiodone | HP 320 has nothing more
+
+ movl #132, d2 | our select code...
+ movl #DIOII_BASE, a0 | and first address
+dioloop:
+ ASRELOC(phys_badaddr, a3)
+ jbsr a3@ | probe address (read ID)
+ movl #DIOII_DEVSIZE, d1
+ tstl d0 | success?
+ jne 1f | no, skip
+ addl d1, d3 | yes, count it
+1:
+ addl d1, a0 | next slot address...
+ addql #1, d2 | and slot number
+ cmpl #256, d2
+ jne dioloop
+
+eiodone:
+ moveq #PGSHIFT, d2
+ lsrl d2, d3 | convert from bytes to pages
+ RELOC(eiomapsize,a2)
+ movl d3,a2@
+
+ /*
* Now that we know what CPU we have, initialize the address error
* and bus error handlers in the vector table:
*
@@ -1867,6 +1913,42 @@ Lm68881rdone:
rts
/*
+ * Probe a memory address, and see if it causes a bus error.
+ * This function is only to be used in physical mode, and before our
+ * trap vectors are initialized.
+ * Invoke with address to probe in a0.
+ * Alters: a3 d0 d1
+ */
+#define BUSERR 0xfffffffc
+ASLOCAL(phys_badaddr)
+ ASRELOC(_bsave,a3)
+ movl BUSERR,a3@ | save ROM bus errror handler
+ ASRELOC(_ssave,a3)
+ movl sp,a3@ | and current stack pointer
+ ASRELOC(catchbad,a3)
+ movl a3,BUSERR | plug in our handler
+ movw a0@,d1 | access address
+ ASRELOC(_bsave,a3) | no fault!
+ movl a3@,BUSERR
+ clrl d0 | return success
+ rts
+ASLOCAL(catchbad)
+ ASRELOC(_bsave,a3) | got a bus error, so restore handler
+ movl a1@,BUSERR
+ ASRELOC(_ssave,a3)
+ movl a3@,sp | and stack
+ moveq #1,d0 | return fault
+ rts
+#undef BUSERR
+
+ .data
+ASLOCAL(_bsave)
+ .long 0
+ASLOCAL(_ssave)
+ .long 0
+ .text
+
+/*
* Handle the nitty-gritty of rebooting the machine.
* Basically we just turn off the MMU and jump to the appropriate ROM routine.
* Note that we must be running in an address range that is mapped one-to-one
@@ -1980,6 +2062,9 @@ GLOBAL(intiolimit)
GLOBAL(extiobase)
.long 0 | KVA of base of external IO space
+GLOBAL(eiomapsize)
+ .long 0 | size of external IO space in pages
+
GLOBAL(CLKbase)
.long 0 | KVA of base of clock registers
diff --git a/sys/arch/hp300/hp300/machdep.c b/sys/arch/hp300/hp300/machdep.c
index b85bdb24f76..4131b3a7717 100644
--- a/sys/arch/hp300/hp300/machdep.c
+++ b/sys/arch/hp300/hp300/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.93 2004/12/23 15:32:09 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.94 2004/12/30 21:26:14 miod Exp $ */
/* $NetBSD: machdep.c,v 1.121 1999/03/26 23:41:29 mycroft Exp $ */
/*
@@ -149,6 +149,7 @@ extern struct emul emul_sunos;
* DIOCSIZE bytes. Play safe and allow for twice this size.
*/
char extiospace[EXTENT_FIXED_STORAGE_SIZE(2 * DIOCSIZE / PAGE_SIZE)];
+extern int eiomapsize;
/* prototypes for local functions */
caddr_t allocsys(caddr_t);
@@ -228,7 +229,7 @@ consinit()
* Initialize the DIO resource map.
*/
extio = extent_create("extio",
- (u_long)extiobase, (u_long)extiobase + ctob(EIOMAPSIZE),
+ (u_long)extiobase, (u_long)extiobase + ctob(eiomapsize),
M_DEVBUF, extiospace, sizeof(extiospace), EX_NOWAIT);
/*
diff --git a/sys/arch/hp300/hp300/mem.c b/sys/arch/hp300/hp300/mem.c
index a8241915fbe..a2a51ed3740 100644
--- a/sys/arch/hp300/hp300/mem.c
+++ b/sys/arch/hp300/hp300/mem.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mem.c,v 1.21 2003/06/02 23:27:45 millert Exp $ */
+/* $OpenBSD: mem.c,v 1.22 2004/12/30 21:26:15 miod Exp $ */
/* $NetBSD: mem.c,v 1.25 1999/03/27 00:30:06 mycroft Exp $ */
/*
@@ -55,6 +55,7 @@
extern u_int lowram;
extern char *extiobase;
+extern int eiomapsize;
static caddr_t devzeropage;
#define mmread mmrw
@@ -167,7 +168,7 @@ mmrw(dev, uio, flags)
*/
if (ISIIOVA(v) ||
((caddr_t)v >= extiobase &&
- (caddr_t)v < (extiobase + (EIOMAPSIZE * NBPG))))
+ (caddr_t)v < (extiobase + (eiomapsize * NBPG))))
return (EFAULT);
error = uiomove((caddr_t)v, c, uio);
diff --git a/sys/arch/hp300/hp300/pmap_bootstrap.c b/sys/arch/hp300/hp300/pmap_bootstrap.c
index 87d35864eb4..d825f1a7e51 100644
--- a/sys/arch/hp300/hp300/pmap_bootstrap.c
+++ b/sys/arch/hp300/hp300/pmap_bootstrap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap_bootstrap.c,v 1.19 2004/12/30 21:22:19 miod Exp $ */
+/* $OpenBSD: pmap_bootstrap.c,v 1.20 2004/12/30 21:26:15 miod Exp $ */
/* $NetBSD: pmap_bootstrap.c,v 1.13 1997/06/10 18:56:50 veego Exp $ */
/*
@@ -54,13 +54,14 @@ caddr_t ledbase; /* SPU LEDs mapping */
extern vaddr_t CLKbase, MMUbase;
extern char *extiobase;
extern int maxmem;
+extern int eiomapsize;
#define RELOC(v, t) *((t*)((u_int)&(v) + firstpa))
#define PA2VA(v, t) *((t*)((u_int)&(v)))
#define MACHINE_IIOMAPSIZE IIOMAPSIZE
#define MACHINE_INTIOBASE INTIOBASE
-#define MACHINE_EIOMAPSIZE EIOMAPSIZE
+#define MACHINE_EIOMAPSIZE RELOC(eiomapsize, int)
#define PMAP_MD_LOCALS /* nothing */
diff --git a/sys/arch/hp300/include/vmparam.h b/sys/arch/hp300/include/vmparam.h
index 247bc35867a..e1ac81f5c22 100644
--- a/sys/arch/hp300/include/vmparam.h
+++ b/sys/arch/hp300/include/vmparam.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmparam.h,v 1.14 2003/06/02 23:27:45 millert Exp $ */
+/* $OpenBSD: vmparam.h,v 1.15 2004/12/30 21:26:17 miod Exp $ */
/* $NetBSD: vmparam.h,v 1.16 1998/08/20 08:33:48 kleink Exp $ */
/*
@@ -49,16 +49,6 @@
#include <m68k/vmparam.h>
/*
- * External IO space map size.
- * By default we make it large enough to map up to 3 DIO-II devices and
- * the complete DIO space. For a 320-only configuration (which has no
- * DIO-II) you could define a considerably smaller region.
- */
-#ifndef EIOMAPSIZE
-#define EIOMAPSIZE 3584 /* 14mb */
-#endif
-
-/*
* Constants which control the way the VM system deals with memory segments.
* The hp300 only has one physical memory segment.
*/