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

Improve PSF log message #12991

Merged
merged 2 commits into from
Nov 27, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions rpcs3/Crypto/unpkg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ bool package_reader::read_param_sfo()

tmp.seek(0);

m_psf = psf::load_object(tmp);
m_psf = psf::load_object(tmp, name);

if (m_psf.empty())
{
Expand Down Expand Up @@ -610,7 +610,8 @@ package_error package_reader::check_target_app_version() const
return package_error::no_error;
}

const fs::file installed_sfo_file(rpcs3::utils::get_hdd0_dir() + "game/" + std::string(title_id) + "/PARAM.SFO");
const std::string sfo_path = rpcs3::utils::get_hdd0_dir() + "game/" + std::string(title_id) + "/PARAM.SFO";
const fs::file installed_sfo_file(sfo_path);
if (!installed_sfo_file)
{
if (!target_app_ver.empty())
Expand All @@ -624,7 +625,7 @@ package_error package_reader::check_target_app_version() const
return package_error::no_error;
}

const auto installed_psf = psf::load_object(installed_sfo_file);
const auto installed_psf = psf::load_object(installed_sfo_file, sfo_path);

const auto installed_title_id = psf::get_string(installed_psf, "TITLE_ID", "");
const auto installed_app_ver = psf::get_string(installed_psf, "APP_VER", "");
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellAudioOut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ audio_out_configuration::audio_out_configuration()
std::vector<CellAudioOutSoundMode>& primary_modes = primary_output.sound_modes;
std::vector<CellAudioOutSoundMode>& secondary_modes = secondary_output.sound_modes;

const psf::registry sfo = psf::load_object(fs::file(Emu.GetSfoDir(true) + "/PARAM.SFO"));
const psf::registry sfo = psf::load_object(Emu.GetSfoDir(true) + "/PARAM.SFO");
const s32 sound_format = psf::get_integer(sfo, "SOUND_FORMAT", psf::sound_format_flag::lpcm_2); // Default to Linear PCM 2 Ch.

