Compare commits

...

3 Commits

2 changed files with 20 additions and 22 deletions

View File

@ -57,19 +57,16 @@ pub fn parse(self: *Self, allocator: Allocator, emu: Emulator) !String {
return .{ .alloc = try std.fmt.allocPrint(allocator, "T{x:0>2}thread:1;", .{@enumToInt(ret)}) };
},
'g' => {
// TODO: Actually reference GBA Registers
const r = emu.registers();
const cpsr = emu.cpsr();
const char_len = 2;
const reg_len = @sizeOf(u32) * char_len; // Every byte is represented by 2 characters
const reg_len = @sizeOf(u32) * 2; // Every byte is represented by 2 characters
const ret = try allocator.alloc(u8, r.len * reg_len + reg_len); // r0 -> r15 + CPSR
{
var i: u32 = 0;
while (i < r.len + 1) : (i += 1) {
const reg: u32 = if (i < r.len) r[i] else cpsr;
const reg: u32 = @byteSwap(if (i < r.len) r[i] else cpsr); // Seems like GDB expects this
// bufPrintIntToSlice writes to the provided slice, which is all we want from this
// consequentially, we ignore the slice it returns since it just references the slice
@ -110,6 +107,10 @@ pub fn parse(self: *Self, allocator: Allocator, emu: Emulator) !String {
's' => @panic("TODO: Step"),
// Optional
'D' => {
log.info("Disconneccting...", .{});
return .{ .static = "OK" };
},
'H' => {
log.warn("{s}", .{self.contents});
@ -184,6 +185,8 @@ pub fn parse(self: *Self, allocator: Allocator, emu: Emulator) !String {
const offset_str = tokens.next() orelse return .{ .static = "E9999" };
const length_str = tokens.next() orelse return .{ .static = "E9999" };
log.info("Providing GBA memory map", .{});
const offset = try std.fmt.parseInt(usize, offset_str, 16);
const length = try std.fmt.parseInt(usize, length_str, 16);

View File

@ -39,23 +39,18 @@ pub const target: []const u8 =
// Game Pak SRAM isn't included
// TODO: Can i be more specific here?
pub const memory_map: []const u8 =
\\ <?xml version="1.0"?>
\\ <!DOCTYPE memory-map
\\ PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN"
\\ "http://sourceware.org/gdb/gdb-memory-map.dtd">
\\
\\ <memory-map>
\\ <memory type="rom" start="0" length="4000">
\\ <memory type="ram" start="2000000" length="40000">
\\ <memory type="ram" start="3000000" length="8000">
\\ <memory type="ram" start="4000000" length="400">
\\ <memory type="ram" start="5000000" length="400">
\\ <memory type="ram" start="6000000" length="18000">
\\ <memory type="ram" start="7000000" length="400">
\\ <memory type="rom" start="8000000" length="20000000">
\\ <memory type="rom" start="A000000" length="20000000">
\\ <memory type="rom" start="C000000" length="20000000">
\\ </memory-map>;
\\ <memory-map version="1.0">
\\ <memory type="rom" start="0x00000000" length="0x00004000"/>
\\ <memory type="ram" start="0x02000000" length="0x00040000"/>
\\ <memory type="ram" start="0x03000000" length="0x00008000"/>
\\ <memory type="ram" start="0x04000000" length="0x00000400"/>
\\ <memory type="ram" start="0x05000000" length="0x00000400"/>
\\ <memory type="ram" start="0x06000000" length="0x00018000"/>
\\ <memory type="ram" start="0x07000000" length="0x00000400"/>
\\ <memory type="rom" start="0x08000000" length="0x02000000"/>
\\ <memory type="rom" start="0x0A000000" length="0x02000000"/>
\\ <memory type="rom" start="0x0C000000" length="0x02000000"/>
\\ </memory-map>
;
// FIXME: Shouldn't this be a Packet Struct?