diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a4f176..ef8f497 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,18 @@ add_custom_command( "${CMAKE_CURRENT_SOURCE_DIR}/lib/syscalls_cg.def" > "${CMAKE_CURRENT_BINARY_DIR}/FxOS_SyscallDefs_CG.c" DEPENDS lib/syscalls_cg.def) +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/FxOS_AsmDefs_SH3.c" + COMMAND xxd -i -n FxOS_AsmDefs_SH3 + "${CMAKE_CURRENT_SOURCE_DIR}/lib/sh3.def" > + "${CMAKE_CURRENT_BINARY_DIR}/FxOS_AsmDefs_SH3.c" + DEPENDS lib/sh3.def) +add_custom_command( + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/FxOS_AsmDefs_SH4.c" + COMMAND xxd -i -n FxOS_AsmDefs_SH4 + "${CMAKE_CURRENT_SOURCE_DIR}/lib/sh4.def" > + "${CMAKE_CURRENT_BINARY_DIR}/FxOS_AsmDefs_SH4.c" + DEPENDS lib/sh4.def) set(fxos_core_SOURCES lib/analysis.cpp @@ -80,6 +92,8 @@ set(fxos_core_SOURCES lib/vspace.cpp "${CMAKE_CURRENT_BINARY_DIR}/FxOS_SyscallDefs_FX.c" "${CMAKE_CURRENT_BINARY_DIR}/FxOS_SyscallDefs_CG.c" + "${CMAKE_CURRENT_BINARY_DIR}/FxOS_AsmDefs_SH3.c" + "${CMAKE_CURRENT_BINARY_DIR}/FxOS_AsmDefs_SH4.c" lib/ai/RelConst.cpp lib/util/bson.cpp diff --git a/include/fxos/util/Buffer.h b/include/fxos/util/Buffer.h index 08ce09f..2aabfab 100644 --- a/include/fxos/util/Buffer.h +++ b/include/fxos/util/Buffer.h @@ -46,6 +46,9 @@ struct Buffer /* Create a buffer by copying and resizing another buffer */ Buffer(Buffer const &other, size_t new_size, int fill = 0x00); + /* Buffer initialized from pure data. */ + Buffer(void const *ptr, size_t size, std::string const &path = "(inline)"); + /* Buffer size */ size_t size; /* Data */ diff --git a/lib/util/Buffer.cpp b/lib/util/Buffer.cpp index 5d856d1..9bd6b79 100644 --- a/lib/util/Buffer.cpp +++ b/lib/util/Buffer.cpp @@ -123,3 +123,11 @@ Buffer::Buffer(Buffer const &other, size_t new_size, int fill): memcpy(this->data.get(), other.data.get(), std::min(new_size, other.size)); this->path = other.path; } + +Buffer::Buffer(void const *ptr, size_t ptrsize, std::string const &path) +{ + this->data = std::make_unique(ptrsize); + memcpy(this->data.get(), ptr, ptrsize); + this->size = ptrsize; + this->path = path; +} diff --git a/shell/dot.cpp b/shell/dot.cpp index cae70e4..cf7eb1c 100644 --- a/shell/dot.cpp +++ b/shell/dot.cpp @@ -24,23 +24,6 @@ void _dot(Session &s, std::vector const &files, bool absolute) lex_include(paths); } -//--- -// .dt -//--- - -static std::string parse_dot_dt(Session &session, Parser &parser) -{ - std::string filename = parser.str(); - parser.end(); - return session.file(filename); -} - -void _dot_dt(Session &, std::string filename) -{ - Buffer buf(filename); - FxOS::load_instructions(buf); -} - //--- // Command registration //--- @@ -53,14 +36,3 @@ static ShellCommand _dot_cmd( Reads file paths from its string arguments, and executes each of them as a sequence of commands in the order of the command line. )"); - -static ShellCommand _dot_dt_cmd( - ".dt", [](Session &s, Parser &p) { _dot_dt(s, parse_dot_dt(s, p)); }, - [](Session &s, Parser &p) { parse_dot_dt(s, p); }, - "Include Disassembly Table", - R"( -.dt "" - -Loads a disassembly table from the specified file. This command is mostly -designed to be used in startup scripts. -)"); diff --git a/shell/main.cpp b/shell/main.cpp index d88e41b..3f13c90 100644 --- a/shell/main.cpp +++ b/shell/main.cpp @@ -413,6 +413,18 @@ int main(int argc, char **argv) if(histfile[0]) read_history(histfile); + /* Load embedded instruction tables */ + + extern char const FxOS_AsmDefs_SH3[]; + extern int FxOS_AsmDefs_SH3_len; + Buffer defSH3(FxOS_AsmDefs_SH3, FxOS_AsmDefs_SH3_len, "lib/sh3.def"); + FxOS::load_instructions(defSH3); + + extern char const FxOS_AsmDefs_SH4[]; + extern int FxOS_AsmDefs_SH4_len; + Buffer defSH4(FxOS_AsmDefs_SH4, FxOS_AsmDefs_SH4_len, "lib/sh4.def"); + FxOS::load_instructions(defSH4); + /* Load a project as specified by command-line arguments */ load_initial_project(s, opts.load, opts.load_is_by_name); /* If none was given or it failed, load the most recent project */