Hi

Freedos floppy image was failing when I tried to boot it, because INSB 
instruction is not emulated. So by looking at INSW logic in io.c, I have
added the following emulation for INSB instruction. This is my first
attempt at adding instructions to Plex86, so I maybe wrong. 

If Kevin, or anyone else who knows about adding instructions to plex86 can
tell if what I have added is right or wrong, it will be very useful. 

However the booting problem in Freedos is still not solved, as It is
failing in dma and I have forgotten about 8237 dma controller, to try and
identify as to what the exact problem is with the DMA error. Or is it that
I am not emulating INSB properly, which inturn is affecting the DMA logic
indirectly or so.


The PATCH follows

diff -Naur plex86/kernel/emulation/emulation.c plex86.han/kernel/emulation/emulation.c
--- plex86/kernel/emulation/emulation.c Tue Nov 21 14:31:09 2000
+++ plex86.han/kernel/emulation/emulation.c     Wed Nov 22 14:32:43 2000
@@ -587,6 +587,10 @@
     case 0x6a: /* PUSH_Ib (byte extended to word or dword) */
       PUSH_Iv(vm);
       goto advance;
+      
+    case 0x6c:
+      INSB_YbDX(vm);
+      goto advance;
 
     case 0x6d:
       INSW_YvDX(vm);
diff -Naur plex86/kernel/emulation/io.c plex86.han/kernel/emulation/io.c
--- plex86/kernel/emulation/io.c        Tue Nov 21 11:10:58 2000
+++ plex86.han/kernel/emulation/io.c    Wed Nov 22 14:38:17 2000
@@ -24,6 +24,48 @@
 #include "monitor.h"
 
 
+  void
+INSB_YbDX(vm_t *vm)
+  /* input byte from port to string */
+{
+  Bit32u edi;
+  unsigned int incr;
+  Bit8u value8=0;
+
+  if (vm->i.as_32)
+    edi = G_EDI(vm);
+  else
+    edi = G_DI(vm);
+
+  IOPermCheck(vm, G_DX(vm), 1);
+
+  /* Write a zero to memory, to trigger any segment or page */
+  /* faults before reading from IO port. */
+  write_virtual_byte(vm, SRegES, edi, &value8);
+
+  value8 = sysIOIn(vm, G_DX(vm), 1);
+  /* Not working ???
+  monprint("IOport: %d Value: %d\n",G_DX(vm),value8);
+  */
+
+  /* no seg override allowed */
+  write_virtual_byte(vm, SRegES, edi, &value8);
+  incr = 1;
+
+  if (vm->i.as_32) {
+    if (G_GetDF(vm))
+      G_EDI(vm) -= incr;
+    else
+      G_EDI(vm) += incr;
+    }
+  else {
+    if (G_GetDF(vm))
+      G_DI(vm) -= incr;
+    else
+      G_DI(vm) += incr;
+    }
+}
+
 
   void
 INSW_YvDX(vm_t *vm)
diff -Naur plex86/kernel/include/emulation.h plex86.han/kernel/include/emulation.h
--- plex86/kernel/include/emulation.h   Tue Nov 21 14:31:09 2000
+++ plex86.han/kernel/include/emulation.h       Wed Nov 22 13:38:56 2000
@@ -143,6 +143,7 @@
 void LODSB_ALXb(vm_t *);
 void TEST_EbIb(vm_t *);
 void LOOP_Jb(vm_t *);
+void INSB_YbDX(vm_t *);
 void INSW_YvDX(vm_t *);
 void CALL16_Ep(vm_t *);
 void CALL_Ew(vm_t *);



---------
Keep :-)
HanishKVC
http://www.hanishkvc.com/



Reply via email to