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
99 protected_member(
113 bool (*buffer)(vk_mal_t *mal, uint_fast64_t addr, uint_fast32_t size, vsf_mal_op_t op, vsf_mem_t *mem);
114 uint8_t init_local_size;
115 uint8_t fini_local_size;
116 uint8_t erase_local_size;
117 uint8_t read_local_size;
118 uint8_t write_local_size;
145};
146
155 public_member(
160 const vk_mal_drv_t *drv;
165 void *param;
175 uint8_t feature;
177};
178
179#if VSF_USE_SIMPLE_STREAM == ENABLED
188 public_member(
193 vk_mal_t *mal;
195 protected_member(
196 uint64_t addr;
198 uint32_t rw_size;
199 vsf_stream_t *stream;
200 uint32_t cur_size;
201 uint8_t *cur_buff;
202 vsf_eda_t *cur_eda;
204};
205#endif
206
207#if defined(__VSF_MAL_CLASS_IMPLEMENT) || defined(__VSF_MAL_CLASS_INHERIT__)
211 uint64_t addr;
213)
215 uint64_t addr;
217 uint8_t *buff;
218 uint32_t rsize;
219)
221 uint64_t addr;
223 uint8_t *buff;
225)
226#endif
227
250 public_member(
251 implement(vk_mal_t)
252
253 vk_mal_t *mal;
257};
258#endif
259
260/*============================ GLOBAL VARIABLES ==============================*/
261
262#if VSF_KERNEL_CFG_SUPPORT_SYNC == ENABLED
271#endif
272
273/*============================ PROTOTYPES ====================================*/
274
304extern vsf_err_t vk_mal_init(vk_mal_t *pthis);
305
319extern vsf_err_t vk_mal_fini(vk_mal_t *pthis);
320
339
360
379
404
429
430#if VSF_USE_SIMPLE_STREAM == ENABLED
457
484#endif
485
486#ifdef __cplusplus
487}
488#endif
489
490/*============================ INCLUDES ======================================*/
491
500
501#undef __VSF_MAL_CLASS_IMPLEMENT
502#undef __VSF_MAL_CLASS_INHERIT__
503
504#endif // VSF_USE_MAL
505#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:98
mal stream class
Definition vsf_mal.h:187
mal class
Definition vsf_mal.h:154
Definition vsf_mal.h:249
Definition vsf_eda.h:766
Definition vsf_simple_stream.h:254
Definition vsf_eda.h:892
#define vsf_dcl_class
Definition ooc_class.h:46
#define vsf_class(__name)
Definition ooc_class.h:48
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_utilities.h:51
#define read
Definition unistd.h:122
#define write
Definition unistd.h:123
#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:453
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:442
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:110
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_err_t vk_mal_fini(vk_mal_t *pthis)
prepare subcall to finialize a mal instance.
Definition vsf_mal.c:96
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:122
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:104
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:133
vsf_err_t vk_mal_init(vk_mal_t *pthis)
prepare subcall to initialize a mal instance.
Definition vsf_mal.c:88
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:145
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