/[dynamips]/upstream/dynamips-0.2.6-RC3/mips64.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/dynamips-0.2.6-RC3/mips64.c

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

upstream/dynamips-0.2.6-RC2/mips64.c revision 3 by dpavlin, Sat Oct 6 16:05:34 2007 UTC upstream/dynamips-0.2.6-RC3/mips64.c revision 4 by dpavlin, Sat Oct 6 16:06:49 2007 UTC
# Line 67  int mips64_reset(cpu_mips_t *cpu) Line 67  int mips64_reset(cpu_mips_t *cpu)
67     memset(&cpu->cp0.tlb,0,MIPS64_TLB_MAX_ENTRIES*sizeof(tlb_entry_t));     memset(&cpu->cp0.tlb,0,MIPS64_TLB_MAX_ENTRIES*sizeof(tlb_entry_t));
68    
69     /* Restart the MTS subsystem */     /* Restart the MTS subsystem */
70     mts_shutdown(cpu);     mts_set_addr_mode(cpu,64);
    mts64_init(cpu);  
    mts_init_memop_vectors(cpu);  
71     cpu->mts_rebuild(cpu);     cpu->mts_rebuild(cpu);
72    
73     /* Flush JIT structures */     /* Flush JIT structures */
# Line 87  int mips64_init(cpu_mips_t *cpu) Line 85  int mips64_init(cpu_mips_t *cpu)
85    
86     /* Initialize idle timer */     /* Initialize idle timer */
87     cpu->idle_max = 1500;     cpu->idle_max = 1500;
88     cpu->idle_sleep_time = 50000;     cpu->idle_sleep_time = 30000;
89    
90     /* Timer IRQ parameters (default frequency: 250 Hz <=> 4ms period) */     /* Timer IRQ parameters (default frequency: 250 Hz <=> 4ms period) */
91     cpu->timer_irq_check_itv = 1000;     cpu->timer_irq_check_itv = 1000;
# Line 851  int mips64_load_raw_image(cpu_mips_t *cp Line 849  int mips64_load_raw_image(cpu_mips_t *cp
849  }  }
850    
851  /* Load an ELF image into the simulated memory */  /* Load an ELF image into the simulated memory */
852  int mips64_load_elf_image(cpu_mips_t *cpu,char *filename,  int mips64_load_elf_image(cpu_mips_t *cpu,char *filename,int skip_load,
853                            m_uint32_t *entry_point)                            m_uint32_t *entry_point)
854  {  {
855     m_uint64_t vaddr;     m_uint64_t vaddr;
# Line 903  int mips64_load_elf_image(cpu_mips_t *cp Line 901  int mips64_load_elf_image(cpu_mips_t *cp
901        return(-1);        return(-1);
902     }     }
903    
904     for(i=0;i<ehdr->e_shnum;i++) {     if (!skip_load) {
905        scn = elf_getscn(img_elf,i);        for(i=0;i<ehdr->e_shnum;i++) {
906             scn = elf_getscn(img_elf,i);
907        shdr = elf32_getshdr(scn);  
908        name = elf_strptr(img_elf, ehdr->e_shstrndx, (size_t)shdr->sh_name);           shdr = elf32_getshdr(scn);
909        len  = shdr->sh_size;           name = elf_strptr(img_elf, ehdr->e_shstrndx, (size_t)shdr->sh_name);
910             len  = shdr->sh_size;
911        if (!(shdr->sh_flags & SHF_ALLOC) || !len)  
912           continue;           if (!(shdr->sh_flags & SHF_ALLOC) || !len)
913                continue;
914        fseek(bfd,shdr->sh_offset,SEEK_SET);  
915        vaddr = sign_extend(shdr->sh_addr,32);           fseek(bfd,shdr->sh_offset,SEEK_SET);
916             vaddr = sign_extend(shdr->sh_addr,32);
917        if (cpu->vm->debug_level > 0) {  
918           printf("   * Adding section at virtual address 0x%8.8llx "           if (cpu->vm->debug_level > 0) {
919                  "(len=0x%8.8lx)\n",vaddr & 0xFFFFFFFF,(u_long)len);              printf("   * Adding section at virtual address 0x%8.8llx "
920        }                     "(len=0x%8.8lx)\n",vaddr & 0xFFFFFFFF,(u_long)len);
   
       while(len > 0)  
       {  
          haddr = cpu->mem_op_lookup(cpu,vaddr);  
     
          if (!haddr) {  
             fprintf(stderr,"load_elf_image: invalid load address 0x%llx\n",  
                     vaddr);  
             return(-1);  
921           }           }
922            
923             while(len > 0)
924             {
925                haddr = cpu->mem_op_lookup(cpu,vaddr);
926      
927                if (!haddr) {
928                   fprintf(stderr,"load_elf_image: invalid load address 0x%llx\n",
929                           vaddr);
930                   return(-1);
931                }
932    
933           if (len > MIPS_MIN_PAGE_SIZE)              if (len > MIPS_MIN_PAGE_SIZE)
934              clen = MIPS_MIN_PAGE_SIZE;                 clen = MIPS_MIN_PAGE_SIZE;
935           else              else
936              clen = len;                 clen = len;
937    
938           clen = fread((u_char *)haddr,clen,1,bfd);              clen = fread((u_char *)haddr,clen,1,bfd);
939    
940           if (clen != 1)              if (clen != 1)
941              break;                 break;
942    
943           vaddr += MIPS_MIN_PAGE_SIZE;              vaddr += MIPS_MIN_PAGE_SIZE;
944           len -= clen;              len -= clen;
945             }
946        }        }
947       } else {
948          printf("ELF loading skipped, using a ghost RAM file.\n");
949     }     }
950    
951     printf("ELF entry point: 0x%x\n",ehdr->e_entry);     printf("ELF entry point: 0x%x\n",ehdr->e_entry);

Legend:
Removed from v.3  
changed lines
  Added in v.4

  ViewVC Help
Powered by ViewVC 1.1.26