1 |
/* |
/* |
2 |
* Copyright (C) 2003-2006 Anders Gavare. All rights reserved. |
* Copyright (C) 2003-2007 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: file.c,v 1.135 2006/10/27 04:21:15 debug Exp $ |
* $Id: file.c,v 1.140 2007/02/10 14:29:54 debug Exp $ |
29 |
* |
* |
30 |
* This file contains functions which load executable images into (emulated) |
* This file contains functions which load executable images into (emulated) |
31 |
* memory. File formats recognized so far are: |
* memory. File formats recognized so far are: |
1405 |
ok = 1; |
ok = 1; |
1406 |
} |
} |
1407 |
break; |
break; |
1408 |
case ARCH_AVR32: |
/* case ARCH_AVR32: |
1409 |
switch (emachine) { |
switch (emachine) { |
1410 |
case 6317: |
case 6317: |
1411 |
ok = 1; |
ok = 1; |
1428 |
case EM_IA_64: |
case EM_IA_64: |
1429 |
ok = 1; |
ok = 1; |
1430 |
} |
} |
1431 |
break; |
break; */ |
1432 |
case ARCH_M68K: |
case ARCH_M68K: |
1433 |
switch (emachine) { |
switch (emachine) { |
1434 |
case EM_68K: |
case EM_68K: |
1462 |
ok = 1; |
ok = 1; |
1463 |
} |
} |
1464 |
break; |
break; |
1465 |
case ARCH_X86: |
/* case ARCH_X86: |
1466 |
switch (emachine) { |
switch (emachine) { |
1467 |
case EM_386: |
case EM_386: |
1468 |
case EM_486: |
case EM_486: |
1474 |
ok = 1; |
ok = 1; |
1475 |
break; |
break; |
1476 |
} |
} |
1477 |
break; |
break; */ |
1478 |
default: |
default: |
1479 |
fatal("file.c: INTERNAL ERROR: Unimplemented arch!\n"); |
fatal("file.c: INTERNAL ERROR: Unimplemented arch!\n"); |
1480 |
} |
} |
2086 |
"floppy image. Maybe you forgot the\n-d switch?\n"); |
"floppy image. Maybe you forgot the\n-d switch?\n"); |
2087 |
|
|
2088 |
/* |
/* |
2089 |
|
* Ugly hack for Dreamcast: When booting from a Dreamcast CDROM |
2090 |
|
* image, a temporary file is extracted into /tmp/gxemul.*, but this |
2091 |
|
* is a "scrambled" raw binary. This code unscrambles it, and loads |
2092 |
|
* it as a raw binary. |
2093 |
|
*/ |
2094 |
|
if (machine->machine_type == MACHINE_DREAMCAST && |
2095 |
|
strncmp(filename, "/tmp/gxemul.", 12) == 0) { |
2096 |
|
char *tmp_filename = malloc(strlen(filename) + 100); |
2097 |
|
snprintf(tmp_filename, strlen(filename) + 100, |
2098 |
|
"%s.descrambled", filename); |
2099 |
|
debug("descrambling into %s\n", tmp_filename); |
2100 |
|
dreamcast_descramble(filename, tmp_filename); |
2101 |
|
|
2102 |
|
snprintf(tmp_filename, strlen(filename) + 100, |
2103 |
|
"0x8c010000:%s.descrambled", filename); |
2104 |
|
debug("loading descrambled Dreamcast binary\n"); |
2105 |
|
file_load_raw(machine, mem, tmp_filename, entrypointp); |
2106 |
|
free(tmp_filename); |
2107 |
|
|
2108 |
|
/* Hack: Start a "boot from CDROM" sequence: */ |
2109 |
|
*entrypointp = 0x8c000080; |
2110 |
|
goto ret; |
2111 |
|
} |
2112 |
|
|
2113 |
|
/* |
2114 |
* Last resort: symbol definitions from nm (or nm -S): |
* Last resort: symbol definitions from nm (or nm -S): |
2115 |
* |
* |
2116 |
* If the buf contains typical 'binary' characters, then print |
* If the buf contains typical 'binary' characters, then print |