AUTOSAR存储协议栈NVM

本文详细描述了NvM模块中WriteBlock函数的工作流程,包括数据复制、内存块操作、队列管理和错误处理,以及NvMAPI的不同类别和存储架构代码的组成部分。
摘要由CSDN通过智能技术生成

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值