NvBlock SwComponentPrototypes 的代码会由rte generator 负责实现。NvBlockSwComponentType 提供了获取和管理存储在nvram中的数据的pirt interface。
上图表现了NvBlockSwComponentType 的使用介绍。根据不同的使用场景,swc可以有不同的方式和NvBlockSwComponentType 连接。如果port类型是 SenderReceiverInterfaces / NvDataInterfaces 的连接模式为了获得访问NV data的权限,port类型是ClientServerInterfaces是用于管理nv data。多个swc 可以读出相同的NvBlockSwComponentType 的VariableDataPrototypes。
每个NvBlockSwComponentType 可以包含多个NvBlockDescriptors, 每一个NvBlockDescriptor关联一个NVRAM block。
一个NvBlockDescriptor 包含了一个VariableDataPrototype,作为NVRAM block的ram block, ParameterDataPrototype 作为default ROM value, 可选。ROM 和RAM block的类型应该是要匹配的。RTE会给VariableDataPrototype分配memory。
对于每个存在NvBlockDescriptor 中的element, 应该有一个NvBlockDataMapping ,这个mapping关系把能读写对应VariableDataPrototype element的port关系表现出来了。
NvBlockSwComponentType 可以用于减少ecu上面 nvram的数量,他可以把一些小的数据元素放在一个block里面,还可以让不同的swc访问相同数据元素。
为了保证nvram block在合适的时机写到nv memory中,rte提供了一个叫dirty flag的功能。这个机制能够在rte write api被调用时和nvm module交互,但是具体的表现要依赖于NvBlockDescriptor.
如果一个swc 通过接口调用了RTE_write/Rte_IWrite / Rte_IWriteRef, 并且dirtyFlagSupport & storeatshutdown 设为true, RTE 会通过调用NvM_SetRamBlockStatus把 ram block标为changed.
如果一个swc 通过接口调用了RTE_write/ Rte_IWrite / Rte_IWriteRef, 并且dirtyFlagSupport & storeCyclic 设为true, RTE 会在下个cycle调用NvM_WriteBlock来写数据。周期的信息是NvBlockDescriptor.timingEvent.period.
如果一个swc 通过接口调用了RTE_write/ Rte_IWrite / Rte_IWriteRef, 并且dirtyFlagSupport & storeImmediate 设为true, RTE 会在 NvBlockDescriptor’s RunnableEntity 中调用NvM_WriteBlock
如果swc需要被通知nvm job result, 需要使用NvM Client-Server interfaces。
标准的client sever interface可以实现这些:
• NvMService
This interface is used to send commands to the NVM. The NvBlockSwComponentType provides a server port intended to be used by the SW-C users of this NvBlockSwComponentType.
• NvMNotifyJobFinished
This interface is used by the NVM to notify the end of job. The NvBlockSwComponentType provides a server port intended to be used by the NVM, and client ports intended to be connected to the SW-C users of this NvBlockSwComponentType.
• NvMNotifyInitBlock
This interface is used by the NVM to request users to provide the default values in the RAM Block. The NvBlockSwComponentType provides a server port intended to be used by the NVM, and client ports intended to be connected to the SW-C users of this NvBlockSwComponentType.
• NvMAdmin
This interface is used to order some administrative operations to the NVM. The NvBlockSwComponentType provides a server port intended to be used by the SW-C users of this NvBlockSwComponentType.