mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-25 19:33:05 +00:00
Revert "ppcmmu: Add 64-bit accesses to I/O"
This reverts commit 16123dea45344ba6767ce2512be58dc7819d58b5.
This commit is contained in:
parent
762319055c
commit
b571ff8412
@ -988,10 +988,9 @@ void mmu_print_regs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Forward declarations.
|
// Forward declarations.
|
||||||
template <class T>
|
static uint32_t read_unaligned(uint32_t guest_va, uint8_t *host_va, uint32_t size);
|
||||||
static T read_unaligned(uint32_t guest_va, uint8_t *host_va);
|
static void write_unaligned(uint32_t guest_va, uint8_t *host_va, uint32_t value,
|
||||||
template <class T>
|
uint32_t size);
|
||||||
static void write_unaligned(uint32_t guest_va, uint8_t *host_va, T value);
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
inline T mmu_read_vmem(uint32_t guest_va)
|
inline T mmu_read_vmem(uint32_t guest_va)
|
||||||
@ -1036,28 +1035,11 @@ inline T mmu_read_vmem(uint32_t guest_va)
|
|||||||
#ifdef MMU_PROFILING
|
#ifdef MMU_PROFILING
|
||||||
iomem_reads_total++;
|
iomem_reads_total++;
|
||||||
#endif
|
#endif
|
||||||
if (sizeof(T) == 8) {
|
return (
|
||||||
if (guest_va & 3) {
|
tlb2_entry->reg_desc->devobj->read(tlb2_entry->reg_desc->start,
|
||||||
ppc_exception_handler(Except_Type::EXC_ALIGNMENT, 0x0);
|
static_cast<uint32_t>(tlb2_entry->reg_va_offs + guest_va),
|
||||||
}
|
sizeof(T))
|
||||||
{
|
);
|
||||||
return (
|
|
||||||
((T)tlb2_entry->reg_desc->devobj->read(tlb2_entry->reg_desc->start,
|
|
||||||
static_cast<uint32_t>(tlb2_entry->reg_va_offs + guest_va),
|
|
||||||
4) << 32) |
|
|
||||||
tlb2_entry->reg_desc->devobj->read(tlb2_entry->reg_desc->start,
|
|
||||||
static_cast<uint32_t>(tlb2_entry->reg_va_offs + guest_va) + 4,
|
|
||||||
4)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return (
|
|
||||||
tlb2_entry->reg_desc->devobj->read(tlb2_entry->reg_desc->start,
|
|
||||||
static_cast<uint32_t>(tlb2_entry->reg_va_offs + guest_va),
|
|
||||||
sizeof(T))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1067,7 +1049,7 @@ inline T mmu_read_vmem(uint32_t guest_va)
|
|||||||
|
|
||||||
// handle unaligned memory accesses
|
// handle unaligned memory accesses
|
||||||
if (sizeof(T) > 1 && (guest_va & (sizeof(T) - 1))) {
|
if (sizeof(T) > 1 && (guest_va & (sizeof(T) - 1))) {
|
||||||
return read_unaligned<T>(guest_va, host_va);
|
return read_unaligned(guest_va, host_va, sizeof(T));
|
||||||
}
|
}
|
||||||
|
|
||||||
// handle aligned memory accesses
|
// handle aligned memory accesses
|
||||||
@ -1162,24 +1144,9 @@ inline void mmu_write_vmem(uint32_t guest_va, T value)
|
|||||||
#ifdef MMU_PROFILING
|
#ifdef MMU_PROFILING
|
||||||
iomem_writes_total++;
|
iomem_writes_total++;
|
||||||
#endif
|
#endif
|
||||||
if (sizeof(T) == 8) {
|
tlb2_entry->reg_desc->devobj->write(tlb2_entry->reg_desc->start,
|
||||||
if (guest_va & 3) {
|
static_cast<uint32_t>(tlb2_entry->reg_va_offs + guest_va),
|
||||||
ppc_exception_handler(Except_Type::EXC_ALIGNMENT, 0x0);
|
value, sizeof(T));
|
||||||
}
|
|
||||||
{
|
|
||||||
tlb2_entry->reg_desc->devobj->write(tlb2_entry->reg_desc->start,
|
|
||||||
static_cast<uint32_t>(tlb2_entry->reg_va_offs + guest_va),
|
|
||||||
value >> 32, 4);
|
|
||||||
tlb2_entry->reg_desc->devobj->write(tlb2_entry->reg_desc->start,
|
|
||||||
static_cast<uint32_t>(tlb2_entry->reg_va_offs + guest_va) + 4,
|
|
||||||
(uint32_t)value, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
tlb2_entry->reg_desc->devobj->write(tlb2_entry->reg_desc->start,
|
|
||||||
static_cast<uint32_t>(tlb2_entry->reg_va_offs + guest_va),
|
|
||||||
value, sizeof(T));
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1190,7 +1157,7 @@ inline void mmu_write_vmem(uint32_t guest_va, T value)
|
|||||||
|
|
||||||
// handle unaligned memory accesses
|
// handle unaligned memory accesses
|
||||||
if (sizeof(T) > 1 && (guest_va & (sizeof(T) - 1))) {
|
if (sizeof(T) > 1 && (guest_va & (sizeof(T) - 1))) {
|
||||||
write_unaligned<T>(guest_va, host_va, value);
|
write_unaligned(guest_va, host_va, value, sizeof(T));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1217,53 +1184,42 @@ template void mmu_write_vmem<uint16_t>(uint32_t guest_va, uint16_t value);
|
|||||||
template void mmu_write_vmem<uint32_t>(uint32_t guest_va, uint32_t value);
|
template void mmu_write_vmem<uint32_t>(uint32_t guest_va, uint32_t value);
|
||||||
template void mmu_write_vmem<uint64_t>(uint32_t guest_va, uint64_t value);
|
template void mmu_write_vmem<uint64_t>(uint32_t guest_va, uint64_t value);
|
||||||
|
|
||||||
template <class T>
|
static uint32_t read_unaligned(uint32_t guest_va, uint8_t *host_va, uint32_t size)
|
||||||
static T read_unaligned(uint32_t guest_va, uint8_t *host_va)
|
|
||||||
{
|
{
|
||||||
T result = 0;
|
uint32_t result = 0;
|
||||||
|
|
||||||
// is it a misaligned cross-page read?
|
// is it a misaligned cross-page read?
|
||||||
if (((guest_va & 0xFFF) + sizeof(T)) > 0x1000) {
|
if (((guest_va & 0xFFF) + size) > 0x1000) {
|
||||||
#ifdef MMU_PROFILING
|
#ifdef MMU_PROFILING
|
||||||
unaligned_crossp_r++;
|
unaligned_crossp_r++;
|
||||||
#endif
|
#endif
|
||||||
// Break such a memory access into multiple, bytewise accesses.
|
// Break such a memory access into multiple, bytewise accesses.
|
||||||
// Because such accesses suffer a performance penalty, they will be
|
// Because such accesses suffer a performance penalty, they will be
|
||||||
// presumably very rare so don't waste time optimizing the code below.
|
// presumably very rare so don't waste time optimizing the code below.
|
||||||
for (int i = 0; i < sizeof(T); guest_va++, i++) {
|
for (int i = 0; i < size; guest_va++, i++) {
|
||||||
result = (result << 8) | mmu_read_vmem<uint8_t>(guest_va);
|
result = (result << 8) | mmu_read_vmem<uint8_t>(guest_va);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef MMU_PROFILING
|
#ifdef MMU_PROFILING
|
||||||
unaligned_reads++;
|
unaligned_reads++;
|
||||||
#endif
|
#endif
|
||||||
switch(sizeof(T)) {
|
switch(size) {
|
||||||
case 1:
|
|
||||||
return *host_va;
|
|
||||||
case 2:
|
case 2:
|
||||||
return READ_WORD_BE_U(host_va);
|
return READ_WORD_BE_U(host_va);
|
||||||
case 4:
|
case 4:
|
||||||
return READ_DWORD_BE_U(host_va);
|
return READ_DWORD_BE_U(host_va);
|
||||||
case 8:
|
case 8: // FIXME: should we raise alignment exception here?
|
||||||
if (guest_va & 3) {
|
|
||||||
ppc_exception_handler(Except_Type::EXC_ALIGNMENT, 0x0);
|
|
||||||
}
|
|
||||||
return READ_QWORD_BE_U(host_va);
|
return READ_QWORD_BE_U(host_va);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// explicitely instantiate all required read_unaligned variants
|
static void write_unaligned(uint32_t guest_va, uint8_t *host_va, uint32_t value,
|
||||||
template uint16_t read_unaligned<uint16_t>(uint32_t guest_va, uint8_t *host_va);
|
uint32_t size)
|
||||||
template uint32_t read_unaligned<uint32_t>(uint32_t guest_va, uint8_t *host_va);
|
|
||||||
template uint64_t read_unaligned<uint64_t>(uint32_t guest_va, uint8_t *host_va);
|
|
||||||
|
|
||||||
template <class T>
|
|
||||||
static void write_unaligned(uint32_t guest_va, uint8_t *host_va, T value)
|
|
||||||
{
|
{
|
||||||
// is it a misaligned cross-page write?
|
// is it a misaligned cross-page write?
|
||||||
if (((guest_va & 0xFFF) + sizeof(T)) > 0x1000) {
|
if (((guest_va & 0xFFF) + size) > 0x1000) {
|
||||||
#ifdef MMU_PROFILING
|
#ifdef MMU_PROFILING
|
||||||
unaligned_crossp_w++;
|
unaligned_crossp_w++;
|
||||||
#endif
|
#endif
|
||||||
@ -1271,41 +1227,29 @@ static void write_unaligned(uint32_t guest_va, uint8_t *host_va, T value)
|
|||||||
// Because such accesses suffer a performance penalty, they will be
|
// Because such accesses suffer a performance penalty, they will be
|
||||||
// presumably very rare so don't waste time optimizing the code below.
|
// presumably very rare so don't waste time optimizing the code below.
|
||||||
|
|
||||||
uint32_t shift = (sizeof(T) - 1) * 8;
|
uint32_t shift = (size - 1) * 8;
|
||||||
|
|
||||||
for (int i = 0; i < sizeof(T); shift -= 8, guest_va++, i++) {
|
for (int i = 0; i < size; shift -= 8, guest_va++, i++) {
|
||||||
mmu_write_vmem<uint8_t>(guest_va, (value >> shift) & 0xFF);
|
mmu_write_vmem<uint8_t>(guest_va, (value >> shift) & 0xFF);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef MMU_PROFILING
|
#ifdef MMU_PROFILING
|
||||||
unaligned_writes++;
|
unaligned_writes++;
|
||||||
#endif
|
#endif
|
||||||
switch(sizeof(T)) {
|
switch(size) {
|
||||||
case 1:
|
|
||||||
*host_va = value;
|
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
WRITE_WORD_BE_U(host_va, value);
|
WRITE_WORD_BE_U(host_va, value);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
WRITE_DWORD_BE_U(host_va, value);
|
WRITE_DWORD_BE_U(host_va, value);
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8: // FIXME: should we raise alignment exception here?
|
||||||
if (guest_va & 3) {
|
|
||||||
ppc_exception_handler(Except_Type::EXC_ALIGNMENT, 0x0);
|
|
||||||
}
|
|
||||||
WRITE_QWORD_BE_U(host_va, value);
|
WRITE_QWORD_BE_U(host_va, value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// explicitely instantiate all required write_unaligned variants
|
|
||||||
template void write_unaligned<uint16_t>(uint32_t guest_va, uint8_t *host_va, uint16_t value);
|
|
||||||
template void write_unaligned<uint32_t>(uint32_t guest_va, uint8_t *host_va, uint32_t value);
|
|
||||||
template void write_unaligned<uint64_t>(uint32_t guest_va, uint8_t *host_va, uint64_t value);
|
|
||||||
|
|
||||||
|
|
||||||
/* MMU profiling. */
|
/* MMU profiling. */
|
||||||
#ifdef MMU_PROFILING
|
#ifdef MMU_PROFILING
|
||||||
|
|
||||||
@ -1934,7 +1878,7 @@ uint8_t* quickinstruction_translate(uint32_t addr) {
|
|||||||
|
|
||||||
return real_addr;
|
return real_addr;
|
||||||
}
|
}
|
||||||
#endif // Old and slow code
|
#endif
|
||||||
|
|
||||||
uint64_t mem_read_dbg(uint32_t virt_addr, uint32_t size) {
|
uint64_t mem_read_dbg(uint32_t virt_addr, uint32_t size) {
|
||||||
uint32_t save_dsisr, save_dar;
|
uint32_t save_dsisr, save_dar;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user