53 { |
53 { |
54 __PXYPRINT1(_L("!! Reading medium failed with %d !!"), r); |
54 __PXYPRINT1(_L("!! Reading medium failed with %d !!"), r); |
55 partitionInfo.Close(); |
55 partitionInfo.Close(); |
56 return r; |
56 return r; |
57 } |
57 } |
58 TUint8 *iIntBuf = (TUint8 *) partitionInfo.Ptr(); |
58 TUint8* buffer = const_cast<TUint8*>(partitionInfo.Ptr()); |
59 |
59 |
60 // Read of the first sector successful so check for a Master Boot Record |
60 // Read of the first sector successful so check for a Master Boot Record |
61 if (*(TUint16*)(&iIntBuf[KMBRSignatureOffset])!= KMBRSignature) |
61 if (*(reinterpret_cast<TUint16*>(&buffer[KMBRSignatureOffset]))!= KMBRSignature) |
62 { |
62 { |
63 __PXYPRINT(_L("MBR not present")); |
63 __PXYPRINT(_L("MBR not present")); |
64 iMsDataMemMap.Reset(); |
64 iMsDataMemMap.Reset(); |
65 } |
65 } |
66 else |
66 else |
67 { |
67 { |
68 // Move the partition entries to a 4 byte boundary |
68 // Move the partition entries to a 4 byte boundary |
69 memcpy(&iIntBuf[0],&iIntBuf[KMBRFirstPartitionOffset],(sizeof(TMBRPartitionEntry)<<2)); |
69 memcpy(&buffer[0],&buffer[KMBRFirstPartitionOffset],(sizeof(TMBRPartitionEntry)<<2)); |
70 // Search for a x86 default boot partition - let this be the first |
70 // Search for a x86 default boot partition - let this be the first |
71 TMBRPartitionEntry* pe = (TMBRPartitionEntry*)(&iIntBuf[0]); |
71 TMBRPartitionEntry* pe = reinterpret_cast<TMBRPartitionEntry*>(&buffer[0]); |
72 |
72 |
73 TInt firstValidPartitionCount = -1; |
73 TInt firstValidPartitionCount = -1; |
74 TInt defaultPartitionNumber = -1; |
74 TInt defaultPartitionNumber = -1; |
75 TInt partitionCount = 0; |
75 TInt partitionCount = 0; |
76 for (TInt i = 0; i < KMBRMaxPrimaryPartitions; i++, pe++) |
76 for (TInt i = 0; i < KMBRMaxPrimaryPartitions; i++, pe++) |
77 { |
77 { |
78 if (pe->IsValidDosPartition() || pe->IsValidFAT32Partition()) |
78 if (pe->IsValidDosPartition() || pe->IsValidFAT32Partition() || pe->IsValidExFATPartition()) |
79 { |
79 { |
80 __PXYPRINT(_L("Found a Valid Partition")); |
80 __PXYPRINT(_L("Found a Valid Partition")); |
81 partitionCount++; |
81 partitionCount++; |
82 |
82 |
83 if (firstValidPartitionCount < 0) |
83 if (firstValidPartitionCount < 0) |
97 |
97 |
98 // Check the validity of the partition address boundaries |
98 // Check the validity of the partition address boundaries |
99 if (partitionCount > 0) |
99 if (partitionCount > 0) |
100 { |
100 { |
101 __PXYPRINT1(_L("Using Partition %d"), partitionCount); |
101 __PXYPRINT1(_L("Using Partition %d"), partitionCount); |
102 pe = (TMBRPartitionEntry*)(&iIntBuf[0]); |
102 pe = reinterpret_cast<TMBRPartitionEntry*>(&buffer[0]); |
103 TInt partitionIndex = firstValidPartitionCount; |
103 TInt partitionIndex = firstValidPartitionCount; |
104 if (defaultPartitionNumber > 0) |
104 if (defaultPartitionNumber > 0) |
105 { |
105 { |
106 partitionIndex = defaultPartitionNumber; |
106 partitionIndex = defaultPartitionNumber; |
107 } |
107 } |