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
16static scsi_for_sim_interface *sSimInterface;
17static device_manager_info *sDeviceManager;
18
19
20// module functions
21static status_t
22example_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
43static float
44example_supports_device(device_node_handle parent, bool *noConnection)
45{
46	dprintf(MODULE_NAME": supports device\n");
47	return 0.0f;
48}
49
50
51static status_t
52example_register_device(device_node_handle parent)
53{
54	dprintf(MODULE_NAME": register device\n");
55	return B_OK;
56}
57
58
59static status_t
60example_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
67static status_t
68example_uninit_driver(void *cookie)
69{
70	dprintf(MODULE_NAME": uninit driver\n");
71	return B_OK;
72}
73
74
75static void
76example_device_removed(device_node_handle node, void *cookie)
77{
78	dprintf(MODULE_NAME": device removed\n");
79}
80
81
82static void
83example_device_cleanup(device_node_handle node)
84{
85	dprintf(MODULE_NAME": device cleanup\n");
86}
87
88
89static void
90example_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
102static void
103example_scsi_io(scsi_sim_cookie cookie, scsi_ccb *ccb)
104{
105	dprintf(MODULE_NAME": scsi io\n");
106}
107
108
109static uchar
110example_abort(scsi_sim_cookie cookie, scsi_ccb *ccbToAbort)
111{
112	dprintf(MODULE_NAME": abort\n");
113	return 0;
114}
115
116
117static uchar
118example_reset_device(scsi_sim_cookie cookie, uchar targetID, uchar targetLUN)
119{
120	dprintf(MODULE_NAME": reset device\n");
121	return 0;
122}
123
124
125static uchar
126example_term_io(scsi_sim_cookie cookie, scsi_ccb *ccbToTerminate)
127{
128	dprintf(MODULE_NAME": terminate io\n");
129	return 0;
130}
131
132
133static uchar
134example_path_inquiry(scsi_sim_cookie cookie, scsi_path_inquiry *inquiryData)
135{
136	dprintf(MODULE_NAME": path inquiry\n");
137	return 0;
138}
139
140
141static uchar
142example_scan_bus(scsi_sim_cookie cookie)
143{
144	dprintf(MODULE_NAME": scan bus\n");
145	return 0;
146}
147
148
149static uchar
150example_reset_bus(scsi_sim_cookie cookie)
151{
152	dprintf(MODULE_NAME": reset bus\n");
153	return 0;
154}
155
156
157static void
158example_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
165static status_t
166example_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
175module_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
182scsi_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
217module_info *modules[] = {
218	(module_info *)&example_sim,
219	NULL
220};
221