⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 davpageinit.c

📁 FDI Intel开发的FLASH文件系统,功能很强大
💻 C
📖 第 1 页 / 共 5 页
字号:
         }
         ExitOnError(status);
      }
      currHeaderHandle = FDI_SearchInfo.CurrObj.HeaderAddress;
      currObjectHandle = FDI_SearchInfo.CurrObj.ObjectAddress;
      /* backup the object */
      status = BKUP_CreateBackupObject(&FDI_SearchInfo, bkupChunkHandle, restart);
      ExitOnError(status);
      /* Increment the backup chunk to the next backup location */
      bkupChunkHandle += FDI_SearchInfo.CurrObj.ObjectSize;

      /* Get a handle for the fixed header of the next object in page space */
      if (currObjectHandle < aTopObjectHandle)
      {
         status = SEARCH_CalcNextUserObjectHdrAddr(currHeaderHandle, &currHeaderHandle);
         ExitOnError(status);
         status = FHDR_ReadFixedHeader(currHeaderHandle, &currHeader, restart);
         ExitOnError(status);
         /* Compute the object handle given the fixed header */
         currObjectHandle = FHDR_CalcObjectHandle(&currHeader);
      }
   }
   while ((status == ERR_NONE) && 
          ((FDI_SearchInfo.CurrObj.ObjectAddress + FDI_SearchInfo.CurrObj.ObjectSize) <= aTopObjectHandle));

   return status;
}

 /*#################################################################
  ### RECLAIM_PAGE_EraseOriginalGroup
  ###
  ### DESCRIPTION:
  ###   Erase a group of original objects.  Modify the RAT as needed.
  ###
  ### PARAMETERS:
  ###   aRatEntryPtr  -- IN/OUT: ptr to RAT entry for the group.
  ###   aTopBlock -- IN: top block intersecting with group
  ###   aTopObjectHandle -- IN: handle of top object in group
  ###   aTopObjectSizeInPages  -- IN: size of top object in pages
  ###   aGroupSizeInPages  -- IN: group size in pages.
  ###   aBottomBlock -- IN: bottom block intersecting with group
  ###   aBottomObjectHandle -- IN/OUT: handle to btm object in group
  ###   restart       -- IN: Flag used for PLR.
  ###
  ### RETURNS:
  ###   When this function passes with no errors a value of 0 is
  ###   returned otherwise, it returns a status of type ERR_CODE.
  ###*/
/*Fix Start:SCR964 */
ERR_CODE RECLAIM_PAGE_EraseOriginalGroup(FDI_Handle      aRatEntryHandle,
                                         RATTBL_EntryPtr aRatEntryPtr,
                                         UINT16           aTopBlock, 
                                         FDI_Handle      aTopObjectHandle,
                                         UINT32          aTopObjectSizeInPages,
                                         UINT32          aGroupSizeInPages,
                                         UINT16           aBottomBlock,
                                         FDI_Handle      aBottomObjectHandle,
                                         BOOLEAN         restart)
/*Fix End:SCR964 */
{
ERR_CODE   status = ERR_NONE;
UINT32     copySize;
FDI_Handle topBlockUpperBoundary;
FDI_Handle topBlockLowerBoundary;
FDI_Handle bottomBlockUpperBoundary;
FDI_Handle bottomBlockLowerBoundary;
UINT16     index;

   topBlockUpperBoundary    = (FDI_Handle)((UTIL_CalcOffsetOfBlocksBoundary(aTopBlock, enTopBoundary) * FDI_PageSize) + FDI_PageSpaceAddressBottom - 1);
   topBlockLowerBoundary    = (FDI_Handle)((UTIL_CalcOffsetOfBlocksBoundary(aTopBlock, enBottomBoundary) * FDI_PageSize) + FDI_PageSpaceAddressBottom);
   bottomBlockUpperBoundary = (FDI_Handle)((UTIL_CalcOffsetOfBlocksBoundary(aBottomBlock, enTopBoundary) * FDI_PageSize) + FDI_PageSpaceAddressBottom - 1);
   bottomBlockLowerBoundary = (FDI_Handle)((UTIL_CalcOffsetOfBlocksBoundary(aBottomBlock, enBottomBoundary) * FDI_PageSize) + FDI_PageSpaceAddressBottom);

   if(aTopBlock == aBottomBlock)
   {
      switch(RATTBL_GetRatEntryBtmProgressState(aRatEntryPtr))
      {
      case RATTBL_RatEntryBtmProgressState_BkupOfOrigGroupComplete:
		   /* erase the original group */
		   /* copy btm block valid objects from btm block to reclaim */
         /* Copy data between the top address of the group and the top address of the block to the reclaim block at the same offset */
         copySize = topBlockUpperBoundary - (aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize)) + 1;
         if(copySize > 0)
         {
            status = FLASH_CopyFlash(aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize), FDI_ReclaimBlockAddressBottom + (aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize) - topBlockLowerBoundary), copySize);
            ExitOnError(status);
         }

         /* Copy data between the bottom address of the group and the bottom address of the block to the reclaim block at the same offset */
         copySize = aBottomObjectHandle - bottomBlockLowerBoundary;
         if(copySize > 0)
         {
            status = FLASH_CopyFlash(bottomBlockLowerBoundary, FDI_ReclaimBlockAddressBottom, copySize);
            ExitOnError(status);
         }

		   /* set state: RATTBL_RatEntryBtmProgressState_BtmBlkOrigGroupInReclaim */
         RATTBL_SetRatEntryBtmProgressState(aRatEntryPtr, RATTBL_RatEntryBtmProgressState_BtmBlkOrigGroupInReclaim);
         status = RATTBL_WriteRatEntryBtmProgressState(&aRatEntryHandle, aRatEntryPtr);
         ExitOnError(status);
		   /* fall through to next case */

      case RATTBL_RatEntryBtmProgressState_BtmBlkOrigGroupInReclaim:
		   /* erase the btm block */
		   /* copy btm block valid objects from reclaim to btm block */
	      /* Erase the block */
         status = FLASH_EraseBlock(bottomBlockLowerBoundary, FALSE);
         ExitOnError(status);

         /* If any data was indeed copied up to the reclaim block, then copy it all back down from the reclaim block to the original block */
         FLASH_CopyFlash(FDI_ReclaimBlockAddressBottom, bottomBlockLowerBoundary, FDI_BlockSize);
         ExitOnError(status);

		   /* set state: RATTBL_RatEntryBtmProgressState_TopBlkOrigGroupReclaimComplete */
         /* note: since top block is same as bottom, we're setting top block reclaim complete here */
         RATTBL_SetRatEntryBtmProgressState(aRatEntryPtr, RATTBL_RatEntryBtmProgressState_TopBlkOrigGroupReclaimComplete);
         status = RATTBL_WriteRatEntryBtmProgressState(&aRatEntryHandle, aRatEntryPtr);
         ExitOnError(status);
		   /* fall through to next case */

      case RATTBL_RatEntryBtmProgressState_BtmBlkOrigGroupReclaimComplete:
		   /* fall through to next case */

      case RATTBL_RatEntryBtmProgressState_TopBlkOrigGroupInReclaim:
		   /* fall through to next case */
         break;
      } /* end switch */
   }
   else /* the group spans more than one block */
   {
      switch(RATTBL_GetRatEntryBtmProgressState(aRatEntryPtr))
      {
      case RATTBL_RatEntryBtmProgressState_BkupOfOrigGroupComplete:
         /* Copy data between the bottom address of the group and the bottom address of the block to the reclaim block at the same offset */
         copySize = aBottomObjectHandle - bottomBlockLowerBoundary;
         if(copySize > 0)
         {
            status = FLASH_CopyFlash(bottomBlockLowerBoundary, FDI_ReclaimBlockAddressBottom, copySize);
            ExitOnError(status);
         }

		   /* set state: RATTBL_RatEntryBtmProgressState_BtmBlkOrigGroupInReclaim */
         RATTBL_SetRatEntryBtmProgressState(aRatEntryPtr, RATTBL_RatEntryBtmProgressState_BtmBlkOrigGroupInReclaim);
         status = RATTBL_WriteRatEntryBtmProgressState(&aRatEntryHandle, aRatEntryPtr);
         ExitOnError(status);
		   /* fall through to next case */

      case RATTBL_RatEntryBtmProgressState_BtmBlkOrigGroupInReclaim:
	      /* Erase the block */
         status = FLASH_EraseBlock(bottomBlockLowerBoundary, FALSE);
         ExitOnError(status);

         /* If any data was indeed copied up to the reclaim block, then copy it all back down from the reclaim block to the original block */
         FLASH_CopyFlash(FDI_ReclaimBlockAddressBottom, bottomBlockLowerBoundary, FDI_BlockSize);
         ExitOnError(status);

		   /* set state: RATTBL_RatEntryBtmProgressState_BtmBlkOrigGroupReclaimComplete */
         RATTBL_SetRatEntryBtmProgressState(aRatEntryPtr, RATTBL_RatEntryBtmProgressState_BtmBlkOrigGroupReclaimComplete);
         status = RATTBL_WriteRatEntryBtmProgressState(&aRatEntryHandle, aRatEntryPtr);
         ExitOnError(status);
		   /* fall through to next case */

      case RATTBL_RatEntryBtmProgressState_BtmBlkOrigGroupReclaimComplete:
		   /* erase the reclaim block */
         status = FLASH_EraseBlock(FDI_ReclaimBlockAddressBottom, FALSE);
         ExitOnError(status);
		   /* erase intervening blocks */
         for (index = aBottomBlock + 1; index < aTopBlock; index++)
         {
            /* Erase the block */
            status = FLASH_EraseBlock((index * FDI_BlockSize) + FDI_PageSpaceAddressBottom, FALSE);
            ExitOnError(status);
         }
		   /* copy top block valid objects from top block to reclaim */
         /* Copy data between the top address of the group and the top address of the block to the reclaim block at the same offset */
         copySize = topBlockUpperBoundary - (aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize)) + 1;
         if(copySize > 0)
         {
            status = FLASH_CopyFlash(aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize), FDI_ReclaimBlockAddressBottom + (aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize) - topBlockLowerBoundary), copySize);
            ExitOnError(status);

         }
		   /* set state: RATTBL_RatEntryBtmProgressState_TopBlkOrigGroupInReclaim */
         RATTBL_SetRatEntryBtmProgressState(aRatEntryPtr, RATTBL_RatEntryBtmProgressState_TopBlkOrigGroupInReclaim);
         status = RATTBL_WriteRatEntryBtmProgressState(&aRatEntryHandle, aRatEntryPtr);
         ExitOnError(status);
		   /* fall through to next case */

      case RATTBL_RatEntryBtmProgressState_TopBlkOrigGroupInReclaim:
		   /* erase the top block */
         status = FLASH_EraseBlock(topBlockLowerBoundary, FALSE);
         ExitOnError(status);
		   /* copy top block valid objects from reclaim to top block */
         status = FLASH_CopyFlash(FDI_ReclaimBlockAddressBottom, topBlockLowerBoundary, FDI_BlockSize);
         ExitOnError(status);
		   /* set state: RATTBL_RatEntryBtmProgressState_TopBlkOrigGroupReclaimComplete */
         RATTBL_SetRatEntryBtmProgressState(aRatEntryPtr, RATTBL_RatEntryBtmProgressState_TopBlkOrigGroupReclaimComplete);
         status = RATTBL_WriteRatEntryBtmProgressState(&aRatEntryHandle, aRatEntryPtr);
         ExitOnError(status);
		   /* fall through to next case */
      } /* end switch */
   } /* end else group spans more than one block */

   /* this function ends without erasing the reclaim; must be done by next state */
   return status;
}

 /*#################################################################
  ### RECLAIM_PAGE_EraseBackupGroup
  ###
  ### DESCRIPTION:
  ###   Erase a group of backup objects.  Modify the RAT as needed.
  ###
  ### PARAMETERS:
  ###   aRatEntryPtr  -- IN/OUT: ptr to RAT entry for the group.
  ###   aTopBlock -- IN: top block intersecting with group
  ###   aTopObjectHandle -- IN: handle of top object in group
  ###   aTopObjectSizeInPages  -- IN: size of top object in pages
  ###   aGroupSizeInPages  -- IN: group size in pages.
  ###   aBottomBlock -- IN: bottom block intersecting with group
  ###   aBottomObjectHandle -- IN/OUT: handle to btm object in group
  ###   restart       -- IN: Flag used for PLR.
  ###
  ### RETURNS:
  ###   When this function passes with no errors a value of 0 is
  ###   returned otherwise, it returns a status of type ERR_CODE.
  ###*/