const bool supports_lpcm_2 = (sound_format & psf::sound_format_flag::lpcm_2); // Linear PCM 2 Ch.
Expand Down
12 changes: 6 additions & 6 deletions rpcs3/Emu/Cell/Modules/cellGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ error_code cellHddGameCheck(ppu_thread& ppu, u32 version, vm::cptr<char> dirName
else
{
// TODO: Is cellHddGameCheck really responsible for writing the information in get->getParam ? (If not, delete this else)
const psf::registry psf = psf::load_object(fs::file(local_dir +"/PARAM.SFO"));
const psf::registry psf = psf::load_object(local_dir + "/PARAM.SFO");

// Some following fields may be zero in old FW 1.00 version PARAM.SFO
if (psf.contains("PARENTAL_LEVEL")) get->getParam.parentalLevel = ::at32(psf, "PARENTAL_LEVEL").as_integer();
Expand Down Expand Up @@ -670,7 +670,7 @@ error_code cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr
*attributes = 0; // TODO
// TODO: dirName might be a read only string when BootCheck is called on a disc game. (e.g. Ben 10 Ultimate Alien: Cosmic Destruction)

sfo = psf::load_object(fs::file(vfs::get("/dev_bdvd/PS3_GAME/PARAM.SFO")));
sfo = psf::load_object(vfs::get("/dev_bdvd/PS3_GAME/PARAM.SFO"));
}
else if (cat == "GD")
{
Expand All @@ -679,7 +679,7 @@ error_code cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr
*type = CELL_GAME_GAMETYPE_DISC;
*attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO

sfo = psf::load_object(fs::file(vfs::get(Emu.GetDir() + "PARAM.SFO")));
sfo = psf::load_object(vfs::get(Emu.GetDir() + "PARAM.SFO"));
}
else
{
Expand All @@ -688,7 +688,7 @@ error_code cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr
*type = CELL_GAME_GAMETYPE_HDD;
*attributes = 0; // TODO

sfo = psf::load_object(fs::file(vfs::get(Emu.GetDir() + "PARAM.SFO")));
sfo = psf::load_object(vfs::get(Emu.GetDir() + "PARAM.SFO"));
dir = Emu.GetTitleID();
}

Expand Down Expand Up @@ -723,7 +723,7 @@ error_code cellGamePatchCheck(vm::ptr<CellGameContentSize> size, vm::ptr<void> r
return CELL_GAME_ERROR_NOTPATCH;
}

psf::registry sfo = psf::load_object(fs::file(vfs::get(Emu.GetDir() + "PARAM.SFO")));
psf::registry sfo = psf::load_object(vfs::get(Emu.GetDir() + "PARAM.SFO"));

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

Expand Down Expand Up @@ -1708,7 +1708,7 @@ error_code cellDiscGameGetBootDiscInfo(vm::ptr<CellDiscGameSystemFileParam> getP
return CELL_DISCGAME_ERROR_NOT_DISCBOOT;
}

const psf::registry psf = psf::load_object(fs::file(vfs::get(dir + "/PARAM.SFO")));
const psf::registry psf = psf::load_object(vfs::get(dir + "/PARAM.SFO"));

if (psf.contains("PARENTAL_LEVEL")) getParam->parentalLevel = ::at32(psf, "PARENTAL_LEVEL").as_integer();
if (psf.contains("TITLE_ID")) strcpy_trunc(getParam->titleId, ::at32(psf, "TITLE_ID").as_string());
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/Cell/Modules/cellKb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ error_code cellKbClearBuf(u32 port_no)
const KbInfo& current_info = handler.GetInfo();

if (port_no >= handler.GetKeyboards().size() || current_info.status[port_no] != CELL_KB_STATUS_CONNECTED)
return CELL_KB_ERROR_NO_DEVICE;
return not_an_error(CELL_KB_ERROR_NO_DEVICE);

KbData& current_data = handler.GetData(port_no);
current_data.len = 0;
Expand Down Expand Up @@ -331,7 +331,7 @@ error_code cellKbRead(u32 port_no, vm::ptr<CellKbData> data)
const KbInfo& current_info = handler.GetInfo();

if (port_no >= handler.GetKeyboards().size() || current_info.status[port_no] != CELL_KB_STATUS_CONNECTED)
return CELL_KB_ERROR_NO_DEVICE;
return not_an_error(CELL_KB_ERROR_NO_DEVICE);

KbData& current_data = handler.GetData(port_no);

Expand Down Expand Up @@ -474,7 +474,7 @@ error_code cellKbGetConfiguration(u32 port_no, vm::ptr<CellKbConfig> config)
const KbInfo& current_info = handler.GetInfo();

if (port_no >= handler.GetKeyboards().size() || current_info.status[port_no] != CELL_KB_STATUS_CONNECTED)
return CELL_KB_ERROR_NO_DEVICE;
return not_an_error(CELL_KB_ERROR_NO_DEVICE);

// tests show that config is checked only after the device's status
if (!config)
Expand Down
10 changes: 5 additions & 5 deletions rpcs3/Emu/Cell/Modules/cellMouse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ error_code cellMouseClearBuf(u32 port_no)

if (port_no >= handler.GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
{
return CELL_MOUSE_ERROR_NO_DEVICE;
return not_an_error(CELL_MOUSE_ERROR_NO_DEVICE);
}

handler.GetDataList(port_no).clear();
Expand Down Expand Up @@ -229,7 +229,7 @@ error_code cellMouseGetData(u32 port_no, vm::ptr<CellMouseData> data)

if (port_no >= handler.GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
{
return CELL_MOUSE_ERROR_NO_DEVICE;
return not_an_error(CELL_MOUSE_ERROR_NO_DEVICE);
}

std::memset(data.get_ptr(), 0, data.size());
Expand Down Expand Up @@ -279,7 +279,7 @@ error_code cellMouseGetDataList(u32 port_no, vm::ptr<CellMouseDataList> data)

if (port_no >= handler.GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
{
return CELL_MOUSE_ERROR_NO_DEVICE;
return not_an_error(CELL_MOUSE_ERROR_NO_DEVICE);
}

std::memset(data.get_ptr(), 0, data.size());
Expand Down Expand Up @@ -368,7 +368,7 @@ error_code cellMouseGetTabletDataList(u32 port_no, vm::ptr<CellMouseTabletDataLi

if (port_no >= handler.GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
{
return CELL_MOUSE_ERROR_NO_DEVICE;
return not_an_error(CELL_MOUSE_ERROR_NO_DEVICE);
}

std::memset(data.get_ptr(), 0, data.size());
Expand Down Expand Up @@ -424,7 +424,7 @@ error_code cellMouseGetRawData(u32 port_no, vm::ptr<CellMouseRawData> data)

if (port_no >= handler.GetMice().size() || current_info.status[port_no] != CELL_MOUSE_STATUS_CONNECTED)
{
return CELL_MOUSE_ERROR_NO_DEVICE;
return not_an_error(CELL_MOUSE_ERROR_NO_DEVICE);
}

std::memset(data.get_ptr(), 0, data.size());
Expand Down
8 changes: 4 additions & 4 deletions rpcs3/Emu/Cell/Modules/cellPad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ error_code cellPadPeriphGetData(u32 port_no, vm::ptr<CellPadPeriphData> data)
const auto& pad = pads[port_no];

if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return CELL_PAD_ERROR_NO_DEVICE;
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

pad_get_data(port_no, &data->cellpad_data);

Expand Down Expand Up @@ -753,7 +753,7 @@ error_code cellPadGetCapabilityInfo(u32 port_no, vm::ptr<CellPadCapabilityInfo>
const auto pad = pads[port_no];

if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return CELL_PAD_ERROR_NO_DEVICE;
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

// Should return the same as device capability mask, psl1ght has it backwards in pad->h
memset(info->info, 0, CELL_PAD_MAX_CAPABILITY_INFO * sizeof(u32));
Expand Down Expand Up @@ -811,7 +811,7 @@ error_code cellPadInfoPressMode(u32 port_no)
const auto pad = pads[port_no];

if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return CELL_PAD_ERROR_NO_DEVICE;
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

return not_an_error((pad->m_device_capability & CELL_PAD_CAPABILITY_PRESS_MODE) ? 1 : 0);
}
Expand Down Expand Up @@ -840,7 +840,7 @@ error_code cellPadInfoSensorMode(u32 port_no)
const auto pad = pads[port_no];

if (!(pad->m_port_status & CELL_PAD_STATUS_CONNECTED))
return CELL_PAD_ERROR_NO_DEVICE;
return not_an_error(CELL_PAD_ERROR_NO_DEVICE);

return not_an_error((pad->m_device_capability & CELL_PAD_CAPABILITY_SENSOR_MODE) ? 1 : 0);
}
Expand Down
8 changes: 4 additions & 4 deletions rpcs3/Emu/Cell/Modules/cellSaveData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ static std::vector<SaveDataEntry> get_save_entries(const std::string& base_dir,
}

// PSF parameters
const psf::registry psf = psf::load_object(fs::file(base_dir + entry.name + "/PARAM.SFO"));
const psf::registry psf = psf::load_object(base_dir + entry.name + "/PARAM.SFO");

if (psf.empty())
{
Expand Down Expand Up @@ -755,7 +755,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
listGet->dirListNum++; // number of directories in list

// PSF parameters
const psf::registry psf = psf::load_object(fs::file(base_dir + entry.name + "/PARAM.SFO"));
const psf::registry psf = psf::load_object(base_dir + entry.name + "/PARAM.SFO");

if (psf.empty())
{
Expand Down Expand Up @@ -1372,7 +1372,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v
const std::string old_path = base_dir + ".backup_" + save_entry.escaped + "/";
const std::string new_path = base_dir + ".working_" + save_entry.escaped + "/";

psf::registry psf = psf::load_object(fs::file(dir_path + "PARAM.SFO"));
psf::registry psf = psf::load_object(dir_path + "PARAM.SFO");
bool has_modified = false;
bool recreated = false;

Expand Down Expand Up @@ -2070,7 +2070,7 @@ static NEVER_INLINE error_code savedata_get_list_item(vm::cptr<char> dirName, vm
return CELL_SAVEDATA_ERROR_NODATA;
}

const psf::registry psf = psf::load_object(fs::file(sfo));
const psf::registry psf = psf::load_object(sfo);

if (sysFileParam)
{
Expand Down
18 changes: 10 additions & 8 deletions rpcs3/Emu/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,10 +1000,11 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool

// Load PARAM.SFO (TODO)
psf::registry _psf;
if (fs::file sfov{elf_dir + "/sce_sys/param.sfo"})
const std::string sfo_path = elf_dir + "/sce_sys/param.sfo";
if (fs::file sfov{sfo_path})
{
m_sfo_dir = elf_dir;
_psf = psf::load_object(sfov);
_psf = psf::load_object(sfov, sfo_path);
}
else
{
Expand Down Expand Up @@ -1033,7 +1034,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
m_sfo_dir = rpcs3::utils::get_sfo_dir_from_game_path(elf_dir + "/../", m_title_id);
}

_psf = psf::load_object(fs::file(m_sfo_dir + "/PARAM.SFO"));
_psf = psf::load_object(m_sfo_dir + "/PARAM.SFO");
}

m_title = std::string(psf::get_string(_psf, "TITLE", std::string_view(m_path).substr(m_path.find_last_of(fs::delim) + 1)));
Expand Down Expand Up @@ -1412,7 +1413,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
return game_boot_result::invalid_file_or_folder;
}

const auto game_psf = psf::load_object(fs::file{vfs::get("/dev_bdvd/PS3_GAME/PARAM.SFO")});
const auto game_psf = psf::load_object(vfs::get("/dev_bdvd/PS3_GAME/PARAM.SFO"));
const auto bdvd_title_id = psf::get_string(game_psf, "TITLE_ID");

if (m_title_id.empty())
Expand Down Expand Up @@ -1528,7 +1529,7 @@ game_boot_result Emulator::Load(const std::string& title_id, bool add_only, bool
// Set title to actual disc title if necessary
const std::string disc_sfo_dir = vfs::get("/dev_bdvd/PS3_GAME/PARAM.SFO");

const auto disc_psf_obj = psf::load_object(fs::file{ disc_sfo_dir });
const auto disc_psf_obj = psf::load_object(disc_sfo_dir);

// Install PKGDIR, INSDIR, PS3_EXTRA
if (!bdvd_dir.empty())
Expand Down Expand Up @@ -2877,13 +2878,14 @@ std::set<std::string> Emulator::GetGameDirs() const
if (entry.is_directory && entry.name.starts_with(GetTitleID()))
{
const std::string sfo_dir = game_dir + entry.name + '/';
const fs::file sfo_file(sfo_dir + "PARAM.SFO");
const std::string sfo_path = sfo_dir + "PARAM.SFO";
const fs::file sfo_file(sfo_path);
if (!sfo_file)
{
continue;
}

const psf::registry psf = psf::load_object(sfo_file);
const psf::registry psf = psf::load_object(sfo_file, sfo_path);
const std::string title_id = std::string(psf::get_string(psf, "TITLE_ID", ""));

if (title_id == GetTitleID())
Expand Down Expand Up @@ -3038,7 +3040,7 @@ game_boot_result Emulator::InsertDisc(const std::string& path)

// Double check PARAM.SFO
const std::string sfo_dir = rpcs3::utils::get_sfo_dir_from_game_path(disc_root);
const psf::registry _psf = psf::load_object(fs::file(sfo_dir + "/PARAM.SFO"));
const psf::registry _psf = psf::load_object(sfo_dir + "/PARAM.SFO");

if (_psf.empty())
{
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/system_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ namespace rpcs3::utils

if (entry.is_directory && fs::is_file(sfo_path))
{
const auto psf = psf::load_object(fs::file(sfo_path));
const auto psf = psf::load_object(sfo_path);
const auto serial = psf::get_string(psf, "TITLE_ID");
if (serial == title_id)
{
Expand All @@ -321,7 +321,7 @@ namespace rpcs3::utils
return game_path + "/PS3_GAME";
}

const auto psf = psf::load_object(fs::file(game_path + "/PARAM.SFO"));
const auto psf = psf::load_object(game_path + "/PARAM.SFO");

const auto category = psf::get_string(psf, "CATEGORY");
const auto content_id = psf::get_string(psf, "CONTENT_ID");
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Loader/PSF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ namespace psf
fmt::throw_exception("Invalid format (0x%x)", m_type);
}

load_result_t load(const fs::file& stream)
load_result_t load(const fs::file& stream, std::string_view filename)
{
#define PSF_CHECK(cond, err) if (!static_cast<bool>(cond)) { if (error::err != error::stream) psf_log.error("Error loading PSF: %s%s", error::err, \
#define PSF_CHECK(cond, err) if (!static_cast<bool>(cond)) { if (error::err != error::stream) psf_log.error("Error loading PSF '%s': %s%s", filename, error::err, \
src_loc{__builtin_LINE(), __builtin_COLUMN(), __builtin_FILE(), __builtin_FUNCTION()}); \
result.clear(); \
errc = error::err; \
Expand Down Expand Up @@ -257,7 +257,7 @@ namespace psf

load_result_t load(const std::string& filename)
{
return load(fs::file(filename));
return load(fs::file(filename), filename);
}

std::vector<u8> save_object(const psf::registry& psf, std::vector<u8>&& init)
Expand Down
5 changes: 3 additions & 2 deletions rpcs3/Loader/PSF.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ namespace psf
};

// Load PSF registry from SFO binary format
load_result_t load(const fs::file&);
load_result_t load(const fs::file&, std::string_view filename);
load_result_t load(const std::string& filename);
inline registry load_object(const fs::file& f) { return load(f).sfo; }
inline registry load_object(const fs::file& f, std::string_view filename) { return load(f, filename).sfo; }
inline registry load_object(const std::string& filename) { return load(filename).sfo; }

// Convert PSF registry to SFO binary format
std::vector<u8> save_object(const registry&, std::vector<u8>&& init = std::vector<u8>{});
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Loader/disc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace disc

// Load PARAM.SFO
const std::string sfo_dir = rpcs3::utils::get_sfo_dir_from_game_path(elf_dir + "/../", "");
const psf::registry _psf = psf::load_object(fs::file(sfo_dir + "/PARAM.SFO"));
const psf::registry _psf = psf::load_object(sfo_dir + "/PARAM.SFO");

if (_psf.empty())
{
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/rpcs3qt/game_list_frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ void game_list_frame::Refresh(const bool from_drive, const bool scroll_after)
const Localized thread_localized;

const std::string sfo_dir = rpcs3::utils::get_sfo_dir_from_game_path(dir);
const psf::registry psf = psf::load_object(fs::file(sfo_dir + "/PARAM.SFO"));
const psf::registry psf = psf::load_object(sfo_dir + "/PARAM.SFO");
const std::string_view title_id = psf::get_string(psf, "TITLE_ID", "");

if (title_id.empty())
Expand Down