-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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?
Conversation
| #if 0 | ||
| #if 1 | ||
| // Broadway clock speed | ||
| #define TB_TIMER_CLOCK (243000000u/4000) |
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?
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_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.
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?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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