2 * Copyright 2002-04, Thomas Kurschel. All rights reserved.
3 * Distributed under the terms of the MIT License.
7 //! Devfs entry for raw bus access.
10 #include "scsi_internal.h"
16 #include <device/scsi_bus_raw_driver.h>
20 // (used both as bus cookie and file handle cookie)
21 typedef struct bus_raw_info
{
22 scsi_bus_interface
*interface
;
29 scsi_bus_raw_init(void *driverCookie
, void **_cookie
)
31 device_node
*node
= (device_node
*)driverCookie
;
35 bus
= (bus_raw_info
*)malloc(sizeof(*bus
));
39 parent
= pnp
->get_parent_node(node
);
40 pnp
->get_driver(parent
,
41 (driver_module_info
**)&bus
->interface
, (void **)&bus
->cookie
);
42 pnp
->put_node(parent
);
52 scsi_bus_raw_uninit(void *bus
)
59 scsi_bus_raw_open(void *bus
, const char *path
, int openMode
,
68 scsi_bus_raw_close(void *cookie
)
75 scsi_bus_raw_free(void *cookie
)
82 scsi_bus_raw_control(void *_cookie
, uint32 op
, void *data
, size_t length
)
84 bus_raw_info
*bus
= (bus_raw_info
*)_cookie
;
87 case B_SCSI_BUS_RAW_RESET
:
88 return bus
->interface
->reset_bus(bus
->cookie
);
90 case B_SCSI_BUS_RAW_PATH_INQUIRY
:
91 return bus
->interface
->path_inquiry(bus
->cookie
,
92 (scsi_path_inquiry
*)data
);
100 scsi_bus_raw_read(void *cookie
, off_t position
, void *data
,
109 scsi_bus_raw_write(void *cookie
, off_t position
,
110 const void *data
, size_t *numBytes
)
117 struct device_module_info gSCSIBusRawModule
= {
119 SCSI_BUS_RAW_MODULE_NAME
,
134 scsi_bus_raw_control
,