From e51c9119f1ff89a56efd4bb673e1870cef59f7be Mon Sep 17 00:00:00 2001 From: Henrik Grimler Date: Fri, 10 Dec 2021 21:05:10 +0100 Subject: [PATCH] libpit: describe more parts of pit header The unknown string is "COM_TAR2" in all devices I have access to. The last unknown 4 bytes might be some sort of version, in old devices it is 0000, in Galaxy S6 0003, in Galaxy S7 and S8 0004 and in Galaxy S9 and tab S6 lite 0005. The CPU/bootloader string looks something like: * LSI5410 - Seen in Exynos 5420, 5433 devices (and perhaps others) * LSI7420 - Seen in Exynos 7420, 8890, 8895 devices (and perhaps others) * LSI7880 - Seen in a5y17lte (exynos 7880) * LSI9610 - Seen in gta4xl (exynos 9611) * LSI9810 - Seen in star2lte (exynos 9810) * Mx - Seen in Galaxy S3 (device codename is m0/m3) * MSM8916 - Seen in MSM8916 devices * MSM8960 - Seen in jflte (and probably in others, jflte has a APQ8064AB CPU) --- heimdall/source/Interface.cpp | 13 +++----- libpit/source/libpit.cpp | 62 +++++++++++------------------------ libpit/source/libpit.h | 55 +++++++------------------------ 3 files changed, 36 insertions(+), 94 deletions(-) diff --git a/heimdall/source/Interface.cpp b/heimdall/source/Interface.cpp index 2036ecf..5f0170c 100644 --- a/heimdall/source/Interface.cpp +++ b/heimdall/source/Interface.cpp @@ -207,16 +207,11 @@ void Interface::PrintDeviceDetectionFailed(void) void Interface::PrintPit(const PitData *pitData) { + Interface::Print("--- PIT Header ---\n"); Interface::Print("Entry Count: %d\n", pitData->GetEntryCount()); - - Interface::Print("Unknown 1: %d\n", pitData->GetUnknown1()); - Interface::Print("Unknown 2: %d\n", pitData->GetUnknown2()); - Interface::Print("Unknown 3: %d\n", pitData->GetUnknown3()); - Interface::Print("Unknown 4: %d\n", pitData->GetUnknown4()); - Interface::Print("Unknown 5: %d\n", pitData->GetUnknown5()); - Interface::Print("Unknown 6: %d\n", pitData->GetUnknown6()); - Interface::Print("Unknown 7: %d\n", pitData->GetUnknown7()); - Interface::Print("Unknown 8: %d\n", pitData->GetUnknown8()); + Interface::Print("Unknown string: %s\n", pitData->GetComTar2()); + Interface::Print("CPU/bootloader tag: %s\n", pitData->GetCpuBlId()); + Interface::Print("Version(?): 0x%04x\n", pitData->GetUnknown()); for (unsigned int i = 0; i < pitData->GetEntryCount(); i++) { diff --git a/libpit/source/libpit.cpp b/libpit/source/libpit.cpp index 1d10f2a..e372a91 100644 --- a/libpit/source/libpit.cpp +++ b/libpit/source/libpit.cpp @@ -66,17 +66,10 @@ PitData::PitData() { entryCount = 0; - unknown1 = 0; - unknown2 = 0; + com_tar2[0] = '\0'; + cpu_bl_id[0] = '\0'; - unknown3 = 0; - unknown4 = 0; - - unknown5 = 0; - unknown6 = 0; - - unknown7 = 0; - unknown8 = 0; + unknown_version = 0; } PitData::~PitData() @@ -98,17 +91,14 @@ bool PitData::Unpack(const unsigned char *data) entries.resize(entryCount); - unknown1 = PitData::UnpackInteger(data, 8); - unknown2 = PitData::UnpackInteger(data, 12); + if (!memcpy(com_tar2, &data[8], 8)) + return (false); + com_tar2[8]='\0'; + if (!memcpy(cpu_bl_id, &data[16], 8)) + return (false); + cpu_bl_id[8]='\0'; - unknown3 = PitData::UnpackShort(data, 16); - unknown4 = PitData::UnpackShort(data, 18); - - unknown5 = PitData::UnpackShort(data, 20); - unknown6 = PitData::UnpackShort(data, 22); - - unknown7 = PitData::UnpackShort(data, 24); - unknown8 = PitData::UnpackShort(data, 26); + unknown_version = PitData::UnpackShort(data, 24); unsigned int integerValue; unsigned int entryOffset; @@ -160,17 +150,10 @@ void PitData::Pack(unsigned char *data) const PitData::PackInteger(data, 4, entryCount); - PitData::PackInteger(data, 8, unknown1); - PitData::PackInteger(data, 12, unknown2); + memcpy(&data[8], com_tar2, 8); + memcpy(&data[16], cpu_bl_id, 8); - PitData::PackShort(data, 16, unknown3); - PitData::PackShort(data, 18, unknown4); - - PitData::PackShort(data, 20, unknown5); - PitData::PackShort(data, 22, unknown6); - - PitData::PackShort(data, 24, unknown7); - PitData::PackShort(data, 26, unknown8); + PitData::PackShort(data, 24, unknown_version); int entryOffset; @@ -201,9 +184,10 @@ void PitData::Pack(unsigned char *data) const bool PitData::Matches(const PitData *otherPitData) const { - if (entryCount == otherPitData->entryCount && unknown1 == otherPitData->unknown1 && unknown2 == otherPitData->unknown2 - && unknown3 == otherPitData->unknown3 && unknown4 == otherPitData->unknown4 && unknown5 == otherPitData->unknown5 - && unknown6 == otherPitData->unknown6 && unknown7 == otherPitData->unknown7 && unknown8 == otherPitData->unknown8) + if (entryCount == otherPitData->entryCount && + (strncmp(com_tar2, otherPitData->com_tar2, 8) == 0) && + (strncmp(cpu_bl_id, otherPitData->cpu_bl_id, 8) == 0) && + unknown_version == otherPitData->unknown_version) { for (unsigned int i = 0; i < entryCount; i++) { @@ -223,17 +207,11 @@ void PitData::Clear(void) { entryCount = 0; - unknown1 = 0; - unknown2 = 0; + com_tar2[0] = '\0'; - unknown3 = 0; - unknown4 = 0; + cpu_bl_id[0] = '\0'; - unknown5 = 0; - unknown6 = 0; - - unknown7 = 0; - unknown8 = 0; + unknown_version = 0; for (unsigned int i = 0; i < entries.size(); i++) delete entries[i]; diff --git a/libpit/source/libpit.h b/libpit/source/libpit.h index 228e4ef..0faac39 100644 --- a/libpit/source/libpit.h +++ b/libpit/source/libpit.h @@ -68,8 +68,8 @@ namespace libpit enum { kAttributeWrite = 1, - kAttributeSTL = 1 << 1/*, - kAttributeBML = 1 << 2*/ // ??? + kAttributeSTL = 1 << 1 + /* kAttributeBML = 1 << 2 */ // ??? }; enum @@ -261,18 +261,12 @@ namespace libpit private: - unsigned int entryCount; // 0x04 - unsigned int unknown1; // 0x08 - unsigned int unknown2; // 0x0C + unsigned int entryCount; // 0x04 + char com_tar2[8+1]; // 0x08 - unsigned short unknown3; // 0x10 - unsigned short unknown4; // 0x12 + char cpu_bl_id[8+1]; // 0x10 - unsigned short unknown5; // 0x14 - unsigned short unknown6; // 0x16 - - unsigned short unknown7; // 0x18 - unsigned short unknown8; // 0x1A + unsigned short unknown_version; // 0x18 // Entries start at 0x1C std::vector entries; @@ -371,44 +365,19 @@ namespace libpit return paddedSize; } - unsigned int GetUnknown1(void) const + const char * GetComTar2(void) const { - return unknown1; + return com_tar2; } - unsigned int GetUnknown2(void) const + const char * GetCpuBlId(void) const { - return unknown2; + return cpu_bl_id; } - unsigned short GetUnknown3(void) const + unsigned int GetUnknown(void) const { - return unknown3; - } - - unsigned short GetUnknown4(void) const - { - return unknown4; - } - - unsigned short GetUnknown5(void) const - { - return unknown5; - } - - unsigned short GetUnknown6(void) const - { - return unknown6; - } - - unsigned short GetUnknown7(void) const - { - return unknown7; - } - - unsigned short GetUnknown8(void) const - { - return unknown8; + return unknown_version; } }; }