Skip to content

Commit

Permalink
Renamed partitionType to chipIdentifier as partition type was incorrect.
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin-Dobell committed Mar 29, 2012
1 parent 713af23 commit 907c942
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 49 deletions.
6 changes: 3 additions & 3 deletions heimdall/source/BridgeManager.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ int BridgeManager::ReceivePitFile(unsigned char **pitBuffer) const
return (fileSize); return (fileSize);
} }


bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int partitionType, unsigned int fileIdentifier) const bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int chipIdentifier, unsigned int fileIdentifier) const
{ {
if (destination != EndFileTransferPacket::kDestinationModem && destination != EndFileTransferPacket::kDestinationPhone) if (destination != EndFileTransferPacket::kDestinationModem && destination != EndFileTransferPacket::kDestinationPhone)
{ {
Expand Down Expand Up @@ -1123,7 +1123,7 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int


if (destination == EndFileTransferPacket::kDestinationPhone) if (destination == EndFileTransferPacket::kDestinationPhone)
{ {
EndPhoneFileTransferPacket *endPhoneFileTransferPacket = new EndPhoneFileTransferPacket(sequenceByteCount, 0, partitionType, EndPhoneFileTransferPacket *endPhoneFileTransferPacket = new EndPhoneFileTransferPacket(sequenceByteCount, 0, chipIdentifier,
fileIdentifier, isLastSequence); fileIdentifier, isLastSequence);


success = SendPacket(endPhoneFileTransferPacket, 3000); success = SendPacket(endPhoneFileTransferPacket, 3000);
Expand All @@ -1138,7 +1138,7 @@ bool BridgeManager::SendFile(FILE *file, unsigned int destination, unsigned int
} }
else // destination == EndFileTransferPacket::kDestinationModem else // destination == EndFileTransferPacket::kDestinationModem
{ {
EndModemFileTransferPacket *endModemFileTransferPacket = new EndModemFileTransferPacket(sequenceByteCount, 0, partitionType, isLastSequence); EndModemFileTransferPacket *endModemFileTransferPacket = new EndModemFileTransferPacket(sequenceByteCount, 0, chipIdentifier, isLastSequence);


success = SendPacket(endModemFileTransferPacket, 3000); success = SendPacket(endModemFileTransferPacket, 3000);
delete endModemFileTransferPacket; delete endModemFileTransferPacket;
Expand Down
2 changes: 1 addition & 1 deletion heimdall/source/BridgeManager.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ namespace Heimdall
bool SendPitFile(FILE *file) const; bool SendPitFile(FILE *file) const;
int ReceivePitFile(unsigned char **pitBuffer) const; int ReceivePitFile(unsigned char **pitBuffer) const;


bool SendFile(FILE *file, unsigned int destination, unsigned int partitionType, unsigned int fileIdentifier = 0xFFFFFFFF) const; bool SendFile(FILE *file, unsigned int destination, unsigned int chipIdentifier, unsigned int fileIdentifier = 0xFFFFFFFF) const;
bool ReceiveDump(unsigned int chipType, unsigned int chipId, FILE *file) const; bool ReceiveDump(unsigned int chipType, unsigned int chipId, FILE *file) const;


bool IsVerbose(void) const bool IsVerbose(void) const
Expand Down
14 changes: 7 additions & 7 deletions heimdall/source/EndFileTransferPacket.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ namespace Heimdall


private: private:


unsigned int destination; // Chip identifier perhaps unsigned int destination; // PDA / Modem
unsigned int sequenceByteCount; unsigned int sequenceByteCount;
unsigned int unknown1; unsigned int unknown1;
unsigned int partitionType; unsigned int chipIdentifier;


protected: protected:


EndFileTransferPacket(unsigned int destination, unsigned int sequenceByteCount, unsigned int unknown1, unsigned int partitionType) EndFileTransferPacket(unsigned int destination, unsigned int sequenceByteCount, unsigned int unknown1, unsigned int chipIdentifier)
: FileTransferPacket(FileTransferPacket::kRequestEnd) : FileTransferPacket(FileTransferPacket::kRequestEnd)
{ {
this->destination = destination; this->destination = destination;
this->sequenceByteCount = sequenceByteCount; this->sequenceByteCount = sequenceByteCount;
this->unknown1 = unknown1; this->unknown1 = unknown1;
this->partitionType = partitionType; this->chipIdentifier = chipIdentifier;
} }


public: public:
Expand All @@ -78,9 +78,9 @@ namespace Heimdall
return (unknown1); return (unknown1);
} }


unsigned int GetPartitionType(void) const unsigned int GetChipIdentifier(void) const
{ {
return (partitionType); return (chipIdentifier);
} }


virtual void Pack(void) virtual void Pack(void)
Expand All @@ -90,7 +90,7 @@ namespace Heimdall
PackInteger(FileTransferPacket::kDataSize, destination); PackInteger(FileTransferPacket::kDataSize, destination);
PackInteger(FileTransferPacket::kDataSize + 4, sequenceByteCount); PackInteger(FileTransferPacket::kDataSize + 4, sequenceByteCount);
PackInteger(FileTransferPacket::kDataSize + 8, unknown1); PackInteger(FileTransferPacket::kDataSize + 8, unknown1);
PackInteger(FileTransferPacket::kDataSize + 12, partitionType); PackInteger(FileTransferPacket::kDataSize + 12, chipIdentifier);
} }
}; };
} }
Expand Down
4 changes: 2 additions & 2 deletions heimdall/source/EndModemFileTransferPacket.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace Heimdall


