Skip to content

Commit 1774d54

Browse files
committed
add elfload command
1 parent 0da5350 commit 1774d54

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/command.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ static void perform_dir(const char *arg);
204204
static void perform_echo_dot(const char *arg);
205205
static void perform_echo(const char *arg);
206206
static void perform_elfexec(const char *arg);
207+
static void perform_elfload(const char *arg);
207208
static void perform_exit(const char *arg);
208209
static void perform_for(const char *arg);
209210
static void perform_goto(const char *arg);
@@ -259,6 +260,7 @@ struct built_in_cmd cmd_table[] =
259260
{"echo.", perform_echo_dot, "", "terminal output"}, // before normal echo
260261
{"echo", perform_echo, "", "terminal output"},
261262
{"elfexec", perform_elfexec, "", "execute elf file"},
263+
{"elfload", perform_elfload, "", "load host's elf file"},
262264
{"exit", perform_exit, "", "exit from interpreter"},
263265
{"for", perform_for, "", "FOR loop"},
264266
{"goto", perform_goto, "", "move to label"},
@@ -2728,6 +2730,33 @@ static void perform_elfexec(const char *arg)
27282730
#endif
27292731
}
27302732

2733+
static void perform_elfload(const char *arg)
2734+
{
2735+
#ifdef DJ64
2736+
int rc;
2737+
#endif
2738+
if (!arg || !arg[0])
2739+
{
2740+
cprintf("Syntax error\r\n");
2741+
reset_batfile_call_stack();
2742+
return;
2743+
}
2744+
#if defined(DJ64) && defined(DJ64_API_VERSION) && DJ64_API_VERSION >= 2
2745+
rc = elfload(atoi(arg));
2746+
if (rc == -1)
2747+
printf("elfload failed\n");
2748+
else
2749+
{
2750+
char el[16];
2751+
snprintf(el, sizeof(el), "%d", rc);
2752+
setenv("ERRORLEVEL", el, 1);
2753+
error_level = rc;
2754+
}
2755+
#else
2756+
printf("elfload unsupported\n");
2757+
#endif
2758+
}
2759+
27312760
static void perform_break(const char *arg)
27322761
{
27332762
if (stricmp(arg, "off") == 0)

0 commit comments

Comments
 (0)