summaryrefslogtreecommitdiff
path: root/sys/arch/sparc/stand
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-07-06 20:41:07 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-07-06 20:41:07 +0000
commite6c3132802a7eba510ea62eb25971c58c08b3a7a (patch)
treee429d6ccefa443d2cb142336a8b6b583890d7b8c /sys/arch/sparc/stand
parent5abd393b91c8feee8622baf5da22306b3831353b (diff)
sun4e support in the bootblocks, derived from a diff from jason@ 7 years ago.
Diffstat (limited to 'sys/arch/sparc/stand')
-rw-r--r--sys/arch/sparc/stand/boot/boot.c61
-rw-r--r--sys/arch/sparc/stand/common/mmu.c8
-rw-r--r--sys/arch/sparc/stand/common/promdev.c75
-rw-r--r--sys/arch/sparc/stand/common/srt0.S18
-rw-r--r--sys/arch/sparc/stand/common/version.c5
5 files changed, 98 insertions, 69 deletions
diff --git a/sys/arch/sparc/stand/boot/boot.c b/sys/arch/sparc/stand/boot/boot.c
index 306b8513e01..3d3d8a9d13d 100644
--- a/sys/arch/sparc/stand/boot/boot.c
+++ b/sys/arch/sparc/stand/boot/boot.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: boot.c,v 1.7 2010/06/29 21:33:54 miod Exp $ */
+/* $OpenBSD: boot.c,v 1.8 2010/07/06 20:41:04 miod Exp $ */
/* $NetBSD: boot.c,v 1.2 1997/09/14 19:27:21 pk Exp $ */
/*-
@@ -42,7 +42,11 @@
int debug;
int netif_debug;
-#define FOURMB 0x400000
+#define FOURMB 0x400000
+#ifndef RELOC2
+#define RELOC2 (RELOC + 0x40000)
+#endif
+#define LOWSTACK (16 * 1024)
/*
* Boot device is derived from ROM provided information.
@@ -50,11 +54,9 @@ int netif_debug;
#define DEFAULT_KERNEL "bsd"
extern char *version;
-extern vaddr_t esym;
char fbuf[80], dbuf[128];
paddr_t bstart, bend; /* physical start & end address of the boot program */
-u_long loadaddrmask = -1UL;
int compat = 1; /* try to load in compat mode */
typedef void (*entry_t)(u_long, int, int, int, long, long);
@@ -146,6 +148,17 @@ loadk(char *file, u_long *marks)
vaddr_t va;
paddr_t pa;
u_long minsize, size;
+ vaddr_t extra;
+
+ /*
+ * Regardless of the address where we load the kernel, we need to
+ * make sure it has enough valid space to use during pmap_bootstrap;
+ * 4/4c picks it in locore, 4m needs it now.
+ */
+ if (cputyp == CPU_SUN4 || cputyp == CPU_SUN4C)
+ extra = 0;
+ else
+ extra = 512 * 1024;
if ((fd = open(file, 0)) < 0)
return (errno ? errno : ENOENT);
@@ -157,14 +170,14 @@ loadk(char *file, u_long *marks)
if (files[fd].f_flags & F_RAW) {
flags = (COUNT_KERNEL & ~COUNT_SYM) | (LOAD_KERNEL & ~LOAD_SYM);
- minsize = RELOC + 0x40000; /* RELOC2 */
+ minsize = RELOC2 - LOWSTACK;
va = 0xf8000000; /* KERNBASE */
#ifdef DEBUG
printf("Tape boot: expecting a bsd.rd kernel smaller than %p\n",
minsize);
#endif
/* compensate for extra room below */
- minsize -= 512 * 1024;
+ minsize -= extra;
} else {
flags = LOAD_KERNEL;
marks[MARK_START] = 0;
@@ -202,33 +215,26 @@ loadk(char *file, u_long *marks)
* breathing room after it.
*/
if (compat != 0) {
- if (minsize < bstart)
- size = minsize;
+ if (minsize + extra <= RELOC2 - LOWSTACK)
+ size = RELOC2 - LOWSTACK;
else
compat = 0;
}
+ if (compat == 0)
+ size = minsize + extra;
- /*
- * If we are not loading the kernel in low physical addresses,
- * we need to make sure it has enough valid space to use during
- * pmap_bootstrap; 512KB ought to be enough.
- */
- if (compat == 0) {
- size = minsize + 512 * 1024;
+ /* Get a physical load address */
#ifdef DEBUG
- printf("kernel footprint %p, requesting %p\n", minsize, size);
+ printf("kernel footprint %p, requesting %p\n", minsize, size);
#endif
- }
-
- /* Get a physical load address */
pa = getphysmem(size);
if (pa == (paddr_t)-1) {
/*
- * That 512KB extra might have been too much, if physical
- * memory doesn't have any contiguous large chunks (e.g.
- * on sun4c systems with 4MB regions).
- * If that 512KB increase caused us to cross a 4MB
- * boundary, try to limit ourselves to a 4MB multiple.
+ * The extra bootstrap memory estimate might have been
+ * too much, if physical memory doesn't have any contiguous
+ * large chunks (e.g. on sun4c systems with 4MB regions).
+ * If that increase caused us to cross a 4MB boundary, try
+ * to limit ourselves to a 4MB multiple.
*/
if (compat == 0 && size / FOURMB != minsize / FOURMB) {
size = roundup(minsize, FOURMB);
@@ -250,7 +256,7 @@ loadk(char *file, u_long *marks)
}
/* try and double-map at VA 0 for compatibility */
- if (pa + size >= bstart) {
+ if (pa + size > bstart) {
printf("WARNING: %s is too large for compat mode.\n"
"If your kernel is too old, it will not run correctly.\n",
file);
@@ -259,7 +265,6 @@ loadk(char *file, u_long *marks)
error = EFAULT;
goto out;
}
- loadaddrmask = 0x07ffffffUL;
}
marks[MARK_START] = 0;
@@ -289,7 +294,7 @@ main(int argc, char *argv[])
* than 16K of stack space.
* The top of the boot loader is the next 4MB boundary.
*/
- bstart_va = (vaddr_t)start - 16 * 1024;
+ bstart_va = (vaddr_t)start - LOWSTACK;
if (pmap_extract(bstart_va, &bstart) != 0)
panic("can't figure out where we have been loaded");
@@ -330,7 +335,7 @@ main(int argc, char *argv[])
/* Note: args 2-4 not used due to conflicts with SunOS loaders */
(*(entry_t)marks[MARK_ENTRY])(cputyp == CPU_SUN4 ?
PROM_LOADADDR : (u_long)promvec, 0, 0, 0,
- marks[MARK_END] & loadaddrmask, DDB_MAGIC1);
+ marks[MARK_END], DDB_MAGIC1);
_rtt();
}
diff --git a/sys/arch/sparc/stand/common/mmu.c b/sys/arch/sparc/stand/common/mmu.c
index c992af3101b..c11df529db2 100644
--- a/sys/arch/sparc/stand/common/mmu.c
+++ b/sys/arch/sparc/stand/common/mmu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mmu.c,v 1.2 2010/07/04 22:40:29 deraadt Exp $ */
+/* $OpenBSD: mmu.c,v 1.3 2010/07/06 20:41:06 miod Exp $ */
/* $NetBSD: mmu.c,v 1.8 2008/04/28 20:23:36 martin Exp $ */
/*-
@@ -51,6 +51,10 @@ static int pmap_extract_srmmu(vaddr_t va, paddr_t *ppa);
int (*pmap_map)(vaddr_t va, paddr_t pa, psize_t size);
int (*pmap_extract)(vaddr_t va, paddr_t *ppa);
+#ifndef CPU_SUN4D
+#define CPU_ISSUN4D 0
+#endif
+
int
mmu_init(void)
{
@@ -71,7 +75,7 @@ mmu_init(void)
*/
rcookie = 2;
scookie = 17;
- } else if (CPU_ISSUN4M) {
+ } else if (CPU_ISSUN4M || CPU_ISSUN4D) {
char buf[32];
pmap_map = pmap_map_srmmu;
pmap_extract = pmap_extract_srmmu;
diff --git a/sys/arch/sparc/stand/common/promdev.c b/sys/arch/sparc/stand/common/promdev.c
index 7356452e186..c1ac9dfd093 100644
--- a/sys/arch/sparc/stand/common/promdev.c
+++ b/sys/arch/sparc/stand/common/promdev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: promdev.c,v 1.10 2010/06/29 21:33:54 miod Exp $ */
+/* $OpenBSD: promdev.c,v 1.11 2010/07/06 20:41:06 miod Exp $ */
/* $NetBSD: promdev.c,v 1.16 1995/11/14 15:04:01 pk Exp $ */
/*
@@ -770,31 +770,64 @@ prom_init()
*
* This process is actually started in srt0.S, which has discovered
* the minimal set of machine specific parameters for the 1st-level
- * boot program (bootxx) to run. The page size has already been set
- * and the CPU type is either CPU_SUN4 or CPU_SUN4C.
+ * boot program (bootxx) to run. The CPU type is either CPU_SUN4 or
+ * CPU_SUN4C at this point; we need to figure out the exact cpu type
+ * and our page size.
*/
- if (cputyp == CPU_SUN4)
- return;
-
- /*
- * We have SUN4C, SUN4M or SUN4D.
- * Use the PROM `compatible' property to determine which.
- * Absence of the `compatible' property means `sun4c'.
- */
+ if (cputyp == CPU_SUN4) {
+ pgshift = SUN4_PGSHIFT;
+ } else {
+ /*
+ * We are either SUN4C, SUN4D, SUN4E or SUN4M.
+ * Use the PROM `compatible' property to determine which.
+ * Absence of the `compatible' property means either sun4c
+ * or sun4e; these can be told apart by checking for the
+ * page size.
+ */
- node = prom_findroot();
- cp = prom_getpropstring(node, "compatible");
- if (*cp == '\0' || strcmp(cp, "sun4c") == 0)
- cputyp = CPU_SUN4C;
- else if (strcmp(cp, "sun4m") == 0)
- cputyp = CPU_SUN4M;
+#ifdef BOOTXX
+ char tmpstr[24];
+
+ snprintf(tmpstr, sizeof tmpstr, "pagesize %x l!",
+ (u_long)&nbpg);
+ prom_interpret(tmpstr);
+ if (nbpg == 1 << SUN4_PGSHIFT)
+ pgshift = SUN4_PGSHIFT;
+ else
+ pgshift = SUN4CM_PGSHIFT;
+#else
+ node = prom_findroot();
+ cp = prom_getpropstring(node, "compatible");
+ if (*cp == '\0' || strcmp(cp, "sun4c") == 0) {
+ char tmpstr[24];
+
+ snprintf(tmpstr, sizeof tmpstr, "pagesize %x l!",
+ (u_long)&nbpg);
+ prom_interpret(tmpstr);
+ if (nbpg == 1 << SUN4_PGSHIFT) {
+ pgshift = SUN4_PGSHIFT;
+ /* if netbooted, PROM won't output a cr */
+ printf("\n");
+ } else
+ pgshift = SUN4CM_PGSHIFT;
+ /* note that we don't bother telling 4e apart from 4c */
+ cputyp = CPU_SUN4C;
+ } else if (strcmp(cp, "sun4m") == 0) {
+ cputyp = CPU_SUN4M;
+ pgshift = SUN4CM_PGSHIFT;
#ifdef CPU_SUN4D
- else if (strcmp(cp, "sun4d") == 0)
- cputyp = CPU_SUN4D;
+ } else if (strcmp(cp, "sun4d") == 0) {
+ cputyp = CPU_SUN4D;
+ pgshift = SUN4CM_PGSHIFT;
#endif
- else
- printf("Unknown CPU type (compatible=`%s')\n", cp);
+ } else
+ panic("Unknown CPU type (compatible=`%s')", cp);
+#endif /* BOOTXX */
+ }
+
+ nbpg = 1 << pgshift;
+ pgofset = nbpg - 1;
#endif
}
diff --git a/sys/arch/sparc/stand/common/srt0.S b/sys/arch/sparc/stand/common/srt0.S
index fec67633e0b..34c66f75005 100644
--- a/sys/arch/sparc/stand/common/srt0.S
+++ b/sys/arch/sparc/stand/common/srt0.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: srt0.S,v 1.3 2010/06/29 21:33:54 miod Exp $ */
+/* $OpenBSD: srt0.S,v 1.4 2010/07/06 20:41:06 miod Exp $ */
/* $NetBSD: srt0.S,v 1.5.4.2 1996/07/17 01:51:46 jtc Exp $ */
/*
@@ -43,7 +43,7 @@
.global _C_LABEL(cputyp), _C_LABEL(nbpg), _C_LABEL(pgofset)
.global _C_LABEL(pgshift)
_C_LABEL(cputyp):
- .word 1
+ .word CPU_SUN4C
_C_LABEL(nbpg):
.word 1
_C_LABEL(pgofset):
@@ -147,27 +147,13 @@ start:
st %i0, [%o1 + %lo(_C_LABEL(promvec))]
mov CPU_SUN4C, %g4
- mov SUN4CM_PGSHIFT, %g5
b,a 6f
5:
mov CPU_SUN4, %g4
- mov SUN4_PGSHIFT, %g5
6:
st %g4, [%o0 + %lo(_C_LABEL(cputyp))]
- sethi %hi(_C_LABEL(pgshift)), %o0 ! pgshift = log2(nbpg)
- st %g5, [%o0 + %lo(_C_LABEL(pgshift))]
-
- mov 1, %o0 ! nbpg = 1 << pgshift
- sll %o0, %g5, %g5
- sethi %hi(_C_LABEL(nbpg)), %o0 ! nbpg = bytes in a page
- st %g5, [%o0 + %lo(_C_LABEL(nbpg))]
-
- sub %g5, 1, %g5
- sethi %hi(_C_LABEL(pgofset)), %o0 ! page offset = bytes in a page - 1
- st %g5, [%o0 + %lo(_C_LABEL(pgofset))]
-
call _C_LABEL(main)
mov %i0, %o0
diff --git a/sys/arch/sparc/stand/common/version.c b/sys/arch/sparc/stand/common/version.c
index 66642e57f0d..7b405495f53 100644
--- a/sys/arch/sparc/stand/common/version.c
+++ b/sys/arch/sparc/stand/common/version.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: version.c,v 1.5 2010/06/29 21:33:54 miod Exp $ */
+/* $OpenBSD: version.c,v 1.6 2010/07/06 20:41:06 miod Exp $ */
/* $NetBSD: version.c,v 1.4 1995/09/16 23:20:39 pk Exp $ */
/*
@@ -44,6 +44,7 @@
* 2.2 ELF support added.
* 2.3 Bumped RELOC
* 2.4 Support for larger kernels and fragmented memory layouts.
+ * 2.5 sun4e support
*/
-char *version = "2.4";
+char *version = "2.5";