@@ -204,6 +204,7 @@ static void perform_dir(const char *arg);
204204static void perform_echo_dot (const char * arg );
205205static void perform_echo (const char * arg );
206206static void perform_elfexec (const char * arg );
207+ static void perform_elfload (const char * arg );
207208static void perform_exit (const char * arg );
208209static void perform_for (const char * arg );
209210static 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+
27312760static void perform_break (const char * arg )
27322761 {
27332762 if (stricmp (arg , "off" ) == 0 )
0 commit comments