BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / bus_managers / scsi / bus_raw.cpp
blobc28e3b5786b08094e0ae7eedbcb0c2a918c2a80e
1 /*
2 * Copyright 2002-04, Thomas Kurschel. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 */
7 //! Devfs entry for raw bus access.
10 #include "scsi_internal.h"
12 #include <stdlib.h>
13 #include <stdio.h>
14 #include <string.h>
16 #include <device/scsi_bus_raw_driver.h>
19 // info about bus
20 // (used both as bus cookie and file handle cookie)
21 typedef struct bus_raw_info {
22 scsi_bus_interface *interface;
23 scsi_bus cookie;
24 device_node *node;
25 } bus_raw_info;
28 static status_t
29 scsi_bus_raw_init(void *driverCookie, void **_cookie)
31 device_node *node = (device_node *)driverCookie;
32 device_node *parent;
33 bus_raw_info *bus;
35 bus = (bus_raw_info*)malloc(sizeof(*bus));
36 if (bus == NULL)
37 return B_NO_MEMORY;
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);
44 bus->node = node;
46 *_cookie = bus;
47 return B_OK;
51 static void
52 scsi_bus_raw_uninit(void *bus)
54 free(bus);
58 static status_t
59 scsi_bus_raw_open(void *bus, const char *path, int openMode,
60 void **handle_cookie)
62 *handle_cookie = bus;
63 return B_OK;
67 static status_t
68 scsi_bus_raw_close(void *cookie)
70 return B_OK;
74 static status_t
75 scsi_bus_raw_free(void *cookie)
77 return B_OK;
81 static status_t
82 scsi_bus_raw_control(void *_cookie, uint32 op, void *data, size_t length)
84 bus_raw_info *bus = (bus_raw_info*)_cookie;
86 switch (op) {
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);
95 return B_ERROR;
99 static status_t
100 scsi_bus_raw_read(void *cookie, off_t position, void *data,
101 size_t *numBytes)
103 *numBytes = 0;
104 return B_ERROR;
108 static status_t
109 scsi_bus_raw_write(void *cookie, off_t position,
110 const void *data, size_t *numBytes)
112 *numBytes = 0;
113 return B_ERROR;
117 struct device_module_info gSCSIBusRawModule = {
119 SCSI_BUS_RAW_MODULE_NAME,
121 NULL
124 scsi_bus_raw_init,
125 scsi_bus_raw_uninit,
126 NULL, // removed
128 scsi_bus_raw_open,
129 scsi_bus_raw_close,
130 scsi_bus_raw_free,
131 scsi_bus_raw_read,
132 scsi_bus_raw_write,
133 NULL, // io
134 scsi_bus_raw_control,
135 NULL, // select
136 NULL // deselect