From 5da84aff36d68a7d1aedfa8a94e85db7183c4a96 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Sat, 9 Apr 2022 18:01:17 -0300 Subject: [PATCH] chore: log error on open bus in page 0x00 and 0x01 --- src/bus/Bios.zig | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/bus/Bios.zig b/src/bus/Bios.zig index ec00bec..489ee2b 100644 --- a/src/bus/Bios.zig +++ b/src/bus/Bios.zig @@ -29,6 +29,11 @@ pub fn deinit(self: Self) void { pub fn read(self: *const Self, comptime T: type, addr: usize) T { if (self.buf) |buf| { + if (addr > buf.len) { + log.err("Tried to read {} from {X:0>8} (open bus)", .{ T, addr }); + return 0; + } + return switch (T) { u32 => (@as(u32, buf[addr + 3]) << 24) | (@as(u32, buf[addr + 2]) << 16) | (@as(u32, buf[addr + 1]) << 8) | (@as(u32, buf[addr])), u16 => (@as(u16, buf[addr + 1]) << 8) | @as(u16, buf[addr]),