OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [cpu/] [common/] [parse.c] - Diff between revs 82 and 220

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 82 Rev 220
Line 123... Line 123...
    {
    {
      if ((laddr & ~(PAGE_SIZE - 1)) == eval_direct32 (transl_table + i, 0, 0))
      if ((laddr & ~(PAGE_SIZE - 1)) == eval_direct32 (transl_table + i, 0, 0))
        {
        {
          /* Page modified */
          /* Page modified */
          set_direct32 (transl_table + i + 8, -2, 0, 0);
          set_direct32 (transl_table + i + 8, -2, 0, 0);
          PRINTF ("found paddr=%" PRIx32 "\n",
          PRINTFQ ("found paddr=%" PRIx32 "\n",
                  eval_direct32 (transl_table + i + 4, 0, 0) |
                  eval_direct32 (transl_table + i + 4, 0, 0) |
                  (laddr & (PAGE_SIZE - 1)));
                  (laddr & (PAGE_SIZE - 1)));
          return  (oraddr_t) eval_direct32 (transl_table + i + 4, 0, 0) |
          return  (oraddr_t) eval_direct32 (transl_table + i + 4, 0, 0) |
                  (laddr & (oraddr_t) (PAGE_SIZE - 1));
                  (laddr & (oraddr_t) (PAGE_SIZE - 1));
        }
        }
Line 142... Line 142...
          set_direct32 (transl_table + i, laddr & ~(PAGE_SIZE - 1), 0, 0);
          set_direct32 (transl_table + i, laddr & ~(PAGE_SIZE - 1), 0, 0);
          /* PPN */
          /* PPN */
          set_direct32 (transl_table + i + 4, (i / 16) * PAGE_SIZE, 0, 0);
          set_direct32 (transl_table + i + 4, (i / 16) * PAGE_SIZE, 0, 0);
          /* Page modified */
          /* Page modified */
          set_direct32 (transl_table + i + 8, -2, 0, 0);
          set_direct32 (transl_table + i + 8, -2, 0, 0);
          PRINTF ("newly allocated ppn=%" PRIx32 "\n",
          PRINTFQ ("newly allocated ppn=%" PRIx32 "\n",
                  eval_direct32 (transl_table + i + 4, 0, 0));
                  eval_direct32 (transl_table + i + 4, 0, 0));
          PRINTF ("newly allocated .ppn=%" PRIxADDR "\n", transl_table + i + 4);
          PRINTFQ ("newly allocated .ppn=%" PRIxADDR "\n", transl_table + i + 4);
          PRINTF ("newly allocated ofs=%" PRIxADDR "\n",
          PRINTFQ ("newly allocated ofs=%" PRIxADDR "\n",
                  (laddr & (PAGE_SIZE - 1)));
                  (laddr & (PAGE_SIZE - 1)));
          PRINTF ("newly allocated paddr=%" PRIx32 "\n",
          PRINTFQ ("newly allocated paddr=%" PRIx32 "\n",
                  eval_direct32 (transl_table + i + 4, 0,
                  eval_direct32 (transl_table + i + 4, 0,
                                 0) | (laddr & (PAGE_SIZE - 1)));
                                 0) | (laddr & (PAGE_SIZE - 1)));
          return  (oraddr_t) eval_direct32 (transl_table + i + 4, 0, 0) |
          return  (oraddr_t) eval_direct32 (transl_table + i + 4, 0, 0) |
                  (laddr & (oraddr_t) (PAGE_SIZE - 1));
                  (laddr & (oraddr_t) (PAGE_SIZE - 1));
        }
        }
    }
    }
 
 
  /* If we come this far then all phy memory is used and we can't find our
  /* If we come this far then all phy memory is used and we can't find our
     page nor allocate new page. */
     page nor allocate new page. */
  transl_error = 1;
  transl_error = 1;
  PRINTF ("can't translate %" PRIxADDR "\n", laddr);
  PRINTFQ ("can't translate %" PRIxADDR "\n", laddr);
  exit (1);
  exit (1);
 
 
  return  -1;
  return  -1;
 
 
}       /* translate() */
}       /* translate() */
Line 361... Line 361...
        {
        {
          fclose (inputfs);
          fclose (inputfs);
          perror ("readfile_coff");
          perror ("readfile_coff");
          exit (1);
          exit (1);
        }
        }
      PRINTF ("Section: %s,", coffscnhdr.s_name);
      PRINTFQ ("Section: %s,", coffscnhdr.s_name);
      PRINTF (" paddr: 0x%.8lx,", COFF_LONG_H (coffscnhdr.s_paddr));
      PRINTFQ (" paddr: 0x%.8lx,", COFF_LONG_H (coffscnhdr.s_paddr));
      PRINTF (" vaddr: 0x%.8lx,", COFF_LONG_H (coffscnhdr.s_vaddr));
      PRINTFQ (" vaddr: 0x%.8lx,", COFF_LONG_H (coffscnhdr.s_vaddr));
      PRINTF (" size: 0x%.8lx,", COFF_LONG_H (coffscnhdr.s_size));
      PRINTFQ (" size: 0x%.8lx,", COFF_LONG_H (coffscnhdr.s_size));
      PRINTF (" scnptr: 0x%.8lx\n", COFF_LONG_H (coffscnhdr.s_scnptr));
      PRINTFQ (" scnptr: 0x%.8lx\n", COFF_LONG_H (coffscnhdr.s_scnptr));
 
 
      sectsize = COFF_LONG_H (coffscnhdr.s_size);
      sectsize = COFF_LONG_H (coffscnhdr.s_size);
      ++firstthree;
      ++firstthree;
 
 
      /* loading section */
      /* loading section */
