Chameleon

Chameleon Commit Details

Date:2011-06-26 23:13:15 (8 years 26 days ago)
Author:Evan Lojewski
Commit:1090
Parents: 1089
Message:Initial GPT detection
Changes:
M/branches/rewrite/i386/modules/Disk/include/Partition.hpp
M/branches/rewrite/i386/modules/Disk/GUIDPartition.cpp
M/branches/rewrite/i386/modules/Disk/include/Disk.hpp
M/branches/rewrite/i386/modules/Disk/Partition.cpp
M/branches/rewrite/i386/modules/Disk/include/GUIDPartition.hpp

File differences

branches/rewrite/i386/modules/Disk/GUIDPartition.cpp
1212
1313
1414
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
1545
1646
1747
1848
1949
20
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
mBeginSector = 0;
mPartitionNumber = partitionNumber;
mNumPartitions = 0;
if(mDisk)
{
// read in lba1, this contains the partition map if it's GPT
mDisk->Read(1, 1, mLBABUffer);
mGPTHeader = (gpt_hdr*)mLBABUffer;
}
else
{
mGPTHeader = NULL;
}
if(isGPTDisk())
{
mNumPartitions = mGPTHeader->hdr_entries;
}
mGPTHeader = NULL;
if(mPartitionNumber >= 0 && mPartitionNumber < mNumPartitions)
{
// read in partition entry.
mDisk->Read(2 + mPartitionNumber, 1, mLBABUffer);
mGPTEntry = (gpt_ent*) mLBABUffer;
mNumSectors = mGPTEntry->ent_lba_end - mGPTEntry->ent_lba_start;
mBeginSector = mGPTEntry->ent_lba_start;
//mUUID = mGPTEntry->ent_uuid;
}
}
GUIDPartition::~GUIDPartition()
{
}
}
bool GUIDPartition::isGPTDisk()
{
static bool status = false;
if(status) return status;
if(!mGPTHeader) return false;
if(mGPTHeader->hdr_sig[0] == 'E' &&
mGPTHeader->hdr_sig[1] == 'F' &&
mGPTHeader->hdr_sig[2] == 'I' &&
mGPTHeader->hdr_sig[3] == ' ' &&
mGPTHeader->hdr_sig[4] == 'P' &&
mGPTHeader->hdr_sig[5] == 'A' &&
mGPTHeader->hdr_sig[6] == 'R' &&
mGPTHeader->hdr_sig[7] == 'T') return true;
return false;
}
branches/rewrite/i386/modules/Disk/include/Partition.hpp
2020
2121
2222
23
24
2325
2426
2527
......
2729
2830
2931
32
3033
3134
3235
virtual IOReturn Write(UInt64 sector, UInt64 size, UInt8* buffer);
virtual bool probe();
//virtual uuid_t getUUID();
protected:
Disk *mDisk;
UInt64 mBeginSector;
SInt8 mPartitionNumber;
UInt8 mNumPartitions;
//uuid_t mUUID;
private:
branches/rewrite/i386/modules/Disk/include/Disk.hpp
1414
1515
1616
17
1718
1819
1920
Disk(const char* name);
~Disk();
// TODO: add cacheing
virtual IOReturn Read(UInt64 sector, UInt64 size, UInt8* buffer) = 0;
virtual IOReturn Write(UInt64 sector, UInt64 size, UInt8* buffer) = 0;
branches/rewrite/i386/modules/Disk/include/GUIDPartition.hpp
1616
1717
1818
19
1920
2021
22
23
24
2125
2226
2327
~GUIDPartition();
protected:
bool isGPTDisk();
private:
UInt8 mLBABUffer[512]; // TODO: don't assume 512
gpt_hdr* mGPTHeader;
gpt_ent* mGPTEntry;
};
#endif /* GUID_PARTITION_H */
branches/rewrite/i386/modules/Disk/Partition.cpp
3434
3535
3636
37
38
39
40
41
42
43
{
return (mDisk != NULL) && (mPartitionNumber != INVALID_PARTITION) && mNumSectors;
}
/*
Partition::getUUID()
{
return mUUID;
}
*/

Archive Download the corresponding diff file

Revision: 1090