Browse Source

vga: move to using a 386 ureg struct

The correct operation of vesa pretty much demands it.

Change-Id: I6bd4e20bdb1e18328965886282ee78c617a2458a
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Ronald G. Minnich 8 years ago
parent
commit
122a5f8170
4 changed files with 36 additions and 36 deletions
  1. 20 20
      386/include/ureg.h
  2. 5 9
      sys/src/9/386/vgavesa.c
  3. 8 7
      sys/src/cmd/aux/realemu/main.c
  4. 3 0
      sys/src/cmd/aux/realemu/realemu.json

+ 20 - 20
386/include/ureg.h

@@ -9,26 +9,26 @@
 
 struct Ureg
 {
-	ulong	di;		/* general registers */
-	ulong	si;		/* ... */
-	ulong	bp;		/* ... */
-	ulong	nsp;
-	ulong	bx;		/* ... */
-	ulong	dx;		/* ... */
-	ulong	cx;		/* ... */
-	ulong	ax;		/* ... */
-	ulong	gs;		/* data segments */
-	ulong	fs;		/* ... */
-	ulong	es;		/* ... */
-	ulong	ds;		/* ... */
-	ulong	trap;		/* trap type */
-	ulong	ecode;		/* error code (or zero) */
-	ulong	pc;		/* pc */
-	ulong	cs;		/* old context */
-	ulong	flags;		/* old flags */
+	uint32_t	di;		/* general registers */
+	uint32_t	si;		/* ... */
+	uint32_t	bp;		/* ... */
+	uint32_t	nsp;
+	uint32_t	bx;		/* ... */
+	uint32_t	dx;		/* ... */
+	uint32_t	cx;		/* ... */
+	uint32_t	ax;		/* ... */
+	uint32_t	gs;		/* data segments */
+	uint32_t	fs;		/* ... */
+	uint32_t	es;		/* ... */
+	uint32_t	ds;		/* ... */
+	uint32_t	trap;		/* trap type */
+	uint32_t	ecode;		/* error code (or zero) */
+	uint32_t	pc;		/* pc */
+	uint32_t	cs;		/* old context */
+	uint32_t	flags;		/* old flags */
 	union {
-		ulong	usp;
-		ulong	sp;
+		uint32_t	usp;
+		uint32_t	sp;
 	};
-	ulong	ss;		/* old stack segment */
+	uint32_t	ss;		/* old stack segment */
 };

+ 5 - 9
sys/src/9/386/vgavesa.c

@@ -13,6 +13,7 @@
  * note that setting hwaccel to zero will cause cursor ghosts to be
  * left behind.  hwaccel set non-zero repairs this.
  */
+/* ensure an error here if there is a problem. */
 #include "u.h"
 #include "../port/lib.h"
 #include "mem.h"
@@ -20,7 +21,7 @@
 #include "fns.h"
 #include "io.h"
 #include "../port/error.h"
-#include "ureg.h"
+#include "../../386/include/ureg.h"
 
 #define	Image	IMAGE
 #include <draw.h>
@@ -55,13 +56,8 @@ vbesetup(Ureg *u, int ax)
 	memset(modebuf, 0, sizeof modebuf);
 	memset(u, 0, sizeof *u);
 	u->ax = ax;
-	/* here's the trick to avoid es. We know the real mode
-	 * ip is 16 bits. So we'll drop the segment in the high order 16 bits of the low 32 bits.
-	 * We can fix it up in the external emulator. 
-	 */
-	//u->es = (pa>>4)&0xF000;
-	//u->di = pa&0xFFFF;
-	u->di = pa;
+	u->es = (pa>>4)&0xF000;
+	u->di = pa&0xFFFF;
 	return modebuf;
 }
 
@@ -84,7 +80,7 @@ vbecall(Ureg *u)
 	}
 	pa = PADDR(RMBUF);
 	cmem->dev->write(cmem, modebuf, sizeof modebuf, pa);
-	u->type = 0x10;
+	u->trap = 0x10;
 	creg->dev->write(creg, u, sizeof *u, 0);
 
 	creg->dev->read(creg, u, sizeof *u, 0);

+ 8 - 7
sys/src/cmd/aux/realemu/main.c

@@ -9,7 +9,7 @@
 #include <thread.h>
 #include <9p.h>
 
-#include <ureg.h>
+#include <386/include/ureg.h>
 
 enum {
 	MEMSIZE = 0x100000,
@@ -448,7 +448,7 @@ realmode(Cpu *cpu, struct Ureg *u, void *r)
 		cpu->reg[RSS] = GETUREG(ss);
 		cpu->reg[RSP] = GETUREG(sp);
 		cpu->reg[RCS] = GETUREG(cs);
-		cpu->reg[RIP] = GETUREG(ip);
+		cpu->reg[RIP] = GETUREG(pc);
 //	}
 
 	startclock();
@@ -518,14 +518,14 @@ realmode(Cpu *cpu, struct Ureg *u, void *r)
 	PUTUREG(cx, cpu->reg[RCX]);
 	PUTUREG(ax, cpu->reg[RAX]);
 
-//	PUTUREG(gs, cpu->reg[RGS]);
-//	PUTUREG(fs, cpu->reg[RFS]);
-//	PUTUREG(es, cpu->reg[RES]);
-//	PUTUREG(ds, cpu->reg[RDS]);
+	PUTUREG(gs, cpu->reg[RGS]);
+	PUTUREG(fs, cpu->reg[RFS]);
+	PUTUREG(es, cpu->reg[RES]);
+	PUTUREG(ds, cpu->reg[RDS]);
 
 	PUTUREG(flags, cpu->reg[RFL]);
 
-	PUTUREG(ip, cpu->reg[RIP]);
+	PUTUREG(pc, cpu->reg[RIP]);
 	PUTUREG(cs, cpu->reg[RCS]);
 	PUTUREG(sp, cpu->reg[RSP]);
 	PUTUREG(ss, cpu->reg[RSS]);
@@ -740,6 +740,7 @@ cpuproc(void *data)
 
 		case (Twrite<<8) | Qcall:
 			if(n != sizeof rmu){
+				fprint(2, "n is %d, sizeof(rmu) %d: %s\n", n, sizeof(rmu), Ebadureg);
 				respond(r, Ebadureg);
 				break;
 			}

+ 3 - 0
sys/src/cmd/aux/realemu/realemu.json

@@ -1,5 +1,8 @@
 {
 	"realemu": {
+		"Cflags": [
+			"-I", "/"
+		],
 		"Include": [
 			"../../cmd.json"
 		],