kernel/eka/drivers/medmmc/bgahsmmcptn.cpp
changeset 90 947f0dc9f7a8
parent 52 2d65c2f76d7b
child 202 9aca3be14c27
equal deleted inserted replaced
52:2d65c2f76d7b 90:947f0dc9f7a8
   117 		Info().iFileSystemId = KDriveFileNone;
   117 		Info().iFileSystemId = KDriveFileNone;
   118 		Info().iDriveAtt |= KDriveAttHidden;
   118 		Info().iDriveAtt |= KDriveAttHidden;
   119 		}
   119 		}
   120 	else if ( PartitionIsFAT(aDrive.iPartitionType) || PartitionIsFAT32(aDrive.iPartitionType)	)
   120 	else if ( PartitionIsFAT(aDrive.iPartitionType) || PartitionIsFAT32(aDrive.iPartitionType)	)
   121 		{		
   121 		{		
   122 		Info().iDriveAtt = iPartitionAttributes[aDrive.iPartitionNumber];
   122 		Info().iDriveAtt |= iPartitionAttributes[aDrive.iPartitionNumber];
   123 		}
   123 		}
   124 
   124 
   125 	return KErrNone;
   125 	return KErrNone;
   126 	}
   126 	}
   127 
   127 
   155 	TBool foundSwap = EFalse;
   155 	TBool foundSwap = EFalse;
   156 
   156 
   157 	BGAHSMMCPTN_PI_STR *partitionTable = (BGAHSMMCPTN_PI_STR*)(&iIntBuf[0]);
   157 	BGAHSMMCPTN_PI_STR *partitionTable = (BGAHSMMCPTN_PI_STR*)(&iIntBuf[0]);
   158 
   158 
   159 	// Verify that this is the Nokia partition table
   159 	// Verify that this is the Nokia partition table
   160 	if( memcompare( (TUint8*)&(partitionTable->id[0]), sizeof(BGAHSMMCPTN_PI_ID), (TUint8*)BGAHSMMCPTN_PI_ID, sizeof(BGAHSMMCPTN_PI_ID)) == 0 )
   160 	if( memcompare( (TUint8*)&(partitionTable->iId[0]), sizeof(BGAHSMMCPTN_PI_ID), (TUint8*)BGAHSMMCPTN_PI_ID, sizeof(BGAHSMMCPTN_PI_ID)) == 0 )
   161 		{
   161 		{
   162 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("Nokia partition structure found"));
   162 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("Nokia partition structure found"));
   163 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->id..............: %s", partitionTable->id ));
   163 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->id..............: %s", partitionTable->iId ));
   164 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->sector_size.....: %d = 0x%x", partitionTable->sector_size, partitionTable->sector_size));
   164 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->sector_size.....: %d = 0x%x", partitionTable->iSector_size, partitionTable->iSector_size));
   165 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->major_ver.......: %d", partitionTable->major_ver));
   165 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->major_ver.......: %d", partitionTable->iMajor_ver));
   166 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->minor_ver.......: %d", partitionTable->minor_ver));
   166 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->minor_ver.......: %d", partitionTable->iMinor_ver));
   167 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->partition_amount: %d", partitionTable->partition_amount));
   167 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionTable->partition_amount: %d", partitionTable->iPartition_amount));
   168 		
   168 		
   169 		for( TUint8 index = 0; (index < partitionTable->partition_amount) && (index < BGAHSMMCPTN_LAST_DRIVE); index++ )
   169 		
   170 			{
   170 		TUint8 PartitionType = 0;		
   171 			if( (partitionTable->partitions[index].size > 0) &&
   171 		// Check Supported Version is present
   172 				( PartitionIsFAT(partitionTable->partitions[index].partition_id) ||
   172 		if (partitionTable->iMajor_ver <= BGAHSMMCPTN_PI_VER_MAJOR)
   173 				  PartitionIsFAT32(partitionTable->partitions[index].partition_id) ||
   173 		    {
   174 				  (KPartitionTypePagedData == partitionTable->partitions[index].partition_id && !foundSwap) ) )
   174             for( TUint8 index = 0; (index < partitionTable->iPartition_amount) && (index < BGAHSMMCPTN_LAST_DRIVE); index++ )
   175 				{
   175                 {
   176 				iPartitionInfo->iEntry[partitionCount].iPartitionType	  = partitionTable->partitions[index].partition_id;
   176                 if (partitionTable->iMinor_ver >= BGAHSMMCPTN_PART_TYPE_SUPP_VER_MINOR)
   177 				iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr = (Int64) partitionTable->partitions[index].start_sector << KDiskSectorShift;
   177                     PartitionType = partitionTable->iPartitions[index].iPartition_type;
   178 				iPartitionInfo->iEntry[partitionCount].iPartitionLen	  = (Int64) partitionTable->partitions[index].size << KDiskSectorShift;
   178                 else                    
   179 				iPartitionAttributes[partitionCount]					  = partitionTable->partitions[index].partition_attributes;
   179                     PartitionType = partitionTable->iPartitions[index].iPartition_id;
   180 
   180             
   181 				__KTRACE_OPT(KPBUSDRV, Kern::Printf("Registering partition #%d:", partitionCount));
   181                 if( (partitionTable->iPartitions[index].iSize > 0) &&
   182 				__KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionCount....: %d", partitionCount));
   182                     ( PartitionIsFAT(PartitionType) ||
   183 				__KTRACE_OPT(KPBUSDRV, Kern::Printf("startSector.......: 0x%x", partitionTable->partitions[index].start_sector ));
   183                       PartitionIsFAT32(PartitionType) ||
   184 				__KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionBaseAddr: 0x%lx (sectors: %d)", iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr, (TUint32)(iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr >> KDiskSectorShift)));
   184                      (KPartitionTypePagedData == PartitionType && !foundSwap) ) )
   185 				__KTRACE_OPT(KPBUSDRV, Kern::Printf("size..............: 0x%lx", partitionTable->partitions[index].size ));
   185                     {                   
   186 				__KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionLen.....: 0x%lx (sectors: %d)", iPartitionInfo->iEntry[partitionCount].iPartitionLen, iPartitionInfo->iEntry[partitionCount].iPartitionLen >> KDiskSectorShift));
   186                     iPartitionInfo->iEntry[partitionCount].iPartitionType	  = PartitionType;                    
   187 				__KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionType....: %d", iPartitionInfo->iEntry[partitionCount].iPartitionType));
   187                     iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr = (Int64) partitionTable->iPartitions[index].iStart_sector << KDiskSectorShift;
   188 				__KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionAttribs.: 0x%x", iPartitionAttributes[partitionCount]));
   188                     iPartitionInfo->iEntry[partitionCount].iPartitionLen	  = (Int64) partitionTable->iPartitions[index].iSize << KDiskSectorShift;
   189 				__KTRACE_OPT(KPBUSDRV, Kern::Printf(" "));
   189                     iPartitionAttributes[partitionCount]					  = partitionTable->iPartitions[index].iPartition_attributes;
   190 
   190     
   191 				if(KPartitionTypePagedData == partitionTable->partitions[index].partition_id)
   191                     __KTRACE_OPT(KPBUSDRV, Kern::Printf("Registering partition #%d:", partitionCount));
   192 					{
   192                     __KTRACE_OPT(KPBUSDRV, Kern::Printf("partitionCount....: %d", partitionCount));
   193 					foundSwap = ETrue;
   193                     __KTRACE_OPT(KPBUSDRV, Kern::Printf("startSector.......: 0x%x", partitionTable->iPartitions[index].iStart_sector ));
   194 					}
   194                     __KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionBaseAddr: 0x%lx (sectors: %d)", iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr, (TUint32)(iPartitionInfo->iEntry[partitionCount].iPartitionBaseAddr >> KDiskSectorShift)));
   195 
   195                     __KTRACE_OPT(KPBUSDRV, Kern::Printf("size..............: 0x%lx", partitionTable->iPartitions[index].iSize ));
   196 				partitionCount++;
   196                     __KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionLen.....: 0x%lx (sectors: %d)", iPartitionInfo->iEntry[partitionCount].iPartitionLen, iPartitionInfo->iEntry[partitionCount].iPartitionLen >> KDiskSectorShift));
   197 				}
   197                     __KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionType....: %d", iPartitionInfo->iEntry[partitionCount].iPartitionType));
   198 			}
   198                     __KTRACE_OPT(KPBUSDRV, Kern::Printf("iPartitionAttribs.: 0x%x", iPartitionAttributes[partitionCount]));
   199 		}
   199                     __KTRACE_OPT(KPBUSDRV, Kern::Printf(" "));
       
   200     
       
   201                     if(KPartitionTypePagedData == PartitionType)
       
   202                         {
       
   203                         foundSwap = ETrue;
       
   204                         }
       
   205     
       
   206                     partitionCount++;
       
   207                     }
       
   208                 }
       
   209             } 
       
   210 		} 
   200 
   211 
   201 	// Validate partition address boundaries
   212 	// Validate partition address boundaries
   202 	if(partitionCount == 0)
   213 	if(partitionCount == 0)
   203 		{
   214 		{
   204 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("Mmc: No supported partitions found!"));
   215 		__KTRACE_OPT(KPBUSDRV, Kern::Printf("Mmc: No supported partitions found!"));