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

📄 fdi_mprc.c

📁 FDI Intel开发的FLASH文件系统,功能很强大
💻 C
字号:
/* Copyright(R) 2001-2002 Intel Corporation */
/* ############################################################################
 ### Object: Low Level Driver
 ###
 ### Module: FDI_Mprc.c: Dual/Multi Partition Relocatable Code
 ###   $Archive: /FDI/SRC/LOWLVL/fdi_mprc.c $
 ###   $Revision: 26 $
 ###   $Date: 6/16/03 4:10a $
 ###   $Author: Xhuang4 $
 ###
 ###$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 "fdi_lowl.h"

#if (PARTITIONS != SINGLE)


/* For non-FDI block locking support */
#if (BLOCK_LOCK_SUPPORT == TRUE)
#define BLOCK_LOCK_STATUS_OFFSET             2
#endif



#if (((BLOCK_LOCK_SUPPORT == TRUE) && (ENABLE_NONFDI_BLOCKLOCKING == TRUE)) \
     || (ENABLE_PR != FDI_NONE))
/*#############################################################################
  ### LowLvlReadStat
  ###
  ### DESCRIPTION:
  ###   Reads the status register(s) of the flash hardware.
  ###
  ### PARAMETERS:
  ###    IN:  address (DWORD) -  An absolute physical starting address of the
  ###          partition to have its status register read.
  ###    OUT:
  ###
  ### RETURNS:
  ###   The value of the status register(s).
  ###
 */

FLASH_DATA LowLvlReadStat(volatile FLASH_DATA_PTR flash_ptr)
{
   FLASH_DATA status_reg;


   *flash_ptr = FLASH_COMMAND_STATUS;
   status_reg = *flash_ptr;
   *flash_ptr = FLASH_COMMAND_READ;

   return status_reg;
}
#endif /* (BLOCK_LOCK_SUPPORT && ENABLE_NONFDI_BLOCKLOCKING) || ENABLE_PR */



#if (BLOCK_LOCK_SUPPORT == TRUE)
/*#############################################################################
  ### LowLvlLock
  ###
  ### DESCRIPTION:
  ###   Performs one of the following operations on the flash hardware:
  ###   lock a block, lock down a block, unlock a block, or read the lock
  ###   status of a block.
  ###
  ### PARAMETERS:
  ###    IN:  block_status_ptr (FLASH_DATA_PTR) - A pointer to a buffer to
  ###          store the lock status of the block.
  ###         address (DWORD) - The starting address of the block within
  ###          flash to perform the lock operation on.
  ###         command (HW_CMD) - The lock-related command to issue: lock
  ###          (HW_CMD_LOCK), lock down (HW_CMD_LOCKDOWN), unlock
  ###          (HW_CMD_UNLOCK), or read the block's lock status
  ###          (HW_CMD_READLOCKSTATUS).
  ###    OUT: block_status_ptr - Contains the contents of the block's lock
  ###          status if the command issued was HW_CMD_READLOCKSTATUS;
  ###          otherwise, the contents are unknown.
  ###
  ### RETURNS:
  ###   If the command is not appropriate, the function returns HW_ERR_PARAM;
  ###   otherwise, the function returns HW_ERR_NONE.
  ###
 */

HW_ERROR LowLvlLock(volatile FLASH_DATA_PTR flash_ptr,
                    FLASH_DATA_PTR block_status_ptr, HW_CMD command)
{
   HW_ERROR status = HW_ERR_NONE;

/*E.5.0.633.START*/
/* E 5.1.849 START */
/* indentation */
   if(command == HW_CMD_LOCK)
   {
      *flash_ptr = FLASH_COMMAND_LOCK;
      *flash_ptr = FLASH_COMMAND_LOCK_CONFIRM;
   }
   else if(command == HW_CMD_UNLOCK)
   {
      *flash_ptr = FLASH_COMMAND_LOCK;
      *flash_ptr = FLASH_COMMAND_UNLOCK_CONFIRM;
   }
   else if(command == HW_CMD_LOCKDOWN)
   {
      *flash_ptr = FLASH_COMMAND_LOCK;
      *flash_ptr = FLASH_COMMAND_LOCKDOWN_CONFIRM;
   }
   else if (command == HW_CMD_READLOCKSTATUS)
   {
      *flash_ptr = FLASH_COMMAND_QUERY;
      *block_status_ptr = *(flash_ptr + BLOCK_LOCK_STATUS_OFFSET);
   }
   else
   {
      status = HW_ERR_PARAM;
   }
/* E 5.1.849 END */   
/*E.5.0.633.END*/
   /* place part into read array mode */
   *flash_ptr = FLASH_COMMAND_READ;
   return status;
}
#endif /* BLOCK_LOCK_SUPPORT */

