VSF Documented
Macros | Enumerations | Functions
vsf_mal.c File Reference
#include "./vsf_mal_cfg.h"
#include "service/vsf_service.h"
#include "./vsf_mal.h"

Macros

#define __VSF_SIMPLE_STREAM_CLASS_INHERIT__
 
#define __VSF_MAL_CLASS_IMPLEMENT
 

Enumerations

enum  {
  VSF_EVT_MAL_READ = VSF_EVT_USER + 0 ,
  VSF_EVT_MAL_WRITE = VSF_EVT_USER + 1
}
 

Functions

 dcl_vsf_peda_methods (dcl_vsf_peda_methods(static, __vk_reentrant_mal_init)
 
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_component_peda_ifs_entry (__vk_reentrant_mal_init, vk_mal_init)
 
 __vsf_component_peda_ifs_entry (__vk_reentrant_mal_fini, vk_mal_fini)
 
 __vsf_component_peda_ifs_entry (__vk_reentrant_mal_read, vk_mal_read)
 
 __vsf_component_peda_ifs_entry (__vk_reentrant_mal_write, vk_mal_write)
 
 __vsf_component_peda_private_entry (__vk_mal_read_stream)
 
 __vsf_component_peda_private_entry (__vk_mal_write_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)
 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.
 

Macro Definition Documentation

◆ __VSF_SIMPLE_STREAM_CLASS_INHERIT__

#define __VSF_SIMPLE_STREAM_CLASS_INHERIT__

◆ __VSF_MAL_CLASS_IMPLEMENT

#define __VSF_MAL_CLASS_IMPLEMENT

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
VSF_EVT_MAL_READ 
VSF_EVT_MAL_WRITE 

Function Documentation

◆ dcl_vsf_peda_methods()

dcl_vsf_peda_methods ( dcl_vsf_peda_methods(  static,
__vk_reentrant_mal_init   
)

◆ vk_mal_init()

vsf_err_t vk_mal_init ( vk_mal_t pthis)

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)

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 
)

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 
)

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 
)

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 
)

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 
)

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

◆ __vsf_component_peda_ifs_entry() [1/4]

__vsf_component_peda_ifs_entry ( __vk_reentrant_mal_init  ,
vk_mal_init   
)

◆ __vsf_component_peda_ifs_entry() [2/4]

__vsf_component_peda_ifs_entry ( __vk_reentrant_mal_fini  ,
vk_mal_fini   
)

◆ __vsf_component_peda_ifs_entry() [3/4]

__vsf_component_peda_ifs_entry ( __vk_reentrant_mal_read  ,
vk_mal_read   
)

◆ __vsf_component_peda_ifs_entry() [4/4]

__vsf_component_peda_ifs_entry ( __vk_reentrant_mal_write  ,
vk_mal_write   
)

◆ __vsf_component_peda_private_entry() [1/2]

__vsf_component_peda_private_entry ( __vk_mal_read_stream  )

◆ __vsf_component_peda_private_entry() [2/2]

__vsf_component_peda_private_entry ( __vk_mal_write_stream  )

◆ 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 
)

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 
)

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