/[gxemul]/upstream/0.4.4/src/file.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /upstream/0.4.4/src/file.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 24 by dpavlin, Mon Oct 8 16:19:56 2007 UTC revision 32 by dpavlin, Mon Oct 8 16:20:58 2007 UTC
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: file.c,v 1.131 2006/03/30 19:36:03 debug Exp $   *  $Id: file.c,v 1.135 2006/10/27 04:21:15 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:
# Line 1163  static void file_load_raw(struct machine Line 1163  static void file_load_raw(struct machine
1163          char *filename, uint64_t *entrypointp)          char *filename, uint64_t *entrypointp)
1164  {  {
1165          FILE *f;          FILE *f;
1166          int len;          int len, sign3264;
1167          unsigned char buf[4096];          unsigned char buf[16384];
1168          uint64_t entry, loadaddr, vaddr, skip = 0;          uint64_t entry, loadaddr, vaddr, skip = 0;
1169          char *p, *p2;          char *p, *p2;
1170    
1171            /*  Special case for 32-bit MIPS:  */
1172            sign3264 = 0;
1173            if (m->arch == ARCH_MIPS && m->cpus[0]->is_32bit)
1174                    sign3264 = 1;
1175    
1176          p = strchr(filename, ':');          p = strchr(filename, ':');
1177          if (p == NULL) {          if (p == NULL) {
1178                  fprintf(stderr, "\n");                  fprintf(stderr, "\n");
# Line 1191  static void file_load_raw(struct machine Line 1196  static void file_load_raw(struct machine
1196          } else          } else
1197                  p = p2;                  p = p2;
1198    
1199            if (sign3264) {
1200                    loadaddr = (int64_t)(int32_t)loadaddr;
1201                    entry = (int64_t)(int32_t)entry;
1202                    vaddr = (int64_t)(int32_t)vaddr;
1203                    skip = (int64_t)(int32_t)skip;
1204            }
1205    
1206          f = fopen(strrchr(filename, ':')+1, "r");          f = fopen(strrchr(filename, ':')+1, "r");
1207          if (f == NULL) {          if (f == NULL) {
1208                  perror(p);                  perror(p);
# Line 1201  static void file_load_raw(struct machine Line 1213  static void file_load_raw(struct machine
1213    
1214          /*  Load file contents:  */          /*  Load file contents:  */
1215          while (!feof(f)) {          while (!feof(f)) {
1216                  len = fread(buf, 1, sizeof(buf), f);                  size_t to_read = sizeof(buf);
1217    
1218                    /*  If vaddr isn't buf-size aligned, then start with a
1219                        smaller buffer:  */
1220                    if (vaddr & (sizeof(buf) - 1))
1221                            to_read = sizeof(buf) - (vaddr & (sizeof(buf)-1));
1222    
1223                    len = fread(buf, 1, to_read, f);
1224    
1225                  if (len > 0)                  if (len > 0)
1226                          m->cpus[0]->memory_rw(m->cpus[0], mem, vaddr, &buf[0],                          m->cpus[0]->memory_rw(m->cpus[0], mem, vaddr, &buf[0],
# Line 1386  static void file_load_elf(struct machine Line 1405  static void file_load_elf(struct machine
1405                          ok = 1;                          ok = 1;
1406                  }                  }
1407                  break;                  break;
1408            case ARCH_AVR32:
1409                    switch (emachine) {
1410                    case 6317:
1411                            ok = 1;
1412                    }
1413                    break;
1414          case ARCH_HPPA:          case ARCH_HPPA:
1415                  switch (emachine) {                  switch (emachine) {
1416                  case EM_PARISC:                  case EM_PARISC:
# Line 1476  static void file_load_elf(struct machine Line 1501  static void file_load_elf(struct machine
1501                  debug("%08"PRIx32"\n", (uint32_t) eentry);                  debug("%08"PRIx32"\n", (uint32_t) eentry);
1502    
1503          /*          /*
1504           *  SH64: 32-bit instruction encoding?  TODO           *  SH64: 32-bit instruction encoding?
1505           */           */
1506          if (arch == ARCH_SH && (eentry & 1)) {          if (arch == ARCH_SH && (eentry & 1)) {
1507                  debug("SH64: 32-bit instruction encoding\n");                  debug("SH64: 32-bit instruction encoding\n");
1508                  m->cpus[0]->cd.sh.compact = 0;                  m->cpus[0]->cd.sh.compact = 0;
1509                  m->cpus[0]->cd.sh.bits = 64;                  m->cpus[0]->cd.sh.cpu_type.bits = 64;
1510          }          }
1511    
1512          /*  Read the program headers:  */          /*  Read the program headers:  */

Legend:
Removed from v.24  
changed lines
  Added in v.32

  ViewVC Help
Powered by ViewVC 1.1.26