shithub: riscv

Download patch

ref: f5d1fce9b56143ac90ef0c1c4388ee502f44cfed
parent: d7120ecb77c22496678e2352ed3782b411215118
author: Sigrid <[email protected]>
date: Thu Dec 10 07:19:45 EST 2020

vmx: clean up mksegment, memset only if segment existed (devsegment clears new ones)

--- a/sys/src/cmd/vmx/vmx.c
+++ b/sys/src/cmd/vmx/vmx.c
@@ -320,9 +320,6 @@
 	return (u8int *) v + gavail(v);
 }
 
-void *tmp, *vgamem;
-uvlong tmpoff, vgamemoff;
-
 static void
 mksegment(char *sn)
 {
@@ -355,8 +352,9 @@
 		close(fd);
 		gmem = segattach(0, sn, nil, sz);
 		if(gmem == (void*)-1) sysfatal("segattach: %r");
+	}else{
+		memset(gmem, 0, sz > 1<<24 ? 1<<24 : sz);
 	}
-	memset(gmem, 0, sz > 1<<24 ? 1<<24 : sz);
 	p = gmem;
 	for(r = mmap; r != nil; r = r->next){
 		if(r->segname == nil) continue;
@@ -365,14 +363,12 @@
 		p += r->end - r->start;
 		r->ve = p;
 	}
-	vgamem = p;
-	vgamemoff = p - gmem;
-	regptr(0xa0000)->segoff = vgamemoff;
-	regptr(0xa0000)->v = vgamem;
+	/* vga */
+	r = regptr(0xa0000);
+	r->segoff = p - gmem;
+	r->v = p;
 	p += 256*1024;
-	regptr(0xa0000)->ve = p;
-	tmp = p;
-	tmpoff = p - gmem;
+	r->ve = p;
 
 	for(r = mmap; r != nil; r = r->next)
 		modregion(r);