Ravenslofty / prussia

Prussia - a Rust PS2 SDK.
Other
105 stars 6 forks source link

Add IPU registers #12

Closed zachary-cauchi closed 4 months ago

zachary-cauchi commented 4 months ago

Validated against svd2rust and successfully produces a lib.rs file.

Ravenslofty commented 4 months ago

Okay, so, first off, I realise I made another typo when writing the SVD:

https://github.com/Ravenslofty/prussia/blob/1a1c5c256b4f2dcdf47f560f053536890a159787/ps2.xml#L20

This should be 32 instead.

However, registers like IPU_CMD are instead 64-bit wide, so I think it needs a <size>64</size> in there somewhere, same for IPU_TOP.

zachary-cauchi commented 4 months ago

My bad. Fixed the default size and fixed those two registers as well.

Ravenslofty commented 4 months ago

That this compiles with svd2rust despite the register sizes being wrong is...slightly concerning; I suppose svd2rust is applying the Postel principle a little too well, and makes me want to investigate the generated code a little.

zachary-cauchi commented 4 months ago

It is a little odd, especially considering it allows for discrepancies of this size to slip through. Maybe there's a 'strict' mode to the tool that we didn't spot yet?

zachary-cauchi commented 4 months ago

Just checked the help screen, they have a strict flag which enables stricter checks. Just tested it with the old default size of 31, it produced the below output:

[INFO  svd2rust] Parsing device from SVD file
[ERROR svd2rust] Error parsing SVD XML file

    Caused by:
        0: Parsing device `PlayStation2` at 3:1
        1: `RegisterProperties error: Mask value 0xffffffff doesn't fit in 31 bits

Rerunning it with the fix did not trigger an error. Exactly what errors are caught by this flag I don't know, but it does help.

Ravenslofty commented 4 months ago

Also on the list of things to fix, while we're here, let's point potential users to the relevant manual pages:

https://github.com/Ravenslofty/prussia/blob/1a1c5c256b4f2dcdf47f560f053536890a159787/ps2.xml#L2930

should be Interrupt Controller. See EE User's Manual, Chapter 3.

https://github.com/Ravenslofty/prussia/blob/1a1c5c256b4f2dcdf47f560f053536890a159787/ps2.xml#L1789

should be DMA Controller. See EE User's Manual, Chapter 5.

https://github.com/Ravenslofty/prussia/blob/1a1c5c256b4f2dcdf47f560f053536890a159787/ps2.xml#L863

should be VU Interface. See EE User's Manual, Chapter 6.

https://github.com/Ravenslofty/prussia/blob/1a1c5c256b4f2dcdf47f560f053536890a159787/ps2.xml#L392

should be GS Interface. See EE User's Manual, Chapter 7.

https://github.com/Ravenslofty/prussia/blob/1a1c5c256b4f2dcdf47f560f053536890a159787/ps2.xml#L358

should be Image Data Processor. See EE User's Manual, Chapter 8.

I hope you don't mind the extra work, I'm just going back through what I did and realising how much I messed up >.>

zachary-cauchi commented 4 months ago

Good points, I'll take care of it. No worries at all, this is good practice in my eyes, and it will help everyone in the future when referring back to this document.

zachary-cauchi commented 4 months ago

Fixed.