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

Subversion Repositories or1k

[/] [or1k/] [tags/] [nog_patch_47/] [or1ksim/] [cpu/] [common/] [parse.c] - Diff between revs 306 and 344

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

Rev 306 Rev 344
Line 152... Line 152...
void addprogram(unsigned long address, unsigned long insn, int* breakpoint)
void addprogram(unsigned long address, unsigned long insn, int* breakpoint)
{
{
  char insn_first2_char[3];
  char insn_first2_char[3];
  int vaddr = (!config.filename) ? translate(address,breakpoint) : translate(freemem,breakpoint);
  int vaddr = (!config.filename) ? translate(address,breakpoint) : translate(freemem,breakpoint);
 
 
  debug("addprogram 1\n");
  debug(9,"addprogram 1\n");
 
 
  setsim_mem32 (vaddr, insn);
  setsim_mem32 (vaddr, insn);
 
 
  if(config.filename)
  if(config.filename)
    freemem += insn_len (insn_decode (insn));
    freemem += insn_len (insn_decode (insn));
Line 246... Line 246...
                ++firstthree;
                ++firstthree;
#endif
#endif
 
 
                /* loading section */
                /* loading section */
                freemem = COFF_LONG_H(coffscnhdr.s_paddr);
                freemem = COFF_LONG_H(coffscnhdr.s_paddr);
                debug("Starting to load at 0x%x", freemem);
                debug(2,"Starting to load at 0x%x\n", freemem);
                if (fseek(inputfs, COFF_LONG_H(coffscnhdr.s_scnptr), SEEK_SET) == -1) {
                if (fseek(inputfs, COFF_LONG_H(coffscnhdr.s_scnptr), SEEK_SET) == -1) {
                        fclose(inputfs);
                        fclose(inputfs);
                        perror("readfile_coff");
                        perror("readfile_coff");
                        exit(1);
                        exit(1);
                }
                }
Line 258... Line 258...
                        insn = COFF_LONG_H(inputbuf);
                        insn = COFF_LONG_H(inputbuf);
                        len = insn_len (insn_decode (insn));
                        len = insn_len (insn_decode (insn));
                        if (len == 2)
                        if (len == 2)
                          {
                          {
                            fseek(inputfs, -2, SEEK_CUR);
                            fseek(inputfs, -2, SEEK_CUR);
                            debug("readfile_coff: %x 0x%x   ", sectsize, insn >> 16);
                            debug(8,"readfile_coff: %x 0x%x   \n", sectsize, insn >> 16);
                          }
                          }
                        else
                        else
                          debug("readfile_coff: %x 0x%x   ", sectsize, insn);
                          debug(8,"readfile_coff: %x 0x%x   \n", sectsize, insn);
                        addprogram (freemem, insn, &breakpoint);
                        addprogram (freemem, insn, &breakpoint);
                        sectsize -= len;
                        sectsize -= len;
                }
                }
        }
        }
        if (firstthree < 3) {
        if (firstthree < 3) {
Line 316... Line 316...
    if (COFF_SHORT_H(coffsymhdr.e_type) & COFF_N_TMASK & COFF_STYP_TEXT) {
    if (COFF_SHORT_H(coffsymhdr.e_type) & COFF_N_TMASK & COFF_STYP_TEXT) {
 
 
      if (*((unsigned long *)coffsymhdr.e.e.e_zeroes)) {
      if (*((unsigned long *)coffsymhdr.e.e.e_zeroes)) {
        if (strlen(coffsymhdr.e.e_name) && strlen(coffsymhdr.e.e_name) < 9)
        if (strlen(coffsymhdr.e.e_name) && strlen(coffsymhdr.e.e_name) < 9)
          add_label(COFF_LONG_H(coffsymhdr.e_value), coffsymhdr.e.e_name);
          add_label(COFF_LONG_H(coffsymhdr.e_value), coffsymhdr.e.e_name);
        debug("[%i] Symbol: %s,", count++, coffsymhdr.e.e_name);
        debug(8, "[%i] Symbol: %s,", count++, coffsymhdr.e.e_name);
      } else {
      } else {
        long fpos = ftell (inputfs);
        long fpos = ftell (inputfs);
 
 
        if (fseek(inputfs, symptr + nsyms * COFF_SYMESZ + COFF_LONG_H(coffsymhdr.e.e.e_offset), SEEK_SET) == 0) {
        if (fseek(inputfs, symptr + nsyms * COFF_SYMESZ + COFF_LONG_H(coffsymhdr.e.e.e_offset), SEEK_SET) == 0) {
          char tmp[33], *s = &tmp[0];
          char tmp[33], *s = &tmp[0];
          while (s != &tmp[32])
          while (s != &tmp[32])
            if ((*(s++) = fgetc(inputfs)) == 0) break;
            if ((*(s++) = fgetc(inputfs)) == 0) break;
          tmp[32] = 0;
          tmp[32] = 0;
          add_label(COFF_LONG_H(coffsymhdr.e_value), &tmp[0]);
          add_label(COFF_LONG_H(coffsymhdr.e_value), &tmp[0]);
          debug("[%i] Symbol: %s,", count++, &tmp[0]);
          debug(8, "[%i] Symbol: %s,", count++, &tmp[0]);
        }
        }
        fseek(inputfs, fpos, SEEK_SET);
        fseek(inputfs, fpos, SEEK_SET);
      }
      }
 
 
      debug(" val: 0x%.8x,", COFF_LONG_H(coffsymhdr.e_value));
      debug(9, " val: 0x%.8x,", COFF_LONG_H(coffsymhdr.e_value));
      debug(" type: %x, %x, auxs: %i\n", COFF_SHORT_H(coffsymhdr.e_type), *((unsigned short *)coffsymhdr.e_type), n);
      debug(9, " type: %x, %x, auxs: %i\n", COFF_SHORT_H(coffsymhdr.e_type), *((unsigned short *)coffsymhdr.e_type), n);
    }
    }
 
 
    for (i = 0; i < n; i++)
    for (i = 0; i < n; i++)
      if (fread(&coffsymhdr, COFF_SYMESZ, 1, inputfs) != 1) {
      if (fread(&coffsymhdr, COFF_SYMESZ, 1, inputfs) != 1) {
        fclose(inputfs);
        fclose(inputfs);

powered by: WebSVN 2.1.0

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