feat: implement debug i/o in Bus Interface

This commit is contained in:
Rekai Nyangadzayi Musuka 2023-06-29 23:12:08 -05:00
parent 3c8a87c14d
commit dacb9c71e8
1 changed files with 46 additions and 0 deletions

View File

@ -45,6 +45,14 @@ pub const Bus = struct {
write16: *const fn (ptr: *anyopaque, address: u32, value: u16) void, write16: *const fn (ptr: *anyopaque, address: u32, value: u16) void,
write32: *const fn (ptr: *anyopaque, address: u32, value: u32) void, write32: *const fn (ptr: *anyopaque, address: u32, value: u32) void,
dbg_read8: *const fn (ptr: *anyopaque, address: u32) u8,
dbg_read16: *const fn (ptr: *anyopaque, address: u32) u16,
dbg_read32: *const fn (ptr: *anyopaque, address: u32) u32,
dbg_write8: *const fn (ptr: *anyopaque, address: u32, value: u8) void,
dbg_write16: *const fn (ptr: *anyopaque, address: u32, value: u16) void,
dbg_write32: *const fn (ptr: *anyopaque, address: u32, value: u32) void,
reset: *const fn (ptr: *anyopaque) void, reset: *const fn (ptr: *anyopaque) void,
}; };
@ -89,6 +97,36 @@ pub const Bus = struct {
self.write(u32, address, value); self.write(u32, address, value);
} }
fn dbgRead8(ptr: *anyopaque, address: u32) u8 {
const self = @ptrCast(P, @alignCast(alignment, ptr));
return self.dbgRead(u8, address);
}
fn dbgRead16(ptr: *anyopaque, address: u32) u16 {
const self = @ptrCast(P, @alignCast(alignment, ptr));
return self.dbgRead(u16, address);
}
fn dbgRead32(ptr: *anyopaque, address: u32) u32 {
const self = @ptrCast(P, @alignCast(alignment, ptr));
return self.dbgRead(u32, address);
}
fn dbgWrite8(ptr: *anyopaque, address: u32, value: u8) void {
const self = @ptrCast(P, @alignCast(alignment, ptr));
self.dbgWrite(u8, address, value);
}
fn dbgWrite16(ptr: *anyopaque, address: u32, value: u16) void {
const self = @ptrCast(P, @alignCast(alignment, ptr));
self.dbgWrite(u16, address, value);
}
fn dbgWrite32(ptr: *anyopaque, address: u32, value: u32) void {
const self = @ptrCast(P, @alignCast(alignment, ptr));
self.dbgWrite(u32, address, value);
}
fn reset(ptr: *anyopaque) void { fn reset(ptr: *anyopaque) void {
const self = @ptrCast(P, @alignCast(alignment, ptr)); const self = @ptrCast(P, @alignCast(alignment, ptr));
self.reset(); self.reset();
@ -106,6 +144,14 @@ pub const Bus = struct {
.write16 = impl.write16, .write16 = impl.write16,
.write32 = impl.write32, .write32 = impl.write32,
.dbg_read8 = impl.dbgRead8,
.dbg_read16 = impl.dbgRead16,
.dbg_read32 = impl.dbgRead32,
.dbg_write8 = impl.dbgWrite8,
.dbg_write16 = impl.dbgWrite16,
.dbg_write32 = impl.dbgWrite32,
.reset = impl.reset, .reset = impl.reset,
}, },
}; };