FLEX-FORD-OBC-BM/Source/bsw/FblNvPattern/fbl_nvpattern.h

168 lines
11 KiB
C

/***********************************************************************************************************************
* FILE DESCRIPTION
* ------------------------------------------------------------------------------------------------------------------*/
/** \file
* \brief Implementation of pattern/mask based non-volatile information storage
*
* --------------------------------------------------------------------------------------------------------------------
* COPYRIGHT
* --------------------------------------------------------------------------------------------------------------------
* \par Copyright
* \verbatim
* Copyright (c) 2025 by Vector Informatik GmbH. All rights reserved.
*
* This software is copyright protected and proprietary to Vector Informatik GmbH.
* Vector Informatik GmbH grants to you only those rights as set out in the license conditions.
* All other rights remain with Vector Informatik GmbH.
* \endverbatim
*/
/**********************************************************************************************************************/
/***********************************************************************************************************************
* REVISION HISTORY
* --------------------------------------------------------------------------------------------------------------------
* Version Date Author Change Id Description
* --------------------------------------------------------------------------------------------------------------------
* 02.00.00 2025-03-11 virjjn FBL-9704 Initial version
* 02.01.00 2025-06-19 dganesh FBL-11034 No changes
**********************************************************************************************************************/
#ifndef FBLLIB_NVPATTERN_H
#define FBLLIB_NVPATTERN_H
/***********************************************************************************************************************
* VERSION
**********************************************************************************************************************/
/* ##V_CFG_MANAGEMENT ##CQProject : FblLib_NvPattern CQComponent : Implementation */
#define FBLLIB_NVPATTERN_VERSION 0x0201u
#define FBLLIB_NVPATTERN_RELEASE_VERSION 0x00u
/***********************************************************************************************************************
* INCLUDES
**********************************************************************************************************************/
#include "FblNvPattern_Cfg.h"
#include "fbl_nvpattern_oem.h"
/***********************************************************************************************************************
* DEFINES
**********************************************************************************************************************/
/* Set Id of separator item to last item if storing arbitrary values is not enabled */
#if !defined( FBL_NVPATTERN_ENABLE_BLOCK_PROPERTIES )
# define kFblNvPatternId_Separator kFblNvPatternId_Last
#endif /* FBL_NVPATTERN_ENABLE_BLOCK_PROPERTIES */
/***********************************************************************************************************************
* GLOBAL DATA TYPES AND STRUCTURES
**********************************************************************************************************************/
/** Representation of status of marker/mask */
typedef enum
{
FBL_NVPATTERN_STATE_NOMEMSEGMENT = 0u, /**< No matching memory segment has been found */
FBL_NVPATTERN_STATE_READERROR, /**< Memory area could not be read */
FBL_NVPATTERN_STATE_ERASED, /**< Marker/mask area is erased */
FBL_NVPATTERN_STATE_UNEXPECTEDVALUE, /**< Unexpected marker/mask value */
FBL_NVPATTERN_STATE_EXPECTEDVALUE /**< Expected marker/mask value is set */
} tFblNvPatternItemState;
/** Status of pattern */
typedef struct
{
tFblNvPatternItemState markerState;
tFblNvPatternItemState maskState;
} tFblNvPatternState;
/***********************************************************************************************************************
* GLOBAL FUNCTION PROTOTYPES
**********************************************************************************************************************/
#define FBLNVPATTERN_START_SEC_CODE
#include "MemMap.h" /* PRQA S 5087 */ /* MD_MSR_MemMap */
tFblNvPatternState FblNvPatternGetPatternState( const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * pBlockDescriptor,
tFblNvPatternId patternId,
V_MEMRAM1 IO_PositionType V_MEMRAM2 V_MEMRAM3 * pPatternAddress,
V_MEMRAM1 IO_SizeType V_MEMRAM2 V_MEMRAM3 * pPatternLength );
tFblNvPatternState FblNvPatternGetPatternStateByStartAddress( IO_PositionType patternStartAddress,
tFblNvPatternId patternId,
V_MEMRAM1 IO_PositionType V_MEMRAM2 V_MEMRAM3 * patternAddress,
V_MEMRAM1 IO_SizeType V_MEMRAM2 V_MEMRAM3 * patternLength );
vsint16 FblNvPatternGetBaseAddr( vuint8 blockNr,
tFblNvPatternId patternId,
V_MEMRAM1 IO_PositionType V_MEMRAM2 V_MEMRAM3 * pPatternAddress,
V_MEMRAM1 IO_SizeType V_MEMRAM2 V_MEMRAM3 * pPatternLength );
vsint16 FblNvPatternGetBaseAddrByBlockDescriptor( const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor,
tFblNvPatternId patternId,
V_MEMRAM1 IO_PositionType V_MEMRAM2 V_MEMRAM3 * patternAddress,
V_MEMRAM1 IO_SizeType V_MEMRAM2 V_MEMRAM3 * patternLength );
tFblResult FblNvPatternGetPatternRegionSizeByStartAddress( IO_PositionType patternStartAddress,
V_MEMRAM1 IO_SizeType V_MEMRAM2 V_MEMRAM3 * patternRegionLength );
tFblResult FblNvPatternSet( const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor, tFblNvPatternId patternId );
tFblResult FblNvPatternSetByBlockDescriptor( const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor,
tFblNvPatternId patternId );
tFblResult FblNvPatternSetByStartAddress( IO_PositionType patternStartAddress, tFblNvPatternId patternId );
tFblResult FblNvPatternClr( const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor, tFblNvPatternId patternId );
tFblResult FblNvPatternClrByBlockDescriptor( const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor,
tFblNvPatternId patternId );
tFblResult FblNvPatternClrByStartAddress( IO_PositionType patternStartAddress, tFblNvPatternId patternId );
tFblResult FblNvPatternGet( const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor, tFblNvPatternId patternId );
tFblResult FblNvPatternGetByBlockDescriptor( const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor,
tFblNvPatternId patternId );
tFblResult FblNvPatternGetByStartAddress( IO_PositionType patternStartAddress, tFblNvPatternId patternId );
#if defined( FBL_NVPATTERN_ENABLE_BLOCK_PROPERTIES )
tFblResult FblNvPatternGetProperty(const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor,
tFblNvPatternId propertyId,
IO_SizeType bufferLength,
vuint8* pDestBuffer );
tFblResult FblNvPatternGetPropertyByBlockDescriptor(const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor,
tFblNvPatternId propertyId,
IO_SizeType bufferLength,
vuint8* pDestBuffer );
tFblResult FblNvPatternGetPropertyByStartAddress( IO_PositionType patternStartAddress,
tFblNvPatternId propertyId,
IO_SizeType bufferLength,
vuint8 * destBuffer );
tFblResult FblNvPatternSetProperty(const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor,
const vuint8* pSrcBuffer,
tFblNvPatternId propertyId);
tFblResult FblNvPatternSetPropertyByBlockDescriptor(const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor,
const vuint8* pSrcBuffer,
tFblNvPatternId propertyId);
tFblResult FblNvPatternSetPropertyByStartAddress( IO_PositionType patternStartAddress,
const vuint8* srcBuffer,
tFblNvPatternId propertyId );
# if defined( FBLNVPATTERN_ENABLE_SIGN_PRESENCE_PATTERN )
tFblResult FblNvPatternGetPropertyStateAndAddrByBlockDescriptor(const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 *blockDescriptor,
tFblNvPatternId propertyId,
V_MEMRAM1 IO_PositionType V_MEMRAM2 V_MEMRAM3 *address,
V_MEMRAM1 tFblNvPatternItemState V_MEMRAM2 V_MEMRAM3 *state);
tFblResult FblNvPatternUpdateCmacByBlockDescriptor(const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 *blockDescriptor,
tFblNvPatternId patternId);
tFblResult FblNvPatternVerifyCmacByBlockDescriptor(const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 *blockDescriptor,
tFblNvPatternId patternId);
void FblNvPatternSignedPresencePatternInit(void);
void ApplFblNvPatternSignedPresencePatternInit(void);
tFblResult ApplFblNvPatternVerifyCMAC(tFblNvPatternId patternId,
const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor,
const V_MEMRAM1 vuint8 V_MEMRAM2 V_MEMRAM3 * signatureBuffer);
tFblResult ApplFblNvPatternGenerateCMAC(tFblNvPatternId patternId,
const V_MEMRAM1 tBlockDescriptor V_MEMRAM2 V_MEMRAM3 * blockDescriptor,
V_MEMRAM1 vuint8 V_MEMRAM2 V_MEMRAM3 * signatureBuffer);
# endif /* FBLNVPATTERN_ENABLE_SIGN_PRESENCE_PATTERN */
#endif /* FBL_NVPATTERN_ENABLE_BLOCK_PROPERTIES */
#define FBLNVPATTERN_STOP_SEC_CODE
#include "MemMap.h" /* PRQA S 5087 */ /* MD_MSR_MemMap */
#endif /* FBLLIB_NVPATTERN_H */
/***********************************************************************************************************************
* END OF FILE: FBL_NVPATTERN.H
**********************************************************************************************************************/