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

📄 davmodob.c

📁 FDI Intel开发的FLASH文件系统,功能很强大
💻 C
字号:
/* Copyright (c) 1995-2004 Intel Corporation */
/* Intel Confidential                        */

/* ###########################################################################
###  DAV
###
###  Module: DAVModObj.c - Callback Function for Reclaim:  Modify Object
###                        Module
###
###  $Workfile: davmodob.c $
###  $Revision: 71 $
###  $NoKeywords: $
########################################################################### */

/*                                                               
 *****************************************************************
 * NOTICE OF LICENSE AGREEMENT                                    
 *                                                                
 * This code is provided by Intel Corp., and the use is governed  
 * under the terms of a license agreement. See license agreement  
 * for complete terms of license.                                 
 *                                                                
 * YOU MAY ONLY USE THE SOFTWARE WITH INTEL FLASH PRODUCTS.  YOUR 
 * USE OF THE SOFTWARE WITH ANY OTHER FLASH PRODUCTS IS EXPRESSLY 
 * PROHIBITED UNLESS AND UNTIL YOU APPLY FOR, AND ARE GRANTED IN  
 * INTEL'S SOLE DISCRETION, A SEPARATE WRITTEN SOFTWARE LICENSE   
 * FROM INTEL LICENSING ANY SUCH USE.                             
 *****************************************************************
 */
 

/*### Include Files
#########################*/
#include "davlib.h"

#if (DIRECT_ACCESS_VOLUME == TRUE)

#include "fdi_ext.h"
#include "davmodob.h"
#include <string.h>

/*### Local Declarations
#########################*/

/*### Global Declarations
#########################*/
#ifdef TESTING
VOID_PTR Buff_ptr = NULL; /* Linked with CM_Test.c */
#endif

/*### Local Functions
#########################*/

/*### Global Functions
#########################*/
/* the following prototype is for the notification function in layer3.c */
/*Unsupported option Perf_Test=TRUE Start */
/*#if (PERF_TEST == FALSE)*/
void ModifyDavTable(BYTE* old_flash_ptr, BYTE* new_flash_ptr, DWORD objSize);
/*#endif*/ /* PERF_TEST */
/*Unsupported option Perf_Test=TRUE End */

/*Fix Start:SCR964 */
#define ExitOnError(status) \
   if (status != ERR_NONE) \
   {  return status;  }
/*Fix End:SCR964 */

/*##################################################################
  ### FDI_ModifyObject
  ###
  ### DESCRIPTION:
  ###   This function is a callback function which the OEM creates
  ###   if an object must be modified when moved by Reclaim.  Reclaim
  ###   will call this function when it is time for the object data 
  ###   to be modified.  The function must copy the object data into 
  ###   RAM and modify it there.  It can modify the data however it 
  ###   chooses as long as the size of the object does not change.  The
  ###   function must return a pointer to the RAM location where the 
  ###   modified data resides.  Reclaim will then copy the data to Flash.
  ###   If the OEM does not need to modify the object data when moved by
  ###   Reclaim, then the stub function provided here can be used.
  ###
  ### PARAMETERS:
  ###   src_ptr       IN:  points to the new location of the object data.
  ###                      The data has already been moved at this point,
  ###                      so this will be the final destination of the
  ###                      modified object data.
  ###   size          IN:  the object data size in bytes.
  ###   old_src_ptr   IN:  old_src_ptr points to where the object data was
  ###                      previously stored.  This is only needed if the 
  ###                      data modifications are derived from the old 
  ###                      physical location.
  ###   RAM_ptr   IN/OUT:  RAM_ptr points to storage for the modified 
  ###                      object data in RAM.
  ###   bkup_ptr      IN:  points to the location of the backup of the
  ###                      object data, if a backup exists.  If a backup
  ###                      could not be created, this pointer will point
  ###                      to the same location as src_ptr (resulting in
  ###                      a modify-in-place).
  ###
  ### RETURNS:
  ###   This function returns a boolean value of TRUE if modification is
  ###   needed, otherwise it returns FALSE.  If FALSE is returned RAM_ptr is
  ###   not considered valid and Reclaim will not modify the data on Flash.
  ###
 */
BYTE FDI_ModifyObject( BYTE_PTR src_ptr, 
                       DWORD size,
                       BYTE_PTR old_src_ptr, 
                       VOID_PTR_PTR RAM_ptr,
                       BYTE_PTR bkup_ptr)
{

#ifndef TESTING
   /* Object data modification is not needed */
   return FALSE;
#else
   /* Simulate Object data modification for PLR testing */

   /* free RAM if previously allocated during object modification. */
   DWORD i;
   ERR_CODE status                 = ERR_NONE;

   if(Buff_ptr != NULL)
   {
      free(Buff_ptr);
      Buff_ptr = NULL;
   }

   /* allocate RAM and copy object data from Flash. */
   Buff_ptr = malloc(size);

   /*Fix Start:SCR964 */
   /*checking whether enough memory is available or not.if not return with appropriate status*/
   if(Buff_ptr == NULL)
   {
    status = ERR_MALLOC;
    ExitOnError(status);
   }
   /*Fix End:SCR964 */
   
   /* modify from backup, original at src_ptr has been erased */
   FLASH_ReadBuffer((UINT32)bkup_ptr, (UINT8_PTR)Buff_ptr, size);

   /* Modify data in RAM - complement it for now.  Test_gsm will have
      to be made aware of this for verifies. */
   for (i = 0 ; i < size ; i++)
   {
      *(((BYTE_PTR)Buff_ptr) +i) = ~(*(((BYTE_PTR)Buff_ptr) +i));
   }

/*Unsupported option Perf_Test=TRUE Start */
/*#if (PERF_TEST == FALSE)*/
   /* call this function to process DefragFlash test */
   ModifyDavTable((BYTE_PTR)old_src_ptr, (BYTE_PTR)src_ptr, size/FDI_PageSize);
/*#endif*/ /* PERF_TEST */
/*Unsupported option Perf_Test=TRUE End */

   *RAM_ptr = Buff_ptr;
   /*Fix Start:SCR978 */
   Buff_ptr=NULL;
   /*Fix End:SCR964 */
   return 0x00;

#endif /* TESTING */
}


/* Fix Start:SCR978 */
void FDI_FreeRam(VOID_PTR_PTR ram_ptr)
{
#ifndef TESTING
   /* Object data modification is not needed */
   return ;
#else
if(*ram_ptr != NULL)
   {
      free(*ram_ptr);
      *ram_ptr = NULL;
   }

return;
#endif
}

/* Fix End SCR978 */

#endif /* DIRECT_ACCESS_VOLUME */

⌨️ 快捷键说明

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