ppc: Add hack for working timebase#2257
ppc: Add hack for working timebase#2257Fancy2209 wants to merge 2 commits intounicorn-engine:masterfrom
Conversation
| #if 0 | ||
| #if 1 | ||
| // Broadway clock speed | ||
| #define TB_TIMER_CLOCK (243000000u/4000) |
There was a problem hiding this comment.
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.
Oops sorry I thought it was from QEMU. How does QEMU ever set that?
There was a problem hiding this comment.
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.
Oh in that case, we have cpu_model to do this things (see uc_ctl_set_cpu_model). Does the Wii use a specific cpu model?
There was a problem hiding this comment.
Oh in that case, we have
cpu_modelto do this things (seeuc_ctl_set_cpu_model). Does the Wii use a specific cpu model?
On the code I've just been using PPC 750 who is the closest qemu has
I'll look into that, thanks!
| } | ||
|
|
||
| #if 0 | ||
| #if 1 |
There was a problem hiding this comment.
You can safely remote all such #if 0 swtiches instead of changing it to #if 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)); |
There was a problem hiding this comment.
This should be a simple TEST_CHECK ?
| 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, |
There was a problem hiding this comment.
Consider splitting these into 2 or 3 tests.
|
A few stylish reviews. Thanks for your efforts! The CI failure has nothing to do with this PR. |
This is currently has a hardcoded Timebase Frequency that should probably be made customizable at some point, but at least it works.
Closes #2256