VSF Documented
vsf_mal.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18#ifndef __VSF_MAL_H__
19#define __VSF_MAL_H__
20
41/*============================ INCLUDES ======================================*/
42
43#include "./vsf_mal_cfg.h"
44
45#if VSF_USE_MAL == ENABLED
46
47#include "kernel/vsf_kernel.h"
48
49#if defined(__VSF_MAL_CLASS_IMPLEMENT)
50# define __VSF_CLASS_IMPLEMENT__
51#elif defined(__VSF_MAL_CLASS_INHERIT__)
52# define __VSF_CLASS_INHERIT__
53#endif
54
55#include "utilities/ooc_class.h"
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
61/*============================ MACROS ========================================*/
62
63#if VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL != ENABLED
64# error VSF_KERNEL_CFG_EDA_SUPPORT_SUB_CALL is needed to use mal
65#endif
66
67/*============================ MACROFIED FUNCTIONS ===========================*/
68/*============================ TYPES =========================================*/
69
71#if VSF_USE_SIMPLE_STREAM == ENABLED
73#endif
74
76
82
90
91typedef struct vsf_mal_capability_t {
92 // alignment in bytes, 1 byte alignment if 0
93 uint16_t data_ptr_alignment; // default for read and write
94 uint16_t data_size_alignment; // alignment of data size
95 // direction-specific pointer alignment, 0 inherits data_ptr_alignment
99
108 protected_member(
122 bool (*buffer)(vk_mal_t *mal, uint_fast64_t addr, uint_fast32_t size, vsf_mal_op_t op, vsf_mem_t *mem);
130
131 uint8_t init_local_size;
132 uint8_t fini_local_size;
133 uint8_t erase_local_size;
134 uint8_t read_local_size;
135 uint8_t write_local_size;
162};
163
172 public_member(
177 const vk_mal_drv_t *drv;
182 void *param;
192 uint8_t feature;
194};
195
196#if VSF_USE_SIMPLE_STREAM == ENABLED
205 public_member(
210 vk_mal_t *mal;
212 protected_member(
213 uint64_t addr;
215 uint32_t rw_size;
216 vsf_stream_t *stream;
217 uint32_t cur_size;
218 uint8_t *cur_buff;
219 vsf_eda_t *cur_eda;
221};
222#endif
223
224#if defined(__VSF_MAL_CLASS_IMPLEMENT) || defined(__VSF_MAL_CLASS_INHERIT__)
228 uint64_t addr;
230)
232 uint64_t addr;
234 uint8_t *buff;
235 uint32_t rsize;
236)
238 uint64_t addr;
240 uint8_t *buff;
242)
243#endif
244
267 public_member(
268 implement(vk_mal_t)
269
270 vk_mal_t *mal;
274};
275#endif
276
277/*============================ GLOBAL VARIABLES ==============================*/
278
279#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
288#endif
289
290/*============================ PROTOTYPES ====================================*/
291
321extern vsf_err_t vk_mal_init(vk_mal_t *pthis);
322
336extern vsf_err_t vk_mal_fini(vk_mal_t *pthis);
337
356
376extern 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);
377
390
409
434
459
460#if VSF_USE_SIMPLE_STREAM == ENABLED
487
514#endif
515
516#ifdef __cplusplus
517}
518#endif
519
520/*============================ INCLUDES ======================================*/
521
530
531#undef __VSF_MAL_CLASS_IMPLEMENT
532#undef __VSF_MAL_CLASS_INHERIT__
533
534#endif // VSF_USE_MAL
535#endif // __VSF_MAL_H__
#define ENABLED
Definition __type.h:28
vsf_err_t
Definition __type.h:42
bool
Definition type.h:60
mal driver
Definition vsf_mal.h:107
mal stream class
Definition vsf_mal.h:204
mal class
Definition vsf_mal.h:171
Definition vsf_mal.h:266
The event-driven task (TCB); every VSF task is an eda at the bottom. Tasks share stacks and only occu...
Definition vsf_eda.h:1838
Definition vsf_simple_stream.h:254
Sync object with an owner (mutex base); supports priority inheritance; the owner must leave it itself...
Definition vsf_eda.h:2009
__le16 capability
Definition ieee80211.h:134
#define vsf_dcl_class
Definition ooc_class.h:50
#define vsf_class(__name)
Definition ooc_class.h:52
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned int uint_fast32_t
Definition stdint.h:27
unsigned long long uint64_t
Definition stdint.h:11
unsigned long long uint_fast64_t
Definition stdint.h:29
unsigned char uint8_t
Definition stdint.h:5
Definition mutex.h:10
Definition vsf_mal.h:91
uint16_t data_size_alignment
Definition vsf_mal.h:94
uint16_t read_data_ptr_alignment
Definition vsf_mal.h:96
uint16_t write_data_ptr_alignment
Definition vsf_mal.h:97
uint16_t data_ptr_alignment
Definition vsf_mal.h:93
#define read
Definition unistd.h:125
#define write
Definition unistd.h:126
#define __vsf_component_peda_ifs(__peda_name,...)
Definition vsf_component_cfg.h:62
#define vsf_peda_evthandler_t
Definition vsf_component_cfg.h:37
#define VSF_KERNEL_CFG_SUPPORT_SYNC
Definition vsf_kernel_cfg.h:46
struct vsf_mal_capability_t vsf_mal_capability_t
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.
Definition vsf_mal.c:479
vsf_mal_op_t
This module provides MAL(Memory Abstraction Layer) device class. !
Definition vsf_mal.h:77
@ VSF_MAL_OP_WRITE
Definition vsf_mal.h:80
@ VSF_MAL_OP_READ
Definition vsf_mal.h:79
@ VSF_MAL_OP_ERASE
Definition vsf_mal.h:78
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.
Definition vsf_mal.c:468
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.
Definition vsf_mal.c:112
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
vsf_mal_capability_t vk_mal_capability(vk_mal_t *pthis)
get the capability of mal.
Definition vsf_mal.c:123
vsf_err_t vk_mal_fini(vk_mal_t *pthis)
prepare subcall to finalize a mal instance.
Definition vsf_mal.c:98
vsf_mal_feature_t
Definition vsf_mal.h:83
@ VSF_MAL_READABLE
Definition vsf_mal.h:84
@ VSF_MAL_LOCAL_BUFFER
Definition vsf_mal.h:88
@ VSF_MAL_ERASABLE
Definition vsf_mal.h:86
@ VSF_MAL_WRITABLE
Definition vsf_mal.h:85
@ VSF_MAL_NON_UNIFIED_BLOCK
Definition vsf_mal.h:87
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.
Definition vsf_mal.c:136
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.
Definition vsf_mal.c:106
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.
Definition vsf_mal.c:147
vsf_err_t vk_mal_init(vk_mal_t *pthis)
prepare subcall to initialize a mal instance.
Definition vsf_mal.c:90
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.
Definition vsf_mal.c:159
uint32_t wsize
Definition vsf_memfs.h:52
uint64_t offset
Definition vsf_memfs.h:49
uint8_t * buff
Definition vsf_memfs.h:51
uint32_t size
Definition vsf_memfs.h:50
Generated from commit: vsfteam/vsf@c46986d