VSF Documented
Data Structures | Typedefs | Enumerations | Functions | Variables
vsf_mal.h File Reference
#include "./vsf_mal_cfg.h"
#include "kernel/vsf_kernel.h"
#include "utilities/ooc_class.h"
#include "./driver/mim_mal/vsf_mim_mal.h"
#include "./driver/mem_mal/vsf_mem_mal.h"
#include "./driver/fakefat32_mal/vsf_fakefat32_mal.h"
#include "./driver/scsi_mal/vsf_scsi_mal.h"
#include "./driver/file_mal/vsf_file_mal.h"
#include "./driver/flash_mal/vsf_flash_mal.h"
#include "./driver/sdmmc_mal/vsf_sdmmc_mal.h"
#include "./driver/cached_mal/vsf_cached_mal.h"

Go to the source code of this file.

Data Structures

class  vk_mal_drv_t
 mal driver More...
 
class  vk_mal_t
 mal class More...
 
class  vk_mal_stream_t
 mal stream class More...
 
class  vk_reentrant_mal_t
 

Typedefs

typedef enum vsf_mal_op_t vsf_mal_op_t
 This module provides MAL(Memory Abstraction Layser) device class. !
 
typedef enum vsf_mal_feature_t vsf_mal_feature_t
 

Enumerations

enum  vsf_mal_op_t {
  VSF_MAL_OP_ERASE ,
  VSF_MAL_OP_READ ,
  VSF_MAL_OP_WRITE
}
 This module provides MAL(Memory Abstraction Layser) device class. ! More...
 
enum  vsf_mal_feature_t {
  VSF_MAL_READABLE = 1 << 0 ,
  VSF_MAL_WRITABLE = 1 << 1 ,
  VSF_MAL_ERASABLE = 1 << 2 ,
  VSF_MAL_NON_UNIFIED_BLOCK = 1 << 3 ,
  VSF_MAL_LOCAL_BUFFER = 1 << 4
}
 

Functions

vsf_err_t vk_mal_init (vk_mal_t *pthis)
 prepare subcall to initialize a mal instance.
 
vsf_err_t vk_mal_fini (vk_mal_t *pthis)
 prepare subcall to finialize a mal instance.
 
uint_fast32_t vk_mal_blksz (vk_mal_t *pthis, uint_fast64_t addr, uint_fast32_t size, vsf_mal_op_t op)
 get the block size of a dedicated operation.
 
bool vk_mal_prepare_buffer (vk_mal_t *pthis, uint_fast64_t addr, uint_fast32_t size, vsf_mal_op_t op, vsf_mem_t *mem)
 get the local memory of a dedicated operation, if mal instance has VSF_MAL_LOCAL_BUFFER feature.
 
vsf_err_t vk_mal_erase (vk_mal_t *pthis, uint_fast64_t addr, uint_fast32_t size)
 prepare subcall to erase a mal instance.
 
vsf_err_t vk_mal_read (vk_mal_t *pthis, uint_fast64_t addr, uint_fast32_t size, uint8_t *buff)
 prepare subcall to read a mal instance.
 
vsf_err_t vk_mal_write (vk_mal_t *pthis, uint_fast64_t addr, uint_fast32_t size, uint8_t *buff)
 prepare subcall to write a mal instance.
 
vsf_err_t vk_mal_read_stream (vk_mal_stream_t *pthis, uint_fast64_t addr, uint_fast32_t size, vsf_stream_t *stream)
 prepare subcall to read mal instance into a stream.
 
vsf_err_t vk_mal_write_stream (vk_mal_stream_t *pthis, uint_fast64_t addr, uint_fast32_t size, vsf_stream_t *stream)
 prepare subcall to write a stream into mal instance.
 

Variables

const vk_mal_drv_t vk_reentrant_mal_drv
 class driver of vk_reentrant_mal_t, used to bet set to the drv member in vk_mal_t
 

Typedef Documentation

◆ vsf_mal_op_t

typedef enum vsf_mal_op_t vsf_mal_op_t

This module provides MAL(Memory Abstraction Layser) device class. !

Author
SimonQian !
Note
Supports read/write/erase operation in block granularity. ! Enabled by VSF_USE_MAL. Drivers: ! mim_mal(mim: mal in mal) by VSF_MAL_USE_MIM_MAL: ! Used to derive a mal device from partial of another mal device. ! fakefat32_mal by VSF_MAL_USE_FAKEFAT32_MAL, depends on VSF_USE_FS/VSF_FS_USE_MEMFS/VSF_FS_USE_FATFS: ! Generate a vitual fat32 mal device. ! file_mal by VSF_MAL_USE_FILE_MAL, depends on VSF_USE_FS: ! Generate a mal device from a file. ! flash_mal by VSF_MAL_USE_FLASH_MAL, depends on VSF_HAL_USE_FLASH: ! Generate a mal device from partial of the FLASH in HAL. ! mem_mal by VSF_MAL_USE_MEM_MAL: ! Generate a mal device from io-accessable memory. ! sdmmc_mal by VSF_MAL_USE_SDMMC_MAL: ! Mal device from a SD/MMC card. ! scsi_mal by VSF_MAL_USE_SCSI_MAL, depnends on VSF_USE_SCSI: ! Mal device from a SCSI device.

◆ vsf_mal_feature_t

Enumeration Type Documentation

◆ vsf_mal_op_t

This module provides MAL(Memory Abstraction Layser) device class. !

Author
SimonQian !
Note
Supports read/write/erase operation in block granularity. ! Enabled by VSF_USE_MAL. Drivers: ! mim_mal(mim: mal in mal) by VSF_MAL_USE_MIM_MAL: ! Used to derive a mal device from partial of another mal device. ! fakefat32_mal by VSF_MAL_USE_FAKEFAT32_MAL, depends on VSF_USE_FS/VSF_FS_USE_MEMFS/VSF_FS_USE_FATFS: ! Generate a vitual fat32 mal device. ! file_mal by VSF_MAL_USE_FILE_MAL, depends on VSF_USE_FS: ! Generate a mal device from a file. ! flash_mal by VSF_MAL_USE_FLASH_MAL, depends on VSF_HAL_USE_FLASH: ! Generate a mal device from partial of the FLASH in HAL. ! mem_mal by VSF_MAL_USE_MEM_MAL: ! Generate a mal device from io-accessable memory. ! sdmmc_mal by VSF_MAL_USE_SDMMC_MAL: ! Mal device from a SD/MMC card. ! scsi_mal by VSF_MAL_USE_SCSI_MAL, depnends on VSF_USE_SCSI: ! Mal device from a SCSI device.
Enumerator
VSF_MAL_OP_ERASE 
VSF_MAL_OP_READ 
VSF_MAL_OP_WRITE 

◆ vsf_mal_feature_t

Enumerator
VSF_MAL_READABLE 
VSF_MAL_WRITABLE 
VSF_MAL_ERASABLE 
VSF_MAL_NON_UNIFIED_BLOCK 
VSF_MAL_LOCAL_BUFFER 

Function Documentation

◆ vk_mal_init()

vsf_err_t vk_mal_init ( vk_mal_t pthis)
extern

prepare subcall to initialize a mal instance.

Note
A mal instance MUST be successfully initialized before calling other mal APIs. The initialization is done by a subcall, so if vk_mal_init returns VSF_ERR_NONE, it does not mean that the initialization is done. It depends on the caller context.
  1. If caller is a stack-owner thread, vk_mal_init will return after subcall is done. The result of initialization can be got by vsf_eda_get_return_value, with type vsf_err_t.
  2. If caller is not a stack-owner thread, the initializaion subcall will start after exiting of current event handler. After the subcall is done, VSF_EVT_RETURN will be send to the caller task. And vsf_eda_get_return_value could be called to get the result with type vsf_err_t.
Parameters
[in]pthismal instance
Returns
vsf_err_t: VSF_ERR_NONE if subcall is ready to start, or a negative error code

◆ vk_mal_fini()

vsf_err_t vk_mal_fini ( vk_mal_t pthis)
extern

prepare subcall to finialize a mal instance.

Note
similar to vk_mal_init.
Parameters
[in]pthismal instance
Returns
vsf_err_t: VSF_ERR_NONE if subcall is ready to start, or a negative error code

◆ vk_mal_blksz()

uint_fast32_t vk_mal_blksz ( vk_mal_t pthis,
uint_fast64_t  addr,
uint_fast32_t  size,
vsf_mal_op_t  op 
)
extern

get the block size of a dedicated operation.