#if (ENABLE_PR != FDI_NONE)
/*#############################################################################
  ### LowLvlProtectReg
  ###
  ### DESCRIPTION:
  ###   Reads/writes the protection registers and locks.  When the
  ###   configuration is paired 16-bit parts, the user will address the
  ###   matching registers as a single 32-bit register, instead of addressing
  ###   them as two 16-bit registers on a 32-bit bus.
  ###
  ### PARAMETERS:
  ###    IN:  data_ptr (FLASH_DATA_PTR) - The data value to write if the
  ###          command is a write, or a buffer to store the value fetched
  ###          if the command is a read.
  ###         address (DWORD) - The absolute physical address of the protection
  ###          register to read/write.
  ###         command (HW_CMD) - The protection register related command to
  ###          issue: write protection register lock (HW_CMD_WRITE_PR_LOCK),
  ###          read protection register lock (HW_CMD_READ_PR_LOCK), write
  ###          protection register (HW_CMD_WRITE_PR), or read protection
  ###          registers (HW_CMD_READ_PR).
  ###    OUT: data_ptr - Contains the contents of the protection lock register
  ###          or protection register if the command issued was 
  ###          HW_CMD_READ_PR_LOCK or HW_CMD_READ_PR, respectively.
  ###
  ### RETURNS:
  ###   If the command is not appropriate, the function returs HW_ERR_PARAM.
  ###   If the maximum time limit expires or if an error occurred while
  ###   programming the protection register or protection lock register,
  ###   the function returns HW_ERR_WRITE.  Otherwise, the function returns
  ###   HW_ERR_NONE.
  ###
 */

HW_ERROR LowLvlProtectReg(volatile FLASH_DATA_PTR flash_ptr,
                          FLASH_DATA_PTR data_ptr, HW_CMD command)
{
   HW_ERROR status;

/*E.5.0.633.START*/
   /* issue command */
   if ((command==HW_CMD_WRITE_PR_LOCK) || (command ==HW_CMD_WRITE_PR))
   {
      *flash_ptr = FLASH_COMMAND_WRITE_PR;
      *flash_ptr = *data_ptr;
      /* wait until flash is ready */
      *flash_ptr = FLASH_COMMAND_STATUS;
      while ((*flash_ptr & FLASH_STATUS_READY) != FLASH_STATUS_READY)
      {
      }
 
      /* check for errors */
      if (*flash_ptr & FLASH_STATUS_ERROR)
      {
         *flash_ptr = FLASH_COMMAND_CLEAR;
         status = HW_ERR_WRITE;
      }
      else
      {
          status = HW_ERR_NONE;
      }
   }
   else if ((command==HW_CMD_READ_PR_LOCK) || (command ==HW_CMD_READ_PR))
   {
      *flash_ptr = FLASH_COMMAND_READ_ID;
      *data_ptr = *flash_ptr;
      status = HW_ERR_NONE;
   }
   else
   {
      status = HW_ERR_PARAM;
   }
/*E.5.0.633.END*/
   /* place back into read array mode */
   *flash_ptr = FLASH_COMMAND_READ;
   return status;
}
#endif /* ENABLE_PR != TRUE */



#if (RELOCATE_CODE == TRUE)
/*#############################################################################
  ### LowLvlEnd
  ###
  ### DESCRIPTION:
  ###   This function is used as a "bookmark," allowing the above functions
  ###   to be relocated in memory.
  ###
  ### PARAMETERS:
  ###    IN:
  ###    OUT:
  ###
  ### RETURNS:
  ###   None.
  ###
 */

void LowLvlEnd()
{
   return;
}
#endif /* RELOCATE_CODE */
#endif /* PARTITIONS */

⌨️ 快捷键说明

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