Exemplo n.º 1
0
//----- Make_D_LogTable() ----------------------------------------------
int Make_D_LogTable(struct us_data *us)
{
	WORD  phyblock,logblock;
	//SSFDCTYPE_T aa = (SSFDCTYPE_T ) &Ssfdc;
	//ADDRESS_T   bb = (ADDRESS_T) &Media;

	if (Log2Phy[Media.Zone]==NULL)
	{
		Log2Phy[Media.Zone] = kmalloc(MAX_LOGBLOCK*sizeof(WORD), GFP_KERNEL);
		/* pr_info("ExAllocatePool Zone = %x, Addr = %x\n",
				Media.Zone, Log2Phy[Media.Zone]); */
		if (Log2Phy[Media.Zone]==NULL)
			return(ERROR);
	}

	Media.Sector=0;

	//for(Media.Zone=0; Media.Zone<MAX_ZONENUM; Media.Zone++)
	//for(Media.Zone=0; Media.Zone<Ssfdc.MaxZones; Media.Zone++)
	{
		/* pr_info("Make_D_LogTable --- MediaZone = 0x%x\n",
							Media.Zone); */
		for(Media.LogBlock=0; Media.LogBlock<Ssfdc.MaxLogBlocks; Media.LogBlock++)
			Log2Phy[Media.Zone][Media.LogBlock]=NO_ASSIGN;

		for(Media.PhyBlock=0; Media.PhyBlock<(MAX_BLOCKNUM/8); Media.PhyBlock++)
			Assign[Media.Zone][Media.PhyBlock]=0x00;

		for(Media.PhyBlock=0; Media.PhyBlock<Ssfdc.MaxBlocks; Media.PhyBlock++)
		{
			if ((!Media.Zone) && (Media.PhyBlock<=CisArea.PhyBlock))
			{
				Set_D_Bit(Assign[Media.Zone],Media.PhyBlock);
				continue;
			}

			if (Ssfdc_D_ReadRedtData(us, Redundant))
			{ Ssfdc_D_Reset(us); return(ERROR); }

			if (!Check_D_DataBlank(Redundant))
				continue;

			Set_D_Bit(Assign[Media.Zone],Media.PhyBlock);

			if (Check_D_FailBlock(Redundant))
				continue;

			//if (Check_D_DataStatus(Redundant))
			//    continue;

			if (Load_D_LogBlockAddr(Redundant))
				continue;

			if (Media.LogBlock>=Ssfdc.MaxLogBlocks)
				continue;

			if (Log2Phy[Media.Zone][Media.LogBlock]==NO_ASSIGN)
			{
				Log2Phy[Media.Zone][Media.LogBlock]=Media.PhyBlock;
				continue;
			}

			phyblock     = Media.PhyBlock;
			logblock     = Media.LogBlock;
			Media.Sector = (BYTE)(Ssfdc.MaxSectors-1);

			if (Ssfdc_D_ReadRedtData(us, Redundant))
			{ Ssfdc_D_Reset(us); return(ERROR); }

			if (!Load_D_LogBlockAddr(Redundant))
			{
				if (Media.LogBlock==logblock)
				{
					Media.PhyBlock=Log2Phy[Media.Zone][logblock];

					if (Ssfdc_D_ReadRedtData(us, Redundant))
					{ Ssfdc_D_Reset(us); return(ERROR); }

					Media.PhyBlock=phyblock;

					if (!Load_D_LogBlockAddr(Redundant))
					{
						if (Media.LogBlock!=logblock)
						{
							Media.PhyBlock=Log2Phy[Media.Zone][logblock];
							Log2Phy[Media.Zone][logblock]=phyblock;
						}
					}
					else
					{
						Media.PhyBlock=Log2Phy[Media.Zone][logblock];
						Log2Phy[Media.Zone][logblock]=phyblock;
					}
				}
			}

			Media.Sector=0;

// here Not yet
//#ifdef L2P_ERR_ERASE
//			if (!(Ssfdc.Attribute &MWP))
//			{
//				Ssfdc_D_Reset(fdoExt);
//				if (Ssfdc_D_EraseBlock(fdoExt))
//					return(ERROR);
//
//				if (Ssfdc_D_CheckStatus())
//				{
//					if (MarkFail_D_PhyOneBlock())
//						return(ERROR);
//				}
//				else
//					Clr_D_Bit(Assign[Media.Zone],Media.PhyBlock);
//			}
//#else
//			Ssfdc.Attribute|=MWP;
//#endif
			Media.PhyBlock=phyblock;

		} // End for (Media.PhyBlock<Ssfdc.MaxBlocks)

		AssignStart[Media.Zone]=0;

	} // End for (Media.Zone<MAX_ZONENUM)

	Ssfdc_D_Reset(us);
	return(SMSUCCESS);
}
int Make_D_LogTable(struct us_data *us)
{
	WORD  phyblock,logblock;
	
	

	if (Log2Phy[Media.Zone]==NULL)
	{
		Log2Phy[Media.Zone] = kmalloc(MAX_LOGBLOCK*sizeof(WORD), GFP_KERNEL);
		if (Log2Phy[Media.Zone]==NULL)
			return(ERROR);
	}

	Media.Sector=0;

	
	
	{
		for(Media.LogBlock=0; Media.LogBlock<Ssfdc.MaxLogBlocks; Media.LogBlock++)
			Log2Phy[Media.Zone][Media.LogBlock]=NO_ASSIGN;

		for(Media.PhyBlock=0; Media.PhyBlock<(MAX_BLOCKNUM/8); Media.PhyBlock++)
			Assign[Media.Zone][Media.PhyBlock]=0x00;

		for(Media.PhyBlock=0; Media.PhyBlock<Ssfdc.MaxBlocks; Media.PhyBlock++)
		{
			if ((!Media.Zone) && (Media.PhyBlock<=CisArea.PhyBlock))
			{
				Set_D_Bit(Assign[Media.Zone],Media.PhyBlock);
				continue;
			}

			if (Ssfdc_D_ReadRedtData(us, Redundant))
			{ Ssfdc_D_Reset(us); return(ERROR); }

			if (!Check_D_DataBlank(Redundant))
				continue;

			Set_D_Bit(Assign[Media.Zone],Media.PhyBlock);

			if (Check_D_FailBlock(Redundant))
				continue;

			
			

			if (Load_D_LogBlockAddr(Redundant))
				continue;

			if (Media.LogBlock>=Ssfdc.MaxLogBlocks)
				continue;

			if (Log2Phy[Media.Zone][Media.LogBlock]==NO_ASSIGN)
			{
				Log2Phy[Media.Zone][Media.LogBlock]=Media.PhyBlock;
				continue;
			}

			phyblock     = Media.PhyBlock;
			logblock     = Media.LogBlock;
			Media.Sector = (BYTE)(Ssfdc.MaxSectors-1);

			if (Ssfdc_D_ReadRedtData(us, Redundant))
			{ Ssfdc_D_Reset(us); return(ERROR); }

			if (!Load_D_LogBlockAddr(Redundant))
			{
				if (Media.LogBlock==logblock)
				{
					Media.PhyBlock=Log2Phy[Media.Zone][logblock];

					if (Ssfdc_D_ReadRedtData(us, Redundant))
					{ Ssfdc_D_Reset(us); return(ERROR); }

					Media.PhyBlock=phyblock;

					if (!Load_D_LogBlockAddr(Redundant))
					{
						if (Media.LogBlock!=logblock)
						{
							Media.PhyBlock=Log2Phy[Media.Zone][logblock];
							Log2Phy[Media.Zone][logblock]=phyblock;
						}
					}
					else
					{
						Media.PhyBlock=Log2Phy[Media.Zone][logblock];
						Log2Phy[Media.Zone][logblock]=phyblock;
					}
				}
			}

			Media.Sector=0;

			Media.PhyBlock=phyblock;

		} 

		AssignStart[Media.Zone]=0;

	} 

	Ssfdc_D_Reset(us);
	return(SMSUCCESS);
}