code: plan9front

Download patch

ref: 8f8c2d67796e8da8a3f8d3e86849b07182a96697
parent: ca123ae36601fe3015c7ed745910358c562e031a
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Tue May 19 10:02:02 EDT 2015

aux/vga: dont use /proc/$pid/mem to access vga bios

using /proc/$pid/mem to access vga bios is not portable and crashes
sgi machines when aux/vga is run. instead, try /dev/realmodemem
first (provided by realemu), then #v/vgabios.

--- a/sys/src/cmd/aux/vga/io.c
+++ b/sys/src/cmd/aux/vga/io.c
@@ -12,7 +12,6 @@
 static int iolfd = -1;
 static int biosfd = -1;
 static int msrfd = -1;
-static ulong biosoffset = 0;
 
 enum {
 	Nctlchar	= 256,
@@ -243,20 +242,13 @@
 static long
 doreadbios(char* buf, long len, long offset)
 {
-	char file[64];
-
-	if(biosfd == -1){
-		biosfd = open("#v/vgabios", OREAD);
-		biosoffset = 0;
-	}
-	if(biosfd == -1){
-		snprint(file, sizeof file, "#p/%d/mem", getpid());
-		biosfd = devopen(file, OREAD);
-		biosoffset = 0x80000000;
-	}
-	if(biosfd == -1)
+	if(biosfd < 0)
+		biosfd = open("/dev/realmodemem", OREAD);
+	if(biosfd < 0)
+		biosfd = devopen("#v/vgabios", OREAD);
+	if(biosfd < 0)
 		return -1;
-	seek(biosfd, biosoffset+offset, 0);
+	seek(biosfd, offset, 0);
 	return read(biosfd, buf, len);
 }