/*Fix Start:SCR964 */
ERR_CODE RECLAIM_PAGE_EraseBackupGroup(FDI_Handle      aRatEntryHandle,
                                       RATTBL_EntryPtr aRatEntryPtr,
                                       UINT16           aTopBlock, 
                                       FDI_Handle      aTopObjectHandle,
                                       UINT32          aTopObjectSizeInPages,
                                       UINT32          aGroupSizeInPages,
                                       UINT16           aBottomBlock,
                                       FDI_Handle      aBottomObjectHandle,
                                       BOOLEAN         restart)
/*Fix End:SCR964 */
{
ERR_CODE   status = ERR_NONE;
UINT32     copySize;
FDI_Handle topBlockUpperBoundary;
FDI_Handle topBlockLowerBoundary;
FDI_Handle bottomBlockUpperBoundary;
FDI_Handle bottomBlockLowerBoundary;
UINT16     index;

   topBlockUpperBoundary    = (FDI_Handle)((UTIL_CalcOffsetOfBlocksBoundary(aTopBlock, enTopBoundary) * FDI_PageSize) + FDI_PageSpaceAddressBottom - 1);
   topBlockLowerBoundary    = (FDI_Handle)((UTIL_CalcOffsetOfBlocksBoundary(aTopBlock, enBottomBoundary) * FDI_PageSize) + FDI_PageSpaceAddressBottom);
   bottomBlockUpperBoundary = (FDI_Handle)((UTIL_CalcOffsetOfBlocksBoundary(aBottomBlock, enTopBoundary) * FDI_PageSize) + FDI_PageSpaceAddressBottom - 1);
   bottomBlockLowerBoundary = (FDI_Handle)((UTIL_CalcOffsetOfBlocksBoundary(aBottomBlock, enBottomBoundary) * FDI_PageSize) + FDI_PageSpaceAddressBottom);

   if(aTopBlock == aBottomBlock)
   {
      switch(RATTBL_GetRatEntryTopProgressState(aRatEntryPtr))
      {
      case RATTBL_RatEntryTopProgressState_ModifyComplete:
		   /* erase the backup group */
		   /* copy btm block valid objects from btm block to reclaim */
         /* Copy data between the top address of the group and the top address of the block to the reclaim block at the same offset */
         copySize = topBlockUpperBoundary - (aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize)) + 1;
         if(copySize > 0)
         {
            status = FLASH_CopyFlash(aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize), FDI_ReclaimBlockAddressBottom + (aTopObjectHandle + (aTopObjectSizeInPages * FDI_PageSize) - topBlockLowerBoundary), copySize);
            ExitOnError(status);
         }

         /* Copy data between the bottom address of the group and the bottom address of the block to the reclaim block at the same offset */
         copySize = aBottomObjectHandle - bottomBlockLowerBoundary;
         if(copySize > 0)
         {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -