|
|
| version 1.13, 2004/03/04 15:20:13 | version 1.15, 2004/03/04 16:58:57 |
|---|---|
| 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 975 void MEMCALL i286_memorywrite_d(UINT32 a | Line 969 void MEMCALL i286_memorywrite_d(UINT32 a |
| } | } |
| } | } |
| #ifdef NP2_MEMORY_ASM | #if 0 |
| REG8 MEMCALL i286_membyte_read(UINT seg, UINT off) { | REG8 MEMCALL i286_membyte_read(UINT seg, UINT off) { |
| UINT32 address; | UINT32 address; |
| Line 1027 void MEMCALL i286_memword_write(UINT seg | Line 1021 void MEMCALL i286_memword_write(UINT seg |
| i286_memorywrite_w(address, value); | i286_memorywrite_w(address, value); |
| } | } |
| } | } |
| #endif /* NP2_MEMORY_ASM */ | #endif |
| void MEMCALL memp_read(UINT32 address, void *dat, UINT leng) { | |
| void MEMCALL i286_memx_read(UINT32 address, void *dat, UINT leng) { | BYTE *out = (BYTE *)dat; |
| UINT pos; | |
| UINT diff; | |
| if ((address + leng) < I286_MEMREADMAX) { | /* 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; | |
| } | } |
| } | } |
| /* slow memory access */ | |
| while (leng-- > 0) { | |
| *out++ = i286_memoryread(address++); | |
| } | |
| } | } |
| void MEMCALL i286_memx_write(UINT32 address, const void *dat, UINT leng) { | void MEMCALL memp_write(UINT32 address, const void *dat, UINT leng) { |
| const BYTE *out; | 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 | |
| // ---- | // ---- Logical Space (BIOS) |
| static UINT32 realaddr(UINT32 addr) { | static UINT32 realaddr(UINT32 addr) { |
| Line 1083 static UINT32 realaddr(UINT32 addr) { | Line 1098 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; |
| } | } |
| Line 1108 void MEMCALL i286_memstr_read(UINT seg, | Line 1121 void MEMCALL i286_memstr_read(UINT seg, |
| size = 0x1000 - (adrs & 0xfff); | size = 0x1000 - (adrs & 0xfff); |
| size = min(size, leng); | size = min(size, leng); |
| size = min(size, 0x10000 - off); | size = min(size, 0x10000 - off); |
| i286_memx_read(realaddr(adrs), dat, size); | memp_read(realaddr(adrs), dat, size); |
| off += size; | off += size; |
| dat = ((BYTE *)dat) + size; | dat = ((BYTE *)dat) + size; |
| leng -= size; | leng -= size; |
| } | } |
| } | } |
| void MEMCALL i286_memstr_write(UINT seg, UINT off, const void *dat, UINT leng) { | void MEMCALL i286_memstr_write(UINT seg, UINT off, |
| const void *dat, UINT leng) { | |
| UINT32 adrs; | UINT32 adrs; |
| UINT size; | UINT size; |
| Line 1125 void MEMCALL i286_memstr_write(UINT seg, | Line 1140 void MEMCALL i286_memstr_write(UINT seg, |
| size = 0x1000 - (adrs & 0xfff); | size = 0x1000 - (adrs & 0xfff); |
| size = min(size, leng); | size = min(size, leng); |
| size = min(size, 0x10000 - off); | size = min(size, 0x10000 - off); |
| i286_memx_write(realaddr(adrs), dat, size); | memp_write(realaddr(adrs), dat, size); |
| off += size; | off += size; |
| dat = ((BYTE *)dat) + size; | dat = ((BYTE *)dat) + size; |
| leng -= size; | leng -= size; |
| } | } |
| } | } |
| void MEMCALL meml_read(UINT32 address, void *dat, UINT leng) { | |
| UINT size; | |
| while(leng) { | |
| size = 0x1000 - (address & 0xfff); | |
| size = min(size, leng); | |
| memp_read(realaddr(address), dat, size); | |
| address += size; | |
| dat = ((BYTE *)dat) + size; | |
| leng -= size; | |
| } | |
| } | |
| #if 0 // テスト | void MEMCALL meml_write(UINT32 address, const void *dat, UINT leng) { |
| void MEMCALL cpumem_strread(UINT32 adrs, void *dat, UINT leng) { | |
| UINT size; | UINT size; |
| while(leng) { | while(leng) { |
| size = 0x1000 - (adrs & 0xfff); | size = 0x1000 - (address & 0xfff); |
| size = min(size, leng); | size = min(size, leng); |
| i286_memx_read(realaddr(adrs), dat, size); | memp_write(realaddr(address), dat, size); |
| adrs += size; | address += size; |
| dat = ((BYTE *)dat) + size; | dat = ((BYTE *)dat) + size; |
| leng -= size; | leng -= size; |
| } | } |
| } | } |
| #endif | #endif |