Merge pull request #1389 from ggrtk/ps3-bios-size

BIOS: Add check for older BIOS from PS3
This commit is contained in:
Connor McLaughlin 2021-01-05 17:59:57 +10:00 committed by GitHub
commit a6e1b3c4ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View file

@ -37,7 +37,7 @@ std::string Hash::ToString() const
return str;
}
static constexpr std::array<ImageInfo, 26> s_image_infos = {
static constexpr std::array<ImageInfo, 27> 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<ImageInfo, 26> 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<Image> LoadImageFromFile(const char* filename)
const u32 size = static_cast<u32>(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;
}

View file

@ -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<u8>;

View file

@ -305,7 +305,7 @@ std::optional<std::vector<u8>> 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(