From 79012d5288bb816c230fa30b959b69001a6cbe2d Mon Sep 17 00:00:00 2001 From: Albert Liu <45282415+ggrtk@users.noreply.github.com> Date: Mon, 4 Jan 2021 23:38:42 -0800 Subject: [PATCH] BIOS: Add check for older BIOS from PS3 Same revision number as newer PS3, but different file size and 512KB hash. --- src/core/bios.cpp | 10 +++++----- src/core/bios.h | 3 ++- src/core/host_interface.cpp | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/core/bios.cpp b/src/core/bios.cpp index c77ccb5b6..7fceb571f 100644 --- a/src/core/bios.cpp +++ b/src/core/bios.cpp @@ -37,7 +37,7 @@ std::string Hash::ToString() const return str; } -static constexpr std::array s_image_infos = { +static constexpr std::array s_image_infos = { {{"SCPH-1000, DTL-H1000 (v1.0)", ConsoleRegion::NTSC_J, MakeHashFromString("239665b1a3dade1b5a52c06338011044"), true}, {"SCPH-1001, 5003, DTL-H1201, H3001 (v2.2 12-04-95 A)", ConsoleRegion::NTSC_U, MakeHashFromString("924e392ed05558ffdb115408c263dccf"), true}, @@ -79,6 +79,7 @@ static constexpr std::array s_image_infos = { true}, {"SCPH-1000R (v4.5 05-25-00 J)", ConsoleRegion::NTSC_J, MakeHashFromString("476d68a94ccec3b9c8303bbd1daf2810"), true}, + {"PS3 (v5.0 06-23-03 A)", ConsoleRegion::Auto, MakeHashFromString("c02a6fbb1b27359f84e92fae8bc21316"), false}, {"PS3 (v5.0 06-23-03 A)", ConsoleRegion::Auto, MakeHashFromString("81bbe60ba7a3d1cea1d48c14cbcc647b"), false}}}; Hash GetHash(const Image& image) @@ -104,11 +105,10 @@ std::optional LoadImageFromFile(const char* filename) const u32 size = static_cast(std::ftell(fp.get())); std::fseek(fp.get(), 0, SEEK_SET); - // Apparently some PS1/PS2 BIOS revisions found on the PS3 are neither 512KB nor 4MB, so just check within this range - if (size < BIOS_SIZE || size > BIOS_SIZE_PS2) + if (size != BIOS_SIZE && size != BIOS_SIZE_PS2 && size != BIOS_SIZE_PS3) { - Log_ErrorPrintf("BIOS image '%s' mismatch, expecting between %u and %u bytes, got %u bytes", filename, BIOS_SIZE, - BIOS_SIZE_PS2, size); + Log_ErrorPrintf("BIOS image '%s' size mismatch, expecting either %u or %u or %u bytes but got %u bytes", filename, + BIOS_SIZE, BIOS_SIZE_PS2, BIOS_SIZE_PS3, size); return std::nullopt; } diff --git a/src/core/bios.h b/src/core/bios.h index fa30e106b..f0c569f32 100644 --- a/src/core/bios.h +++ b/src/core/bios.h @@ -10,7 +10,8 @@ enum : u32 { BIOS_BASE = 0x1FC00000, BIOS_SIZE = 0x80000, - BIOS_SIZE_PS2 = 0x400000 + BIOS_SIZE_PS2 = 0x400000, + BIOS_SIZE_PS3 = 0x3E66F0 }; using Image = std::vector; diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index 2a7638125..2a99bf767 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -305,7 +305,7 @@ std::optional> HostInterface::FindBIOSImageInDirectory(ConsoleRe for (const FILESYSTEM_FIND_DATA& fd : results) { - if (fd.Size != BIOS::BIOS_SIZE && fd.Size != BIOS::BIOS_SIZE_PS2) + if (fd.Size != BIOS::BIOS_SIZE && fd.Size != BIOS::BIOS_SIZE_PS2 && fd.Size != BIOS::BIOS_SIZE_PS3) { Log_WarningPrintf("Skipping '%s': incorrect size", fd.FileName.c_str()); continue; @@ -370,7 +370,7 @@ HostInterface::FindBIOSImagesInDirectory(const char* directory) for (FILESYSTEM_FIND_DATA& fd : files) { - if (fd.Size < BIOS::BIOS_SIZE || fd.Size > BIOS::BIOS_SIZE_PS2) + if (fd.Size != BIOS::BIOS_SIZE && fd.Size != BIOS::BIOS_SIZE_PS2 && fd.Size != BIOS::BIOS_SIZE_PS3) continue; std::string full_path(