?? template.c
字號:
/*************************************************************************
*** Intel Confidential
*** Copyright (C) Intel Corporation 2000
*** All Rights Reserved.
*** --------------------------------------------------------------------
***
*** Project Name: Flash Templates
***
*** Module Name: Template
***
*** File: Template.C - Common template C source file
***
*** File Revision: $Revision: 9 $, $JustDate: 4/21/00 $, $Author: Tchuynh $
***
*** Purpose:
***
*** The purpose of this file is to implement the common application
*** programmers interface for flash template software. This module
*** implements all flash template subroutines that do not have
*** a device specific implementation in the device.c module for
*** the supported device. Macros are used to determine if
*** the template.c common implementation or the device.c specific
*** implementation is used by the template for each subroutine.
***
*** Note that some common template functions implemented in this
*** module will return STATUS_UNSUPPORTED since no common
*** implementation is possible due to the differences between
*** supported devices for those functions. The device.c module
*** must contain implementations for these particular functions
*** when the function is in fact supported for that device.
***
*** $NoKeywords: $
*************************************************************************/
/* Include Files */
#include "template.h"
#if !DEVICE_CLEAR_STATUS /* if there is no device.c implementation */
/****************************************************************************
*
* TMPL_ClearStatus
*
* Description:
* This procedure is called to clear the status register on the flash
* device. See the flash device datasheet for specific details on
* this command.
*
* Parameters:
* NONE
*
* Returns:
* NONE
*
* Assumptions:
* NONE
*
***************************************************************************/
void TMPL_ClearStatus ( void )
{
TMPL_WriteF( TMPL_BASE_FLASH_ADDRESS, TMPL_CLEAR_STATUS_REGISTER );
}
#endif /* !DEVICE_CLEAR_STATUS */
#if !DEVICE_ERASE_BLOCK /* if there is no device.c implementation */
/****************************************************************************
*
* TMPL_EraseBlock
*
* Description:
*
* This procedure is called to erase a data block on the flash
* device. See the flash device datasheet for specific details on
* this command.
*
* Parameters:
*
* IN blocknum - the block number on the device.
*
* IN returnSR - flag to indicate whether the device status register
* value should be returned by this function.
*
* Returns:
*
* TMPL_Status - includes function return status defined by enum
* TMPL_CommandStat and optionally the flash device
* status register value.
*
* Assumptions:
*
* NONE
*
***************************************************************************/
TMPL_Status TMPL_EraseBlock ( UINT16 blocknum,
UINT8 returnSR )
{
TMPL_Status stat;
UINT32 blockadd;
stat = TMPL_GetBlockAddress( blocknum, &blockadd );
if ( stat.Result != StatCompleted )
{
return( stat );
}
if ( returnSR )
{
TMPL_ClearStatus();
}
TMPL_WriteF(blockadd, TMPL_BLOCK_ERASE);
TMPL_WriteF(blockadd, TMPL_CONFIRM );
if ( !TMPL_WaitUntilReady( TMPL_ERASE_TIMEOUT ) )
{
stat.Result = StatTimeout;
}
else
{
stat.Result = StatCompleted;
}
if ( returnSR )
{
stat.SR = TMPL_ReadStatus();
}
/* return device to read array mode */
TMPL_WriteF(TMPL_BASE_FLASH_ADDRESS, TMPL_READ_ARRAY );
return( stat );
}
#endif /* !DEVICE_ERASE_BLOCK */
#if !DEVICE_ERASE_ALL_BLOCKS /* if there is no device.c implementation */
/****************************************************************************
*
* TMPL_EraseAllBlocks
*
* Description:
*
* This procedure is called to erase all data blocks on the flash
* device. See the flash device datasheet for specific details on
* the block erase command.
*
* Parameters:
*
* IN returnSR - flag to indicate whether the device status register
* value should be returned by this function.
*
* Returns:
*
* TMPL_Status - includes function return status defined by enum
* TMPL_CommandStat and optionally the flash device
* status register value.
*
* Assumptions:
*
* NONE
*
***************************************************************************/
TMPL_Status TMPL_EraseAllBlocks ( UINT8 returnSR )
{
TMPL_Status stat;
stat.Result = StatUnsupported;
return( stat );
}
#endif /* !DEVICE_ERASE_ALL_BLOCKS */
#if !DEVICE_ERASE_SUSPEND /* if there is no device.c implementation */
/****************************************************************************
*
* TMPL_EraseSuspend
*
* Description:
*
* This procedure is called to issue the erase suspend command to
* the flash device. See the flash device datasheet for specific details
* on this command.
*
* Parameters:
*
* IN blocknum - the block number on the device.
*
* IN returnSR - flag to indicate whether the device status register
* value should be returned by this function.
*
* Returns:
*
* TMPL_Status - includes function return status defined by enum
* TMPL_CommandStat and optionally the flash device
* status register value.
*
* Assumptions:
*
* When this function is called the device is currently in the erase
* mode for the block identified.
*
***************************************************************************/
TMPL_Status TMPL_EraseSuspend ( UINT16 blocknum,
UINT8 returnSR )
{
TMPL_Status stat;
stat.Result = StatUnsupported;
return( stat );
}
#endif /* !DEVICE_ERASE_SUSPEND */
#if !DEVICE_EXTENDED_QUERY
/****************************************************************************
*
* TMPL_ExtendedQuery
*
* Description:
*
* This procedure is called to retrieve the extended query
* data from the flash device. See the flash device datasheet for
* specific details on this command.
*
* Parameters:
*
* OUT *extquery - pointer to extended query structure
*
* Returns:
*
* TMPL_Status - includes function return status defined by enum
* TMPL_CommandStat.
*
* Assumptions:
*
* NONE
***************************************************************************/
TMPL_Status TMPL_ExtendedQuery ( struct TMPL_ExtQueryData *extquery )
{
TMPL_Status stat;
stat.Result = StatUnsupported;
return( stat );
}
#endif /* !DEVICE_EXTENDED_QUERY */
#if !DEVICE_GET_BLOCK_ADDRESS /* if there is no device.c implementation */
/****************************************************************************
*
* TMPL_GetBlockAddress
*
* Description:
*
* This procedure is called to get the flash starting address for the
* specified block number.
*
* Parameters:
*
* IN blocknum - the block number on the device.
*
* OUT address - the starting flash address for the specified
* block.
*
* Returns:
*
* TMPL_Status - includes function return status defined by enum
* TMPL_CommandStat.
*
* Assumptions:
*
* NONE
*
***************************************************************************/
TMPL_Status TMPL_GetBlockAddress ( UINT16 blocknum,
UINT32_PTR address )
{
TMPL_Status stat;
stat.Result = StatUnsupported;
return( stat );
}
#endif /* !DEVICE_GET_BLOCK_ADDRESS */
#if !CLIENT_GET_FPTR /* if there is no client provided implementation */
/****************************************************************************
*
* TMPL_GetFptr
*
* Description:
*
* This procedure is called to return a flash ptr given a
* specified device address. This routine will likely need to be
* provided externally by the template client in order to properly
* deal with addressing details that are specific to the HW platform.
*
* Parameters:
*
* IN address - the flash address
*
* Returns:
*
* TMPL_FDATA_PTR - address returned in ptr form
*
* Assumptions:
*
* NONE
*
***************************************************************************/
TMPL_FDATA_PTR TMPL_GetFptr ( UINT32 address )
{
return( (TMPL_FDATA_PTR)address );
}
#endif /* !CLIENT_GET_FPTR */
#if !DEVICE_GET_QUERY_ADDRESS /* if there is no device.c implementation */
/****************************************************************************
*
* TMPL_GetQueryAddress
*
* Description:
*
* This procedure is called to get the flash address for a given
* query offset.
*
* Parameters:
*
* IN offset - query offset location
*
* OUT address - the flash address for the specified query
* offset.
*
* Returns:
*
* TMPL_Status - includes function return status defined by enum
* TMPL_CommandStat.
*
* Assumptions:
*
* NONE
*
***************************************************************************/
TMPL_Status TMPL_GetQueryAddress ( UINT32 offset,
UINT32_PTR address )
{
TMPL_Status stat;
#if ( X_8 )
*address = offset;
#elif ( X_16 )
*address = offset << 1;
#elif( PX_16 || X_32 )
*address = offset << 2;
#endif
*address += TMPL_BASE_FLASH_ADDRESS;
stat.Result = StatCompleted;
return( stat );
}
#endif /* !DEVICE_GET_QUERY_ADDRESS */
#if !DEVICE_LOCK_BLOCK /* if there is no device.c implementation */
/****************************************************************************
*
* TMPL_LockBlock
*
* Description:
*
* This procedure is called to lock the specified block on the flash
* device. See the flash device datasheet for specific details on this
* command.
*
* Parameters:
*
* IN blocknum - the block number on the device.
*
* IN returnSR - flag to indicate whether the device status register
* value should be returned by this function.
*
* Returns:
*
* TMPL_Status - includes function return status defined by enum
* TMPL_CommandStat and optionally the flash device
* status register value.
*
* Assumptions:
*
* NONE
*
***************************************************************************/
TMPL_Status TMPL_LockBlock ( UINT16 blocknum,
UINT8 returnSR )
{
TMPL_Status stat;
stat.Result = StatUnsupported;
return( stat );
}
#endif /* !DEVICE_LOCK_BLOCK */
#if !DEVICE_LOCK_DOWN_BLOCK /* if there is no device.c implementation */
/****************************************************************************
*
* TMPL_LockDownBlock
*
* Description:
*
* This procedure is called to lockdown the specified block on the flash
* device. See the flash device datasheet for specific details on this
* command.
*
* Parameters:
*
* IN blocknum - the block number on the device.
*
* IN returnSR - flag to indicate whether the device status register
* value should be returned by this function.
*
* Returns:
*
* TMPL_Status - includes function return status defined by enum
* TMPL_CommandStat and optionally the flash device
* status register value.
*
* Assumptions:
*
* NONE
*
***************************************************************************/
TMPL_Status TMPL_LockDownBlock ( UINT16 blocknum,
UINT8 returnSR )
{
TMPL_Status stat;
stat.Result = StatUnsupported;
return( stat );
}
#endif /* !DEVICE_LOCK_DOWN_BLOCK */
#if !DEVICE_LOCK_PROTECTION /* if there is no device.c implementation */
/****************************************************************************
*
* TMPL_LockProtection
*
* Description:
*
* This procedure is called to program the protection register user lock
* bit on the flash device. See the flash device datasheet for specific
* details on this command.
*
* Parameters:
*
* IN returnSR - flag to indicate whether the device status register
* value should be returned by this function.
*
* Returns:
*
* TMPL_Status - includes function return status defined by enum
* TMPL_CommandStat and optionally the flash device
* status register value.
*
* Assumptions:
*
* NONE
*
***************************************************************************/
TMPL_Status TMPL_LockProtection ( UINT8 returnSR )
{
TMPL_Status stat;
stat.Result = StatUnsupported;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -