OSDN Git Service

[VM][I386_NP21] Make some functions inline to resolve bottole-neck of memory access.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 23 Jun 2020 16:45:22 +0000 (01:45 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Tue, 23 Jun 2020 16:45:22 +0000 (01:45 +0900)
source/src/vm/np21/i386c/cpumem.cpp
source/src/vm/np21/i386c/cpumem.h
source/src/vm/np21/i386c/ia32/cpu.h
source/src/vm/np21/i386c/ia32/cpu_mem.cpp
source/src/vm/np21/i386c/ia32/ia32.cpp

index d3494c7..790d9bc 100644 (file)
@@ -1,4 +1,5 @@
 //#include     "compiler.h"
+
 #if 1
 #undef TRACEOUT
 #define USE_TRACEOUT_VS
@@ -35,6 +36,7 @@ static void __FASTCALL trace_fmt_ex(const char *fmt, ...)
 #include       "i386hax/haxfunc.h"
 #include       "i386hax/haxcore.h"
 #endif
+#include "./cpumem.h"
 
 DEVICE *device_cpu = NULL;
 DEVICE *device_mem = NULL;
@@ -52,183 +54,10 @@ SINT32 __exception_set;
 UINT32 __exception_pc;
 UINT64 __exception_code;
 // ----
-REG8 MEMCALL memp_read8(UINT32 address) {
-       
-       address = address & CPU_ADRSMASK;
-       int wait = 0;
-       REG8 val;
-       val = device_mem->read_data8w(address, &wait);
-       i386_memory_wait += wait;
-       return val;
-}
-
-REG16 MEMCALL memp_read16(UINT32 address) {
-
-       address = address & CPU_ADRSMASK;
-       int wait = 0;
-       REG16 val;
-       val = device_mem->read_data16w(address, &wait);
-       i386_memory_wait += wait;
-       return val;
-//     return device_mem->read_data16(address);
-}
-
-UINT32 MEMCALL memp_read32(UINT32 address) {
-       address = address & CPU_ADRSMASK;
-       int wait = 0;
-       UINT32 val;
-       val = device_mem->read_data32w(address, &wait);
-       i386_memory_wait += wait;
-       return val;
-//     return device_mem->read_data32(address);
-}
-
-// ----
-REG8 MEMCALL memp_read8_codefetch(UINT32 address) {
-       
-       address = address & CPU_ADRSMASK;
-       int wait = 0;
-       REG8 val;
-       if(device_debugger != NULL) {
-               codefetch_address = address & CPU_ADRSMASK;
-               val = device_mem->read_data8w(codefetch_address, &wait);
-       } else {
-               val = device_mem->read_data8w(address, &wait);
-       }
-       i386_memory_wait += wait;
-       return val;
-//     return device_mem->read_data8(address);
-}
-
-REG16 MEMCALL memp_read16_codefetch(UINT32 address) {
-
-       address = address & CPU_ADRSMASK;
-       int wait = 0;
-       REG16 val;
-       if(device_debugger != NULL) {
-               codefetch_address = address & CPU_ADRSMASK;
-               val = device_mem->read_data16w(codefetch_address, &wait);
-       } else {
-               val = device_mem->read_data16w(address, &wait);
-       }
-       i386_memory_wait += wait;
-       return val;
-//     return device_mem->read_data16(address);
-}
-
-UINT32 MEMCALL memp_read32_codefetch(UINT32 address) {
-
-       address = address & CPU_ADRSMASK;
-       int wait = 0;
-       UINT32 val;
-       if(device_debugger != NULL) {
-               codefetch_address = address & CPU_ADRSMASK;
-               val = device_mem->read_data32w(codefetch_address, &wait);
-       } else {
-               val = device_mem->read_data32w(address, &wait);
-       }
-       i386_memory_wait += wait;
-       return val;
-//     return device_mem->read_data32(address);
-}
-
-// ----
-REG8 MEMCALL memp_read8_paging(UINT32 address) {
-       
-       return memp_read8_codefetch(address);
-}
-REG16 MEMCALL memp_read16_paging(UINT32 address) {
-       
-       return memp_read16_codefetch(address);
-}
-
-UINT32 MEMCALL memp_read32_paging(UINT32 address) {
-       
-       return memp_read32_codefetch(address);
-}
-
-void MEMCALL memp_write8(UINT32 address, REG8 value) {
-       
-       address = address & CPU_ADRSMASK;
-       int wait = 0;
-       device_mem->write_data8w(address, value, &wait);
-       i386_memory_wait += wait;
-}
-
-void MEMCALL memp_write16(UINT32 address, REG16 value) {
-       
-       address = address & CPU_ADRSMASK;
-       int wait = 0;
-       device_mem->write_data16w(address, value, &wait);
-       i386_memory_wait += wait;
-//     device_mem->write_data16(address, value);
-}
-
-void MEMCALL memp_write32(UINT32 address, UINT32 value) {
-       
-       address = address & CPU_ADRSMASK;
-       int wait = 0;
-       device_mem->write_data32w(address, value, &wait);
-       i386_memory_wait += wait;
-//     device_mem->write_data32(address, value);
-}
-
-void MEMCALL memp_write8_paging(UINT32 address, REG8 value) {
-       
-       address = address & CPU_ADRSMASK;
-       int wait = 0;
-       device_mem->write_data8w(address, value, &wait);
-       i386_memory_wait += wait;
-//     device_mem->write_data8(address, value);
-}
-
-void MEMCALL memp_write16_paging(UINT32 address, REG16 value) {
-       
-       address = address & CPU_ADRSMASK;
-       int wait = 0;
-       device_mem->write_data16w(address, value, &wait);
-       i386_memory_wait += wait;
-//     device_mem->write_data16(address, value);
-}
-
-void MEMCALL memp_write32_paging(UINT32 address, UINT32 value) {
-       
-       address = address & CPU_ADRSMASK;
-//     device_mem->write_data32(address, value);
-       int wait = 0;
-       device_mem->write_data32w(address, value, &wait);
-       i386_memory_wait += wait;
-}
-
-
-void MEMCALL memp_reads(UINT32 address, void *dat, UINT leng) {
-
-       UINT8 *out = (UINT8 *)dat;
-       
-       //address = address & CPU_ADRSMASK;
-
-       /* slow memory access */
-       while (leng-- > 0) {
-               *out++ = memp_read8(address++);
-       }
-}
-
-void MEMCALL memp_writes(UINT32 address, const void *dat, UINT leng) {
-
-       const UINT8 *out = (UINT8 *)dat;
-
-       //address = address & CPU_ADRSMASK;
-
-       /* slow memory access */
-       while (leng-- > 0) {
-               memp_write8(address++, *out++);
-       }
-}
-
 
 // ---- Logical Space (BIOS)
-
-static UINT32 MEMCALL physicaladdr(UINT32 addr, BOOL wr) {
+#if 1
+static inline UINT32 MEMCALL physicaladdr(UINT32 addr, BOOL wr) {
 
        UINT32  a;
        UINT32  pde;
@@ -399,60 +228,5 @@ void MEMCALL memr_writes(UINT seg, UINT off, const void *dat, UINT leng) {
        }
 }
 
-void IOOUTCALL iocore_out8(UINT port, REG8 dat)
-{
-       int wait = 0;
-       device_io->write_io8w(port, dat, &wait);
-       i386_memory_wait += wait;
-}
-
-REG8 IOINPCALL iocore_inp8(UINT port)
-{
-       int wait = 0;
-       REG8 val = device_io->read_io8w(port, &wait);
-       i386_memory_wait += wait;
-       return val;
-}
-
-void IOOUTCALL iocore_out16(UINT port, REG16 dat)
-{
-       int wait = 0;
-       device_io->write_io16w(port, dat, &wait);
-       i386_memory_wait += wait;
-//     device_io->write_io16(port, dat);       
-}
-
-REG16 IOINPCALL iocore_inp16(UINT port)
-{
-       int wait = 0;
-       REG16 val = device_io->read_io16w(port, &wait);
-       i386_memory_wait += wait;
-       return val;
-//     return device_io->read_io16(port);
-}
-
-void IOOUTCALL iocore_out32(UINT port, UINT32 dat)
-{
-       int wait = 0;
-       device_io->write_io32w(port, dat, &wait);
-       i386_memory_wait += wait;
-//     device_io->write_io32(port, dat);       
-}
-
-UINT32 IOINPCALL iocore_inp32(UINT port)
-{
-       int wait = 0;
-       UINT32 val = device_io->read_io32w(port, &wait);
-       i386_memory_wait += wait;
-       return val;
-//     return device_io->read_io32(port);
-}
-
-void dmax86(void)
-{
-//#ifdef SINGLE_MODE_DMA
-       if(device_dma != NULL) device_dma->do_dma();
-//#endif
-}
-
+#endif
 #endif
index 6d5d95c..a706324 100644 (file)
@@ -1,5 +1,10 @@
 #ifndef        NP2_I386C_CPUMEM_H__
 #define        NP2_I386C_CPUMEM_H__
+#include       "cpucore.h"
+#if defined(SUPPORT_IA32_HAXM)
+#include       "i386hax/haxfunc.h"
+#include       "i386hax/haxcore.h"
+#endif
 
 #ifdef NP2_MEMORY_ASM                  // \83A\83Z\83\93\83u\83\89\94Å\82Í \95K\82¸fastcall\82Å
 #undef MEMCALL
 //#ifdef __cplusplus
 //extern "C" {
 //#endif
+#include "../../common.h"
+#include "../device.h"
 
-REG8 MEMCALL memp_read8(UINT32 address);
-REG16 MEMCALL memp_read16(UINT32 address);
-UINT32 MEMCALL memp_read32(UINT32 address);
-void MEMCALL memp_write8(UINT32 address, REG8 value);
-void MEMCALL memp_write16(UINT32 address, REG16 value);
-void MEMCALL memp_write32(UINT32 address, UINT32 value);
-void MEMCALL memp_reads(UINT32 address, void *dat, UINT leng);
-void MEMCALL memp_writes(UINT32 address, const void *dat, UINT leng);
-REG8 MEMCALL memp_read8_codefetch(UINT32 address);
-REG16 MEMCALL memp_read16_codefetch(UINT32 address);
-UINT32 MEMCALL memp_read32_codefetch(UINT32 address);
-REG8 MEMCALL memp_read8_paging(UINT32 address);
-REG16 MEMCALL memp_read16_paging(UINT32 address);
-UINT32 MEMCALL memp_read32_paging(UINT32 address);
-void MEMCALL memp_write8_paging(UINT32 address, REG8 value);
-void MEMCALL memp_write16_paging(UINT32 address, REG16 value);
-void MEMCALL memp_write32_paging(UINT32 address, UINT32 value);
+extern DEVICE *device_cpu;
+extern DEVICE *device_mem;
+extern DEVICE *device_io;
+//#ifdef I386_PSEUDO_BIOS
+extern DEVICE *device_bios;
+//#endif
+//#ifdef SINGLE_MODE_DMA
+extern DEVICE *device_dma;
+//#endif
+extern SINT64 i386_memory_wait;
+extern DEBUGGER *device_debugger;
+extern UINT32 codefetch_address;
+extern SINT32 __exception_set;
+extern UINT32 __exception_pc;
+extern UINT64 __exception_code;
+
+inline REG8 MEMCALL memp_read8(UINT32 address);
+inline REG16 MEMCALL memp_read16(UINT32 address);
+inline UINT32 MEMCALL memp_read32(UINT32 address);
+inline void MEMCALL memp_write8(UINT32 address, REG8 value);
+inline void MEMCALL memp_write16(UINT32 address, REG16 value);
+inline void MEMCALL memp_write32(UINT32 address, UINT32 value);
+inline void MEMCALL memp_reads(UINT32 address, void *dat, UINT leng);
+inline void MEMCALL memp_writes(UINT32 address, const void *dat, UINT leng);
+inline REG8 MEMCALL memp_read8_codefetch(UINT32 address);
+inline REG16 MEMCALL memp_read16_codefetch(UINT32 address);
+inline UINT32 MEMCALL memp_read32_codefetch(UINT32 address);
+inline REG8 MEMCALL memp_read8_paging(UINT32 address);
+inline REG16 MEMCALL memp_read16_paging(UINT32 address);
+inline UINT32 MEMCALL memp_read32_paging(UINT32 address);
+inline void MEMCALL memp_write8_paging(UINT32 address, REG8 value);
+inline void MEMCALL memp_write16_paging(UINT32 address, REG16 value);
+inline void MEMCALL memp_write32_paging(UINT32 address, UINT32 value);
 
 REG8 MEMCALL meml_read8(UINT32 address);
 REG16 MEMCALL meml_read16(UINT32 address);
@@ -50,16 +73,16 @@ void MEMCALL memr_write32(UINT seg, UINT off, UINT32 dat);
 void MEMCALL memr_reads(UINT seg, UINT off, void *dat, UINT leng);
 void MEMCALL memr_writes(UINT seg, UINT off, const void *dat, UINT leng);
 
-void IOOUTCALL iocore_out8(UINT port, REG8 dat);
-REG8 IOINPCALL iocore_inp8(UINT port);
+inline void IOOUTCALL iocore_out8(UINT port, REG8 dat);
+inline REG8 IOINPCALL iocore_inp8(UINT port);
 
-void IOOUTCALL iocore_out16(UINT port, REG16 dat);
-REG16 IOINPCALL iocore_inp16(UINT port);
+inline void IOOUTCALL iocore_out16(UINT port, REG16 dat);
+inline REG16 IOINPCALL iocore_inp16(UINT port);
 
-void IOOUTCALL iocore_out32(UINT port, UINT32 dat);
-UINT32 IOINPCALL iocore_inp32(UINT port);
+inline void IOOUTCALL iocore_out32(UINT port, UINT32 dat);
+inline UINT32 IOINPCALL iocore_inp32(UINT port);
 
-void dmax86(void);
+inline void dmax86(void);
 
 //#ifdef __cplusplus
 //}
@@ -118,4 +141,233 @@ void dmax86(void);
 #define MEMR_WRITES(seg, off, dat, leng)       \
                        memr_writes((seg), (off), (dat), (leng))
 
+inline REG8 MEMCALL memp_read8(UINT32 address) {
+       
+       address = address & CPU_ADRSMASK;
+       int wait = 0;
+       REG8 val;
+       val = device_mem->read_data8w(address, &wait);
+       i386_memory_wait += wait;
+       return val;
+}
+
+inline REG16 MEMCALL memp_read16(UINT32 address) {
+
+       address = address & CPU_ADRSMASK;
+       int wait = 0;
+       REG16 val;
+       val = device_mem->read_data16w(address, &wait);
+       i386_memory_wait += wait;
+       return val;
+//     return device_mem->read_data16(address);
+}
+
+inline UINT32 MEMCALL memp_read32(UINT32 address) {
+       address = address & CPU_ADRSMASK;
+       int wait = 0;
+       UINT32 val;
+       val = device_mem->read_data32w(address, &wait);
+       i386_memory_wait += wait;
+       return val;
+//     return device_mem->read_data32(address);
+}
+
+// ----
+inline REG8 MEMCALL memp_read8_codefetch(UINT32 address) {
+       
+       address = address & CPU_ADRSMASK;
+       int wait = 0;
+       REG8 val;
+       if(device_debugger != NULL) {
+               codefetch_address = address & CPU_ADRSMASK;
+               val = device_mem->read_data8w(codefetch_address, &wait);
+       } else {
+               val = device_mem->read_data8w(address, &wait);
+       }
+       i386_memory_wait += wait;
+       return val;
+//     return device_mem->read_data8(address);
+}
+
+inline REG16 MEMCALL memp_read16_codefetch(UINT32 address) {
+
+       address = address & CPU_ADRSMASK;
+       int wait = 0;
+       REG16 val;
+       if(device_debugger != NULL) {
+               codefetch_address = address & CPU_ADRSMASK;
+               val = device_mem->read_data16w(codefetch_address, &wait);
+       } else {
+               val = device_mem->read_data16w(address, &wait);
+       }
+       i386_memory_wait += wait;
+       return val;
+//     return device_mem->read_data16(address);
+}
+
+inline UINT32 MEMCALL memp_read32_codefetch(UINT32 address) {
+
+       address = address & CPU_ADRSMASK;
+       int wait = 0;
+       UINT32 val;
+       if(device_debugger != NULL) {
+               codefetch_address = address & CPU_ADRSMASK;
+               val = device_mem->read_data32w(codefetch_address, &wait);
+       } else {
+               val = device_mem->read_data32w(address, &wait);
+       }
+       i386_memory_wait += wait;
+       return val;
+//     return device_mem->read_data32(address);
+}
+
+// ----
+inline REG8 MEMCALL memp_read8_paging(UINT32 address) {
+       
+       return memp_read8_codefetch(address);
+}
+inline REG16 MEMCALL memp_read16_paging(UINT32 address) {
+       
+       return memp_read16_codefetch(address);
+}
+
+inline UINT32 MEMCALL memp_read32_paging(UINT32 address) {
+       
+       return memp_read32_codefetch(address);
+}
+
+inline void MEMCALL memp_write8(UINT32 address, REG8 value) {
+       
+       address = address & CPU_ADRSMASK;
+       int wait = 0;
+       device_mem->write_data8w(address, value, &wait);
+       i386_memory_wait += wait;
+}
+
+inline void MEMCALL memp_write16(UINT32 address, REG16 value) {
+       
+       address = address & CPU_ADRSMASK;
+       int wait = 0;
+       device_mem->write_data16w(address, value, &wait);
+       i386_memory_wait += wait;
+//     device_mem->write_data16(address, value);
+}
+
+inline void MEMCALL memp_write32(UINT32 address, UINT32 value) {
+       
+       address = address & CPU_ADRSMASK;
+       int wait = 0;
+       device_mem->write_data32w(address, value, &wait);
+       i386_memory_wait += wait;
+//     device_mem->write_data32(address, value);
+}
+
+inline void MEMCALL memp_write8_paging(UINT32 address, REG8 value) {
+       
+       address = address & CPU_ADRSMASK;
+       int wait = 0;
+       device_mem->write_data8w(address, value, &wait);
+       i386_memory_wait += wait;
+//     device_mem->write_data8(address, value);
+}
+
+inline void MEMCALL memp_write16_paging(UINT32 address, REG16 value) {
+       
+       address = address & CPU_ADRSMASK;
+       int wait = 0;
+       device_mem->write_data16w(address, value, &wait);
+       i386_memory_wait += wait;
+//     device_mem->write_data16(address, value);
+}
+
+inline void MEMCALL memp_write32_paging(UINT32 address, UINT32 value) {
+       
+       address = address & CPU_ADRSMASK;
+//     device_mem->write_data32(address, value);
+       int wait = 0;
+       device_mem->write_data32w(address, value, &wait);
+       i386_memory_wait += wait;
+}
+
+
+inline void MEMCALL memp_reads(UINT32 address, void *dat, UINT leng) {
+
+       UINT8 *out = (UINT8 *)dat;
+       
+       //address = address & CPU_ADRSMASK;
+
+       /* slow memory access */
+       while (leng-- > 0) {
+               *out++ = memp_read8(address++);
+       }
+}
+
+inline void MEMCALL memp_writes(UINT32 address, const void *dat, UINT leng) {
+
+       const UINT8 *out = (UINT8 *)dat;
+
+       //address = address & CPU_ADRSMASK;
+
+       /* slow memory access */
+       while (leng-- > 0) {
+               memp_write8(address++, *out++);
+       }
+}
+
+inline void dmax86(void)
+{
+//#ifdef SINGLE_MODE_DMA
+       if(device_dma != NULL) device_dma->do_dma();
+//#endif
+}
+
+inline void IOOUTCALL iocore_out8(UINT port, REG8 dat)
+{
+       int wait = 0;
+       device_io->write_io8w(port, dat, &wait);
+       i386_memory_wait += wait;
+}
+
+inline REG8 IOINPCALL iocore_inp8(UINT port)
+{
+       int wait = 0;
+       REG8 val = device_io->read_io8w(port, &wait);
+       i386_memory_wait += wait;
+       return val;
+}
+
+inline void IOOUTCALL iocore_out16(UINT port, REG16 dat)
+{
+       int wait = 0;
+       device_io->write_io16w(port, dat, &wait);
+       i386_memory_wait += wait;
+//     device_io->write_io16(port, dat);       
+}
+
+inline REG16 IOINPCALL iocore_inp16(UINT port)
+{
+       int wait = 0;
+       REG16 val = device_io->read_io16w(port, &wait);
+       i386_memory_wait += wait;
+       return val;
+//     return device_io->read_io16(port);
+}
+
+inline void IOOUTCALL iocore_out32(UINT port, UINT32 dat)
+{
+       int wait = 0;
+       device_io->write_io32w(port, dat, &wait);
+       i386_memory_wait += wait;
+//     device_io->write_io32(port, dat);       
+}
+
+inline UINT32 IOINPCALL iocore_inp32(UINT port)
+{
+       int wait = 0;
+       UINT32 val = device_io->read_io32w(port, &wait);
+       i386_memory_wait += wait;
+       return val;
+//     return device_io->read_io32(port);
+}
+
 #endif /* !NP2_I386C_CPUMEM_H__ */
index c26f342..570e816 100644 (file)
@@ -1089,7 +1089,6 @@ extern UINT32             codefetch_address;
 void CPUCALL set_flags(UINT16 new_flags, UINT16 mask);
 void CPUCALL set_eflags(UINT32 new_flags, UINT32 mask);
 
-
 #define        CPU_INST_OP32           CPU_STATSAVE.cpu_inst.op_32
 #define        CPU_INST_AS32           CPU_STATSAVE.cpu_inst.as_32
 #define        CPU_INST_REPUSE         CPU_STATSAVE.cpu_inst.rep_used
index 313861a..9fe43c6 100644 (file)
@@ -23,7 +23,6 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-//#include "compiler.h"
 #include "cpu.h"
 #include "../cpumem.h"
 
@@ -367,66 +366,6 @@ exc:
 }
 
 
-/*
- * code fetch
- */
-UINT8 MEMCALL
-cpu_codefetch(UINT32 offset)
-{
-       const int ucrw = CPU_PAGE_READ_CODE | CPU_STAT_USER_MODE;
-       descriptor_t *sdp;
-       UINT32 addr;
-
-       sdp = &CPU_CS_DESC;
-       addr = sdp->u.seg.segbase + offset;
-
-       if (!CPU_STAT_PM)
-               return cpu_memoryread_codefetch(addr);
-       if (offset <= sdp->u.seg.limit)
-               return cpu_lmemoryread_codefetch(addr, ucrw);
-
-       EXCEPTION(GP_EXCEPTION, 0);
-       return 0;       /* compiler happy */
-}
-
-UINT16 MEMCALL
-cpu_codefetch_w(UINT32 offset)
-{
-       const int ucrw = CPU_PAGE_READ_CODE | CPU_STAT_USER_MODE;
-       descriptor_t *sdp;
-       UINT32 addr;
-
-       sdp = &CPU_CS_DESC;
-       addr = sdp->u.seg.segbase + offset;
-
-       if (!CPU_STAT_PM)
-               return cpu_memoryread_w_codefetch(addr);
-       if (offset <= sdp->u.seg.limit - 1)
-               return cpu_lmemoryread_w_codefetch(addr, ucrw);
-
-       EXCEPTION(GP_EXCEPTION, 0);
-       return 0;       /* compiler happy */
-}
-
-UINT32 MEMCALL
-cpu_codefetch_d(UINT32 offset)
-{
-       const int ucrw = CPU_PAGE_READ_CODE | CPU_STAT_USER_MODE;
-       descriptor_t *sdp;
-       UINT32 addr;
-
-       sdp = &CPU_CS_DESC;
-       addr = sdp->u.seg.segbase + offset;
-
-       if (!CPU_STAT_PM)
-               return cpu_memoryread_d_codefetch(addr);
-
-       if (offset <= sdp->u.seg.limit - 3)
-               return cpu_lmemoryread_d_codefetch(addr, ucrw);
-
-       EXCEPTION(GP_EXCEPTION, 0);
-       return 0;       /* compiler happy */
-}
 
 /*
  * additional physical address memory access functions
@@ -563,3 +502,64 @@ range_failure:
 err:
        EXCEPTION(exc, 0);
 }
+
+/*
+ * code fetch
+ */
+UINT8 MEMCALL
+cpu_codefetch(UINT32 offset)
+{
+       const int ucrw = CPU_PAGE_READ_CODE | CPU_STAT_USER_MODE;
+       descriptor_t *sdp;
+       UINT32 addr;
+
+       sdp = &CPU_CS_DESC;
+       addr = sdp->u.seg.segbase + offset;
+
+       if (!CPU_STAT_PM)
+               return cpu_memoryread_codefetch(addr);
+       if (offset <= sdp->u.seg.limit)
+               return cpu_lmemoryread_codefetch(addr, ucrw);
+
+       EXCEPTION(GP_EXCEPTION, 0);
+       return 0;       /* compiler happy */
+}
+
+UINT16 MEMCALL
+cpu_codefetch_w(UINT32 offset)
+{
+       const int ucrw = CPU_PAGE_READ_CODE | CPU_STAT_USER_MODE;
+       descriptor_t *sdp;
+       UINT32 addr;
+
+       sdp = &CPU_CS_DESC;
+       addr = sdp->u.seg.segbase + offset;
+
+       if (!CPU_STAT_PM)
+               return cpu_memoryread_w_codefetch(addr);
+       if (offset <= sdp->u.seg.limit - 1)
+               return cpu_lmemoryread_w_codefetch(addr, ucrw);
+
+       EXCEPTION(GP_EXCEPTION, 0);
+       return 0;       /* compiler happy */
+}
+
+UINT32 MEMCALL
+cpu_codefetch_d(UINT32 offset)
+{
+       const int ucrw = CPU_PAGE_READ_CODE | CPU_STAT_USER_MODE;
+       descriptor_t *sdp;
+       UINT32 addr;
+
+       sdp = &CPU_CS_DESC;
+       addr = sdp->u.seg.segbase + offset;
+
+       if (!CPU_STAT_PM)
+               return cpu_memoryread_d_codefetch(addr);
+
+       if (offset <= sdp->u.seg.limit - 3)
+               return cpu_lmemoryread_d_codefetch(addr, ucrw);
+
+       EXCEPTION(GP_EXCEPTION, 0);
+       return 0;       /* compiler happy */
+}
index 5f9b415..114fcce 100644 (file)
@@ -265,8 +265,7 @@ modify_eflags(UINT32 new_flags, UINT32 mask)
        }
 }
 
-void CPUCALL
-set_flags(UINT16 new_flags, UINT16 mask)
+void CPUCALL set_flags(UINT16 new_flags, UINT16 mask)
 {
 
        mask &= I_FLAG|IOPL_FLAG;
@@ -274,8 +273,7 @@ set_flags(UINT16 new_flags, UINT16 mask)
        modify_eflags(new_flags, mask);
 }
 
-void CPUCALL
-set_eflags(UINT32 new_flags, UINT32 mask)
+void CPUCALL set_eflags(UINT32 new_flags, UINT32 mask)
 {
 
        mask &= I_FLAG|IOPL_FLAG|RF_FLAG|VM_FLAG|VIF_FLAG|VIP_FLAG;