~grimler/Heimdall

c3516307d2b2a1b63611d888119ee8596a103cf9 — Henrik Grimler 2 years ago f6c4698
libpit: last number in PIT header is the "LUN count"

Where LUN probably stands for Logical Unit Number.  Previous
assumption that it was the odin protocol version was wrong, so let's
fix this.
3 files changed, 12 insertions(+), 12 deletions(-)

M heimdall/source/Interface.cpp
M libpit/source/libpit.cpp
M libpit/source/libpit.h
M heimdall/source/Interface.cpp => heimdall/source/Interface.cpp +1 -1
@@ 211,7 211,7 @@ void Interface::PrintPit(const PitData *pitData)
	Interface::Print("Entry Count: %d\n", pitData->GetEntryCount());
	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());
	Interface::Print("Logic unit count: %d\n", pitData->GetLUCount());

	for (unsigned int i = 0; i < pitData->GetEntryCount(); i++)
	{

M libpit/source/libpit.cpp => libpit/source/libpit.cpp +5 -5
@@ 69,7 69,7 @@ PitData::PitData()
	com_tar2[0] = '\0';
	cpu_bl_id[0] = '\0';

	unknown_version = 0;
	luCount = 0;
}

PitData::~PitData()


@@ 98,7 98,7 @@ bool PitData::Unpack(const unsigned char *data)
		return (false);
	cpu_bl_id[8]='\0';

	unknown_version = PitData::UnpackShort(data, 24);
	luCount = PitData::UnpackShort(data, 24);

	unsigned int integerValue;
	unsigned int entryOffset;


@@ 153,7 153,7 @@ void PitData::Pack(unsigned char *data) const
	memcpy(&data[8], com_tar2, 8);
	memcpy(&data[16], cpu_bl_id, 8);

	PitData::PackShort(data, 24, unknown_version);
	PitData::PackShort(data, 24, luCount);

	int entryOffset;



@@ 187,7 187,7 @@ bool PitData::Matches(const PitData *otherPitData) const
	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)
	    luCount == otherPitData->luCount)
	{
		for (unsigned int i = 0; i < entryCount; i++)
		{


@@ 211,7 211,7 @@ void PitData::Clear(void)

	cpu_bl_id[0] = '\0';

	unknown_version = 0;
	luCount = 0;

	for (unsigned int i = 0; i < entries.size(); i++)
		delete entries[i];

M libpit/source/libpit.h => libpit/source/libpit.h +6 -6
@@ 261,12 261,12 @@ namespace libpit

		private:

			unsigned int entryCount;         // 0x04
			char com_tar2[8+1];              // 0x08
			unsigned int entryCount; // 0x04
			char com_tar2[8+1];      // 0x08

			char cpu_bl_id[8+1];             // 0x10
			char cpu_bl_id[8+1];     // 0x10

			unsigned short unknown_version;  // 0x18
			unsigned short luCount;  // 0x18

			// Entries start at 0x1C
			std::vector<PitEntry *> entries;


@@ 375,9 375,9 @@ namespace libpit
				return cpu_bl_id;
			}

			unsigned int GetUnknown(void) const
			unsigned int GetLUCount(void) const
			{
				return unknown_version;
				return luCount;
			}
	};
}