-
Notifications
You must be signed in to change notification settings - Fork 43
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
Rdram size testing #31
Comments
Hi bryanperris, I made a simple test for RDRAM size testing here: https://github.com/PeterLemon/N64/tree/master/RDRAMTest |
Thank you :), and I will keep investigating this bug, maybe your test will identify something right away. |
So far the test seems to be stuck in an infinite loop, it has gone over $A0800000 and continued running till the emulator crashed. Update 1: I forced rdram to check bounds, so this allows the test to work correctly now. I will now match all of the register values that the screenshot shows, I know some of those values are actually checked in the IPL cart bootrom. Update 2: Here are the values I get back in the test, I noticed that mode is different compared to the ones that are just zero: https://imgur.com/a/uuJuv5f Update 3: Fixing some of the initial values of the RDRAM registers has not affected osSizeMem, and mode is still the same value too. I did not think it would matter anyways since I know in emulators like pj64 do not bother setting them either. It seems only MI_VERSION is the most important one because the IPL does check it. Update 4: Starting with RI_SELECT register to not equal to zero will cause the IPL to skip RDRAM configuration stuff, including writing osMemSize. It could be possible to use this as an advantage if the emulator provides the information instead. Also the 'defect' for RDRAM mode isn't there either. Update 5: Undocumented RDRAM registers? Example: RDRAM Delay is actually $A3F00008 but the address being used is $A3F80008 In your boot.asm source: In my trace log: |
I was debugging the interpreter for Project64 and created a memory write breakpoint for address 0xA0000318, the only catch I got was value 0 (s6 = 0), even checked in RAM too, so same result as my emulator. I did not catch anything else (even 80000318) writing into that address. After helloworld runs and prints text to framebuffer, I do a memory search and actually find a value sitting in there. What a strange thing. @project64 Do you know about the osMemSize field? I can't even find in PJ64's source of any high level routine that fills it in. |
rightly or wrongly pj64 does it on the first dma (CDMA::OnFirstDMA) g_MMU->SW_PAddr(base + offset, rt); now on the real n64, I can not remember how it is set, I assume from the pif rom booting, in which case not sure why i do it on the first dma and not on start. |
Thanks zilmar! In the IPL bootrom from the cartridge, if you look at boot.asm in this repo, you will find the comment osMemSize. When you debug that line of code, the register contains 0 but really it should be the detected RDRAM size from the boot logic. Injecting a value from start will not work because it will be replaced by 0, so it must be why you did that in the first DMA which always is the one that copies the game code right into RDRAM so it makes sense. I can continue my work now by creating my own hack, but that was very helpful to know that its a known issue not just in my emulator. If I could understand the rdram configuration routine better, a test rom could identify what is missing that causes that happen. I don't know what goes on for cen64, but without being able to debug it, I can't dump out differences in CPU states, but I know it boots from the real PIF rom, so I am sure its not using any hacks to make osMemSize to work. |
cen64 takes a dumb approach and just and sets the memory byte before the console even starts executing the first stage of IPL.
|
(and yes, +1 to @project64 - the actual console probes the RAC during IPL and sets |
@tj90241 So the hardware itself is just dumping this value right into memory just right after IPL writes a 0 to it? |
Don't believe so. It should populate $s6 with a non-zero value before the write to that address. |
Interesting. From the assembly source, I was trying to figure out how s6 was being filled. I did find some logic that would write 1s into RDRAM, and then read it back, and that would loop many times but no idea on what was supposed to happen based on that. Thanks for the info, this sheds a lot more light. |
@PeterLemon I guess the test only needs to display the values from os config data, and that the screenshot shows they need to be filled in with. |
I partly "reverse engineered" the IPL3 and I can tell you it's a horrible mess with like 3 copies of similar code paths and variables and I still can't figure out why the detection refuses to go through. I hunted down various docs to give names to magic values, but unfortunately there are holes. Either way, only mupen64plus got it right, so I should check what they're doing right by comparing the runtime. I might share my abomination of a file full of scattered comments and naughty words. |
EE folk can do strange things with hardware. Sounds those routines are used for debugging purposes and to trigger the memory probe. |
Problem is they hardcoded these paths for specific memory chips they ordered for the console, instead of using the DeviceType fields to compute the memory size. |
@bryanperris as promised, here it is in all its infamy: https://nabile.duckdns.org/Shared/IPL3.c I spilled some more beans on the Discord64 server, if you'd like to join the discussion. |
Thanks for sharing this file |
I have ran into the issue that the cart bootrom is writing 0 for osMemSize (vaddr A0000318) therefore breaking program execution, and don't know what is causing it. A test could check that the reported value is valid by being either 4 MB or 8 MB. Also the test could check the other fields of the structure "os_boot_config_t". Once I figure out what bug causes this issue, I can update about it here, then the test can check for that too.
The text was updated successfully, but these errors were encountered: