libnx icon indicating copy to clipboard operation
libnx copied to clipboard

Support for PhysicalMemory SVCs

Open fincs opened this issue 4 years ago • 3 comments

In version 3.0 of the Horizon kernel, new memory management SVCs were added. These essentially implement a new, more flexible take on heap management. Newer official software is known to take advantage of this improved heap management system. As a result, it would be desirable to add support for PhysicalMemory SVCs to libnx so that homebrew can take advantage of it.

Adding support involves redesigning how libnx applications interact with the homebrew environment (specifically nx-hbloader), and also figuring out a way to fall back on older style svcSetHeapSize heap management on systems running older Horizon kernels. Also note that Mesosphère implements all newer Horizon kernel functionality regardless of the installed firmware version; and a future version of Atmosphère will unconditionally have Mesosphère enabled, therefore making this a non-issue.

fincs avatar Nov 07 '20 23:11 fincs

Well, it seems that now Mesosphère is close to being unconditionally enabled.. Can you please look at this?

It seems that it might break a lot of stuff... Heap overrides are already in the ABI...

Also a relevant place to look at: https://github.com/devkitPro/newlib/blob/devkitA64/libgloss/libsysbase/sbrk.c.

sbrk emulation for windows using virtual memory APIs in newlib: https://github.com/devkitPro/newlib/blob/a60a4501b77dca8f30e01327b96171ee89c278f7/newlib/libc/stdlib/mallocr.c#L1170 (may be used as reference if & when implementing sbrk emulation).

Just FYI: I would like to help with implementation of this if it would be of any use.

DCNick3 avatar May 09 '21 09:05 DCNick3

Hello, I was wondering if there was an update to this? As of Atmosphère 1.0.0 from what I can tell Mesosphère is no longer opt-out and thus unconditionally enabled.

It would be nice to be able to use generic virtual memory in homebrew applications to align with PC counterparts like VirtualAlloc/mmap (that said, I haven't wrapped my head around SVC call stuff, so this might not even be what I think it is)

Bulmanator avatar Mar 30 '22 00:03 Bulmanator

Yes, having mmap is somestging I do need for a port of X-Ray game engine (open source version of famous S.T.A.L.K.E.R game engine). Would you provide any update please?

xfreshx avatar Apr 05 '23 20:04 xfreshx