Module Name:    src
Committed By:   ragge
Date:           Mon Mar 19 15:43:45 UTC 2018

Modified Files:
        src/sys/arch/vax/boot/boot: devopen.c hp.c if_de.c ra.c vaxstand.h

Log Message:
Use a common routine ubmap() that setup the map registers as needed,
not expecting everything to be below 4M.  This solves the problem
that large kernels cannot be loaded reported on port-vax.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/vax/boot/boot/devopen.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/vax/boot/boot/hp.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/vax/boot/boot/if_de.c \
    src/sys/arch/vax/boot/boot/vaxstand.h
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/vax/boot/boot/ra.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/vax/boot/boot/devopen.c
diff -u src/sys/arch/vax/boot/boot/devopen.c:1.18 src/sys/arch/vax/boot/boot/devopen.c:1.19
--- src/sys/arch/vax/boot/boot/devopen.c:1.18	Mon May 22 16:59:32 2017
+++ src/sys/arch/vax/boot/boot/devopen.c	Mon Mar 19 15:43:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.18 2017/05/22 16:59:32 ragge Exp $ */
+/*	$NetBSD: devopen.c,v 1.19 2018/03/19 15:43:45 ragge Exp $ */
 /*
  * Copyright (c) 1997 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -27,6 +27,7 @@
 #include <lib/libsa/stand.h>
 #include <lib/libkern/libkern.h>
 
+#include <machine/param.h>
 #include <machine/rpb.h>
 #include <machine/sid.h>
 #include <machine/pte.h>
@@ -38,7 +39,12 @@
 #include "vaxstand.h"
 
 int nexaddr, csrbase;
+static int *mapaddr;
 
+/*
+ * Boot device syntax:
+ * device(adapter, controller, unit, partition)file
+ */
 int
 devopen(struct open_file *f, const char *fname, char **file)
 {
@@ -127,6 +133,7 @@ devopen(struct open_file *f, const char 
 		if (adapt < 0)
 			break;
 		nexaddr = (NEX750 + NEXSIZE * adapt);
+		mapaddr = (int *)nexaddr + VAX_NBPG;
 		csrbase = (adapt == 8 ? 0xffe000 : 0xfbe000);
 		break;
 	case VAX_BTYP_780:
@@ -135,6 +142,7 @@ devopen(struct open_file *f, const char 
 		if (adapt < 0)
 			break;
 		nexaddr = ((int)NEX780 + NEXSIZE * adapt);
+		mapaddr = (int *)nexaddr + VAX_NBPG;
 		csrbase = 0x2007e000 + 0x40000 * adapt;
 		break;
 	case VAX_BTYP_9CC: /* 6000/200 */
@@ -176,6 +184,7 @@ devopen(struct open_file *f, const char 
 		mapregs = (void *)0x20088000;
 		if (bootrpb.adpphy == 0x20087800) {
 			nexaddr = bootrpb.adpphy;
+			mapaddr = (int *)nexaddr + VAX_NBPG;
 			for (i = 0; i < 8192; i++)
 				mapregs[i] = PG_V | i;
 		}
@@ -195,3 +204,24 @@ usage:
 	printf("usage: dev(adapter,controller,unit,partition)file -asd\n");
 	return -1;
 }
+
+/*
+ * Map in virtual address vaddr of size vsize starting with map mapno.
+ * Returns the unibus address of the mapped area.
+ */
+int
+ubmap(int mapno, int vaddr, int size)
+{
+	int voff = (vaddr & VAX_PGOFSET);
+	int rv = (mapno << VAX_PGSHIFT) + voff;
+	int vpag, npag;
+
+	if (mapaddr == 0)
+		return vaddr; /* no map, phys == virt */
+
+	npag = (voff + size) / VAX_NBPG;
+	vpag = vaddr >> VAX_PGSHIFT;
+	while (npag-- >= 0)
+		mapaddr[mapno++] = vpag++ | PG_V;
+	return rv;
+}

Index: src/sys/arch/vax/boot/boot/hp.c
diff -u src/sys/arch/vax/boot/boot/hp.c:1.10 src/sys/arch/vax/boot/boot/hp.c:1.11
--- src/sys/arch/vax/boot/boot/hp.c:1.10	Mon May 22 16:59:32 2017
+++ src/sys/arch/vax/boot/boot/hp.c	Mon Mar 19 15:43:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: hp.c,v 1.10 2017/05/22 16:59:32 ragge Exp $ */
+/*	$NetBSD: hp.c,v 1.11 2018/03/19 15:43:45 ragge Exp $ */
 /*
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -108,13 +108,9 @@ int
 hpstrategy(void *f, int func, daddr_t dblk,
     size_t size, void *buf, size_t *rsize)
 {
-	unsigned int pfnum, mapnr, nsize, bn, cn, sn, tn;
+	unsigned int bn, cn, sn, tn;
 
-	pfnum = (u_int)buf >> VAX_PGSHIFT;
-
-	for(mapnr = 0, nsize = size; (nsize + VAX_NBPG) > 0;
-	    nsize -= VAX_NBPG, mapnr++, pfnum++)
-		MBA_WCSR(MAPREG(mapnr), PG_V | pfnum);
+	(void)ubmap(0, (int)buf, size);
 
 	MBA_WCSR(MBA_VAR, ((u_int)buf & VAX_PGOFSET));
 	MBA_WCSR(MBA_BC, (~size) + 1);

Index: src/sys/arch/vax/boot/boot/if_de.c
diff -u src/sys/arch/vax/boot/boot/if_de.c:1.9 src/sys/arch/vax/boot/boot/if_de.c:1.10
--- src/sys/arch/vax/boot/boot/if_de.c:1.9	Mon May 22 16:59:32 2017
+++ src/sys/arch/vax/boot/boot/if_de.c	Mon Mar 19 15:43:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_de.c,v 1.9 2017/05/22 16:59:32 ragge Exp $	*/
+/*	$NetBSD: if_de.c,v 1.10 2018/03/19 15:43:45 ragge Exp $	*/
 
 /*
  * Copyright (c) 2000 Ludd, University of Lule}, Sweden. All rights reserved.
@@ -86,7 +86,7 @@ static int crx, ctx;
 int
 deopen(struct open_file *f, int adapt, int ctlr, int unit, int part)
 {
-	int i, cdata, *map, npgs;
+	int i;
 	u_char eaddr[6];
 
 	/* point to the device in memory */
@@ -108,14 +108,8 @@ deopen(struct open_file *f, int adapt, i
 
 	/* Map in the control structures and buffers */
 	dc = alloc(sizeof(struct de_cdata));
-	pdc = (struct de_cdata *)((int)dc & VAX_PGOFSET);
-	map = (int *)nexaddr + 512;
-	npgs = (sizeof(struct de_cdata) >> VAX_PGSHIFT) + 1;
-	cdata = (int)dc >> VAX_PGSHIFT;
-	for (i = 0; i < npgs; i++) {
-		map[i] = PG_V | (cdata + i);
-	}
 
+	pdc = (struct de_cdata *)ubmap(0, (int)dc, sizeof(struct de_cdata));
 	memset((char *)dc, 0, sizeof(struct de_cdata));
 	
 	/* Tell the DEUNA about our PCB */
Index: src/sys/arch/vax/boot/boot/vaxstand.h
diff -u src/sys/arch/vax/boot/boot/vaxstand.h:1.9 src/sys/arch/vax/boot/boot/vaxstand.h:1.10
--- src/sys/arch/vax/boot/boot/vaxstand.h:1.9	Mon May 22 16:59:32 2017
+++ src/sys/arch/vax/boot/boot/vaxstand.h	Mon Mar 19 15:43:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: vaxstand.h,v 1.9 2017/05/22 16:59:32 ragge Exp $ */
+/*	$NetBSD: vaxstand.h,v 1.10 2018/03/19 15:43:45 ragge Exp $ */
 /*
  * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -46,6 +46,7 @@ extern int csrbase, nexaddr;
 struct netif_driver;
 
 int net_devinit(struct open_file *f, struct netif_driver *drv, u_char *eaddr);
+int ubmap(int mapno, int vaddr, int size);
 
 /* device calls */
 int	raopen(struct open_file *, int, int, int, int),

Index: src/sys/arch/vax/boot/boot/ra.c
diff -u src/sys/arch/vax/boot/boot/ra.c:1.20 src/sys/arch/vax/boot/boot/ra.c:1.21
--- src/sys/arch/vax/boot/boot/ra.c:1.20	Mon May 22 16:59:32 2017
+++ src/sys/arch/vax/boot/boot/ra.c	Mon Mar 19 15:43:45 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ra.c,v 1.20 2017/05/22 16:59:32 ragge Exp $ */
+/*	$NetBSD: ra.c,v 1.21 2018/03/19 15:43:45 ragge Exp $ */
 /*
  * Copyright (c) 1995 Ludd, University of Lule}, Sweden.
  * All rights reserved.
@@ -67,7 +67,6 @@ static struct disklabel ralabel;
 static char io_buf[DEV_BSIZE];
 static int dpart, dunit, remap, is_tmscp, curblock;
 static volatile u_short *ra_ip, *ra_sa, *ra_sw;
-static volatile u_int *mapregs;
 
 int
 raopen(struct open_file *f, int adapt, int ctlr, int unit, int part)
@@ -102,14 +101,9 @@ raopen(struct open_file *f, int adapt, i
 			csrbase += (ctlr ? 000334 : 012150);
 		ra_ip = (u_short *)csrbase;
 		ra_sa = ra_sw = (u_short *)csrbase + 1;
-		if (nexaddr) { /* have map registers */
-			mapregs = (u_int *)nexaddr + 512;
-			mapregs[494] = PG_V | (((u_int)&uda) >> 9);
-			mapregs[495] = mapregs[494] + 1;
-			ubauda = (struct uda *)((char*)0x3dc00 +
-			    (((u_int)(&uda))&0x1ff));
-		} else
-			ubauda = &uda;
+		
+		ubauda = (struct uda *)ubmap(494,
+		    (int)&uda, sizeof(struct uda));
 		johan = (((u_int)ubauda) & 0xffff) + 8;
 		johan2 = (((u_int)ubauda) >> 16) & 077;
 		*ra_ip = 0; /* Start init */
@@ -258,21 +252,13 @@ int
 rastrategy(void *f, int func, daddr_t dblk,
     size_t size, void *buf, size_t *rsize)
 {
-	u_int	pfnum, mapnr, nsize;
 
 #ifdef DEV_DEBUG
 	printf("rastrategy: buf %p remap %d is_tmscp %d\n",
 	    buf, remap, is_tmscp);
 #endif
-	if (remap) {
-		pfnum = (u_int)buf >> VAX_PGSHIFT;
 
-		for(mapnr = 0, nsize = size; (nsize + VAX_NBPG) > 0;
-		    nsize -= VAX_NBPG)
-			mapregs[mapnr++] = PG_V | pfnum++;
-		uda.uda_cmd.mscp_seq.seq_buffer = ((u_int)buf) & 0x1ff;
-	} else
-		uda.uda_cmd.mscp_seq.seq_buffer = ((u_int)buf);
+	uda.uda_cmd.mscp_seq.seq_buffer = ubmap(0, (int)buf, size);
 
 	if (is_tmscp) {
 		int i;

Reply via email to