[PR #2807] [MERGED] Emulate memory behavior of libSceGnmDriver initialization #2993

Closed
opened 2026-02-27 22:02:02 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/shadps4-emu/shadPS4/pull/2807
Author: @StevenMiller123
Created: 4/18/2025
Status: Merged
Merged: 4/18/2025
Merged by: @georgemoralis

Base: mainHead: nba-fix


📝 Commits (6)

  • de549a2 Emulate memory behavior of libSceGnmDriver _DT_INIT
  • 36ed12e Clang
  • c40bd3f Fix address input for direct memory call
  • 273faba Merge branch 'shadps4-emu:main' into nba-fix
  • edbe39a Fix bug with DirectQueryAvailable
  • a242e66 DirectQueryAvailable fix

📊 Changes

4 files changed (+16 additions, -10 deletions)

View changed files

📝 src/core/libraries/gnmdriver/gnmdriver.cpp (+1 -1)
📝 src/core/libraries/kernel/memory.cpp (+0 -6)
📝 src/core/linker.cpp (+14 -2)
📝 src/core/memory.cpp (+1 -1)

📄 Description

Some games check if sceKernelAllocateDirectMemory failed by looking at the phys_addr_out returned, treating a returned value of 0 as a failed call. On real hardware, a phys_addr_out of 0 is never returned due to libSceGnmDriver's initialization performing a direct memory mapping. This PR naively implements this by adding the relevant code to Linker::Execute, similar to how I handled the SceKernelInternalMemory mapping.

Also includes a hotfix for sceKernelAvailableDirectMemorySize, as emulating this mapping revealed a typo in my code.

This PR fixes an early crash in NBA2K18 (CUSA08500), and fixes the remaining discrepancy shown in the tests I did for https://github.com/shadps4-emu/shadPS4/pull/2803


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/shadps4-emu/shadPS4/pull/2807 **Author:** [@StevenMiller123](https://github.com/StevenMiller123) **Created:** 4/18/2025 **Status:** ✅ Merged **Merged:** 4/18/2025 **Merged by:** [@georgemoralis](https://github.com/georgemoralis) **Base:** `main` ← **Head:** `nba-fix` --- ### 📝 Commits (6) - [`de549a2`](https://github.com/shadps4-emu/shadPS4/commit/de549a23dc4169627631cebee4039a25d4ef4ef9) Emulate memory behavior of libSceGnmDriver _DT_INIT - [`36ed12e`](https://github.com/shadps4-emu/shadPS4/commit/36ed12e9d3309e5037f43d141fe2757e955d5a02) Clang - [`c40bd3f`](https://github.com/shadps4-emu/shadPS4/commit/c40bd3f3392ccb7711af5cea5b89a9a572964834) Fix address input for direct memory call - [`273faba`](https://github.com/shadps4-emu/shadPS4/commit/273faba1bbdfb2148948b994aaa3e14da21936ef) Merge branch 'shadps4-emu:main' into nba-fix - [`edbe39a`](https://github.com/shadps4-emu/shadPS4/commit/edbe39a1ec7b2ccb6cc4d4ea7a0972b4a9f51a1d) Fix bug with DirectQueryAvailable - [`a242e66`](https://github.com/shadps4-emu/shadPS4/commit/a242e663f77c03006b5d29711feef7104abfa2ed) DirectQueryAvailable fix ### 📊 Changes **4 files changed** (+16 additions, -10 deletions) <details> <summary>View changed files</summary> 📝 `src/core/libraries/gnmdriver/gnmdriver.cpp` (+1 -1) 📝 `src/core/libraries/kernel/memory.cpp` (+0 -6) 📝 `src/core/linker.cpp` (+14 -2) 📝 `src/core/memory.cpp` (+1 -1) </details> ### 📄 Description Some games check if sceKernelAllocateDirectMemory failed by looking at the phys_addr_out returned, treating a returned value of 0 as a failed call. On real hardware, a phys_addr_out of 0 is never returned due to libSceGnmDriver's initialization performing a direct memory mapping. This PR naively implements this by adding the relevant code to Linker::Execute, similar to how I handled the SceKernelInternalMemory mapping. Also includes a hotfix for sceKernelAvailableDirectMemorySize, as emulating this mapping revealed a typo in my code. This PR fixes an early crash in NBA2K18 (CUSA08500), and fixes the remaining discrepancy shown in the tests I did for https://github.com/shadps4-emu/shadPS4/pull/2803 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 22:02:02 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/shadPS4#2993
No description provided.