1 /*
2 * Copyright 2007, Haiku Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 * Michael Lotz <mmlr@mlotz.ch>
7 */
8 #include <module.h>
9 #include <device_manager.h>
10 #include <bus/SCSI.h>
11
12
13 #define MODULE_NAME "example_scsi"
14
15
16 static scsi_for_sim_interface *sSimInterface;
17 static device_manager_info *sDeviceManager;
18
19
20 // module functions
21 static status_t
example_std_ops(int32 op,...)22 example_std_ops(int32 op, ...)
23 {
24 dprintf(MODULE_NAME": std ops\n");
25
26 switch (op) {
27 case B_MODULE_INIT: {
28 dprintf(MODULE_NAME": B_MODULE_INIT\n");
29 return B_OK;
30 }
31
32 case B_MODULE_UNINIT: {
33 dprintf(MODULE_NAME": B_MODULE_UNINIT\n");
34 return B_OK;
35 }
36 }
37
38 return B_ERROR;
39 }
40
41
42 // driver functions
43 static float
example_supports_device(device_node_handle parent,bool * noConnection)44 example_supports_device(device_node_handle parent, bool *noConnection)
45 {
46 dprintf(MODULE_NAME": supports device\n");
47 return 0.0f;
48 }
49
50
51 static status_t
example_register_device(device_node_handle parent)52 example_register_device(device_node_handle parent)
53 {
54 dprintf(MODULE_NAME": register device\n");
55 return B_OK;
56 }
57
58
59 static status_t
example_init_driver(device_node_handle node,void * userCookie,void ** cookie)60 example_init_driver(device_node_handle node, void *userCookie, void **cookie)
61 {
62 dprintf(MODULE_NAME": init driver\n");
63 return B_OK;
64 }
65
66
67 static status_t
example_uninit_driver(void * cookie)68 example_uninit_driver(void *cookie)
69 {
70 dprintf(MODULE_NAME": uninit driver\n");
71 return B_OK;
72 }
73
74
75 static void
example_device_removed(device_node_handle node,void * cookie)76 example_device_removed(device_node_handle node, void *cookie)
77 {
78 dprintf(MODULE_NAME": device removed\n");
79 }
80
81
82 static void
example_device_cleanup(device_node_handle node)83 example_device_cleanup(device_node_handle node)
84 {
85 dprintf(MODULE_NAME": device cleanup\n");
86 }
87
88
89 static void
example_get_supported_paths(const char *** busses,const char *** devices)90 example_get_supported_paths(const char ***busses, const char ***devices)
91 {
92 static const char *sBusses[] = { "pci", NULL };
93 static const char *sDevices[] = { "drivers/dev/example", NULL };
94
95 dprintf(MODULE_NAME": get supported paths\n");
96 *busses = sBusses;
97 *devices = sDevices;
98 }
99
100
101 // sim functions
102 static void
example_scsi_io(scsi_sim_cookie cookie,scsi_ccb * ccb)103 example_scsi_io(scsi_sim_cookie cookie, scsi_ccb *ccb)
104 {
105 dprintf(MODULE_NAME": scsi io\n");
106 }
107
108
109 static uchar
example_abort(scsi_sim_cookie cookie,scsi_ccb * ccbToAbort)110 example_abort(scsi_sim_cookie cookie, scsi_ccb *ccbToAbort)
111 {
112 dprintf(MODULE_NAME": abort\n");
113 return 0;
114 }
115
116
117 static uchar
example_reset_device(scsi_sim_cookie cookie,uchar targetID,uchar targetLUN)118 example_reset_device(scsi_sim_cookie cookie, uchar targetID, uchar targetLUN)
119 {
120 dprintf(MODULE_NAME": reset device\n");
121 return 0;
122 }
123
124
125 static uchar
example_term_io(scsi_sim_cookie cookie,scsi_ccb * ccbToTerminate)126 example_term_io(scsi_sim_cookie cookie, scsi_ccb *ccbToTerminate)
127 {
128 dprintf(MODULE_NAME": terminate io\n");
129 return 0;
130 }
131
132
133 static uchar
example_path_inquiry(scsi_sim_cookie cookie,scsi_path_inquiry * inquiryData)134 example_path_inquiry(scsi_sim_cookie cookie, scsi_path_inquiry *inquiryData)
135 {
136 dprintf(MODULE_NAME": path inquiry\n");
137 return 0;
138 }
139
140
141 static uchar
example_scan_bus(scsi_sim_cookie cookie)142 example_scan_bus(scsi_sim_cookie cookie)
143 {
144 dprintf(MODULE_NAME": scan bus\n");
145 return 0;
146 }
147
148
149 static uchar
example_reset_bus(scsi_sim_cookie cookie)150 example_reset_bus(scsi_sim_cookie cookie)
151 {
152 dprintf(MODULE_NAME": reset bus\n");
153 return 0;
154 }
155
156
157 static void
example_get_restrictions(scsi_sim_cookie cookie,uchar targetID,bool * isATAPI,bool * noAutosense,uint32 * maxBlocks)158 example_get_restrictions(scsi_sim_cookie cookie, uchar targetID, bool *isATAPI,
159 bool *noAutosense, uint32 *maxBlocks)
160 {
161 dprintf(MODULE_NAME": get restrictions\n");
162 }
163
164
165 static status_t
example_ioctl(scsi_sim_cookie cookie,uint8 targetID,uint32 op,void * buffer,size_t bufferLength)166 example_ioctl(scsi_sim_cookie cookie, uint8 targetID, uint32 op, void *buffer,
167 size_t bufferLength)
168 {
169 dprintf(MODULE_NAME": io control\n");
170 return B_ERROR;
171 }
172
173
174 // module management
175 module_dependency module_dependencies[] = {
176 { SCSI_FOR_SIM_MODULE_NAME, (module_info **)&sSimInterface },
177 { B_DEVICE_MANAGER_MODULE_NAME, (module_info **)&sDeviceManager },
178 {}
179 };
180
181
182 scsi_sim_interface example_sim = {
183 { // driver_module_info
184 { // module_info
185 "busses/scsi/example/v1", // module name
186 0, // module flags
187 example_std_ops // module standard ops
188 },
189
190 example_supports_device, // supports device
191 example_register_device, // register device
192
193 example_init_driver, // init driver
194 example_uninit_driver, // uninit driver
195
196 example_device_removed, // device removed
197 example_device_cleanup, // device cleanup
198
199 example_get_supported_paths // get supported paths
200 },
201
202 example_scsi_io, // scsi io
203 example_abort, // abort
204 example_reset_device, // reset device
205 example_term_io, // terminate io
206
207 example_path_inquiry, // path inquiry
208 example_scan_bus, // scan bus
209 example_reset_bus, // reset bus
210
211 example_get_restrictions, // get restrictions
212
213 example_ioctl // io control
214 };
215
216
217 module_info *modules[] = {
218 (module_info *)&example_sim,
219 NULL
220 };
221