1,
Std_ReturnType NvM_WriteBlock(NvM_BlockIdType BlockId, NvM_Rb_ConstVoidPtr NvM_SrcPtr)
{
// TRACE[SWS_NvM_00455] Service to copy the data of the RAM block to its corresponding NV block
#ifdef NVM_CFG_API_WRITE_BLOCK
// TRACE[BSW_SWS_AR4_0_R2_NVRAMManager_Ext-2920] Call the overloading function
return NVM_CFG_API_WRITE_BLOCK(BlockId, NvM_SrcPtr);
#else
return NvM_Prv_WriteBlock(NVM_SERVICE_ID_WRITE_BLOCK, BlockId, NvM_SrcPtr);
#endif
}
static Std_ReturnType NvM_Prv_WriteBlock(NvM_Prv_idService_tuo idService_uo,
NvM_BlockIdType BlockId,
NvM_Rb_ConstVoidPtr NvM_SrcPtr)
{
Std_ReturnType stReturn_uo = E_NOT_OK;
NvM_Prv_idQueue_tuo idQueue_uo;
NvM_Prv_Service_Configuration_tst ServiceConfiguration_st;
NvM_Prv_BlockData_tst BlockData_st;
// The following union is necessary to remove an otherwise unavoidable compiler warning
// due to a discarded const qualifier
union
{
const void *pcv;
void *pv;
} adrRamBlock_un;
adrRamBlock_un.pcv = NvM_SrcPtr;
// put all service parameters in a structure for new block data
BlockData_st.QueueEntry_st.idBlock_uo = BlockId;
BlockData_st.QueueEntry_st.BlockData_un.ptrRamBlock_pv = adrRamBlock_un.pv;
BlockData_st.QueueEntry_st.idService_uo = idService_uo;
BlockData_st.QueueEntry_st.ServiceBit_uo = NvM_Prv_ServiceBit_Write_e;
BlockData_st.Result_uo = NVM_REQ_PENDING;
BlockData_st.idxDataset_u8 = 0;
BlockData_st.maskBitsToChange_u8 = 0u;
BlockData_st.maskBitsNewValue_u8 = 0u;
// determine whether permanent RAM block shall be used
if (NULL_PTR == BlockData_st.QueueEntry_st.BlockData_un.ptrRamBlock_pv)
{
// TRACE[SWS_NvM_00280] Only take the permanent RAM block if no temporary RAM block has been specified
BlockData_st.QueueEntry_st.BlockData_un.ptrRamBlock_pv = NvM_Prv_GetPRamBlockAddress(BlockId);
}
// determine which queue is required
idQueue_uo = NvM_Prv_idQueue_Standard_e;
#if (NVM_JOB_PRIORITIZATION == STD_ON)
if (NvM_Prv_HasBlockImmediateJobPriority(BlockId))
{
// TRACE[SWS_NvM_00378] Only single block write requests for immediate blocks are queued in the immediate queue
// All other single block requests are queued in the standard queue.
idQueue_uo = NvM_Prv_idQueue_Immediate_e;
}
#endif
ServiceConfiguration_st.CheckPendingBlock_b = TRUE;
ServiceConfiguration_st.CheckParameter_pfct = NvM_Prv_Write_CheckParameter;
ServiceConfiguration_st.CheckBlockData_pfct = NvM_Prv_Write_CheckBlockData;
ServiceConfiguration_st.SetBlockData_pfct = NvM_Prv_Write_SetBlockData;
// TRACE[SWS_NvM_00614] Report the DET error NVM_E_NOT_INITIALIZED when the NVM is not yet initialized
// TRACE[SWS_NvM_00827] Report the DET error NVM_E_NOT_INITIALIZED when the NVM is not yet initialized
// TRACE[SWS_NvM_00828] Report the DET error NVM_E_BLOCK_PENDING when another request is pending for the passed block
// TRACE[SWS_NvM_00618] Report the DET error NVM_E_PARAM_BLOCK_ID when the passed BlockID is out of range
// TRACE[SWS_NvM_00829] Report the DET error NVM_E_PARAM_BLOCK_ID when the passed BlockID is out of range
// TRACE[SWS_NvM_00798] Take over given parameters, queue the read request in the job queue and return
stReturn_uo = NvM_Prv_Service_Initiate(idQueue_uo,
&BlockData_st,
&ServiceConfiguration_st);
// Return whether this operation was successful
return stReturn_uo;
}
2,架构图
3, NvM的API,可以分三类:
Class3:所有指定的API调用都可以用,最多支持功能
Class2:有一组中间API调用可用
Class1: 特别是对于硬件资源非常有限的匹配系统,此API配置类仅提供最少的一组。
***Class3***包含下面API:
Type 1:
NvM_SetDataIndex()
NvM_GetDataIndex()
NvM_SetBlockProtection()
NvM_GetErrorStatus()
NvM_SetRamBlockStatus()
NvM_SetBlockLockStatus()
Type 2:
NvM_ReadBlock()
NvM_WriteBlock()
NvM_RestoreBlockDefaults()
NvM_EraseNvBlock()
NvM_InvalidateNvBlock()
NvM_CancelJobs()
NvM_ReadPRAMBlock()
NvM_WritePRAMBlock()
NvM_RestorePRAMBlockDefaults()
Type 3:
NvM_ReadAll()
NvM_WriteAll()
NvM_CancelWrite()
NvM_ValidateAll()
Type 4:
NvM_Init()
4,存储架构代码有哪些?
Fls→Fee→MemIf→NvM
Fls:
Fls_17_Dmu.c(MCAL静态代码)
Fls_17_Dmu.h(MCAL静态代码)
Fls_17_Dmu_ac.c(MCAL静态代码)
Fls_17_Dmu_ac.h(MCAL静态代码)
Fls_17_Dmu_Cfg.h(MCAL配置代码)
Fls_17_Dmu_PBcfg.c(MCAL配置代码)
Fls_17_Dmu_PBcfg.h(MCAL配置代码)
Fee:
Fee.c(MCAL静态代码)
Fee.h(MCAL静态代码)
Fee_Cbk.h(MCAL静态代码)
Fee_Cfg.h(MCAL配置代码)
Fee_PBcfg.c(MCAL配置代码)
Fee_PBcfg.h(MCAL配置代码)
MemIf:
MemIf.c
MemIf.h
MemIf_Cfg.h
MemIf_Cfg_SchM.h
MemIf_MainFunction.c
MemIf_Rb_GetStatus.c
MemIf_Rb_MainFunction.c
MemIf_Types.h