changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: bcm64: reorganize virtual memory map for rapberry pi4

changeset 7317: 406bef7018a8
parent 7316: 234f51ace8cd
child 7318: 386fe43162b4
author: cinap_lenrek@felloff.net
date: Thu, 25 Jul 2019 09:10:07 +0200
files: sys/src/9/bcm64/mem.h sys/src/9/bcm64/mkfile
description: bcm64: reorganize virtual memory map for rapberry pi4
     1.1--- a/sys/src/9/bcm64/mem.h
     1.2+++ b/sys/src/9/bcm64/mem.h
     1.3@@ -5,11 +5,6 @@
     1.4 #define MiB		1048576u		/* Mebi 0x0000000000100000 */
     1.5 #define GiB		1073741824u		/* Gibi 000000000040000000 */
     1.6 
     1.7-#define	HOWMANY(x,y)	(((x)+((y)-1))/(y))
     1.8-#define	ROUNDUP(x,y)	(HOWMANY((x),(y))*(y))
     1.9-#define	PGROUND(s)	ROUNDUP(s, BY2PG)
    1.10-#define	ROUND(s, sz)	(((s)+(sz-1))&~(sz-1))
    1.11-
    1.12 /*
    1.13  * Sizes:
    1.14  * 	L0	L1	L2	L3
    1.15@@ -19,19 +14,21 @@
    1.16  */
    1.17 #define	PGSHIFT		16		/* log(BY2PG) */
    1.18 #define	BY2PG		(1ULL<<PGSHIFT)	/* bytes per page */
    1.19+#define	ROUND(s, sz)	(((s)+(sz-1))&~(sz-1))
    1.20+#define	PGROUND(s)	ROUND(s, BY2PG)
    1.21 
    1.22 /* effective virtual address space */
    1.23-#define EVASHIFT	33
    1.24+#define EVASHIFT	34
    1.25 #define EVAMASK		((1ULL<<EVASHIFT)-1)
    1.26 
    1.27 #define PTSHIFT		(PGSHIFT-3)
    1.28-#define PTLEVELS	HOWMANY(EVASHIFT-PGSHIFT, PTSHIFT)
    1.29+#define PTLEVELS	(((EVASHIFT-PGSHIFT)+PTSHIFT-1)/PTSHIFT)	
    1.30 #define PTLX(v, l)	((((v) & EVAMASK) >> (PGSHIFT + (l)*PTSHIFT)) & ((1 << PTSHIFT)-1))
    1.31 #define PGLSZ(l)	(1ULL << (PGSHIFT + (l)*PTSHIFT))
    1.32 
    1.33 #define PTL1X(v, l)	(L1TABLEX(v, l) | PTLX(v, l))
    1.34 #define L1TABLEX(v, l)	(L1TABLE(v, l) << PTSHIFT)
    1.35-#define L1TABLES	HOWMANY(-KSEG0, PGLSZ(2))
    1.36+#define L1TABLES	((-KSEG0+PGLSZ(2)-1)/PGLSZ(2))
    1.37 #define L1TABLE(v, l)	(L1TABLES - ((PTLX(v, 2) % L1TABLES) >> (((l)-1)*PTSHIFT)) + (l)-1)
    1.38 #define L1TOPSIZE	(1ULL << (EVASHIFT - PTLEVELS*PTSHIFT))
    1.39 
    1.40@@ -43,12 +40,18 @@
    1.41 #define TRAPFRAMESIZE	(38*8)
    1.42 
    1.43 #define KSEG0		(0xFFFFFFFF00000000ULL)
    1.44-#define VIRTIO		(0xFFFFFFFF3F000000ULL)	/* i/o registers */
    1.45-#define	ARMLOCAL	(0xFFFFFFFF40000000ULL)
    1.46-#define	KZERO		(0xFFFFFFFF80000000ULL)	/* kernel address space */
    1.47-#define FRAMEBUFFER	(0xFFFFFFFFC0000000ULL|PTEWT)
    1.48+#define FRAMEBUFFER	(0xFFFFFFFF00000000ULL|PTEWT)
    1.49 #define	VGPIO		0			/* virtual gpio for pi3 ACT LED */
    1.50 
    1.51+#define VIRTPCI		(0xFFFFFFFF80000000ULL) /* virtual pcie mmio */
    1.52+
    1.53+#define VIRTIO2		(0xFFFFFFFFBC000000ULL)	/* 0x7C000000	-		0xFC000000 */
    1.54+#define VIRTIO1		(0xFFFFFFFFBD000000ULL)	/* 0x7D000000	-		0xFD000000 */
    1.55+#define VIRTIO		(0xFFFFFFFFBE000000ULL) /* 0x7E000000	0x3F000000	0xFE000000 */
    1.56+#define	ARMLOCAL	(0xFFFFFFFFBF800000ULL)	/* -		0x40000000	0xFF800000 */
    1.57+
    1.58+#define	KZERO		(0xFFFFFFFFC0000000ULL)	/* kernel address space */
    1.59+
    1.60 #define SPINTABLE	(KZERO+0xd8)
    1.61 #define CONFADDR	(KZERO+0x100)
    1.62 #define	REBOOTADDR	(0x1c00)		/* reboot code - physical address */
    1.63@@ -127,7 +130,6 @@
    1.64  *	BUS  addresses as seen from the videocore gpu.
    1.65  */
    1.66 #define	PHYSDRAM	0
    1.67-#define	IOSIZE		(16*MiB)
    1.68 
    1.69 #define MIN(a, b)	((a) < (b)? (a): (b))
    1.70 #define MAX(a, b)	((a) > (b)? (a): (b))
     2.1--- a/sys/src/9/bcm64/mkfile
     2.2+++ b/sys/src/9/bcm64/mkfile
     2.3@@ -1,7 +1,7 @@
     2.4 CONF=pi3
     2.5 CONFLIST=pi3
     2.6 
     2.7-loadaddr=0xffffffff80080000
     2.8+loadaddr=0xffffffffc0080000
     2.9 
    2.10 objtype=arm64
    2.11 </$objtype/mkfile
    2.12@@ -107,8 +107,8 @@ main.$O: reboot.h
    2.13 devmouse.$O mouse.$O screen.$O: screen.h
    2.14 usbdwc.$O: dwcotg.h ../port/usb.h
    2.15 
    2.16-io.h:D:	../bcm/io.h
    2.17-	echo '#include "../bcm/io.h"' > io.h
    2.18+io.h:	../bcm/io.h
    2.19+	touch $target
    2.20 screen.h:D: ../bcm/screen.h
    2.21 	echo '#include "../bcm/screen.h"' > screen.h
    2.22 dwcotg.h:D: ../bcm/dwcotg.h
    2.23@@ -136,4 +136,4 @@ errstr.h:D:	../port/mkerrstr ../port/err
    2.24 	rc ../port/mkerrstr > errstr.h
    2.25 
    2.26 $CONF.clean:
    2.27-	rm -rf $p$CONF s$p$CONF errstr.h reboot.h io.h screen.h dwcotg.h $CONF.c boot$CONF.c
    2.28+	rm -rf $p$CONF s$p$CONF errstr.h reboot.h screen.h dwcotg.h $CONF.c boot$CONF.c