shithub: riscv

Download patch

ref: da6e5efe394ccb8e5edff66f9ec3ac8d9b1ed081
parent: 164588e3e2aca1f6deac1dd4bcf962a0867a26fc
author: aiju <devnull@localhost>
date: Tue Jun 20 14:20:25 EDT 2017

vmx(1): round up frame buffer size to whole pages, ignore vga access in linear framebuffer, tell openbsd about framebuffer

--- a/sys/src/cmd/vmx/ksetup.c
+++ b/sys/src/cmd/vmx/ksetup.c
@@ -555,6 +555,34 @@
 }
 
 static void
+obsdfb(void)
+{
+	int i, s, p;
+	u32int r, g, b, a, m;
+	extern VgaMode *curmode, textmode;
+	extern uintptr fbaddr, fbsz;
+
+	if(curmode == &textmode) return;
+	p = r = g = b = a = 0;
+	for(i = 0; i < 4; i++){
+		s = curmode->chan >> 8 * i & 0xf;
+		if(s == 0) continue;
+		m = (1<<s)-1 << p;
+		p += s;
+		switch(curmode->chan >> 4 + 8 * i & 0xf){
+		case CRed: r |= m; break;
+		case CGreen: g |= m; break;
+		case CBlue: b |= m; break;
+		case CAlpha: case CIgnore: a |= m; break;
+		default: return;
+		}
+	}
+	obsdstart(BOOTARG_EFIINFO);
+	obsdpack("vvvviiiiiii", 0ULL, 0ULL, (uvlong)fbaddr, (uvlong)fbsz, curmode->h, curmode->w, curmode->w, r, g, b, a);
+	obsdend();
+}
+
+static void
 obsdargs(void)
 {
 	Region *r;
@@ -572,6 +600,7 @@
 	if(obsddbcons != -1){
 		obsdstart(BOOTARG_DDB); obsdpack("i", obsddbcons); obsdend();
 	}
+	obsdfb();
 	obsdstart(BOOTARG_END); obsdend();
 }
 
--- a/sys/src/cmd/vmx/vga.c
+++ b/sys/src/cmd/vmx/vga.c
@@ -17,6 +17,7 @@
 VgaMode *curmode, *nextmode, *modes, **modeslast = &modes;
 int curhbytes, nexthbytes;
 int vesamode, maxw, maxh;
+int novga;
 
 VgaMode textmode = {
 	.w 640, .h 400, .no 3
@@ -152,6 +153,8 @@
 {
 	u32int m;
 
+	if(novga)
+		return 0;
 	if(port == 0x3d4 && sz == 2 && !isin){
 		vgaio(0, 0x3d4, (u8int)val, 1, nil);
 		return vgaio(0, 0x3d5, (u8int)(val >> 8), 1, nil);
@@ -691,6 +694,8 @@
 	if(vesamode == 0){
 		curmode = modes;
 		curhbytes = curmode->hbytes;
+		fbsz = -(-fbsz & -4096);
+		novga = 1;
 	}else{
 		curmode = &textmode;
 		if(fbsz < (1<<22))