Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/i386 Handle instruction prefixes (skip them, i...



details:   https://anonhg.NetBSD.org/src/rev/d65328a86198
branches:  trunk
changeset: 472117:d65328a86198
user:      fvdl <fvdl%NetBSD.org@localhost>
date:      Thu Apr 22 00:23:33 1999 +0000

description:
Handle instruction prefixes (skip them, in our case).

diffstat:

 sys/arch/i386/i386/math_emu.h     |  17 +++++++++++++-
 sys/arch/i386/i386/math_emulate.c |  47 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 61 insertions(+), 3 deletions(-)

diffs (100 lines):

diff -r f39023e425eb -r d65328a86198 sys/arch/i386/i386/math_emu.h
--- a/sys/arch/i386/i386/math_emu.h     Wed Apr 21 22:14:15 1999 +0000
+++ b/sys/arch/i386/i386/math_emu.h     Thu Apr 22 00:23:33 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: math_emu.h,v 1.5 1995/05/03 00:17:16 mycroft Exp $     */
+/*     $NetBSD: math_emu.h,v 1.6 1999/04/22 00:23:33 fvdl Exp $        */
 
 /*
  * linux/include/linux/math_emu.h
@@ -103,6 +103,21 @@
 #define set_C2() (I387.swd |= 0x0400)
 #define set_C3() (I387.swd |= 0x4000)
 
+#define INSPREF_LOCK   0xf0
+#define INSPREF_REPN   0xf2
+#define INSPREF_REPE   0xf3
+
+#define INSPREF_CS     0x2e
+#define INSPREF_SS     0x36
+#define INSPREF_DS     0x3e
+#define INSPREF_ES     0x26
+#define INSPREF_FS     0x64
+#define INSPREF_GS     0x65
+
+#define INSPREF_OSIZE  0x66
+#define INSPREF_ASIZE  0x67
+
+
 /* ea.c */
 
 char * ea(struct trapframe *, unsigned short);
diff -r f39023e425eb -r d65328a86198 sys/arch/i386/i386/math_emulate.c
--- a/sys/arch/i386/i386/math_emulate.c Wed Apr 21 22:14:15 1999 +0000
+++ b/sys/arch/i386/i386/math_emulate.c Thu Apr 22 00:23:33 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: math_emulate.c,v 1.20 1998/01/24 13:19:53 mycroft Exp $        */
+/*     $NetBSD: math_emulate.c,v 1.21 1999/04/22 00:23:33 fvdl Exp $   */
 
 /*
  * expediant "port" of linux 8087 emulator to 386BSD, with apologies -wfj
@@ -76,6 +76,10 @@
        temp_real tmp;
        char * address;
        u_long oldeip;
+       int override_seg, override_addrsize, override_datasize;
+       int prefix;
+
+       override_seg = override_addrsize = override_datasize = 0;
 
        if (!USERMODE(info->tf_cs, info->tf_eflags))
                panic("math emulator called from supervisor mode");
@@ -94,8 +98,47 @@
                I387.swd &= 0x7fff;
 
        I387.fip = oldeip = info->tf_eip;
+
+       /*
+        * Scan for instruction prefixes. More to be politically correct
+        * than anything else. Prefixes aren't useful for the instructions
+        * we can emulate anyway.
+        */
+       while (1) {
+               prefix = fubyte((const void *)info->tf_eip);
+               switch (prefix) {
+               case INSPREF_LOCK:
+                       math_abort(info, SIGILL);
+                       break;
+               case INSPREF_REPN:
+               case INSPREF_REPE:
+                       break;
+               case INSPREF_CS:
+               case INSPREF_SS:
+               case INSPREF_DS:
+               case INSPREF_ES:
+               case INSPREF_FS:
+               case INSPREF_GS:
+                       override_seg = prefix;
+                       break;
+               case INSPREF_OSIZE:
+                       override_datasize = prefix;     
+                       break;
+               case INSPREF_ASIZE:
+                       override_addrsize = prefix;
+                       break;
+               case -1:
+                       math_abort(info,SIGSEGV);
+                       break;
+               default:
+                       goto done;
+               }
+               info->tf_eip++;
+       }
+
+done:
+       code = htons(fusword((u_short *) info->tf_eip)) & 0x7ff;
        info->tf_eip += 2;
-       code = htons(fusword((u_short *) oldeip)) & 0x7ff;
        *((u_short *) &I387.fcs) = (u_short) info->tf_cs;
        *((u_short *) &I387.fcs + 1) = code;
 



Home | Main Index | Thread Index | Old Index