Line 394... Line 394...
          sectsize -= len;
          sectsize -= len;
        }
        }
    }
    }
  if (firstthree < 3)
  if (firstthree < 3)
    {
    {
      PRINTF ("One or more missing sections. At least");
      PRINTFQ ("One or more missing sections. At least");
      PRINTF (" three sections expected (.text, .data, .bss).\n");
      PRINTFQ (" three sections expected (.text, .data, .bss).\n");
      exit (1);
      exit (1);
    }
    }
  if (firstthree > 3)
  if (firstthree > 3)
    {
    {
      PRINTF ("Warning: one or more extra sections. These");
      PRINTFQ ("Warning: one or more extra sections. These");
      PRINTF (" sections were handled as .data sections.\n");
      PRINTFQ (" sections were handled as .data sections.\n");
    }
    }
 
 
  fclose (inputfs);
  fclose (inputfs);
  PRINTF ("Finished loading COFF.\n");
  PRINTFQ ("Finished loading COFF.\n");
  return;
  return;
 
 
}       /* readfile_coff () */
}       /* readfile_coff () */
 
 
 
 
Line 490... Line 490...
      syms -= n;
      syms -= n;
      count += n;
      count += n;
    }
    }
 
 
  fclose (inputfs);
  fclose (inputfs);
  PRINTF ("Finished loading symbols.\n");
  PRINTFQ ("Finished loading symbols.\n");
  return;
  return;
}
}
 
 
static void
static void
readfile_elf (char *filename)
readfile_elf (char *filename)
Line 692... Line 692...
            }
            }
 
 
 
 
 
 
          if (ELF_LONG_H (elf_spnt->sh_name) && s_str)
          if (ELF_LONG_H (elf_spnt->sh_name) && s_str)
            PRINTF ("Section: %s,", &s_str[ELF_LONG_H (elf_spnt->sh_name)]);
            {
 
              PRINTFQ ("Section: %s,", &s_str[ELF_LONG_H (elf_spnt->sh_name)]);
 
            }
          else
          else
            PRINTF ("Section: noname,");
            {
          PRINTF (" vaddr: 0x%.8lx,", ELF_LONG_H (elf_spnt->sh_addr));
              PRINTFQ ("Section: noname,");
          PRINTF (" paddr: 0x%" PRIx32, padd);
            }
          PRINTF (" offset: 0x%.8lx,", ELF_LONG_H (elf_spnt->sh_offset));
 
          PRINTF (" size: 0x%.8lx\n", ELF_LONG_H (elf_spnt->sh_size));
          PRINTFQ (" vaddr: 0x%.8lx,", ELF_LONG_H (elf_spnt->sh_addr));
 
          PRINTFQ (" paddr: 0x%" PRIx32, padd);
 
          PRINTFQ (" offset: 0x%.8lx,", ELF_LONG_H (elf_spnt->sh_offset));
 
          PRINTFQ (" size: 0x%.8lx\n", ELF_LONG_H (elf_spnt->sh_size));
 
 
          freemem = padd;
          freemem = padd;
          sectsize = ELF_LONG_H (elf_spnt->sh_size);
          sectsize = ELF_LONG_H (elf_spnt->sh_size);
 
 
          if (fseek (inputfs, ELF_LONG_H (elf_spnt->sh_offset), SEEK_SET) !=
          if (fseek (inputfs, ELF_LONG_H (elf_spnt->sh_offset), SEEK_SET) !=
Line 775... Line 780...
  if (fread (&coffhdr, sizeof (coffhdr), 1, inputfs) == 1)
  if (fread (&coffhdr, sizeof (coffhdr), 1, inputfs) == 1)
    {
    {
      if (COFF_SHORT_H (coffhdr.f_magic) == 0x17a)
      if (COFF_SHORT_H (coffhdr.f_magic) == 0x17a)
        {
        {
          uint32_t opthdr_size;
          uint32_t opthdr_size;
          PRINTF ("COFF magic: 0x%.4x\n", COFF_SHORT_H (coffhdr.f_magic));
          PRINTFQ ("COFF magic: 0x%.4x\n", COFF_SHORT_H (coffhdr.f_magic));
          PRINTF ("COFF flags: 0x%.4x\n", COFF_SHORT_H (coffhdr.f_flags));
          PRINTFQ ("COFF flags: 0x%.4x\n", COFF_SHORT_H (coffhdr.f_flags));
          PRINTF ("COFF symptr: 0x%.8lx\n", COFF_LONG_H (coffhdr.f_symptr));
          PRINTFQ ("COFF symptr: 0x%.8lx\n", COFF_LONG_H (coffhdr.f_symptr));
          if ((COFF_SHORT_H (coffhdr.f_flags) & COFF_F_EXEC) != COFF_F_EXEC)
          if ((COFF_SHORT_H (coffhdr.f_flags) & COFF_F_EXEC) != COFF_F_EXEC)
            {
            {
              PRINTF ("This COFF is not an executable.\n");
              PRINTFQ ("This COFF is not an executable.\n");
              exit (1);
              exit (1);
            }
            }
          opthdr_size = COFF_SHORT_H (coffhdr.f_opthdr);
          opthdr_size = COFF_SHORT_H (coffhdr.f_opthdr);
          if (opthdr_size != sizeof (COFF_AOUTHDR))
          if (opthdr_size != sizeof (COFF_AOUTHDR))
            {
            {
              PRINTF ("COFF optional header is missing or not recognized.\n");
              PRINTFQ ("COFF optional header is missing or not recognized.\n");
              PRINTF ("COFF f_opthdr: 0x%" PRIx32 "\n", opthdr_size);
              PRINTFQ ("COFF f_opthdr: 0x%" PRIx32 "\n", opthdr_size);
              exit (1);
              exit (1);
            }
            }
          fclose (inputfs);
          fclose (inputfs);
          readfile_coff (filename, COFF_SHORT_H (coffhdr.f_nscns));
          readfile_coff (filename, COFF_SHORT_H (coffhdr.f_nscns));
          readsyms_coff (filename, COFF_LONG_H (coffhdr.f_symptr),
          readsyms_coff (filename, COFF_LONG_H (coffhdr.f_symptr),
                         COFF_LONG_H (coffhdr.f_nsyms));
                         COFF_LONG_H (coffhdr.f_nsyms));
          return;
          return;
        }
        }
      else
      else
        {
        {
          PRINTF ("Not COFF file format\n");
          PRINTFQ ("Not COFF file format\n");
          fseek (inputfs, 0, SEEK_SET);
          fseek (inputfs, 0, SEEK_SET);
        }
        }
    }
    }
  if (fread (&elfhdr, sizeof (elfhdr), 1, inputfs) == 1)
  if (fread (&elfhdr, sizeof (elfhdr), 1, inputfs) == 1)
    {
    {
      if (elfhdr.e_ident[0] == 0x7f && elfhdr.e_ident[1] == 0x45
      if (elfhdr.e_ident[0] == 0x7f && elfhdr.e_ident[1] == 0x45
          && elfhdr.e_ident[2] == 0x4c && elfhdr.e_ident[3] == 0x46)
          && elfhdr.e_ident[2] == 0x4c && elfhdr.e_ident[3] == 0x46)
        {
        {
          PRINTF ("ELF type: 0x%.4x\n", ELF_SHORT_H (elfhdr.e_type));
          PRINTFQ ("ELF type: 0x%.4x\n", ELF_SHORT_H (elfhdr.e_type));
          PRINTF ("ELF machine: 0x%.4x\n", ELF_SHORT_H (elfhdr.e_machine));
          PRINTFQ ("ELF machine: 0x%.4x\n", ELF_SHORT_H (elfhdr.e_machine));
          PRINTF ("ELF version: 0x%.8lx\n", ELF_LONG_H (elfhdr.e_version));
          PRINTFQ ("ELF version: 0x%.8lx\n", ELF_LONG_H (elfhdr.e_version));
          PRINTF ("ELF sec = %d\n", ELF_SHORT_H (elfhdr.e_shnum));
          PRINTFQ ("ELF sec = %d\n", ELF_SHORT_H (elfhdr.e_shnum));
          if (ELF_SHORT_H (elfhdr.e_type) != ET_EXEC)
          if (ELF_SHORT_H (elfhdr.e_type) != ET_EXEC)
            {
            {
              PRINTF ("This ELF is not an executable.\n");
              PRINTFQ ("This ELF is not an executable.\n");
              exit (1);
              exit (1);
            }
            }
          fclose (inputfs);
          fclose (inputfs);
          readfile_elf (filename);
          readfile_elf (filename);
          return;
          return;
        }
        }
      else
      else
        {
        {
          PRINTF ("Not ELF file format.\n");
          PRINTFQ ("Not ELF file format.\n");
          fseek (inputfs, 0, SEEK_SET);
          fseek (inputfs, 0, SEEK_SET);
        }
        }
    }
    }
 
 
  perror ("identifyfile2");
  perror ("identifyfile2");
Line 855... Line 860...
  int breakpoint = 0;
  int breakpoint = 0;
 
 
  transl_error = 0;
  transl_error = 0;
  transl_table = virtphy_transl;
  transl_table = virtphy_transl;
  freemem      = startaddr;
  freemem      = startaddr;
  PRINTF ("loadcode: filename %s  startaddr=%" PRIxADDR "  virtphy_transl=%"
  PRINTFQ ("loadcode: filename %s  startaddr=%" PRIxADDR "  virtphy_transl=%"
          PRIxADDR "\n", filename, startaddr, virtphy_transl);
          PRIxADDR "\n", filename, startaddr, virtphy_transl);
  identifyfile (filename);
  identifyfile (filename);
 
 
#if IMM_STATS
#if IMM_STATS
  {
  {
    int i = 0, a = 0, b = 0, c = 0;
    int i = 0, a = 0, b = 0, c = 0;
    PRINTF ("index:arith/branch/jump\n");
    PRINTFQ ("index:arith/branch/jump\n");
    for (i = 0; i < 33; i++)
    for (i = 0; i < 33; i++)
      PRINTF ("%2i:\t%3.0f%% / %3.0f%%/ %3.0f%%\t%5i / %5i / %5i\n", i,
      PRINTFQ ("%2i:\t%3.0f%% / %3.0f%%/ %3.0f%%\t%5i / %5i / %5i\n", i,
              100. * (a += bcnt[i][0]) / bsum[0], 100. * (b +=
              100. * (a += bcnt[i][0]) / bsum[0], 100. * (b +=
                                                          bcnt[i][1]) /
                                                          bcnt[i][1]) /
              bsum[1], 100. * (c +=
              bsum[1], 100. * (c +=
                               bcnt[i][2]) / bsum[2], bcnt[i][0],
                               bcnt[i][2]) / bsum[2], bcnt[i][0],
              bcnt[i][1], bcnt[i][2]);
              bcnt[i][1], bcnt[i][2]);
    PRINTF ("\nsum %i %i %i\n", bsum[0], bsum[1], bsum[2]);
    PRINTFQ ("\nsum %i %i %i\n", bsum[0], bsum[1], bsum[2]);
  }
  }
#endif
#endif
 
 
  if (transl_error)
  if (transl_error)
    return -1;
    return -1;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.