Diff for /np2/i386c/ia32/ia32.c between versions 1.6 and 1.16

version 1.6, 2004/01/23 14:33:26 version 1.16, 2004/06/15 13:50:13
Line 34 Line 34
   
 I386CORE        i386core;  I386CORE        i386core;
   
 BYTE iflags[] = {  UINT8   *reg8_b20[0x100];
         0x44, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00,  UINT8   *reg8_b53[0x100];
         0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04,  UINT16  *reg16_b20[0x100];
         0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04,  UINT16  *reg16_b53[0x100];
         0x04, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00,  UINT32  *reg32_b20[0x100];
         0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04,  UINT32  *reg32_b53[0x100];
         0x04, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00,  
         0x04, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00,  
         0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04,  
         0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04,  
         0x04, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00,  
         0x04, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00,  
         0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04,  
         0x04, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00,  
         0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04,  
         0x00, 0x04, 0x04, 0x00, 0x04, 0x00, 0x00, 0x04,  
         0x04, 0x00, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00,  
         0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84,  
         0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80,  
         0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80,  
         0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84,  
         0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80,  
         0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84,  
         0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84,  
         0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80,  
         0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80,  
         0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84,  
         0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84,  
         0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80,  
         0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84,  
         0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80,  
         0x84, 0x80, 0x80, 0x84, 0x80, 0x84, 0x84, 0x80,  
         0x80, 0x84, 0x84, 0x80, 0x84, 0x80, 0x80, 0x84,  
 };  
   
 BYTE    *reg8_b20[0x100];  
 BYTE    *reg8_b53[0x100];  
 WORD    *reg16_b20[0x100];  
 WORD    *reg16_b53[0x100];  
 DWORD   *reg32_b20[0x100];  
 DWORD   *reg32_b53[0x100];  
   
   
 void  void
Line 83  ia32_init(void) Line 48  ia32_init(void)
         int i;          int i;
   
         memset(&i386core.s, 0, sizeof(i386core.s));          memset(&i386core.s, 0, sizeof(i386core.s));
         CPU_STATSAVE.cpu_inst_default.seg_base = (DWORD)-1;          ia32_initreg();
   
         CPU_EDX = (CPU_FAMILY << 8) | (CPU_MODEL << 4) | CPU_STEPPING;  
         CPU_EFLAG = 2;  
         CPU_CR0 = CPU_CR0_CD | CPU_CR0_NW | CPU_CR0_ET;  
         CPU_MXCSR = 0x1f80;  
         CPU_GDTR_LIMIT = 0xffff;  
         CPU_IDTR_LIMIT = 0xffff;  
   
         for (i = 0; i < CPU_SEGREG_NUM; ++i) {  
                 CPU_STAT_SREG_INIT(i);  
         }  
         CPU_LDTR_LIMIT = 0xffff;  
         CPU_TR_LIMIT = 0xffff;  
   
         for (i = 0; i < 0x100; ++i) {          for (i = 0; i < 0x100; ++i) {
                 /* 8bit */                  /* 8bit */
Line 126  ia32_init(void) Line 78  ia32_init(void)
         }          }
   
         resolve_init();          resolve_init();
 #if defined(IA32_SUPPORT_TLB)  
         tlb_init();  
 #endif  
 #ifdef USE_FPU  #ifdef USE_FPU
         fpu_init();          fpu_init();
 #endif  #endif
 }  }
   
   void
   ia32_setextsize(UINT32 size)
   {
   
           if (CPU_EXTMEMSIZE != size) {
                   if (CPU_EXTMEM) {
                           _MFREE(CPU_EXTMEM);
                           CPU_EXTMEM = NULL;
                   }
                   if (size) {
                           CPU_EXTMEM = (BYTE *)_MALLOC(size + 16, "EXTMEM");
                           if (CPU_EXTMEM == NULL) {
                                   size = 0;
                           }
                           ZeroMemory(CPU_EXTMEM, size + 16);
                   }
                   CPU_EXTMEMSIZE = size;
           }
           CPU_EMSPTR[0] = mem + 0xc0000;
           CPU_EMSPTR[1] = mem + 0xc4000;
           CPU_EMSPTR[2] = mem + 0xc8000;
           CPU_EMSPTR[3] = mem + 0xcc000;
   }
   
   void
   ia32_setemm(UINT frame, UINT32 addr) {
   
           BYTE    *ptr;
   
           frame &= 3;
           if (addr < USE_HIMEM) {
                   ptr = mem + addr;
           }
           else if ((addr - 0x100000 + 0x4000) <= CPU_EXTMEMSIZE) {
                   ptr = CPU_EXTMEM + (addr - 0x100000);
           }
           else {
                   ptr = mem + 0xc0000 + (frame << 14);
           }
           CPU_EMSPTR[frame] = ptr;
   }
   
   
 /*  /*
  * モード遷移   * モード遷移
  */   */
Line 156  change_pm(BOOL onoff) Line 148  change_pm(BOOL onoff)
             CPU_STATSAVE.cpu_inst_default.op_32 =               CPU_STATSAVE.cpu_inst_default.op_32 = 
             CPU_STATSAVE.cpu_inst_default.as_32 = 0;              CPU_STATSAVE.cpu_inst_default.as_32 = 0;
         CPU_STAT_SS32 = 0;          CPU_STAT_SS32 = 0;
         CPU_STAT_CPL = 0;          CPU_SET_CPL(0);
         CPU_STAT_PM = onoff;          CPU_STAT_PM = onoff;
 }  }
   
Line 180  change_vm(BOOL onoff) Line 172  change_vm(BOOL onoff)
         CPU_STAT_VM86 = onoff;          CPU_STAT_VM86 = onoff;
         if (onoff) {          if (onoff) {
                 for (i = 0; i < CPU_SEGREG_NUM; i++) {                  for (i = 0; i < CPU_SEGREG_NUM; i++) {
                           CPU_STAT_SREGLIMIT(i) = 0xffff;
                         CPU_SET_SEGREG(i, CPU_REGS_SREG(i));                          CPU_SET_SEGREG(i, CPU_REGS_SREG(i));
                 }                  }
                 CPU_INST_OP32 = CPU_INST_AS32 =                  CPU_INST_OP32 = CPU_INST_AS32 =
                     CPU_STATSAVE.cpu_inst_default.op_32 =                      CPU_STATSAVE.cpu_inst_default.op_32 =
                     CPU_STATSAVE.cpu_inst_default.as_32 = 0;                      CPU_STATSAVE.cpu_inst_default.as_32 = 0;
                 CPU_STAT_SS32 = 0;                  CPU_STAT_SS32 = 0;
                 CPU_STAT_CPL = 3;                  CPU_SET_CPL(3);
                 VERBOSE(("Entering to Virtual-8086-Mode..."));                  VERBOSE(("Entering to Virtual-8086-Mode..."));
         } else {          } else {
                 VERBOSE(("Leaveing from Virtual-8086-Mode..."));                  VERBOSE(("Leaveing from Virtual-8086-Mode..."));
         }          }
 }  }
   
   #if !defined(IA32_DONT_USE_SET_EFLAGS_FUNCTION)
 /*  /*
  * flags   * flags
  */   */
 static void  static void
 modify_eflags(DWORD new_flags, DWORD mask)  modify_eflags(UINT32 new_flags, UINT32 mask)
 {  {
         DWORD orig = CPU_EFLAG;          UINT32 orig = CPU_EFLAG;
   
         new_flags &= ALL_EFLAG;          new_flags &= ALL_EFLAG;
         mask &= ALL_EFLAG;          mask &= ALL_EFLAG;
         CPU_EFLAG = (REAL_EFLAGREG & ~mask) | (new_flags & mask) | 0x2;          CPU_EFLAG = (REAL_EFLAGREG & ~mask) | (new_flags & mask);
   
         CPU_OV = CPU_FLAG & O_FLAG;          CPU_OV = CPU_FLAG & O_FLAG;
         CPU_TRAP = (CPU_FLAG & (I_FLAG|T_FLAG)) == (I_FLAG|T_FLAG);          CPU_TRAP = (CPU_FLAG & (I_FLAG|T_FLAG)) == (I_FLAG|T_FLAG);
         if ((orig ^ CPU_EFLAG) & VM_FLAG) {          if (CPU_STAT_PM) {
                 if (CPU_EFLAG & VM_FLAG) {                  if ((orig ^ CPU_EFLAG) & VM_FLAG) {
                         change_vm(1);                          if (CPU_EFLAG & VM_FLAG) {
                 } else {                                  change_vm(1);
                         change_vm(0);                          } else {
                                   change_vm(0);
                           }
                 }                  }
         }          }
 }  }
   
 void  void
 set_flags(WORD new_flags, WORD mask)  set_flags(UINT16 new_flags, UINT16 mask)
 {  {
   
         mask &= I_FLAG|IOPL_FLAG;          mask &= I_FLAG|IOPL_FLAG;
Line 226  set_flags(WORD new_flags, WORD mask) Line 222  set_flags(WORD new_flags, WORD mask)
 }  }
   
 void  void
 set_eflags(DWORD new_flags, DWORD mask)  set_eflags(UINT32 new_flags, UINT32 mask)
 {  {
   
         mask &= I_FLAG|IOPL_FLAG|RF_FLAG|VM_FLAG|VIF_FLAG|VIP_FLAG;          mask &= I_FLAG|IOPL_FLAG|RF_FLAG|VM_FLAG|VIF_FLAG|VIP_FLAG;
Line 234  set_eflags(DWORD new_flags, DWORD mask) Line 230  set_eflags(DWORD new_flags, DWORD mask)
         mask |= AC_FLAG|ID_FLAG;          mask |= AC_FLAG|ID_FLAG;
         modify_eflags(new_flags, mask);          modify_eflags(new_flags, mask);
 }  }
   #endif  /* !IA32_DONT_USE_SET_EFLAGS_FUNCTION */

Removed from v.1.6  
changed lines
  Added in v.1.16


RetroPC.NET-CVS <cvs@retropc.net>