Skip to content

Commit

Permalink
BIOS: Add check for older BIOS from PS3
Browse files Browse the repository at this point in the history
Same revision number as newer PS3, but different file size and 512KB
hash.
  • Loading branch information
ggrtk committed Jan 5, 2021
1 parent e3de44d commit 79012d5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions src/core/bios.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}

Expand Down
3 changes: 2 additions & 1 deletion src/core/bios.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down
4 changes: 2 additions & 2 deletions src/core/host_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 79012d5

Please sign in to comment.