public: public:


EndModemFileTransferPacket(unsigned int sequenceByteCount, unsigned int unknown1, unsigned int partitionType, bool endOfFile) EndModemFileTransferPacket(unsigned int sequenceByteCount, unsigned int unknown1, unsigned int chipIdentifier, bool endOfFile)
: EndFileTransferPacket(EndFileTransferPacket::kDestinationModem, sequenceByteCount, unknown1, partitionType) : EndFileTransferPacket(EndFileTransferPacket::kDestinationModem, sequenceByteCount, unknown1, chipIdentifier)
{ {
this->endOfFile = (endOfFile) ? 1 : 0; this->endOfFile = (endOfFile) ? 1 : 0;
} }
Expand Down
4 changes: 2 additions & 2 deletions heimdall/source/EndPhoneFileTransferPacket.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ namespace Heimdall


public: public:


EndPhoneFileTransferPacket(unsigned int sequenceByteCount, unsigned int unknown1, unsigned int partitionType, EndPhoneFileTransferPacket(unsigned int sequenceByteCount, unsigned int unknown1, unsigned int chipIdentifier,
unsigned int fileIdentifier, bool endOfFile) unsigned int fileIdentifier, bool endOfFile)
: EndFileTransferPacket(EndFileTransferPacket::kDestinationPhone, sequenceByteCount, unknown1, partitionType) : EndFileTransferPacket(EndFileTransferPacket::kDestinationPhone, sequenceByteCount, unknown1, chipIdentifier)
{ {
this->fileIdentifier = fileIdentifier; this->fileIdentifier = fileIdentifier;
this->endOfFile = (endOfFile) ? 1 : 0; this->endOfFile = (endOfFile) ? 1 : 0;
Expand Down
9 changes: 2 additions & 7 deletions heimdall/source/Interface.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -444,14 +444,9 @@ void Interface::PrintPit(const PitData *pitData)
Interface::Print("\n\n--- Entry #%d ---\n", i); Interface::Print("\n\n--- Entry #%d ---\n", i);
Interface::Print("Unused: %s\n", (entry->GetUnused()) ? "Yes" : "No"); Interface::Print("Unused: %s\n", (entry->GetUnused()) ? "Yes" : "No");


const char *partitionTypeText = "Unknown"; const char *chipIdentifierText = "Unknown";


if (entry->GetPartitionType() == PitEntry::kPartitionTypeRfs) Interface::Print("Chip Identifier: %d (%s)\n", entry->GetChipIdentifier());
partitionTypeText = "RFS";
else if (entry->GetPartitionType() == PitEntry::kPartitionTypeExt4)
partitionTypeText = "EXT4";

Interface::Print("Partition Type: %d (%s)\n", entry->GetPartitionType(), partitionTypeText);


Interface::Print("Partition Identifier: %d\n", entry->GetPartitionIdentifier()); Interface::Print("Partition Identifier: %d\n", entry->GetPartitionIdentifier());


Expand Down
22 changes: 11 additions & 11 deletions heimdall/source/main.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ vector<const char *> knownPartitionNames[kKnownPartitionCount];


struct PartitionInfo struct PartitionInfo
{ {
unsigned int partitionType; unsigned int chipIdentifier;
string partitionName; string partitionName;
FILE *file; FILE *file;


PartitionInfo(unsigned int partitionType, const char *partitionName, FILE *file) PartitionInfo(unsigned int chipIdentifier, const char *partitionName, FILE *file)
{ {
this->partitionType = partitionType; this->chipIdentifier = chipIdentifier;
this->partitionName = partitionName; this->partitionName = partitionName;
this->file = file; this->file = file;
} }
Expand Down Expand Up @@ -218,7 +218,7 @@ bool mapFilesToPartitions(const map<string, FILE *>& argumentFileMap, const PitD


if (!pitEntry && knownPartition == kKnownPartitionPit) if (!pitEntry && knownPartition == kKnownPartitionPit)
{ {
// NOTE: We're assuming a PIT file always has partitionType zero. // NOTE: We're assuming a PIT file always has chipIdentifier zero.
PartitionInfo partitionInfo(0, knownPartitionNames[kKnownPartitionPit][0], it->second); PartitionInfo partitionInfo(0, knownPartitionNames[kKnownPartitionPit][0], it->second);
partitionInfoMap.insert(pair<unsigned int, PartitionInfo>(0xFFFFFFFF, partitionInfo)); partitionInfoMap.insert(pair<unsigned int, PartitionInfo>(0xFFFFFFFF, partitionInfo));


Expand All @@ -232,7 +232,7 @@ bool mapFilesToPartitions(const map<string, FILE *>& argumentFileMap, const PitD
return (false); return (false);
} }


PartitionInfo partitionInfo(pitEntry->GetPartitionType(), pitEntry->GetPartitionName(), it->second); PartitionInfo partitionInfo(pitEntry->GetChipIdentifier(), pitEntry->GetPartitionName(), it->second);
partitionInfoMap.insert(pair<unsigned int, PartitionInfo>(pitEntry->GetPartitionIdentifier(), partitionInfo)); partitionInfoMap.insert(pair<unsigned int, PartitionInfo>(pitEntry->GetPartitionIdentifier(), partitionInfo));
} }


Expand Down Expand Up @@ -264,7 +264,7 @@ int downloadPitFile(BridgeManager *bridgeManager, unsigned char **pitBuffer)
return (devicePitFileSize); return (devicePitFileSize);
} }


bool flashFile(BridgeManager *bridgeManager, unsigned int partitionType, unsigned int partitionIndex, const char *partitionName, FILE *file) bool flashFile(BridgeManager *bridgeManager, unsigned int chipIdentifier, unsigned int partitionIndex, const char *partitionName, FILE *file)
{ {
// PIT files need to be handled differently, try determine if the partition we're flashing to is a PIT partition. // PIT files need to be handled differently, try determine if the partition we're flashing to is a PIT partition.
bool isPit = false; bool isPit = false;
Expand Down Expand Up @@ -313,7 +313,7 @@ bool flashFile(BridgeManager *bridgeManager, unsigned int partitionType, unsigne


//if (bridgeManager->SendFile(file, EndPhoneFileTransferPacket::kDestinationPhone, // <-- Kies method. WARNING: Doesn't work on Galaxy Tab! //if (bridgeManager->SendFile(file, EndPhoneFileTransferPacket::kDestinationPhone, // <-- Kies method. WARNING: Doesn't work on Galaxy Tab!
// EndPhoneFileTransferPacket::kFileModem)) // EndPhoneFileTransferPacket::kFileModem))
if (bridgeManager->SendFile(file, EndModemFileTransferPacket::kDestinationModem, partitionType)) // <-- Odin method if (bridgeManager->SendFile(file, EndModemFileTransferPacket::kDestinationModem, chipIdentifier)) // <-- Odin method
{ {
Interface::Print("%s upload successful\n", partitionName); Interface::Print("%s upload successful\n", partitionName);
return (true); return (true);
Expand All @@ -329,7 +329,7 @@ bool flashFile(BridgeManager *bridgeManager, unsigned int partitionType, unsigne
// We're uploading to a phone partition // We're uploading to a phone partition
Interface::Print("Uploading %s\n", partitionName); Interface::Print("Uploading %s\n", partitionName);


if (bridgeManager->SendFile(file, EndPhoneFileTransferPacket::kDestinationPhone, partitionType, partitionIndex)) if (bridgeManager->SendFile(file, EndPhoneFileTransferPacket::kDestinationPhone, chipIdentifier, partitionIndex))
{ {
Interface::Print("%s upload successful\n", partitionName); Interface::Print("%s upload successful\n", partitionName);
return (true); return (true);
Expand Down Expand Up @@ -474,7 +474,7 @@ bool attemptFlash(BridgeManager *bridgeManager, map<string, FILE *> argumentFile
{ {
PartitionInfo *partitionInfo = &(it->second); PartitionInfo *partitionInfo = &(it->second);


if (!flashFile(bridgeManager, partitionInfo->partitionType, it->first, partitionInfo->partitionName.c_str(), partitionInfo->file)) if (!flashFile(bridgeManager, partitionInfo->chipIdentifier, it->first, partitionInfo->partitionName.c_str(), partitionInfo->file))
return (false); return (false);


break; break;
Expand All @@ -489,7 +489,7 @@ bool attemptFlash(BridgeManager *bridgeManager, map<string, FILE *> argumentFile
{ {
PartitionInfo *partitionInfo = &(it->second); PartitionInfo *partitionInfo = &(it->second);


if (!flashFile(bridgeManager, partitionInfo->partitionType, it->first, partitionInfo->partitionName.c_str(), partitionInfo->file)) if (!flashFile(bridgeManager, partitionInfo->chipIdentifier, it->first, partitionInfo->partitionName.c_str(), partitionInfo->file))
return (false); return (false);
} }
} }
Expand All @@ -501,7 +501,7 @@ bool attemptFlash(BridgeManager *bridgeManager, map<string, FILE *> argumentFile
{ {
PartitionInfo *partitionInfo = &(it->second); PartitionInfo *partitionInfo = &(it->second);


if (!flashFile(bridgeManager, partitionInfo->partitionType, it->first, partitionInfo->partitionName.c_str(), partitionInfo->file)) if (!flashFile(bridgeManager, partitionInfo->chipIdentifier, it->first, partitionInfo->partitionName.c_str(), partitionInfo->file))
return (false); return (false);
} }
} }
Expand Down
8 changes: 4 additions & 4 deletions libpit/Source/libpit.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ using namespace libpit;
PitEntry::PitEntry() PitEntry::PitEntry()
{ {
unused = false; unused = false;
partitionType = 0; chipIdentifier = 0;
partitionIdentifier = 0; partitionIdentifier = 0;
partitionFlags = 0; partitionFlags = 0;
unknown1 = 0; unknown1 = 0;
Expand All @@ -45,7 +45,7 @@ PitEntry::~PitEntry()


bool PitEntry::Matches(const PitEntry *otherPitEntry) const bool PitEntry::Matches(const PitEntry *otherPitEntry) const
{ {
if (unused == otherPitEntry->unused && partitionType == otherPitEntry->partitionType && partitionIdentifier == otherPitEntry->partitionIdentifier if (unused == otherPitEntry->unused && chipIdentifier == otherPitEntry->chipIdentifier && partitionIdentifier == otherPitEntry->partitionIdentifier
&& partitionFlags == otherPitEntry->partitionFlags && unknown1 == otherPitEntry->unknown1 && partitionBlockSize == otherPitEntry->partitionBlockSize && partitionFlags == otherPitEntry->partitionFlags && unknown1 == otherPitEntry->unknown1 && partitionBlockSize == otherPitEntry->partitionBlockSize
&& partitionBlockCount == otherPitEntry->partitionBlockCount && unknown2 == otherPitEntry->unknown2 && unknown3 == otherPitEntry->unknown3 && partitionBlockCount == otherPitEntry->partitionBlockCount && unknown2 == otherPitEntry->unknown2 && unknown3 == otherPitEntry->unknown3
&& strcmp(partitionName, otherPitEntry->partitionName) == 0 && strcmp(filename, otherPitEntry->filename) == 0) && strcmp(partitionName, otherPitEntry->partitionName) == 0 && strcmp(filename, otherPitEntry->filename) == 0)
Expand Down Expand Up @@ -121,7 +121,7 @@ bool PitData::Unpack(const unsigned char *data)
entries[i]->SetUnused((integerValue != 0) ? true : false); entries[i]->SetUnused((integerValue != 0) ? true : false);


integerValue = PitData::UnpackInteger(data, entryOffset + 4); integerValue = PitData::UnpackInteger(data, entryOffset + 4);
entries[i]->SetPartitionType(integerValue); entries[i]->SetChipIdentifier(integerValue);


integerValue = PitData::UnpackInteger(data, entryOffset + 8); integerValue = PitData::UnpackInteger(data, entryOffset + 8);
entries[i]->SetPartitionIdentifier(integerValue); entries[i]->SetPartitionIdentifier(integerValue);
Expand Down Expand Up @@ -177,7 +177,7 @@ void PitData::Pack(unsigned char *data) const


PitData::PackInteger(data, entryOffset, (entries[i]->GetUnused()) ? 1 : 0); PitData::PackInteger(data, entryOffset, (entries[i]->GetUnused()) ? 1 : 0);


PitData::PackInteger(data, entryOffset + 4, entries[i]->GetPartitionType()); PitData::PackInteger(data, entryOffset + 4, entries[i]->GetChipIdentifier());
PitData::PackInteger(data, entryOffset + 8, entries[i]->GetPartitionIdentifier()); PitData::PackInteger(data, entryOffset + 8, entries[i]->GetPartitionIdentifier());
PitData::PackInteger(data, entryOffset + 12, entries[i]->GetPartitionFlags()); PitData::PackInteger(data, entryOffset + 12, entries[i]->GetPartitionFlags());


Expand Down
17 changes: 5 additions & 12 deletions libpit/Source/libpit.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -46,13 +46,6 @@ namespace libpit
kFilenameMaxLength = 64 kFilenameMaxLength = 64
}; };


enum
{
kPartitionTypeRfs = 0,
kPartitionTypeBlank = 1, // ?
kPartitionTypeExt4 = 2
};

enum enum
{ {
kPartitionFlagWrite = 1 << 1 kPartitionFlagWrite = 1 << 1
Expand All @@ -62,7 +55,7 @@ namespace libpit


bool unused; bool unused;


unsigned int partitionType; unsigned int chipIdentifier;
unsigned int partitionIdentifier; unsigned int partitionIdentifier;
unsigned int partitionFlags; unsigned int partitionFlags;


Expand Down Expand Up @@ -94,14 +87,14 @@ namespace libpit
this->unused = unused; this->unused = unused;
} }


unsigned int GetPartitionType(void) const unsigned int GetChipIdentifier(void) const
{ {
return partitionType; return chipIdentifier;
} }


void SetPartitionType(unsigned int partitionType) void SetChipIdentifier(unsigned int chipIdentifier)
{ {
this->partitionType = partitionType; this->chipIdentifier = chipIdentifier;
} }


unsigned int GetPartitionIdentifier(void) const unsigned int GetPartitionIdentifier(void) const
Expand Down

0 comments on commit 907c942

Please sign in to comment.