Parameters
[in]pthismal instance
[in]addraddress(starting from 0) to operate
[in]sizesize in bytes to operation
[in]opthe operation, one in vsf_mal_op_t
Returns
block size in bytes: if 0 means the specified operation is not supported

◆ vk_mal_prepare_buffer()

bool vk_mal_prepare_buffer ( vk_mal_t pthis,
uint_fast64_t  addr,
uint_fast32_t  size,
vsf_mal_op_t  op,
vsf_mem_t mem 
)
extern

get the local memory of a dedicated operation, if mal instance has VSF_MAL_LOCAL_BUFFER feature.

Parameters
[in]pthismal instance
[in]addraddress(starting from 0) to operate
[in]sizesize in bytes to operation
[in]opthe operation, one in vsf_mal_op_t
[out]memthe memory returned
Returns
true: a valid local memory is returned; false: local memory is not supported

◆ vk_mal_erase()

vsf_err_t vk_mal_erase ( vk_mal_t pthis,
uint_fast64_t  addr,
uint_fast32_t  size 
)
extern

prepare subcall to erase a mal instance.

Note
similar to vk_mal_init.
Parameters
[in]pthismal instance
[in]addraddress(starting from 0) to operate
[in]sizesize in bytes to operation
Returns
vsf_err_t: VSF_ERR_NONE if subcall is ready to start, or a negative error code

◆ vk_mal_read()

vsf_err_t vk_mal_read ( vk_mal_t pthis,
uint_fast64_t  addr,
uint_fast32_t  size,
uint8_t buff 
)
extern

prepare subcall to read a mal instance.

Note
similar to vk_mal_init. The result of subcall from vsf_eda_get_return_value is int32_t type. result < 0 means error; result >= 0 means the actual byte size read.
Parameters
[in]pthismal instance
[in]addraddress(starting from 0) to read
[in]sizesize in bytes to read
[in]bufferdata buffer for reading
Returns
vsf_err_t: VSF_ERR_NONE if subcall is ready to start, or a negative error code

◆ vk_mal_write()

vsf_err_t vk_mal_write ( vk_mal_t pthis,
uint_fast64_t  addr,
uint_fast32_t  size,
uint8_t buff 
)
extern

prepare subcall to write a mal instance.

Note
similar to vk_mal_init. The result of subcall from vsf_eda_get_return_value is int32_t type. result < 0 means error; result >= 0 means the actual byte size written.
Parameters
[in]pthismal instance
[in]addraddress(starting from 0) to write
[in]sizesize in bytes to write
[in]bufferdata buffer for writing
Returns
vsf_err_t: VSF_ERR_NONE if subcall is ready to start, or a negative error code

◆ vk_mal_read_stream()

vsf_err_t vk_mal_read_stream ( vk_mal_stream_t pthis,
uint_fast64_t  addr,
uint_fast32_t  size,
vsf_stream_t stream 
)
extern

prepare subcall to read mal instance into a stream.

Note
similar to vk_mal_init. stream will be connected/disconnected automatically. The result of subcall from vsf_eda_get_return_value is int32_t type. result < 0 means error; result >= 0 means the actual byte size read.
Parameters
[in]pthismal_stream instance
[in]addraddress(starting from 0) to read
[in]sizesize in bytes to read
[in]streamstream for reading
Returns
vsf_err_t: VSF_ERR_NONE if stream is started, or a negative error code

◆ vk_mal_write_stream()

vsf_err_t vk_mal_write_stream ( vk_mal_stream_t pthis,
uint_fast64_t  addr,
uint_fast32_t  size,
vsf_stream_t stream 
)
extern

prepare subcall to write a stream into mal instance.

Note
similar to vk_mal_init. stream will be connected/disconnected automatically. The result of subcall from vsf_eda_get_return_value is int32_t type. result < 0 means error; result >= 0 means the actual byte size written.
Parameters
[in]pthismal_stream instance
[in]addraddress(starting from 0) to write
[in]sizesize in bytes to write
[in]streamstream for writing
Returns
vsf_err_t: VSF_ERR_NONE if stream is started, or a negative error code

Variable Documentation

◆ vk_reentrant_mal_drv

const vk_mal_drv_t vk_reentrant_mal_drv
extern

class driver of vk_reentrant_mal_t, used to bet set to the drv member in vk_mal_t