fxos: internalize assembly tables, for real this time
This commit is contained in:
parent
9b817fe808
commit
f5ad03152d
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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<char[]>(ptrsize);
|
||||
memcpy(this->data.get(), ptr, ptrsize);
|
||||
this->size = ptrsize;
|
||||
this->path = path;
|
||||
}
|
||||
|
|
|
@ -24,23 +24,6 @@ void _dot(Session &s, std::vector<std::string> 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 "<file>"
|
||||
|
||||
Loads a disassembly table from the specified file. This command is mostly
|
||||
designed to be used in startup scripts.
|
||||
)");
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue