Skip to content
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

cellGame/sceNpDrm/Loader: Few fixes #14537

Merged
merged 3 commits into from Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 7 additions & 4 deletions rpcs3/Emu/Cell/Modules/cellGame.cpp
Expand Up @@ -703,7 +703,7 @@ error_code cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr

auto& perm = g_fxo->get<content_permission>();

lv2_sleep(5000);
lv2_sleep(500);

const auto init = perm.init.init();

Expand Down Expand Up @@ -831,8 +831,6 @@ error_code cellGameDataCheck(u32 type, vm::cptr<char> dirName, vm::ptr<CellGameC

const std::string dir = type == CELL_GAME_GAMETYPE_DISC ? "/dev_bdvd/PS3_GAME"s : "/dev_hdd0/game/" + name;

lv2_sleep(5000);

// TODO: not sure what should be checked there

auto& perm = g_fxo->get<content_permission>();
Expand All @@ -841,9 +839,14 @@ error_code cellGameDataCheck(u32 type, vm::cptr<char> dirName, vm::ptr<CellGameC

if (!init)
{
lv2_sleep(300);
return CELL_GAME_ERROR_BUSY;
}

// This function is incredibly slow, slower for DISC type and even if the game/disc data does not exist
// Null size does not change it
lv2_sleep(type == CELL_GAME_GAMETYPE_DISC ? 300000 : 120000);

auto [sfo, psf_error] = psf::load(vfs::get(dir + "/PARAM.SFO"));

if (const std::string_view cat = psf::get_string(sfo, "CATEGORY"); [&]()
Expand All @@ -870,7 +873,7 @@ error_code cellGameDataCheck(u32 type, vm::cptr<char> dirName, vm::ptr<CellGameC
size->hddFreeSizeKB = 40 * 1024 * 1024 - 1; // Read explanation in cellHddGameCheck

// TODO: Calculate data size for game data, if necessary.
size->sizeKB = CELL_GAME_SIZEKB_NOTCALC;
size->sizeKB = sfo.empty() ? 0 : CELL_GAME_SIZEKB_NOTCALC;
size->sysSizeKB = 0; // TODO
}

Expand Down
33 changes: 29 additions & 4 deletions rpcs3/Emu/Cell/Modules/sceNp.cpp
Expand Up @@ -17,6 +17,7 @@

#include "Emu/Cell/lv2/sys_time.h"
#include "Emu/Cell/lv2/sys_fs.h"
#include "Emu/Cell/lv2/sys_sync.h"
#include "Emu/NP/np_handler.h"
#include "Emu/NP/np_contexts.h"
#include "Emu/NP/np_helpers.h"
Expand Down Expand Up @@ -408,6 +409,8 @@ void message_data::print() const
sceNp.notice("commId: %s, msgId: %d, mainType: %d, subType: %d, subject: %s, body: %s, data_size: %d", static_cast<const char *>(commId.data), msgId, mainType, subType, subject, body, data.size());
}

extern void lv2_sleep(u64 timeout, ppu_thread* ppu = nullptr);

error_code sceNpInit(u32 poolsize, vm::ptr<void> poolptr)
{
sceNp.warning("sceNpInit(poolsize=0x%x, poolptr=*0x%x)", poolsize, poolptr);
Expand Down Expand Up @@ -553,18 +556,40 @@ error_code npDrmIsAvailable(vm::cptr<u8> k_licensee_addr, vm::cptr<char> drm_pat
return CELL_OK;
}

error_code sceNpDrmIsAvailable(vm::cptr<u8> k_licensee_addr, vm::cptr<char> drm_path)
error_code sceNpDrmIsAvailable(ppu_thread& ppu, vm::cptr<u8> k_licensee_addr, vm::cptr<char> drm_path)
{
sceNp.warning("sceNpDrmIsAvailable(k_licensee=*0x%x, drm_path=*0x%x)", k_licensee_addr, drm_path);

return npDrmIsAvailable(k_licensee_addr, drm_path);
if (!drm_path)
{
return SCE_NP_DRM_ERROR_INVALID_PARAM;
}

lv2_obj::sleep(ppu);

const auto ret = npDrmIsAvailable(k_licensee_addr, drm_path);
lv2_sleep(100000, &ppu);

return ret;
}

error_code sceNpDrmIsAvailable2(vm::cptr<u8> k_licensee_addr, vm::cptr<char> drm_path)
error_code sceNpDrmIsAvailable2(ppu_thread& ppu, vm::cptr<u8> k_licensee_addr, vm::cptr<char> drm_path)
{
sceNp.warning("sceNpDrmIsAvailable2(k_licensee=*0x%x, drm_path=*0x%x)", k_licensee_addr, drm_path);

return npDrmIsAvailable(k_licensee_addr, drm_path);
if (!drm_path)
{
return SCE_NP_DRM_ERROR_INVALID_PARAM;
}

lv2_obj::sleep(ppu);

const auto ret = npDrmIsAvailable(k_licensee_addr, drm_path);

// TODO: Accurate sleep time
//lv2_sleep(20000, &ppu);

return ret;
}

error_code npDrmVerifyUpgradeLicense(vm::cptr<char> content_id)
Expand Down
10 changes: 10 additions & 0 deletions rpcs3/Emu/Cell/PPUAnalyser.cpp
Expand Up @@ -699,6 +699,11 @@ bool ppu_module::analyse(u32 lib_toc, u32 entry, const u32 sec_end, const std::b
// Find OPD section
for (const auto& sec : secs)
{
if (sec.size % 8)
Megamouse marked this conversation as resolved.
Show resolved Hide resolved
{
continue;
}

vm::cptr<void> sec_end = vm::cast(sec.addr + sec.size);

// Probe
Expand Down Expand Up @@ -785,6 +790,11 @@ bool ppu_module::analyse(u32 lib_toc, u32 entry, const u32 sec_end, const std::b
// Find .eh_frame section
for (const auto& sec : secs)
{
if (sec.size % 4)
{
continue;
}

vm::cptr<void> sec_end = vm::cast(sec.addr + sec.size);

// Probe
Expand Down