42 |
/* Initialize a PowerPC processor */ |
/* Initialize a PowerPC processor */ |
43 |
int ppc32_init(cpu_ppc_t *cpu) |
int ppc32_init(cpu_ppc_t *cpu) |
44 |
{ |
{ |
45 |
|
/* Initialize JIT operations */ |
46 |
|
jit_op_init_cpu(cpu->gen); |
47 |
|
|
48 |
/* Initialize idle timer */ |
/* Initialize idle timer */ |
49 |
cpu->gen->idle_max = 1500; |
cpu->gen->idle_max = 1500; |
50 |
cpu->gen->idle_sleep_time = 30000; |
cpu->gen->idle_sleep_time = 30000; |
53 |
cpu->timer_irq_check_itv = 1000; |
cpu->timer_irq_check_itv = 1000; |
54 |
cpu->timer_irq_freq = 250; |
cpu->timer_irq_freq = 250; |
55 |
|
|
56 |
|
/* Enable/disable direct block jump */ |
57 |
|
cpu->exec_blk_direct_jump = cpu->vm->exec_blk_direct_jump; |
58 |
|
|
59 |
/* Idle loop mutex and condition */ |
/* Idle loop mutex and condition */ |
60 |
pthread_mutex_init(&cpu->gen->idle_mutex,NULL); |
pthread_mutex_init(&cpu->gen->idle_mutex,NULL); |
61 |
pthread_cond_init(&cpu->gen->idle_cond,NULL); |
pthread_cond_init(&cpu->gen->idle_cond,NULL); |
70 |
cpu->gen->set_idle_pc = (void *)ppc32_set_idle_pc; |
cpu->gen->set_idle_pc = (void *)ppc32_set_idle_pc; |
71 |
cpu->gen->get_idling_pc = (void *)ppc32_get_idling_pc; |
cpu->gen->get_idling_pc = (void *)ppc32_get_idling_pc; |
72 |
|
|
73 |
|
/* zzz */ |
74 |
|
memset(cpu->vtlb,0xFF,sizeof(cpu->vtlb)); |
75 |
|
|
76 |
/* Set the startup parameters */ |
/* Set the startup parameters */ |
77 |
ppc32_reset(cpu); |
ppc32_reset(cpu); |
78 |
return(0); |
return(0); |
235 |
printf("Restart the emulator with \"--idle-pc=0x%llx\" (for example)\n", |
printf("Restart the emulator with \"--idle-pc=0x%llx\" (for example)\n", |
236 |
cpu->idle_pc_prop[0].pc); |
cpu->idle_pc_prop[0].pc); |
237 |
} else { |
} else { |
238 |
printf("Done. No suggestion for idling PC\n"); |
printf("Done. No suggestion for idling PC, dumping the full table:\n"); |
239 |
|
|
240 |
|
for(i=0;i<IDLE_HASH_SIZE;i++) |
241 |
|
for(p=pc_hash[i];p;p=p->next) { |
242 |
|
printf(" 0x%8.8x (%3u)\n",p->ia,p->count); |
243 |
|
|
244 |
|
if (cpu->idle_pc_prop_count < CPU_IDLE_PC_MAX_RES) { |
245 |
|
res = &cpu->idle_pc_prop[cpu->idle_pc_prop_count++]; |
246 |
|
|
247 |
|
res->pc = p->ia; |
248 |
|
res->count = p->count; |
249 |
|
} |
250 |
|
} |
251 |
|
|
252 |
|
printf("\n"); |
253 |
} |
} |
254 |
|
|
255 |
/* Re-enable IRQ */ |
/* Re-enable IRQ */ |
423 |
printf("\n"); |
printf("\n"); |
424 |
printf(" ia = 0x%8.8x, lr = 0x%8.8x\n", pcpu->ia, pcpu->lr); |
printf(" ia = 0x%8.8x, lr = 0x%8.8x\n", pcpu->ia, pcpu->lr); |
425 |
printf(" cr = 0x%8.8x, msr = 0x%8.8x, xer = 0x%8.8x, dec = 0x%8.8x\n", |
printf(" cr = 0x%8.8x, msr = 0x%8.8x, xer = 0x%8.8x, dec = 0x%8.8x\n", |
426 |
pcpu->cr, pcpu->msr, |
ppc32_get_cr(pcpu), pcpu->msr, |
427 |
pcpu->xer | (pcpu->xer_ca << PPC32_XER_CA_BIT), |
pcpu->xer | (pcpu->xer_ca << PPC32_XER_CA_BIT), |
428 |
pcpu->dec); |
pcpu->dec); |
429 |
|
|
441 |
printf(" Timer IRQ count: %llu, pending: %u, timer drift: %u\n\n", |
printf(" Timer IRQ count: %llu, pending: %u, timer drift: %u\n\n", |
442 |
pcpu->timer_irq_count,pcpu->timer_irq_pending,pcpu->timer_drift); |
pcpu->timer_irq_count,pcpu->timer_irq_pending,pcpu->timer_drift); |
443 |
|
|
444 |
|
printf(" Device access count: %llu\n",cpu->dev_access_counter); |
445 |
|
|
446 |
printf("\n"); |
printf("\n"); |
447 |
} |
} |
448 |
|
|
508 |
if (!haddr) { |
if (!haddr) { |
509 |
fprintf(stderr,"load_raw_image: invalid load address 0x%8.8x\n", |
fprintf(stderr,"load_raw_image: invalid load address 0x%8.8x\n", |
510 |
vaddr); |
vaddr); |
511 |
return(-1); |
// return(-1); |
512 |
} |
} |
513 |
|
|
514 |
if (len > PPC32_MIN_PAGE_SIZE) |
if (len > PPC32_MIN_PAGE_SIZE) |
598 |
|
|
599 |
fseek(bfd,shdr->sh_offset,SEEK_SET); |
fseek(bfd,shdr->sh_offset,SEEK_SET); |
600 |
vaddr = shdr->sh_addr; |
vaddr = shdr->sh_addr; |
601 |
|
// XXX my kernel address in elf file |
602 |
|
vaddr = vaddr - 0xc0000000; |
603 |
|
|
604 |
if (cpu->vm->debug_level > 0) { |
if (cpu->vm->debug_level > 0) { |
605 |
printf(" * Adding section at virtual address 0x%8.8x " |
printf(" * Adding section at virtual address 0x%8.8x " |
637 |
printf("ELF loading skipped, using a ghost RAM file.\n"); |
printf("ELF loading skipped, using a ghost RAM file.\n"); |
638 |
} |
} |
639 |
|
|
640 |
|
ehdr->e_entry = ehdr->e_entry - 0xc0000000; // XXX |
641 |
printf("ELF entry point: 0x%x\n",ehdr->e_entry); |
printf("ELF entry point: 0x%x\n",ehdr->e_entry); |
642 |
|
|
643 |
if (entry_point) |
if (entry_point) |