From bcf988aff1316d675b4353549197662e6f5d7b17 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Fri, 23 Aug 2019 21:39:20 +0200 Subject: bcm64: deal with discontinuous memory regions, avoid virtual memory aliasing, implement vmap() proper on the 2GB and 4GB raspberry pi 4 variants, there are two memory regions for ram: [0x00000000..0x3e600000) [0x40000000..0xfc000000) the framebuffer is somewhere at the end of the first GB of memory. to handle these, we append the region base and limit of the second region to *maxmem= like: *maxmem=0x3e600000 0x40000000 0xfc000000 the mmu code has been changed to have non-existing ram unmapped and mmukmap() now uses small 64K pages instead of 512GB pages to avoid aliasing (framebuffer). the VIRTPCI mapping has been removed as we now have a proper vmap() implementation which assigns vritual addresses automatically. --- sys/src/9/bcm/bootargs.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'sys/src/9/bcm') diff --git a/sys/src/9/bcm/bootargs.c b/sys/src/9/bcm/bootargs.c index d2304af0f..efb0183b5 100644 --- a/sys/src/9/bcm/bootargs.c +++ b/sys/src/9/bcm/bootargs.c @@ -11,7 +11,7 @@ static char *confname[MAXCONF]; static char *confval[MAXCONF]; static int nconf; -static char maxmem[11]; +static char maxmem[256]; static int findconf(char *k) @@ -89,13 +89,25 @@ beget4(uchar *p) static void devtreeprop(char *path, char *key, void *val, int len) { - if(strcmp(path, "/memory") == 0 && strcmp(key, "reg") == 0 && len == 3*4){ - if(findconf("*maxmem") < 0){ + if(strcmp(path, "/memory") == 0 && strcmp(key, "reg") == 0){ + if(findconf("*maxmem") < 0 && len > 0 && (len % (3*4)) == 0){ uvlong top; + uchar *p = val; + char *s; - top = (uvlong)beget4((uchar*)val)<<32 | beget4((uchar*)val+4); - top += beget4((uchar*)val+8); - snprint(maxmem, sizeof(maxmem), "%#llux", top); + top = (uvlong)beget4(p)<<32 | beget4(p+4); + top += beget4(p+8); + s = seprint(maxmem, &maxmem[sizeof(maxmem)], "%#llux", top); + p += 3*4; + len -= 3*4; + while(len > 0){ + top = (uvlong)beget4(p)<<32 | beget4(p+4); + s = seprint(s, &maxmem[sizeof(maxmem)], " %#llux", top); + top += beget4(p+8); + s = seprint(s, &maxmem[sizeof(maxmem)], " %#llux", top); + p += 3*4; + len -= 3*4; + } addconf("*maxmem", maxmem); } return; -- cgit v1.2.3