shithub: riscv

Download patch

ref: 1046d3e30be09d7f1f07bf0a49f0e32584e86874
parent: 5a934b56f59f2cc0c7a700618a3f8211541c1bcd
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Wed May 8 22:17:50 EDT 2019

bcm64: map framebuffer write-through to allow unaligned access

--- a/sys/src/9/bcm64/mem.h
+++ b/sys/src/9/bcm64/mem.h
@@ -63,7 +63,7 @@
 #define MACHADDR(n)	(KTZERO-((n)+1)*MACHSIZE)
 
 #define	KTZERO		(KZERO+0x80000)		/* kernel text start */
-#define FRAMEBUFFER	0xFFFFFFFFC0000000ULL
+#define FRAMEBUFFER	(0xFFFFFFFFC0000000ULL | PTEWT)
 #define VIRTIO		0xFFFFFFFFE0000000ULL	/* i/o registers */
 #define	ARMLOCAL	(VIRTIO+IOSIZE)
 #define	VGPIO		0			/* virtual gpio for pi3 ACT LED */
@@ -125,7 +125,7 @@
 
 #define PTEWT		PTEMA(MA_MEM_WT)
 #define	PTEUNCACHED	PTEMA(MA_MEM_UC)
-#define	PTEDEVICE	PTEMA(MA_DEV_nGnRnE)
+#define	PTEDEVICE	PTEMA(MA_DEV_nGnRE)
 
 /*
  * Physical machine information from here on.
--- a/sys/src/9/bcm64/mmu.c
+++ b/sys/src/9/bcm64/mmu.c
@@ -124,18 +124,19 @@
 uintptr
 mmukmap(uintptr va, uintptr pa, usize size)
 {
-	uintptr a, pe, off;
+	uintptr a, pe, off, attr;
 
 	if(va == 0)
 		return 0;
 
-	assert((va % PGLSZ(1)) == 0);
+	attr = va & PTEMA(7);
+	va &= -PGLSZ(1);
 	off = pa % PGLSZ(1);
 	a = va + off;
 	pe = (pa + size + (PGLSZ(1)-1)) & -PGLSZ(1);
 	while(pa < pe){
 		((uintptr*)L1)[PTL1X(va, 1)] = pa | PTEVALID | PTEBLOCK | PTEWRITE | PTEAF
-			| PTEKERNEL | PTESH(SHARE_OUTER) | PTEDEVICE;
+			| PTEKERNEL | PTESH(SHARE_OUTER) | attr;
 		pa += PGLSZ(1);
 		va += PGLSZ(1);
 	}