Skip to content

Commit

Permalink
[sh4] Print warning on invalid P4 read access rather than crashing
Browse files Browse the repository at this point in the history
  • Loading branch information
Senryoku committed Jul 14, 2024
1 parent c466254 commit 9eb10c8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/sh4.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,10 @@ pub const SH4 = struct {
// Too spammy, even for debugging.
P4Register.TCNT0 => return @constCast(self).p4_register_addr(T, virtual_addr).*,
else => {
if (!(virtual_addr & 0xFF000000 == 0xFF000000 or virtual_addr & 0xFF000000 == 0x1F000000) or !(virtual_addr & 0b0000_0000_0000_0111_1111_1111_1000_0000 == 0)) {
sh4_log.warn(termcolor.yellow(" Invalid Read({any}) to P4 register @{X:0>8}"), .{ T, virtual_addr });
return 0;
}
sh4_log.debug(" Read({any}) to P4 register @{X:0>8} {s} = 0x{X}", .{ T, virtual_addr, P4.getP4RegisterName(virtual_addr), @constCast(self).p4_register_addr(T, virtual_addr).* });
return @constCast(self).p4_register_addr(T, virtual_addr).*;
},
Expand Down

0 comments on commit 9eb10c8

Please sign in to comment.