|
|
| version 1.31, 2012/01/08 18:26:10 | version 1.33, 2012/01/08 19:09:40 |
|---|---|
| Line 482 cpu_memorywrite_f(UINT32 paddr, const RE | Line 482 cpu_memorywrite_f(UINT32 paddr, const RE |
| #include "cpu_mem.mcr" | #include "cpu_mem.mcr" |
| VIRTUAL_ADDRESS_MEMORY_ACCESS_FUNCTION(b, UINT8, 1) | DECLARE_VIRTUAL_ADDRESS_MEMORY_RW_FUNCTIONS(b, UINT8, 1) |
| VIRTUAL_ADDRESS_MEMORY_ACCESS_FUNCTION(w, UINT16, 2) | DECLARE_VIRTUAL_ADDRESS_MEMORY_RMW_FUNCTIONS(b, UINT8, 1) |
| VIRTUAL_ADDRESS_MEMORY_ACCESS_FUNCTION(d, UINT32, 4) | DECLARE_VIRTUAL_ADDRESS_MEMORY_RW_FUNCTIONS(w, UINT16, 2) |
| DECLARE_VIRTUAL_ADDRESS_MEMORY_RMW_FUNCTIONS(w, UINT16, 2) | |
| UINT64 MEMCALL | DECLARE_VIRTUAL_ADDRESS_MEMORY_RW_FUNCTIONS(d, UINT32, 4) |
| cpu_vmemoryread_q(int idx, UINT32 offset) | DECLARE_VIRTUAL_ADDRESS_MEMORY_RMW_FUNCTIONS(d, UINT32, 4) |
| { | DECLARE_VIRTUAL_ADDRESS_MEMORY_RW_FUNCTIONS(q, UINT64, 8) |
| descriptor_t *sdp; | |
| UINT32 addr; | |
| int exc; | |
| __ASSERT((unsigned int)idx < CPU_SEGREG_NUM); | |
| sdp = &CPU_STAT_SREG(idx); | |
| addr = sdp->u.seg.segbase + offset; | |
| if (!CPU_STAT_PM) | |
| return cpu_memoryread_q(addr); | |
| if (!SEG_IS_VALID(sdp)) { | |
| exc = GP_EXCEPTION; | |
| goto err; | |
| } | |
| if (!(sdp->flag & CPU_DESC_FLAG_READABLE)) { | |
| cpu_memoryread_check(sdp, offset, 8, CHOOSE_EXCEPTION(idx)); | |
| } else if (!(sdp->flag & CPU_DESC_FLAG_WHOLEADR)) { | |
| if (!check_limit_upstairs(sdp, offset, 8)) | |
| goto range_failure; | |
| } | |
| return cpu_lmemoryread_q(addr, CPU_PAGE_READ_DATA | CPU_STAT_USER_MODE); | |
| range_failure: | |
| VERBOSE(("cpu_vmemoryread_q: type = %d, offset = %08x, limit = %08x", sdp->type, offset, sdp->u.seg.limit)); | |
| exc = CHOOSE_EXCEPTION(idx); | |
| err: | |
| EXCEPTION(exc, 0); | |
| return 0; /* compiler happy */ | |
| } | |
| void MEMCALL | |
| cpu_vmemorywrite_q(int idx, UINT32 offset, UINT64 value) | |
| { | |
| descriptor_t *sdp; | |
| UINT32 addr; | |
| int exc; | |
| __ASSERT((unsigned int)idx < CPU_SEGREG_NUM); | |
| sdp = &CPU_STAT_SREG(idx); | |
| addr = sdp->u.seg.segbase + offset; | |
| if (!CPU_STAT_PM) { | |
| cpu_memorywrite_q(addr, value); | |
| return; | |
| } | |
| if (!SEG_IS_VALID(sdp)) { | |
| exc = GP_EXCEPTION; | |
| goto err; | |
| } | |
| if (!(sdp->flag & CPU_DESC_FLAG_WRITABLE)) { | |
| cpu_memorywrite_check(sdp, offset, 8, CHOOSE_EXCEPTION(idx)); | |
| } else if (!(sdp->flag & CPU_DESC_FLAG_WHOLEADR)) { | |
| if (!check_limit_upstairs(sdp, offset, 8)) | |
| goto range_failure; | |
| } | |
| if (!CPU_STAT_PAGING) { | |
| cpu_memorywrite_q(addr, value); | |
| } else { | |
| cpu_linear_memory_write_q(addr, value, CPU_PAGE_READ_DATA | CPU_STAT_USER_MODE); | |
| } | |
| return; | |
| range_failure: | |
| VERBOSE(("cpu_vmemorywrite_q: type = %d, offset = %08x, limit = %08x", sdp->type, offset, sdp->u.seg.limit)); | |
| exc = CHOOSE_EXCEPTION(idx); | |
| err: | |
| EXCEPTION(exc, 0); | |
| } | |
| REG80 MEMCALL | REG80 MEMCALL |
| cpu_vmemoryread_f(int idx, UINT32 offset) | cpu_vmemoryread_f(int idx, UINT32 offset) |
| Line 587 cpu_vmemoryread_f(int idx, UINT32 offset | Line 515 cpu_vmemoryread_f(int idx, UINT32 offset |
| if (!check_limit_upstairs(sdp, offset, 10)) | if (!check_limit_upstairs(sdp, offset, 10)) |
| goto range_failure; | goto range_failure; |
| } | } |
| if (!CPU_STAT_PAGING) | return cpu_lmemoryread_f(addr, CPU_PAGE_READ_DATA | CPU_STAT_USER_MODE); |
| return cpu_memoryread_f(addr); | |
| return cpu_linear_memory_read_f(addr, CPU_PAGE_READ_DATA | CPU_PAGE_READ_DATA | CPU_STAT_USER_MODE); | |
| range_failure: | range_failure: |
| VERBOSE(("cpu_vmemoryread_f: type = %d, offset = %08x, limit = %08x", sdp->type, offset, sdp->u.seg.limit)); | VERBOSE(("cpu_vmemoryread_f: type = %d, offset = %08x, limit = %08x", sdp->type, offset, sdp->u.seg.limit)); |
| Line 630 cpu_vmemorywrite_f(int idx, UINT32 offse | Line 556 cpu_vmemorywrite_f(int idx, UINT32 offse |
| if (!check_limit_upstairs(sdp, offset, 10)) | if (!check_limit_upstairs(sdp, offset, 10)) |
| goto range_failure; | goto range_failure; |
| } | } |
| if (!CPU_STAT_PAGING) { | cpu_lmemorywrite_f(addr, value, CPU_PAGE_WRITE_DATA | CPU_STAT_USER_MODE); |
| cpu_memorywrite_f(addr, value); | |
| } else { | |
| cpu_linear_memory_write_f(addr, value, CPU_PAGE_WRITE_DATA | CPU_STAT_USER_MODE); | |
| } | |
| return; | return; |
| range_failure: | range_failure: |