tmp: progress towards gdb stub

This commit is contained in:
Rekai Nyangadzayi Musuka 2023-12-15 00:49:29 -06:00
parent 14f5682095
commit e96be7b18a
5 changed files with 50 additions and 1 deletions

3
.gitmodules vendored
View File

@ -7,3 +7,6 @@
[submodule "lib/arm32"]
path = lib/arm32
url = https://git.musuka.dev/paoda/arm32.git
[submodule "lib/zba-gdbstub"]
path = lib/zba-gdbstub
url = https://git.musuka.dev/paoda/zba-gdbstub

View File

@ -1,8 +1,9 @@
const std = @import("std");
const Sdk = @import("lib/SDL.zig/Sdk.zig");
const Sdk = @import("lib/SDL.zig/build.zig");
const zgui = @import("lib/zgui/build.zig");
const arm32 = @import("lib/arm32/build.zig");
const gdbstub = @import("lib/zba-gdbstub/build.zig");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
@ -29,6 +30,7 @@ pub fn build(b: *std.Build) void {
});
exe.addModule("arm32", arm32.module(b));
exe.addModule("gdbstub", gdbstub.module(b));
exe.addModule("zig-clap", b.dependency("zig-clap", .{}).module("clap"));
exe.addAnonymousModule("bitfield", .{ .source_file = .{ .path = "lib/bitfield.zig" } }); // https://github.com/FlorenceOS/

1
lib/zba-gdbstub Submodule

@ -0,0 +1 @@
Subproject commit 479319e7cad78c3fd38b6865c56e9fe9e78d495c

42
src/gdb.zig Normal file
View File

@ -0,0 +1,42 @@
const std = @import("std");
const Server = @import("gdbstub").Server;
const Interface = @import("gdbstub").Emulator;
const System = @import("core/emu.zig").System;
const Scheduler = @import("core/Scheduler.zig");
const Allocator = std.mem.Allocator;
pub const TurboWrapper = struct {
system: System,
scheduler: *Scheduler,
pub fn init(system: System, scheduler: *Scheduler) @This() {
return .{ .system = system, .scheduler = scheduler };
}
pub fn interface(self: *@This(), allocator: Allocator) Interface {
return Interface.init(allocator, self);
}
pub fn read(self: *const @This(), addr: u32) u8 {
return self.cpu.bus.dbgRead(u8, addr);
}
pub fn write(self: *@This(), addr: u32, value: u8) void {
self.cpu.bus.dbgWrite(u8, addr, value);
}
pub fn registers(self: *const @This()) *[16]u32 {
return &self.cpu.r;
}
pub fn cpsr(self: *const @This()) u32 {
return self.cpu.cpsr.raw;
}
pub fn step(self: *@This()) void {
_ = self;
@panic("TODO: Handle ARM7 and ARM9 lol");
}
};

View File

@ -14,6 +14,7 @@ const ClapResult = clap.Result(clap.Help, &cli_params, clap.parsers.default);
const cli_params = clap.parseParamsComptime(
\\-h, --help Display this help and exit.
\\-f, --firm <str> Path to NDS Firmware Directory
\\--gdb Run Turbo in GDB Mode
\\<str> Path to the NDS ROM
\\
);