MemIf¶
文档信息(Document Information)¶
版本历史(Version History)¶
日期(Date) |
作者(Author) |
版本(Version) |
状态(Status) |
说明(Description) |
|---|---|---|---|---|
2025/03/13 |
peng.wu |
V0.1 |
发布(Release) |
首次发布(First release) |
2025/04/04 |
peng.wu |
V1.0 |
发布(Release) |
正式发布(Official release) |
参考文档(Reference Document)¶
编号(Number) |
分类(Classification) |
标题(Title) |
版本(Version) |
|---|---|---|---|
1 |
Autosar |
AUTOSAR_CP_SRS_MemoryHWAbstractionLayer.pdf |
R23-11 |
2 |
Autosar |
AUTOSAR_CP_SWS_MemoryAbstractionInterface.pdf |
R23-11 |
术语与简写(Terms and Abbreviations)¶
术语(Term)¶
术语(Term) |
解释(Explanation) |
|---|---|
Address area |
Contiguous memory area in the logical address space. Typically, multiple physical memory sectors are combined to one logical address area. |
Fast Mode |
During startup / shutdown the underlying driver may be switched into fast mode in order to allow for fast reading / writing in those phases. |
Slow Mode |
During normal operation the underlying driver may be used in slow mode in order to reduce the resource usage in terms of runtime or blocking time of the underlying device /communication media. |
Vendor specific library |
A vendor specific library is an ICC-2 implementation of the FEE/FLS and EA/EEP modules respectively. It provides the same upper layer interface (API) and functionality as the corresponding ICC-3 implementation. |
简写(Abbreviation)¶
简写(Abbreviation) |
全称(Full name) |
解释(Explanation) |
|---|---|---|
LSB |
Least significant bit / byte (depending on context). |
最低有效位/字节(取决于上下文) |
Mem |
AUTOSAR Basic Software Module Memory Driver |
AUTOSAR基本软件模块内存驱动程序. |
FEE |
Flash EEPROM Emulation. |
Flash EEPROM仿真 |
EA |
EEPROM Abstraction |
EEPROM抽象. |
EEPROM |
Electrically Erasable and Programmable ROM (Read Only Memory) |
电可擦可编程只读存储器(只读型存储器). |
MemIf |
Memory Abstraction Interface |
内存抽象接口. |
NvM |
NVRAM Manager |
非易失RAM管理. |
MemAcc |
Memory Access- AUTOSAR Basic Software module for memory access |
AUTOSAR基本软件模块存储器访问. |
MSB |
Most significant bit / byte (depending on context) |
最高有效位/字节(取决于上下文). |
NVRAM |
Non-volatile RAM (Random Access Memory) |
非易失性RAM(随机存取存储器). |
简介(Introduction)¶
MemIf模块的核心功能是为上层模块(如NvM)提供统一的访问接口,同时将具体的存储操作委托给底层驱动, 由MemIf接口层提供统一FLASH或EEPROM内存写入、读取、擦除、比较等接口给存储栈服务层使用, 存储栈中所有的状态控制类、操作结果等数据类型也是由MemIf接口层来实现。
The core function of the MemIf module is to provide a unified access interface for upper-layer modules (such as NvM), while entrusting specific storage operations to the underlying driver. The MemIf interface layer provides unified interfaces for FLASH or EEPROM memory writing, reading, erasing, comparing, etc. For the storage stack service layer, all relevant data types, such as those for state control and operation results used within the storage stack, are defined by the MemIf interface layer.
功能描述(Functional Description)¶
特性(Features)¶
抽象接口(Abstract Interface)¶
提供统一的读写接口,使得上层模块可以透明地访问不同类型的非易失性存储器。支持同步和异步操作模式。
Provides a unified read-write interface, enabling upper-layer modules to transparently access different types of non-volatile memory devices. It supports both synchronous and asynchronous operation modes.
多驱动支持(Multi-Driver Support)¶
允许NVM访问多个存储抽象模块,支持多个底层存储驱动(如EEPROM驱动、Flash驱动)。 给Flash或者EEPROM或者同时给两者一个Device Index,根据Device Index将NvM模块的指令转发给对应的Fee模块或者Ea模块。
Allows NVM to access multiple storage abstraction modules and supports multiple underlying storage drivers (such as EEPROM drivers, Flash drivers). Assign a Device Index to Flash, EEPROM, or both, and forward instructions from the NvM module to the corresponding Fee module or Ea module based on the Device Index.
错误传递(Error Propagation)¶
MemIf模块将底层驱动的错误传递给上层模块(如NvM),以便进行错误处理。错误类型包括:读取失败、写入失败、擦除失败等。
The MemIf module propagates errors from the underlying drivers to upper-layer modules (such as NvM) for error handling. Error types include: read failure, write failure, erase failure, etc.
集成(Integration)¶
初始化(Initialization)¶
MemIf模块没有初始化,没有配置指针,没有状态指针。
The MemIf module requires no explicit initialization routine and does not maintain its own configuration or status pointers; it relies on the initialization of the underlying modules.
底层模块映射(Underlying Module Mapping)¶
MemIf模块配置了MemIfDevErrorDetect功能后,将使用源码对底层模块进行。可以使用MemIf_Read、MemIf_Write、MemIf_InvalidateBlock、 MemIf_EraseImmediateBlock、MemIf_Cancel、MemIf_GetJobResult等接口。若打开了MemIfDevErrorDetect功能,且MemIfNumberOfDevices为2,则可使用MemIf_GetStatus接口。 若打开了MemIfVersionInfoApi功能,则可使用MemIf_GetVersionInfo接口。 若没有打开MemIfDevErrorDetect功能。则将使用宏定义映射底层模块的MemIf_Read、MemIf_Write、MemIf_InvalidateBlock、MemIf_EraseImmediateBlock、MemIf_Cancel、 MemIf_GetJobResult、MemIf_GetStatus等接口。
If the MemIfDevErrorDetect development error detection is enabled, the MemIf module will use function pointers to call the underlying modules (EA, FEE). Interfaces such as MemIf_Read, MemIf_Write, MemIf_InvalidateBlock, MemIf_EraseImmediateBlock, MemIf_Cancel, and MemIf_GetJobResult can be used. If the MemIfDevErrorDetect function is enabled and MemIfNumberOfDevices is 2, the MemIf_GetStatus interface can be used. If the MemIfVersionInfoApi function is enabled, the MemIf_GetVersionInfo interface can be used. If the MemIfDevErrorDetect function is not enabled, macro definitions will be used to map the underlying module’s interfaces such as MemIf_Read, MemIf_Write, MemIf_InvalidateBlock, MemIf_EraseImmediateBlock, MemIf_Cancel, MemIf_GetJobResult, and MemIf_GetStatus.
文件列表(File List)¶
静态文件(Static Files)¶
文件(File) |
描述(Description) |
|---|---|
MemIf_Types.h |
Type definition of MemIf module; including type definition, and configuration structure declaration that need to be used. |
MemIf.h |
API declarations and macro definitions of MemIf module; including macro definitions, and external function declarations that need to be used. |
MemIf.c |
API implementation of MemIf module; contains macro definitions, internal functions, and global functions that need to be used. |
MemIf_MemMap.h |
Memory abstraction including MemIf module. |
动态文件(Dynamic Files)¶
文件(File) |
描述(Description) |
|---|---|
MemIf_Cfg.h |
Configuration parameters required for the implementation of MemIf; Contains macro definitions, version information. |
MemIf_Cfg.c |
Configuration parameters required for the implementation of MemIf; Contains the API information that need to be used. |
错误处理(Error handling)¶
开发错误(Development error)¶
Error code |
Value[hex] |
Description |
|---|---|---|
MEMIF_E_NO_ERROR |
0x0u |
API function called with no det error |
MEMIF_E_PARAM_DEVICE |
0x01u |
API service called with wrong device index parameter |
MEMIF_E_PARAM_POINTER |
0x02u |
API service called with NULL pointer argument |
产品错误(Product Errors)¶
None
接口描述(Interface Description)¶
类型定义(Type Definitions )¶
Type Name |
Type |
Description |
|---|---|---|
MemIf_StatusType |
enum |
Denotes the current status of the underlying abstraction module and device drive. |
MemIf_JobResultType |
enum |
Denotes the result of the last job. |
MemIf_ModeType |
enum |
Denotes the mode type of the lower layer.(Reserved for compatibility with older versions of Mcal) |
提供的服务(Provided Services)¶
MemIf_Read¶
Std_ReturnType MemIf_Read(uint16 DeviceIndex, uint16 BlockNumber, uint16 BlockOffset, uint8 *DataBufferPtr, uint16 Length)
Invokes the “Read” function of the underlying memory abstraction module selected by the parameter DeviceIndex.
- Sync/Async
Synchronous
- Reentrancy
Non Reentrant
Parameters
Dir |
Name |
Description |
|---|---|---|
[in] |
DeviceIndex |
index number of device |
[in] |
BlockNumber |
number of logic block |
[in] |
BlockOffset |
Read address offset inside the block |
[out] |
DataBufferPtr |
Pointer to data buffer |
[in] |
Length |
Number of bytes to read |
- Return type
Std_ReturnType
Return values
Name |
Description |
|---|---|
E_OK |
The requested job has been accepted by the module |
E_NOT_OK |
The requested job has not been accepted by the module. |
MemIf_Write¶
Std_ReturnType MemIf_Write(uint16 DeviceIndex, uint16 BlockNumber, const uint8 *DataBufferPtr)
Invokes the “Write” function of the underlying memory abstraction module selected by the parameter DeviceIndex.
- Sync/Async
Synchronous
- Reentrancy
Non Reentrant
Parameters
Dir |
Name |
Description |
|---|---|---|
[in] |
DeviceIndex |
index number of device |
[in] |
BlockNumber |
number of logic block |
[in] |
DataBufferPtr |
Pointer to data buffer |
- Return type
Std_ReturnType
Return values
Name |
Description |
|---|---|
E_OK |
The requested job has been accepted by the module |
E_NOT_OK |
The requested job has not been accepted by the module. |
MemIf_Cancel¶
void MemIf_Cancel(uint16 DeviceIndex)
Invokes the “Cancel” function of the underlying memory abstraction module selected by the parameter DeviceIndex.
- Sync/Async
Synchronous
- Reentrancy
Non Reentrant
Parameters
Dir |
Name |
Description |
|---|---|---|
[in] |
DeviceIndex |
index number of device |
- Return type
void
MemIf_GetJobResult¶
MemIf_JobResultType MemIf_GetJobResult(uint16 DeviceIndex)
Invokes the “GetJobResult” function of the underlying memory abstraction module selected by the parameter DeviceIndex.
- Sync/Async
Synchronous
- Reentrancy
Non Reentrant
Parameters
Dir |
Name |
Description |
|---|---|---|
[in] |
DeviceIndex |
index number of device |
- Return type
MemIf_JobResultType
Return values
Name |
Description |
|---|---|
MEMIF_JOB_OK |
The job has been finished successfully |
MEMIF_JOB_FAILED |
The job has not been finished successfully |
MEMIF_JOB_PENDING |
The job has not yet been finished. |
MEMIF_JOB_CANCELED |
The job has been canceled. |
MEMIF_BLOCK_INCONSISTENT |
|
MEMIF_BLOCK_INVALID |
The requested block has been marked as invalid, the requested operation can not be performed. |
MemIf_InvalidateBlock¶
Std_ReturnType MemIf_InvalidateBlock(uint16 DeviceIndex, uint16 BlockNumber)
Invokes the “InvalidateBlock” function of the underlying memory abstraction module selected by the parameter DeviceIndex.
- Sync/Async
Synchronous
- Reentrancy
Non Reentrant
Parameters
Dir |
Name |
Description |
|---|---|---|
[in] |
DeviceIndex |
index number of device |
[in] |
BlockNumber |
number of logic block |
- Return type
Std_ReturnType
Return values
Name |
Description |
|---|---|
E_OK |
The requested job has been accepted by the module |
E_NOT_OK |
The requested job has not been accepted by the module. |
MemIf_EraseImmediateBlock¶
Std_ReturnType MemIf_EraseImmediateBlock(uint16 DeviceIndex, uint16 BlockNumber)
Invokes the “EraseImmediateBlock” function of the underlying memory abstraction module selected by the parameter DeviceIndex.
- Sync/Async
Synchronous
- Reentrancy
Non Reentrant
Parameters
Dir |
Name |
Description |
|---|---|---|
[in] |
DeviceIndex |
index number of device |
[in] |
BlockNumber |
number of logic block |
- Return type
Std_ReturnType
Return values
Name |
Description |
|---|---|
E_OK |
The requested job has been accepted by the module |
E_NOT_OK |
The requested job has not been accepted by the module. |
MemIf_GetStatus¶
MemIf_StatusType MemIf_GetStatus(uint16 DeviceIndex)
Invokes the “GetStatus” function of the underlying memory abstraction module selected by the parameter DeviceIndex.
- Sync/Async
Synchronous
- Reentrancy
Non Reentrant
Parameters
Dir |
Name |
Description |
|---|---|---|
[in] |
DeviceIndex |
index number of device |
- Return type
MemIf_StatusType
Return values
Name |
Description |
|---|---|
MEMIF_UNINIT |
The underlying abstraction module or device driver has not been initialized (yet). |
MEMIF_IDLE |
The underlying abstraction module or device driver is currently idle. |
MEMIF_BUSY |
The underlying abstraction module or device driver is currently busy. |
MEMIF_BUSY_INTERNAL |
The underlying abstraction module is busy with internal management operations. The underlying device driver can be busy or idle. |
MemIf_GetVersionInfo¶
void MemIf_GetVersionInfo(Std_VersionInfoType *VersionInfoPtr)
Returns version information.
- Sync/Async
Synchronous
- Reentrancy
Reentrant
Parameters
Dir |
Name |
Description |
|---|---|---|
[out] |
VersionInfoPtr |
Pointer to standard version information structure. |
- Return type
void
依赖的服务(Dependent Services)¶
可选接口(Optional Interfaces)¶
API Function |
Header File |
Description |
|---|---|---|
Det_ReportError |
Det.h |
Service to report development errors |
强制接口(Mandatory Interfaces)¶
API Function |
Header File |
Description |
|---|---|---|
Ea_EraseImmediateBlock |
Ea.h |
Erases the block BlockNumber |
Ea_GetStatus |
Ea.h |
Service to return the Status |
Ea_InvalidateBlock |
Ea.h |
Invalidates the block BlockNumber |
Fee_EraseImmediateBlock |
Fee.h |
Service to erase a logical block |
Fee_GetStatus |
Fee.h |
Service to return the status. |
Fee_InvalidateBlock |
Fee.h |
Service to invalidate a logical block |
配置(configuration)¶
MemIfGeneral¶
在General中,MemIfVersionInfoApi配置项用于打开获取版本的功能。MemIfDevErrorDetect配置项用于配置MemIf模块是使用函数指针还是宏定义的方式进行映射, MemIfDevErrorDetect没有勾选,则使用宏定义的方式。若勾选了,则使用函数指针的方式,且当MemIfDevErrorDetect勾选后,MemIfNumberOfDevices配置为2, 则可使用MemIf_GetStatus接口。 如图 MemIf General Configuration 展示了MemIfGeneral的配置界面。
In General, the MemIfVersionInfoApi configuration item enables the version information API. The MemIfDevErrorDetect configuration item is used to configure whether the MemIf module uses function pointers or macro definitions for mapping. If MemIfDevErrorDetect is not checked, the macro definition method will be used. If it is checked, the function pointer method will be adopted. Moreover, when MemIfDevErrorDetect is checked and MemIfNumberOfDevices is configured as 2, the MemIf_GetStatus interface can be used. As shown in Figure MemIf General Configuration, it displays the configuration interface of MemIfGeneral.
MemIf General Configuration¶