diff --git a/Makefile.cfg b/Makefile.cfg index 5ab4f01..02e8707 100644 --- a/Makefile.cfg +++ b/Makefile.cfg @@ -89,7 +89,7 @@ endif # You generally shouldn't change this unless you are making forked # versions (or test versions) # Version numbers must be of the form x.x.x -VERSION = 1.0.6 +VERSION = 1.0.7 # Define this if you want a standalone, statically linked, no dependency binary #STANDALONE_BINARY = 1 diff --git a/host-src/tool/dc-io.h b/host-src/tool/dc-io.h index ea38b6f..ad9bd80 100644 --- a/host-src/tool/dc-io.h +++ b/host-src/tool/dc-io.h @@ -5,5 +5,6 @@ int send_uint(unsigned int value); unsigned int recv_uint(void); void recv_data(void *data, unsigned int total, unsigned int verbose); void send_data(unsigned char *addr, unsigned int size, unsigned int verbose); +void finish_serial(void); #endif /* __DC_IO_H__ */ diff --git a/host-src/tool/dc-tool.c b/host-src/tool/dc-tool.c index fee2f95..c45d75a 100644 --- a/host-src/tool/dc-tool.c +++ b/host-src/tool/dc-tool.c @@ -858,8 +858,6 @@ void usage(void) { printf("-g Start a GDB server\n"); printf("-h Usage information (you\'re looking at it)\n\n"); cleanup(); - - exit(0); } /* Got to make sure WinSock is initalized */ @@ -1209,11 +1207,14 @@ void do_console(unsigned char *path, unsigned char *isofile) { case 21: dc_rewinddir(); break; + case 22: + dc_exit(); + break; default: printf("Unimplemented command (%d) \n", command); printf("Assuming program has exited, or something...\n"); finish_serial(); - exit(0); + exit(-1); break; } } @@ -1263,16 +1264,17 @@ int main(int argc, char *argv[]) { unsigned char *isofile = 0; int someopt; - if(argc < 2) + if (argc < 2) { usage(); - + exit(-1); + } someopt = getopt(argc, argv, AVAILABLE_OPTIONS); while(someopt > 0) { switch(someopt) { case 'x': if(command) { printf("You can only specify one of -x, -u, and -d\n"); - exit(0); + exit(-1); } command = 'x'; filename = malloc(strlen(optarg) + 1); @@ -1281,7 +1283,7 @@ int main(int argc, char *argv[]) { case 'u': if(command) { printf("You can only specify one of -x, -u, and -d\n"); - exit(0); + exit(-1); } command = 'u'; filename = malloc(strlen(optarg) + 1); @@ -1290,7 +1292,7 @@ int main(int argc, char *argv[]) { case 'd': if(command) { printf("You can only specify one of -x, -u, and -d\n"); - exit(0); + exit(-1); } command = 'd'; filename = malloc(strlen(optarg) + 1); @@ -1332,6 +1334,7 @@ int main(int argc, char *argv[]) { break; case 'h': usage(); + exit(0); break; case 'e': speedhack = 1; @@ -1359,7 +1362,7 @@ int main(int argc, char *argv[]) { struct stat statbuf; if(stat((char *)filename, &statbuf)) { perror((char *)filename); - exit(1); + exit(-1); } } @@ -1427,7 +1430,7 @@ int main(int argc, char *argv[]) { if(!size) { printf("You must specify a size (-s ) with download (-d )\n"); cleanup(); - exit(0); + exit(-1); } printf("Download %d bytes at <0x%x> to <%s>\n", size, address, filename); @@ -1439,6 +1442,7 @@ int main(int argc, char *argv[]) { do_dumbterm(); else usage(); + exit(-1); break; } diff --git a/host-src/tool/syscalls.c b/host-src/tool/syscalls.c index 6bf14a3..edbd616 100644 --- a/host-src/tool/syscalls.c +++ b/host-src/tool/syscalls.c @@ -553,3 +553,11 @@ void dc_gdbpacket(void) { if(retval > 0) send_data((unsigned char *)gdb_buf, retval, 0); } + +void dc_exit(void) { + int exit_code = (int32_t) recv_uint(); + printf("Program returned %d\n", exit_code); + finish_serial(); + exit(exit_code); +} + diff --git a/host-src/tool/syscalls.h b/host-src/tool/syscalls.h index 82a7aba..5983c3d 100644 --- a/host-src/tool/syscalls.h +++ b/host-src/tool/syscalls.h @@ -46,4 +46,6 @@ void dc_cdfs_redir_read_sectors(int isofd); void dc_gdbpacket(void); +_Noreturn void dc_exit(void); + #endif diff --git a/target-src/dcload/syscalls.c b/target-src/dcload/syscalls.c index 0556559..2d3af41 100644 --- a/target-src/dcload/syscalls.c +++ b/target-src/dcload/syscalls.c @@ -44,8 +44,9 @@ int strlen(const char *s) { return c; } -void dcexit(void) { - scif_putchar(0); +void dcexit(int ret_code) { + scif_putchar(22); + put_uint(ret_code); scif_flush(); }