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
77typedef enum vsf_mal_op_t {
82
83typedef enum vsf_mal_feature_t {
90
91typedef struct vsf_mal_capability_t {
92 // alignment in bytes, 1 byte alignment if 0
93 uint16_t data_ptr_alignment; // alignment of data pointer
94 uint16_t data_size_alignment; // alignment of data size
96
105 protected_member(
119 bool (*buffer)(vk_mal_t *mal, uint_fast64_t addr, uint_fast32_t size, vsf_mal_op_t op, vsf_mem_t *mem);
127
128 uint8_t init_local_size;
129 uint8_t fini_local_size;
130 uint8_t erase_local_size;
131 uint8_t read_local_size;
132 uint8_t write_local_size;
159};
160
169 public_member(
174 const vk_mal_drv_t *drv;
179 void *param;
189 uint8_t feature;
191};
192
193#if VSF_USE_SIMPLE_STREAM == ENABLED
202 public_member(
207 vk_mal_t *mal;
209 protected_member(
210 uint64_t addr;
212 uint32_t rw_size;
213 vsf_stream_t *stream;
214 uint32_t cur_size;
215 uint8_t *cur_buff;
216 vsf_eda_t *cur_eda;
218};
219#endif
220
221#if defined(__VSF_MAL_CLASS_IMPLEMENT) || defined(__VSF_MAL_CLASS_INHERIT__)
225 uint64_t addr;
227)
229 uint64_t addr;
231 uint8_t *buff;
232 uint32_t rsize;
233)
235 uint64_t addr;
237 uint8_t *buff;
239)
240#endif
241
264 public_member(
265 implement(vk_mal_t)
266
267 vk_mal_t *mal;
271};
272#endif
273
274/*============================ GLOBAL VARIABLES ==============================*/
275
276#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
285#endif
286
287/*============================ PROTOTYPES ====================================*/
288
318extern vsf_err_t vk_mal_init(vk_mal_t *pthis);
319
333extern vsf_err_t vk_mal_fini(vk_mal_t *pthis);
334
353
374
387
406
431
456
457#if VSF_USE_SIMPLE_STREAM == ENABLED
484
511#endif
512
513#ifdef __cplusplus
514}
515#endif
516
517/*============================ INCLUDES ======================================*/
518
527
528#undef __VSF_MAL_CLASS_IMPLEMENT
529#undef __VSF_MAL_CLASS_INHERIT__
530
531#endif // VSF_USE_MAL
532#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:104
mal stream class
Definition vsf_mal.h:201
mal class
Definition vsf_mal.h:168
Definition vsf_mal.h:263
Definition vsf_eda.h:766
Definition vsf_simple_stream.h:254
Definition vsf_eda.h:892
__le16 capability
Definition ieee80211.h:134
unsigned short uint16_t
Definition lvgl.h:41
unsigned int uint32_t
Definition lvgl.h:43
unsigned char uint8_t
Definition lvgl.h:40
#define vsf_dcl_class
Definition ooc_class.h:46
#define vsf_class(__name)
Definition ooc_class.h:48
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
Definition mutex.h:10
Definition vsf_mal.h:91
uint16_t data_size_alignment
Definition vsf_mal.h:94
uint16_t data_ptr_alignment
Definition vsf_mal.h:93
Definition vsf_utilities.h:51
#define read
Definition unistd.h:124
#define write
Definition unistd.h:125
#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
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:473
vsf_mal_op_t
This module provides MAL(Memory Abstraction Layser) 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:462
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 finialize 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