libdragon icon indicating copy to clipboard operation
libdragon copied to clipboard

Disable 64-bit memory addressing

Open rasky opened this issue 3 years ago • 1 comments

In entrypoint, libdragon activates the 64-bit addressing mode: https://github.com/DragonMinded/libdragon/blob/1c522f2da5928bb5bb79ac76436c2186091fef75/src/entrypoint.S#L18

This is not very useful nor used at all, since our GCC toolchain uses 32-bit pointers. The only way to construct and dereference a 64-bit pointers would be through assembly. There is no code in libdragon that does this, nor it sounds specifically useful. Also, notice that the 64-bit addressing mode is backward compatible with 32-bit, so whatever you do from C would work exactly the same way with 32-bit addressing.

This is also not used in any commercial games as it was unsupported by Nintendo. So the end result is that emulators fail to run libdragon code because they see that bit set and they panic because they haven't implemented 64-bit addressing, when in reality this is not even used.

See for instance: https://github.com/mupen64plus/mupen64plus-core/issues/738

We should just avoid activating 64-bit addressing.

rasky avatar Jun 06 '21 18:06 rasky

@rasky, I disabled 64 bit addressing here. Not sure if there's more that we want to do to fix the emulator issue, but I was not able to run on Mupen64Plus even with the change in place.

stefanmielke avatar Jun 11 '21 00:06 stefanmielke

I retract this. There are some cases where building a 64-bit address and using it inline assembly might turned out to be useful, for instance to access regions of the PI bus in the range 0x2000_0000 - 0x7FFF_FFFF. In theory, there should be no problem in keeping 64-bit addressing on, and I think in general emulators are catching on on that.

rasky avatar Nov 13 '22 13:11 rasky