|
|
| version 1.13, 2004/03/04 15:20:13 | version 1.14, 2004/03/04 15:55:26 |
|---|---|
| Line 796 REG8 MEMCALL i286_memoryread(UINT32 addr | Line 796 REG8 MEMCALL i286_memoryread(UINT32 addr |
| UINT32 pos; | UINT32 pos; |
| addr &= CPU_ADRSMASK; | |
| if (addr < I286_MEMREADMAX) { | if (addr < I286_MEMREADMAX) { |
| return(mem[addr]); | return(mem[addr]); |
| } | } |
| else if (addr >= USE_HIMEM) { | else if (addr >= USE_HIMEM) { |
| pos = addr - 0x100000; | pos = (addr & CPU_ADRSMASK) - 0x100000; |
| if (pos < CPU_EXTMEMSIZE) { | if (pos < CPU_EXTMEMSIZE) { |
| return(CPU_EXTMEM[pos]); | return(CPU_EXTMEM[pos]); |
| } | } |
| Line 827 REG16 MEMCALL i286_memoryread_w(UINT32 a | Line 826 REG16 MEMCALL i286_memoryread_w(UINT32 a |
| UINT32 pos; | UINT32 pos; |
| REG16 ret; | REG16 ret; |
| addr &= CPU_ADRSMASK; | |
| if (addr < (I286_MEMREADMAX - 1)) { | if (addr < (I286_MEMREADMAX - 1)) { |
| return(LOADINTELWORD(mem + addr)); | return(LOADINTELWORD(mem + addr)); |
| } | } |
| else if ((addr + 1) & 0x7fff) { // non 32kb boundary | else if ((addr + 1) & 0x7fff) { // non 32kb boundary |
| if (addr >= USE_HIMEM) { | if (addr >= USE_HIMEM) { |
| pos = addr - 0x100000; | pos = (addr & CPU_ADRSMASK) - 0x100000; |
| if (pos < CPU_EXTMEMSIZE) { | if (pos < CPU_EXTMEMSIZE) { |
| return(LOADINTELWORD(CPU_EXTMEM + pos)); | return(LOADINTELWORD(CPU_EXTMEM + pos)); |
| } | } |
| Line 863 UINT32 MEMCALL i286_memoryread_d(UINT32 | Line 861 UINT32 MEMCALL i286_memoryread_d(UINT32 |
| UINT32 pos; | UINT32 pos; |
| UINT32 ret; | UINT32 ret; |
| addr &= CPU_ADRSMASK; | |
| if (addr < (I286_MEMREADMAX - 3)) { | if (addr < (I286_MEMREADMAX - 3)) { |
| return(LOADINTELDWORD(mem + addr)); | return(LOADINTELDWORD(mem + addr)); |
| } | } |
| else if (addr >= USE_HIMEM) { | else if (addr >= USE_HIMEM) { |
| pos = addr - 0x100000; | pos = (addr & CPU_ADRSMASK) - 0x100000; |
| if ((pos + 3) < CPU_EXTMEMSIZE) { | if ((pos + 3) < CPU_EXTMEMSIZE) { |
| return(LOADINTELDWORD(CPU_EXTMEM + pos)); | return(LOADINTELDWORD(CPU_EXTMEM + pos)); |
| } | } |
| Line 889 void MEMCALL i286_memorywrite(UINT32 add | Line 886 void MEMCALL i286_memorywrite(UINT32 add |
| UINT32 pos; | UINT32 pos; |
| addr &= CPU_ADRSMASK; | |
| if (addr < I286_MEMWRITEMAX) { | if (addr < I286_MEMWRITEMAX) { |
| mem[addr] = (BYTE)value; | mem[addr] = (BYTE)value; |
| } | } |
| else if (addr >= USE_HIMEM) { | else if (addr >= USE_HIMEM) { |
| pos = addr - 0x100000; | pos = (addr & CPU_ADRSMASK) - 0x100000; |
| if (pos < CPU_EXTMEMSIZE) { | if (pos < CPU_EXTMEMSIZE) { |
| CPU_EXTMEM[pos] = (BYTE)value; | CPU_EXTMEM[pos] = (BYTE)value; |
| } | } |
| Line 919 void MEMCALL i286_memorywrite_w(UINT32 a | Line 915 void MEMCALL i286_memorywrite_w(UINT32 a |
| UINT32 pos; | UINT32 pos; |
| addr &= CPU_ADRSMASK; | |
| if (addr < (I286_MEMWRITEMAX - 1)) { | if (addr < (I286_MEMWRITEMAX - 1)) { |
| STOREINTELWORD(mem + addr, value); | STOREINTELWORD(mem + addr, value); |
| } | } |
| else if ((addr + 1) & 0x7fff) { // non 32kb boundary | else if ((addr + 1) & 0x7fff) { // non 32kb boundary |
| if (addr >= USE_HIMEM) { | if (addr >= USE_HIMEM) { |
| pos = addr - 0x100000; | pos = (addr & CPU_ADRSMASK) - 0x100000; |
| if (pos < CPU_EXTMEMSIZE) { | if (pos < CPU_EXTMEMSIZE) { |
| STOREINTELWORD(CPU_EXTMEM + pos, value); | STOREINTELWORD(CPU_EXTMEM + pos, value); |
| } | } |
| Line 952 void MEMCALL i286_memorywrite_d(UINT32 a | Line 947 void MEMCALL i286_memorywrite_d(UINT32 a |
| UINT32 pos; | UINT32 pos; |
| addr &= CPU_ADRSMASK; | |
| if (addr < (I286_MEMWRITEMAX - 3)) { | if (addr < (I286_MEMWRITEMAX - 3)) { |
| STOREINTELDWORD(mem + addr, value); | STOREINTELDWORD(mem + addr, value); |
| return; | return; |
| } | } |
| else if (addr >= USE_HIMEM) { | else if (addr >= USE_HIMEM) { |
| pos = addr - 0x100000; | pos = (addr & CPU_ADRSMASK) - 0x100000; |
| if ((pos + 3) < CPU_EXTMEMSIZE) { | if ((pos + 3) < CPU_EXTMEMSIZE) { |
| STOREINTELDWORD(CPU_EXTMEM + pos, value); | STOREINTELDWORD(CPU_EXTMEM + pos, value); |
| return; | return; |
| Line 1031 void MEMCALL i286_memword_write(UINT seg | Line 1025 void MEMCALL i286_memword_write(UINT seg |
| void MEMCALL i286_memx_read(UINT32 address, void *dat, UINT leng) { | void MEMCALL i286_memx_read(UINT32 address, void *dat, UINT leng) { |
| if ((address + leng) < I286_MEMREADMAX) { | BYTE *out = (BYTE *)dat; |
| UINT pos; | |
| UINT diff; | |
| /* fast memory access */ | |
| if (address + leng < I286_MEMREADMAX) { | |
| CopyMemory(dat, mem + address, leng); | CopyMemory(dat, mem + address, leng); |
| } | return; |
| else { | } else if (address >= USE_HIMEM) { |
| BYTE *out = (BYTE *)dat; | pos = (address & CPU_ADRSMASK) - 0x100000; |
| if (address < I286_MEMREADMAX) { | if (pos + leng < CPU_EXTMEMSIZE) { |
| CopyMemory(out, mem + address, I286_MEMREADMAX - address); | CopyMemory(dat, CPU_EXTMEM + pos, leng); |
| out += I286_MEMREADMAX - address; | return; |
| leng -= I286_MEMREADMAX - address; | |
| address = I286_MEMREADMAX; | |
| } | } |
| while(leng--) { | if (pos < CPU_EXTMEMSIZE) { |
| *out++ = i286_memoryread(address++); | diff = CPU_EXTMEMSIZE - pos; |
| CopyMemory(out, CPU_EXTMEM + pos, diff); | |
| out += diff; | |
| leng -= diff; | |
| address += diff; | |
| } | } |
| } | } |
| } | |
| void MEMCALL i286_memx_write(UINT32 address, const void *dat, UINT leng) { | /* slow memory access */ |
| while (leng-- > 0) { | |
| *out++ = i286_memoryread(address++); | |
| } | |
| } | |
| const BYTE *out; | void MEMCALL i286_memx_write(UINT32 address, const void *dat, UINT leng) |
| { | |
| const BYTE *out = (BYTE *)dat; | |
| UINT pos; | |
| UINT diff; | |
| if ((address + leng) < I286_MEMWRITEMAX) { | /* fast memory access */ |
| if (address + leng < I286_MEMREADMAX) { | |
| CopyMemory(mem + address, dat, leng); | CopyMemory(mem + address, dat, leng); |
| } | return; |
| else { | } else if (address >= USE_HIMEM) { |
| out = (BYTE *)dat; | pos = (address & CPU_ADRSMASK) - 0x100000; |
| if (address < I286_MEMWRITEMAX) { | if (pos + leng < CPU_EXTMEMSIZE) { |
| CopyMemory(mem + address, out, I286_MEMWRITEMAX - address); | CopyMemory(CPU_EXTMEM + pos, dat, leng); |
| out += I286_MEMWRITEMAX - address; | return; |
| leng -= I286_MEMWRITEMAX - address; | |
| address = I286_MEMWRITEMAX; | |
| } | } |
| while(leng--) { | if (pos < CPU_EXTMEMSIZE) { |
| i286_memorywrite(address++, *out++); | diff = CPU_EXTMEMSIZE - pos; |
| CopyMemory(CPU_EXTMEM + pos, dat, diff); | |
| out += diff; | |
| leng -= diff; | |
| address += diff; | |
| } | } |
| } | } |
| /* slow memory access */ | |
| while (leng-- > 0) { | |
| i286_memorywrite(address++, *out++); | |
| } | |
| } | } |
| #endif | #endif |
| Line 1083 static UINT32 realaddr(UINT32 addr) { | Line 1099 static UINT32 realaddr(UINT32 addr) { |
| if (!(pde & CPU_PDE_PRESENT)) { | if (!(pde & CPU_PDE_PRESENT)) { |
| goto retdummy; | goto retdummy; |
| } | } |
| // ページサイズ 4KB固定(ぉ | pte = cpu_memoryread_d((pde & CPU_PDE_BASEADDR_MASK) + ((addr >> 10) & 0xffc)); |
| pte = cpu_memoryread_d((pde & CPU_PDE_BASEADDR_MASK) | |
| + ((addr >> 10) & 0xffc)); | |
| if (!(pte & CPU_PTE_PRESENT)) { | if (!(pte & CPU_PTE_PRESENT)) { |
| goto retdummy; | goto retdummy; |
| } | } |