forked from Miroirs/x49gp
Compare commits
2 commits
6fe6c501b0
...
69ce49c003
Author | SHA1 | Date | |
---|---|---|---|
|
69ce49c003 | ||
|
b5f7f5dfde |
5 changed files with 39 additions and 51 deletions
|
@ -705,7 +705,7 @@ static int gdb_handle_packet( GDBState* s, const char* line_buf )
|
|||
case 'k':
|
||||
/* Kill the target */
|
||||
fprintf( stderr, "\nQEMU: Terminated via GDBstub\n" );
|
||||
exit( 0 );
|
||||
exit( EXIT_SUCCESS );
|
||||
case 'D':
|
||||
/* Detach packet */
|
||||
gdb_breakpoint_remove_all();
|
||||
|
|
|
@ -36,7 +36,7 @@ int main( int argc, char** argv )
|
|||
|
||||
if ( argc < 3 ) {
|
||||
fprintf( stderr, "usage: %s <infile> <outfile>\n", argv[ 0 ] );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( !strcmp( argv[ 1 ], "-" ) )
|
||||
|
@ -45,7 +45,7 @@ int main( int argc, char** argv )
|
|||
in = open( argv[ 1 ], O_RDONLY );
|
||||
if ( in < 0 ) {
|
||||
perror( argv[ 1 ] );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ int main( int argc, char** argv )
|
|||
out = open( argv[ 2 ], O_WRONLY | O_CREAT | O_TRUNC, 0666 );
|
||||
if ( out < 0 ) {
|
||||
perror( argv[ 2 ] );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,12 +65,12 @@ int main( int argc, char** argv )
|
|||
input = ( unsigned char* )malloc( size );
|
||||
if ( !input ) {
|
||||
fprintf( stderr, "%s: out of memory\n", argv[ 0 ] );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( read( in, input, size ) != size ) {
|
||||
perror( "read" );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
close( in );
|
||||
|
@ -78,7 +78,7 @@ int main( int argc, char** argv )
|
|||
memory = malloc( size >> 1 );
|
||||
if ( !memory ) {
|
||||
fprintf( stderr, "%s: out of memory\n", argv[ 0 ] );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
p = input;
|
||||
|
@ -91,7 +91,7 @@ int main( int argc, char** argv )
|
|||
memory[ i ] = ( *p - 'A' + 10 ) << 0;
|
||||
else {
|
||||
fprintf( stderr, "%s: parse error at byte %d\n", argv[ 0 ], i );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
p++;
|
||||
if ( '0' <= *p && *p <= '9' )
|
||||
|
@ -102,7 +102,7 @@ int main( int argc, char** argv )
|
|||
memory[ i ] |= ( *p - 'A' + 10 ) << 4;
|
||||
else {
|
||||
fprintf( stderr, "%s: parse error at byte %d\n", argv[ 0 ], i );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ int main( int argc, char** argv )
|
|||
|
||||
if ( argc < 3 ) {
|
||||
fprintf( stderr, "usage: %s <infile> <outfile>\n", argv[ 0 ] );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( !strcmp( argv[ 1 ], "-" ) )
|
||||
|
@ -45,7 +45,7 @@ int main( int argc, char** argv )
|
|||
in = open( argv[ 1 ], O_RDONLY );
|
||||
if ( in < 0 ) {
|
||||
perror( argv[ 1 ] );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -55,7 +55,7 @@ int main( int argc, char** argv )
|
|||
out = open( argv[ 2 ], O_WRONLY | O_CREAT | O_TRUNC, 0666 );
|
||||
if ( out < 0 ) {
|
||||
perror( argv[ 2 ] );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,12 +65,12 @@ int main( int argc, char** argv )
|
|||
input = ( unsigned char* )malloc( size );
|
||||
if ( !input ) {
|
||||
fprintf( stderr, "%s: out of memory\n", argv[ 0 ] );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( read( in, input, size ) != size ) {
|
||||
perror( "read" );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
close( in );
|
||||
|
@ -78,7 +78,7 @@ int main( int argc, char** argv )
|
|||
memory = malloc( size >> 1 );
|
||||
if ( !memory ) {
|
||||
fprintf( stderr, "%s: out of memory\n", argv[ 0 ] );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
p = input;
|
||||
|
@ -91,7 +91,7 @@ int main( int argc, char** argv )
|
|||
memory[ ( i & ~3 ) + 3 - ( i & 3 ) ] = ( *p - 'A' + 10 ) << 0;
|
||||
else {
|
||||
fprintf( stderr, "%s: parse error at byte %d\n", argv[ 0 ], i );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
p++;
|
||||
if ( '0' <= *p && *p <= '9' )
|
||||
|
@ -102,7 +102,7 @@ int main( int argc, char** argv )
|
|||
memory[ ( i & ~3 ) + 3 - ( i & 3 ) ] |= ( *p - 'A' + 10 ) << 4;
|
||||
else {
|
||||
fprintf( stderr, "%s: parse error at byte %d\n", argv[ 0 ], i );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
|
54
src/main.c
54
src/main.c
|
@ -259,7 +259,7 @@ static void config_init( char* progname, int argc, char* argv[] )
|
|||
struct option long_options[] = {
|
||||
{"help", no_argument, NULL, 'h'},
|
||||
|
||||
{"config", required_argument, NULL, 'c'},
|
||||
{"config", required_argument, NULL, 'c'},
|
||||
|
||||
{"enable-debug", required_argument, NULL, 'D'},
|
||||
{"debug", no_argument, NULL, 'd'},
|
||||
|
@ -277,35 +277,24 @@ static void config_init( char* progname, int argc, char* argv[] )
|
|||
case 'h':
|
||||
fprintf( stderr,
|
||||
"%s %i.%i.%i Emulator for HP 49G+ / 50G calculators\n"
|
||||
"Usage: %s [<options>] [<config-file>]\n"
|
||||
"Usage: %s [<options>]\n"
|
||||
"Valid options:\n"
|
||||
" -c, --config[=<filename>] alternate config file\n"
|
||||
" -D, --enable-debug[=<port>] enable the debugger interface\n"
|
||||
" (default port: %u)\n"
|
||||
" -d, --debug use along -D to also start the"
|
||||
" debugger immediately\n"
|
||||
" -f, --reflash[=firmware] rebuild the flash using the"
|
||||
" supplied firmware\n"
|
||||
" (default: select one"
|
||||
" interactively)\n"
|
||||
" (implies -r for safety"
|
||||
" reasons)\n"
|
||||
" -F, --reflash-full use along -f to drop the"
|
||||
" flash contents\n"
|
||||
" in the area beyond the"
|
||||
" firmware\n"
|
||||
" -r, --reboot reboot on startup instead of"
|
||||
" continuing from the\n"
|
||||
" saved state in the config"
|
||||
" file\n"
|
||||
" -h, --help print this message and exit\n"
|
||||
"The config file is formatted as INI file and contains the"
|
||||
" settings for which\n"
|
||||
"persistence makes sense, like calculator model, CPU"
|
||||
" registers, etc.\n"
|
||||
" -c --config[=<filename>] alternate config file\n"
|
||||
" -D --enable-debug[=<port>] enable the debugger interface\n"
|
||||
" (default port: %u)\n"
|
||||
" -d --debug use along -D to also start the debugger immediately\n"
|
||||
" -f --reflash[=firmware] rebuild the flash using the supplied firmware\n"
|
||||
" (default: select one interactively)\n"
|
||||
" (implies -r for safety reasons)\n"
|
||||
" -F --reflash-full use along -f to drop the flash contents\n"
|
||||
" in the area beyond the firmware\n"
|
||||
" -r --reboot reboot on startup instead of continuing from the\n"
|
||||
" saved state in the config file\n"
|
||||
" -h --help print this message and exit\n"
|
||||
"The config file is formatted as INI file and contains the settings for which\n"
|
||||
" persistence makes sense, like calculator model, CPU registers, etc.\n"
|
||||
"If the config file is omitted, ~/.config/%s/config is used.\n"
|
||||
"Please consult the manual for more details on config file"
|
||||
" settings.\n",
|
||||
"Please consult the manual for more details on config file settings.\n",
|
||||
progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, progname, DEFAULT_GDBSTUB_PORT, progname );
|
||||
exit( EXIT_SUCCESS );
|
||||
break;
|
||||
|
@ -333,8 +322,7 @@ static void config_init( char* progname, int argc, char* argv[] )
|
|||
|
||||
if ( opt.debug_port != 0 && opt.debug_port != DEFAULT_GDBSTUB_PORT )
|
||||
fprintf( stderr,
|
||||
"Additional debug port \"%s\" specified,"
|
||||
" overriding\n",
|
||||
"Additional debug port \"%s\" specified, overriding\n",
|
||||
optarg );
|
||||
opt.debug_port = port;
|
||||
}
|
||||
|
@ -393,7 +381,7 @@ int main( int argc, char** argv )
|
|||
x49gp = malloc( sizeof( x49gp_t ) );
|
||||
if ( NULL == x49gp ) {
|
||||
fprintf( stderr, "%s: %s:%u: Out of memory\n", progname, __FUNCTION__, __LINE__ );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
memset( x49gp, 0, sizeof( x49gp_t ) );
|
||||
|
||||
|
@ -435,7 +423,7 @@ int main( int argc, char** argv )
|
|||
x49gp_s3c2410_init( x49gp );
|
||||
|
||||
if ( x49gp_modules_init( x49gp ) ) {
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
if ( opt.config == NULL ) {
|
||||
|
@ -454,7 +442,7 @@ int main( int argc, char** argv )
|
|||
error = x49gp_modules_load( x49gp, opt.config );
|
||||
if ( error || opt.reinit >= X49GP_REINIT_REBOOT_ONLY ) {
|
||||
if ( error && error != -EAGAIN ) {
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
x49gp_modules_reset( x49gp, X49GP_RESET_POWER_ON );
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ int x49gp_modules_init( x49gp_t* x49gp )
|
|||
phys_ram_base = mmap( 0, phys_ram_size, PROT_NONE, MAP_SHARED | MAP_ANON, -1, 0 );
|
||||
if ( phys_ram_base == ( uint8_t* )-1 ) {
|
||||
fprintf( stderr, "%s: can't mmap %08x anonymous bytes\n", __FUNCTION__, phys_ram_size );
|
||||
exit( 1 );
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
#ifdef DEBUG_X49GP_MODULES
|
||||
|
|
Loading…
Reference in a new issue