-
Notifications
You must be signed in to change notification settings - Fork 1.4k
ppc: Add hack for working timebase #2257
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -54,7 +54,7 @@ | |
| # define LOG_TB(...) do { } while (0) | ||
| #endif | ||
|
|
||
| #if 0 | ||
| #if 1 | ||
| static void cpu_ppc_tb_stop (CPUPPCState *env); | ||
| static void cpu_ppc_tb_start (CPUPPCState *env); | ||
| #endif | ||
|
|
@@ -90,7 +90,9 @@ void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level) | |
| env->pending_interrupts, CPU(cpu)->interrupt_request); | ||
| } | ||
|
|
||
| #if 0 | ||
| #if 1 | ||
| // Broadway clock speed | ||
| #define TB_TIMER_CLOCK (243000000u/4000) | ||
| /* PowerPC 6xx / 7xx internal IRQ controller */ | ||
| static void ppc6xx_set_irq(void *opaque, int pin, int level) | ||
| { | ||
|
|
@@ -111,6 +113,7 @@ static void ppc6xx_set_irq(void *opaque, int pin, int level) | |
| LOG_IRQ("%s: %s the time base\n", | ||
| __func__, level ? "start" : "stop"); | ||
| if (level) { | ||
| cpu_ppc_tb_init(env, TB_TIMER_CLOCK); | ||
| cpu_ppc_tb_start(env); | ||
| } else { | ||
| cpu_ppc_tb_stop(env); | ||
|
|
@@ -174,6 +177,7 @@ static void ppc6xx_set_irq(void *opaque, int pin, int level) | |
|
|
||
| void ppc6xx_irq_init(PowerPCCPU *cpu) | ||
| { | ||
| ppc6xx_set_irq((void*)cpu, PPC6xx_INPUT_TBEN, 1); | ||
| #if 0 | ||
| CPUPPCState *env = &cpu->env; | ||
|
|
||
|
|
@@ -735,7 +739,7 @@ void cpu_ppc_store_tbu40(CPUPPCState *env, uint64_t value) | |
| &tb_env->tb_offset, tb); | ||
| } | ||
|
|
||
| #if 0 | ||
| #if 1 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can safely remote all such |
||
| static void cpu_ppc_tb_stop (CPUPPCState *env) | ||
| { | ||
| ppc_tb_t *tb_env = env->tb_env; | ||
|
|
@@ -1565,5 +1569,6 @@ void ppc_irq_reset(PowerPCCPU *cpu) | |
| CPUPPCState *env = &cpu->env; | ||
|
|
||
| env->irq_input_state = 0; | ||
| ppc6xx_set_irq((void*)cpu, PPC6xx_INPUT_TBEN, 0); | ||
| // kvmppc_set_interrupt(cpu, PPC_INTERRUPT_EXT, 0); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -107,15 +107,34 @@ static void test_ppc32_cr(void) | |
|
|
||
| static void test_ppc32_spr_time(void) | ||
| { | ||
| char code[] = ("\x7c\x76\x02\xa6" // mfspr r3, DEC | ||
| "\x7c\x6d\x42\xa6" // mfspr r3, TBUr | ||
| ); | ||
|
|
||
| uint32_t r3_val; | ||
| uc_engine *uc; | ||
| uc_common_setup(&uc, UC_ARCH_PPC, UC_MODE_32 | UC_MODE_BIG_ENDIAN, code, | ||
| sizeof(code) - 1); | ||
|
|
||
| OK(uc_emu_start(uc, code_start, code_start + sizeof(code) - 1, 0, 0)); | ||
| char code_dec[] = "\x7c\x76\x02\xa6"; // mfspr r3, DEC | ||
| uc_common_setup(&uc, UC_ARCH_PPC, UC_MODE_32 | UC_MODE_BIG_ENDIAN, code_dec, | ||
| sizeof(code_dec) - 1); | ||
|
|
||
| OK(uc_emu_start(uc, code_start, code_start + sizeof(code_dec) - 1, 0, 0)); | ||
| OK(uc_reg_read(uc, UC_PPC_REG_3, &r3_val)); | ||
| printf("DEC: 0x%08x\n", BEINT32(r3_val)); | ||
| OK(uc_close(uc)); | ||
|
|
||
| char code_tbur[] = "\x7c\x6d\x42\xa6"; // mfspr r3, TBUr | ||
| uc_common_setup(&uc, UC_ARCH_PPC, UC_MODE_32 | UC_MODE_BIG_ENDIAN, code_tbur, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider splitting these into 2 or 3 tests. |
||
| sizeof(code_tbur) - 1); | ||
|
|
||
| OK(uc_emu_start(uc, code_start, code_start + sizeof(code_tbur) - 1, 0, 0)); | ||
| OK(uc_reg_read(uc, UC_PPC_REG_3, &r3_val)); | ||
| printf("TBUr: 0x%08x\n", BEINT32(r3_val)); | ||
| OK(uc_close(uc)); | ||
|
|
||
| char code_tblr[] = "\x7c\x6c\x42\xa6"; // mfspr r3, TBLr | ||
| uc_common_setup(&uc, UC_ARCH_PPC, UC_MODE_32 | UC_MODE_BIG_ENDIAN, code_tblr, | ||
| sizeof(code_tblr) - 1); | ||
|
|
||
| OK(uc_emu_start(uc, code_start, code_start + sizeof(code_tblr) - 1, 0, 0)); | ||
| OK(uc_reg_read(uc, UC_PPC_REG_3, &r3_val)); | ||
| printf("TBLr: 0x%08x\n", BEINT32(r3_val)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be a simple |
||
| OK(uc_close(uc)); | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it from original qemu code?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, for my specific case I needed to use the Wii CPU's Timebase Frequency which is what this value represents
I can replace it with a value used by Qemu somewhere if desired, not sure which one since timebase frequency is different per machine in qemu due to it being hardware and software implementation dependent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops sorry I thought it was from QEMU. How does QEMU ever set that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Qemu hardcodes the frequency per machine
E.g. old world PowerMac frequency is set here
https://github.com/qemu/qemu/blob/593aee5df98b4a862ff8841a57ea3dbf22131a5f/hw/ppc/mac_oldworld.c#L117
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh in that case, we have
cpu_modelto do this things (seeuc_ctl_set_cpu_model). Does the Wii use a specific cpu model?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the code I've just been using PPC 750 who is the closest qemu has
I'll look into that, thanks!