Skip to content

Commit e689d62

Browse files
joevtdingusdev
authored andcommitted
debugger: Parse BAT registers.
1 parent 52631da commit e689d62

2 files changed

Lines changed: 20 additions & 11 deletions

File tree

cpu/ppc/ppcmmu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,9 @@ enum TLBFlags : uint16_t {
120120
extern std::function<void(uint32_t bat_reg)> ibat_update;
121121
extern std::function<void(uint32_t bat_reg)> dbat_update;
122122

123+
extern PPC_BAT_entry ibat_array[4];
124+
extern PPC_BAT_entry dbat_array[4];
125+
123126
extern MapDmaResult mmu_map_dma_mem(uint32_t addr, uint32_t size, bool allow_mmio);
124127

125128
extern void mmu_change_mode(void);

debugger/debugger.cpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -526,18 +526,24 @@ static void print_mmu_regs()
526526

527527
printf("\nBAT registers:\n");
528528

529-
for (int i = 0; i < 4; i++) {
530-
printf(" ibat%du : %08X ibat%dl : %08X\n",
531-
i, ppc_state.spr[528+i*2],
532-
i, ppc_state.spr[529+i*2]);
533-
}
534-
535-
if (!is_601) {
536-
for (int i = 0; i < 4; i++) {
537-
printf(" dbat%du : %08X dbat%dl : %08X\n",
538-
i, ppc_state.spr[536+i*2],
539-
i, ppc_state.spr[537+i*2]);
529+
for (int i = 0; i < 4 + (is_601 ? 0 : 4); i++) {
530+
PPC_BAT_entry *bat_entry = i < 4 ? ibat_array : dbat_array;
531+
bat_entry = &bat_entry[i & 3];
532+
printf(" %sbat%du : %08X ibat%dl : %08X ; range : %08X..%08X -> %08X..%08X access : %s%s protection : %s%s",
533+
is_601 ? "" : i < 4 ? "i" : "d",
534+
i & 3, ppc_state.spr[528+i*2],
535+
i & 3, ppc_state.spr[529+i*2],
536+
bat_entry->bepi, bat_entry->bepi + ~bat_entry->hi_mask,
537+
bat_entry->phys_hi, bat_entry->phys_hi + ~bat_entry->hi_mask,
538+
bat_entry->access & 2 ? is_601 ? "Ks" : "Vs" : "__",
539+
bat_entry->access & 1 ? is_601 ? "Ku" : "Vp" : "__",
540+
bat_entry->prot & 2 ? "P" : "_",
541+
bat_entry->prot & 1 ? "P" : "_"
542+
);
543+
if (is_601) {
544+
printf(" (%s)", bat_entry->valid ? "valid" : "invalid");
540545
}
546+
printf("\n");
541547
}
542548

543549
printf("\n");

0 commit comments

Comments
 (0)