VSF Documented
vsf_virtual_scsi.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_VIRTUAL_SCSI_H__
19#define __VSF_VIRTUAL_SCSI_H__
20
21/*============================ INCLUDES ======================================*/
22
23#include "../../vsf_scsi_cfg.h"
24
25#if VSF_USE_SCSI == ENABLED && VSF_SCSI_USE_VIRTUAL_SCSI == ENABLED
26
27#if defined(__VSF_VIRTUAL_SCSI_CLASS_IMPLEMENT)
28# define __VSF_CLASS_IMPLEMENT__
29#elif defined(__VSF_VIRTUAL_SCSI_CLASS_INHERIT__)
30# define __VSF_CLASS_INHERIT__
31#endif
32
33#include "utilities/ooc_class.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/*============================ MACROS ========================================*/
40/*============================ MACROFIED FUNCTIONS ===========================*/
41/*============================ TYPES =========================================*/
42
45
50
52 protected_member(
53 uint8_t drv_type : 4;
54 uint8_t feature : 4;
55 union {
56 struct {
57 bool (*buffer)(vk_scsi_t *scsi, bool is_read, uint_fast64_t addr, uint_fast32_t size, vsf_mem_t *mem);
58 void (*init)(void);
59 void (*read)(void);
60 void (*write)(void);
61 };
62 struct {
63 bool (*buffer)(vk_scsi_t *scsi, bool is_read, uint_fast64_t addr, uint_fast32_t size, vsf_mem_t *mem);
64 vsf_err_t (*init)(vk_scsi_t *scsi);
67 } normal;
68 struct {
69 bool (*buffer)(vk_scsi_t *scsi, bool is_read, uint_fast64_t addr, uint_fast32_t size, vsf_mem_t *mem);
73 } param_subcall;
74 };
75 )
76};
77
78typedef enum scsi_pdt_t {
82
86 char vendor[8];
87 char product[16];
88 char revision[4];
89 char *serial;
93
95 implement(vk_scsi_t)
96 public_member(
97 const vk_virtual_scsi_drv_t *virtual_scsi_drv;
98 )
99
100 protected_member(
101 union {
102 uint8_t reply[36];
103 };
104
105#if VSF_USE_SIMPLE_STREAM == ENABLED
106 bool is_stream;
107#endif
108 scsi_sensekey_t sense_key;
109 scsi_asc_t asc;
111};
112
113#if defined(__VSF_VIRTUAL_SCSI_CLASS_IMPLEMENT) || defined(__VSF_VIRTUAL_SCSI_CLASS_INHERIT__)
114__vsf_component_peda_ifs(vk_virtual_scsi_init)
115__vsf_component_peda_ifs(vk_virtual_scsi_read,
116 uint64_t addr;
118 void *mem_stream;
119)
120__vsf_component_peda_ifs(vk_virtual_scsi_write,
121 uint64_t addr;
123 void *mem_stream;
124)
125#endif
126
127/*============================ GLOBAL VARIABLES ==============================*/
128
130
131/*============================ PROTOTYPES ====================================*/
132
133#ifdef __cplusplus
134}
135#endif
136
137#undef __VSF_VIRTUAL_SCSI_CLASS_IMPLEMENT
138#undef __VSF_VIRTUAL_SCSI_CLASS_INHERIT__
139
140#endif // VSF_USE_SCSI && VSF_SCSI_USE_VIRTUAL_SCSI
141#endif // __VSF_MAL_SCSI_H__
vsf_err_t
Definition __type.h:42
bool
Definition type.h:60
Definition vsf_scsi.h:133
Definition vsf_scsi.h:146
Definition vsf_virtual_scsi.h:51
Definition vsf_virtual_scsi.h:94
#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
int int_fast32_t
Definition stdint.h:26
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 vsf_virtual_scsi.h:83
char revision[4]
Definition vsf_virtual_scsi.h:88
scsi_pdt_t type
Definition vsf_virtual_scsi.h:91
bool removable
Definition vsf_virtual_scsi.h:90
char product[16]
Definition vsf_virtual_scsi.h:87
uint32_t block_size
Definition vsf_virtual_scsi.h:84
char vendor[8]
Definition vsf_virtual_scsi.h:86
char * serial
Definition vsf_virtual_scsi.h:89
uint32_t block_num
Definition vsf_virtual_scsi.h:85
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
uint32_t size
Definition vsf_memfs.h:50
scsi_asc_t
Definition vsf_scsi.h:74
scsi_sensekey_t
This module provides SCSI device class which can execute SCSI commands. !
Definition vsf_scsi.h:57
scsi_pdt_t
Definition vsf_virtual_scsi.h:78
@ SCSI_PDT_CD_DVD
Definition vsf_virtual_scsi.h:80
@ SCSI_PDT_DIRECT_ACCESS_BLOCK
Definition vsf_virtual_scsi.h:79
vsf_virtual_scsi_drv_type_t
Definition vsf_virtual_scsi.h:46
@ VSF_VIRTUAL_SCSI_DRV_NORMAL
Definition vsf_virtual_scsi.h:47
@ VSF_VIRTUAL_SCSI_DRV_PARAM_SUBCALL
Definition vsf_virtual_scsi.h:48
const vk_scsi_drv_t vk_virtual_scsi_drv