[2715978] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Vojtech Horky
|
---|
[ff65e91] | 3 | * Copyright (c) 2011 Jiri Svoboda
|
---|
[2715978] | 4 | * All rights reserved.
|
---|
| 5 | *
|
---|
| 6 | * Redistribution and use in source and binary forms, with or without
|
---|
| 7 | * modification, are permitted provided that the following conditions
|
---|
| 8 | * are met:
|
---|
| 9 | *
|
---|
| 10 | * - Redistributions of source code must retain the above copyright
|
---|
| 11 | * notice, this list of conditions and the following disclaimer.
|
---|
| 12 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 13 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 14 | * documentation and/or other materials provided with the distribution.
|
---|
| 15 | * - The name of the author may not be used to endorse or promote products
|
---|
| 16 | * derived from this software without specific prior written permission.
|
---|
| 17 | *
|
---|
| 18 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 19 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 20 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 21 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 22 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 23 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 24 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 25 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 26 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 27 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 28 | */
|
---|
| 29 |
|
---|
| 30 | /** @addtogroup drvusbmast
|
---|
| 31 | * @{
|
---|
| 32 | */
|
---|
| 33 | /**
|
---|
| 34 | * @file
|
---|
| 35 | * Main routines of USB mass storage driver.
|
---|
| 36 | */
|
---|
[58563585] | 37 |
|
---|
[ff65e91] | 38 | #include <as.h>
|
---|
| 39 | #include <async.h>
|
---|
[4802dd7] | 40 | #include <bd_srv.h>
|
---|
[ff65e91] | 41 | #include <macros.h>
|
---|
[7d521e24] | 42 | #include <usb/dev/driver.h>
|
---|
[2715978] | 43 | #include <usb/debug.h>
|
---|
| 44 | #include <usb/classes/classes.h>
|
---|
| 45 | #include <usb/classes/massstor.h>
|
---|
| 46 | #include <errno.h>
|
---|
[7a1757e] | 47 | #include <io/logctl.h>
|
---|
[2715978] | 48 | #include <str_error.h>
|
---|
[89d3f3c7] | 49 | #include "cmdw.h"
|
---|
| 50 | #include "bo_trans.h"
|
---|
[6430ac6] | 51 | #include "scsi_ms.h"
|
---|
[7190bbc] | 52 | #include "usbmast.h"
|
---|
[2715978] | 53 |
|
---|
| 54 | #define NAME "usbmast"
|
---|
| 55 |
|
---|
[9871bca] | 56 | static const usb_endpoint_description_t bulk_in_ep = {
|
---|
[2715978] | 57 | .transfer_type = USB_TRANSFER_BULK,
|
---|
| 58 | .direction = USB_DIRECTION_IN,
|
---|
| 59 | .interface_class = USB_CLASS_MASS_STORAGE,
|
---|
| 60 | .interface_subclass = USB_MASSSTOR_SUBCLASS_SCSI,
|
---|
| 61 | .interface_protocol = USB_MASSSTOR_PROTOCOL_BBB,
|
---|
| 62 | .flags = 0
|
---|
| 63 | };
|
---|
[9871bca] | 64 | static const usb_endpoint_description_t bulk_out_ep = {
|
---|
[2715978] | 65 | .transfer_type = USB_TRANSFER_BULK,
|
---|
| 66 | .direction = USB_DIRECTION_OUT,
|
---|
| 67 | .interface_class = USB_CLASS_MASS_STORAGE,
|
---|
| 68 | .interface_subclass = USB_MASSSTOR_SUBCLASS_SCSI,
|
---|
| 69 | .interface_protocol = USB_MASSSTOR_PROTOCOL_BBB,
|
---|
| 70 | .flags = 0
|
---|
| 71 | };
|
---|
| 72 |
|
---|
[b803845] | 73 | static const usb_endpoint_description_t *mast_endpoints[] = {
|
---|
[2715978] | 74 | &bulk_in_ep,
|
---|
| 75 | &bulk_out_ep,
|
---|
| 76 | NULL
|
---|
| 77 | };
|
---|
| 78 |
|
---|
[2aceec5] | 79 | static int usbmast_fun_create(usbmast_dev_t *mdev, unsigned lun);
|
---|
[ff65e91] | 80 | static void usbmast_bd_connection(ipc_callid_t iid, ipc_call_t *icall,
|
---|
| 81 | void *arg);
|
---|
| 82 |
|
---|
[135486d] | 83 | static int usbmast_bd_open(bd_srvs_t *, bd_srv_t *);
|
---|
[4802dd7] | 84 | static int usbmast_bd_close(bd_srv_t *);
|
---|
| 85 | static int usbmast_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
|
---|
[dd8b6a8] | 86 | static int usbmast_bd_sync_cache(bd_srv_t *, aoff64_t, size_t);
|
---|
[4802dd7] | 87 | static int usbmast_bd_write_blocks(bd_srv_t *, aoff64_t, size_t, const void *, size_t);
|
---|
| 88 | static int usbmast_bd_get_block_size(bd_srv_t *, size_t *);
|
---|
| 89 | static int usbmast_bd_get_num_blocks(bd_srv_t *, aoff64_t *);
|
---|
| 90 |
|
---|
| 91 | static bd_ops_t usbmast_bd_ops = {
|
---|
| 92 | .open = usbmast_bd_open,
|
---|
| 93 | .close = usbmast_bd_close,
|
---|
| 94 | .read_blocks = usbmast_bd_read_blocks,
|
---|
[dd8b6a8] | 95 | .sync_cache = usbmast_bd_sync_cache,
|
---|
[4802dd7] | 96 | .write_blocks = usbmast_bd_write_blocks,
|
---|
| 97 | .get_block_size = usbmast_bd_get_block_size,
|
---|
| 98 | .get_num_blocks = usbmast_bd_get_num_blocks
|
---|
| 99 | };
|
---|
| 100 |
|
---|
| 101 | static usbmast_fun_t *bd_srv_usbmast(bd_srv_t *bd)
|
---|
| 102 | {
|
---|
[f73b291] | 103 | return (usbmast_fun_t *) bd->srvs->sarg;
|
---|
[4802dd7] | 104 | }
|
---|
| 105 |
|
---|
[3002434] | 106 | /** Callback when a device is removed from the system.
|
---|
| 107 | *
|
---|
| 108 | * @param dev Representation of USB device.
|
---|
| 109 | * @return Error code.
|
---|
| 110 | */
|
---|
| 111 | static int usbmast_device_gone(usb_device_t *dev)
|
---|
| 112 | {
|
---|
[c39e9fb] | 113 | usbmast_dev_t *mdev = usb_device_data_get(dev);
|
---|
[3002434] | 114 | assert(mdev);
|
---|
| 115 |
|
---|
| 116 | for (size_t i = 0; i < mdev->lun_count; ++i) {
|
---|
| 117 | const int rc = ddf_fun_unbind(mdev->luns[i]);
|
---|
| 118 | if (rc != EOK) {
|
---|
| 119 | usb_log_error("Failed to unbind LUN function %zu: "
|
---|
| 120 | "%s\n", i, str_error(rc));
|
---|
| 121 | return rc;
|
---|
| 122 | }
|
---|
| 123 | ddf_fun_destroy(mdev->luns[i]);
|
---|
| 124 | mdev->luns[i] = NULL;
|
---|
| 125 | }
|
---|
| 126 | free(mdev->luns);
|
---|
| 127 | return EOK;
|
---|
| 128 | }
|
---|
| 129 |
|
---|
[9871bca] | 130 | /** Callback when a device is about to be removed.
|
---|
| 131 | *
|
---|
| 132 | * @param dev Representation of USB device.
|
---|
| 133 | * @return Error code.
|
---|
| 134 | */
|
---|
| 135 | static int usbmast_device_remove(usb_device_t *dev)
|
---|
| 136 | {
|
---|
| 137 | //TODO: flush buffers, or whatever.
|
---|
[dcc10b8d] | 138 | //TODO: remove device
|
---|
[9871bca] | 139 | return ENOTSUP;
|
---|
| 140 | }
|
---|
| 141 |
|
---|
[2715978] | 142 | /** Callback when new device is attached and recognized as a mass storage.
|
---|
| 143 | *
|
---|
[9871bca] | 144 | * @param dev Representation of USB device.
|
---|
[2715978] | 145 | * @return Error code.
|
---|
| 146 | */
|
---|
[1a4ea01d] | 147 | static int usbmast_device_add(usb_device_t *dev)
|
---|
[2715978] | 148 | {
|
---|
| 149 | int rc;
|
---|
[2aceec5] | 150 | usbmast_dev_t *mdev = NULL;
|
---|
| 151 | unsigned i;
|
---|
[2715978] | 152 |
|
---|
[3e23316] | 153 | usb_endpoint_mapping_t *epm_in =
|
---|
| 154 | usb_device_get_mapped_ep_desc(dev, &bulk_in_ep);
|
---|
| 155 | usb_endpoint_mapping_t *epm_out =
|
---|
| 156 | usb_device_get_mapped_ep_desc(dev, &bulk_out_ep);
|
---|
| 157 | if (!epm_in || !epm_out || !epm_in->present || !epm_out->present) {
|
---|
| 158 | usb_log_error("Required EPs were not mapped.\n");
|
---|
| 159 | return ENOENT;
|
---|
| 160 | }
|
---|
| 161 |
|
---|
[ff65e91] | 162 | /* Allocate softstate */
|
---|
[065064e6] | 163 | mdev = usb_device_data_alloc(dev, sizeof(usbmast_dev_t));
|
---|
[2aceec5] | 164 | if (mdev == NULL) {
|
---|
[ff65e91] | 165 | usb_log_error("Failed allocating softstate.\n");
|
---|
[d6c953e9] | 166 | return ENOMEM;
|
---|
[2715978] | 167 | }
|
---|
[ff65e91] | 168 |
|
---|
[2aceec5] | 169 | mdev->usb_dev = dev;
|
---|
[ff65e91] | 170 |
|
---|
[7c69861] | 171 | usb_log_info("Initializing mass storage `%s'.\n",
|
---|
| 172 | usb_device_get_name(dev));
|
---|
[b77931d] | 173 | usb_log_debug("Bulk in endpoint: %d [%zuB].\n",
|
---|
[816f5f4] | 174 | epm_in->pipe.desc.endpoint_no, epm_in->pipe.desc.max_packet_size);
|
---|
[2715978] | 175 | usb_log_debug("Bulk out endpoint: %d [%zuB].\n",
|
---|
[816f5f4] | 176 | epm_out->pipe.desc.endpoint_no, epm_out->pipe.desc.max_packet_size);
|
---|
[2715978] | 177 |
|
---|
[239e7e10] | 178 | usb_log_debug("Get LUN count...\n");
|
---|
[87037cc9] | 179 | mdev->lun_count = usb_masstor_get_lun_count(mdev);
|
---|
| 180 | mdev->luns = calloc(mdev->lun_count, sizeof(ddf_fun_t*));
|
---|
| 181 | if (mdev->luns == NULL) {
|
---|
| 182 | rc = ENOMEM;
|
---|
| 183 | usb_log_error("Failed allocating luns table.\n");
|
---|
| 184 | goto error;
|
---|
| 185 | }
|
---|
[239e7e10] | 186 |
|
---|
[3cc55b47] | 187 | mdev->bulk_in_pipe = &epm_in->pipe;
|
---|
| 188 | mdev->bulk_out_pipe = &epm_out->pipe;
|
---|
[87037cc9] | 189 | for (i = 0; i < mdev->lun_count; i++) {
|
---|
[2aceec5] | 190 | rc = usbmast_fun_create(mdev, i);
|
---|
| 191 | if (rc != EOK)
|
---|
| 192 | goto error;
|
---|
[ff65e91] | 193 | }
|
---|
| 194 |
|
---|
[2aceec5] | 195 | return EOK;
|
---|
| 196 | error:
|
---|
[3002434] | 197 | /* Destroy functions */
|
---|
| 198 | for (size_t i = 0; i < mdev->lun_count; ++i) {
|
---|
| 199 | if (mdev->luns[i] == NULL)
|
---|
| 200 | continue;
|
---|
| 201 | const int rc = ddf_fun_unbind(mdev->luns[i]);
|
---|
| 202 | if (rc != EOK) {
|
---|
| 203 | usb_log_warning("Failed to unbind LUN function %zu: "
|
---|
| 204 | "%s.\n", i, str_error(rc));
|
---|
| 205 | }
|
---|
| 206 | ddf_fun_destroy(mdev->luns[i]);
|
---|
| 207 | }
|
---|
| 208 | free(mdev->luns);
|
---|
[2aceec5] | 209 | return rc;
|
---|
| 210 | }
|
---|
| 211 |
|
---|
| 212 | /** Create mass storage function.
|
---|
| 213 | *
|
---|
| 214 | * Called once for each LUN.
|
---|
| 215 | *
|
---|
| 216 | * @param mdev Mass storage device
|
---|
| 217 | * @param lun LUN
|
---|
| 218 | * @return EOK on success or negative error code.
|
---|
| 219 | */
|
---|
| 220 | static int usbmast_fun_create(usbmast_dev_t *mdev, unsigned lun)
|
---|
| 221 | {
|
---|
| 222 | int rc;
|
---|
| 223 | char *fun_name = NULL;
|
---|
| 224 | ddf_fun_t *fun = NULL;
|
---|
| 225 | usbmast_fun_t *mfun = NULL;
|
---|
| 226 |
|
---|
| 227 | if (asprintf(&fun_name, "l%u", lun) < 0) {
|
---|
| 228 | usb_log_error("Out of memory.\n");
|
---|
| 229 | rc = ENOMEM;
|
---|
| 230 | goto error;
|
---|
| 231 | }
|
---|
| 232 |
|
---|
[7c69861] | 233 | fun = usb_device_ddf_fun_create(mdev->usb_dev, fun_exposed, fun_name);
|
---|
[2aceec5] | 234 | if (fun == NULL) {
|
---|
| 235 | usb_log_error("Failed to create DDF function %s.\n", fun_name);
|
---|
| 236 | rc = ENOMEM;
|
---|
| 237 | goto error;
|
---|
| 238 | }
|
---|
| 239 |
|
---|
[5f6e25e] | 240 | /* Allocate soft state */
|
---|
[d95f02ff] | 241 | mfun = ddf_fun_data_alloc(fun, sizeof(usbmast_fun_t));
|
---|
[5f6e25e] | 242 | if (mfun == NULL) {
|
---|
| 243 | usb_log_error("Failed allocating softstate.\n");
|
---|
| 244 | rc = ENOMEM;
|
---|
| 245 | goto error;
|
---|
| 246 | }
|
---|
| 247 |
|
---|
[87037cc9] | 248 | mfun->ddf_fun = fun;
|
---|
[5f6e25e] | 249 | mfun->mdev = mdev;
|
---|
| 250 | mfun->lun = lun;
|
---|
| 251 |
|
---|
[135486d] | 252 | bd_srvs_init(&mfun->bds);
|
---|
| 253 | mfun->bds.ops = &usbmast_bd_ops;
|
---|
| 254 | mfun->bds.sarg = mfun;
|
---|
[4802dd7] | 255 |
|
---|
[2aceec5] | 256 | /* Set up a connection handler. */
|
---|
[56fd7cf] | 257 | ddf_fun_set_conn_handler(fun, usbmast_bd_connection);
|
---|
[2aceec5] | 258 |
|
---|
[0feaae4] | 259 | usb_log_debug("Inquire...\n");
|
---|
[6430ac6] | 260 | usbmast_inquiry_data_t inquiry;
|
---|
[2aceec5] | 261 | rc = usbmast_inquiry(mfun, &inquiry);
|
---|
[70c12d6] | 262 | if (rc != EOK) {
|
---|
[0feaae4] | 263 | usb_log_warning("Failed to inquire device `%s': %s.\n",
|
---|
[7c69861] | 264 | usb_device_get_name(mdev->usb_dev), str_error(rc));
|
---|
[ff65e91] | 265 | rc = EIO;
|
---|
| 266 | goto error;
|
---|
[70c12d6] | 267 | }
|
---|
| 268 |
|
---|
[2aceec5] | 269 | usb_log_info("Mass storage `%s' LUN %u: " \
|
---|
| 270 | "%s by %s rev. %s is %s (%s).\n",
|
---|
[7c69861] | 271 | usb_device_get_name(mdev->usb_dev),
|
---|
[2aceec5] | 272 | lun,
|
---|
[7b2c17c] | 273 | inquiry.product,
|
---|
| 274 | inquiry.vendor,
|
---|
| 275 | inquiry.revision,
|
---|
[6430ac6] | 276 | usbmast_scsi_dev_type_str(inquiry.device_type),
|
---|
[2aceec5] | 277 | inquiry.removable ? "removable" : "non-removable");
|
---|
[7a5c8b8f] | 278 |
|
---|
[71fa44c] | 279 | uint32_t nblocks, block_size;
|
---|
| 280 |
|
---|
[2aceec5] | 281 | rc = usbmast_read_capacity(mfun, &nblocks, &block_size);
|
---|
[71fa44c] | 282 | if (rc != EOK) {
|
---|
| 283 | usb_log_warning("Failed to read capacity, device `%s': %s.\n",
|
---|
[7c69861] | 284 | usb_device_get_name(mdev->usb_dev), str_error(rc));
|
---|
[ff65e91] | 285 | rc = EIO;
|
---|
| 286 | goto error;
|
---|
[71fa44c] | 287 | }
|
---|
| 288 |
|
---|
| 289 | usb_log_info("Read Capacity: nblocks=%" PRIu32 ", "
|
---|
| 290 | "block_size=%" PRIu32 "\n", nblocks, block_size);
|
---|
| 291 |
|
---|
[2aceec5] | 292 | mfun->nblocks = nblocks;
|
---|
| 293 | mfun->block_size = block_size;
|
---|
[f7a55f9] | 294 |
|
---|
[ff65e91] | 295 | rc = ddf_fun_bind(fun);
|
---|
[f7a55f9] | 296 | if (rc != EOK) {
|
---|
[ff65e91] | 297 | usb_log_error("Failed to bind DDF function %s: %s.\n",
|
---|
| 298 | fun_name, str_error(rc));
|
---|
| 299 | goto error;
|
---|
[f7a55f9] | 300 | }
|
---|
| 301 |
|
---|
[f97f5cc2] | 302 | ddf_fun_add_to_category(fun, "disk");
|
---|
| 303 |
|
---|
[60c6fe0] | 304 | free(fun_name);
|
---|
[87037cc9] | 305 | mdev->luns[lun] = fun;
|
---|
[60c6fe0] | 306 |
|
---|
[ff65e91] | 307 | return EOK;
|
---|
[f7a55f9] | 308 |
|
---|
[ff65e91] | 309 | /* Error cleanup */
|
---|
| 310 | error:
|
---|
| 311 | if (fun != NULL)
|
---|
| 312 | ddf_fun_destroy(fun);
|
---|
[2aceec5] | 313 | if (fun_name != NULL)
|
---|
| 314 | free(fun_name);
|
---|
[ff65e91] | 315 | return rc;
|
---|
| 316 | }
|
---|
| 317 |
|
---|
| 318 | /** Blockdev client connection handler. */
|
---|
| 319 | static void usbmast_bd_connection(ipc_callid_t iid, ipc_call_t *icall,
|
---|
| 320 | void *arg)
|
---|
| 321 | {
|
---|
[2aceec5] | 322 | usbmast_fun_t *mfun;
|
---|
[4802dd7] | 323 |
|
---|
[56fd7cf] | 324 | mfun = (usbmast_fun_t *) ddf_fun_data_get((ddf_fun_t *)arg);
|
---|
[135486d] | 325 | bd_conn(iid, icall, &mfun->bds);
|
---|
[4802dd7] | 326 | }
|
---|
[ff65e91] | 327 |
|
---|
[4802dd7] | 328 | /** Open device. */
|
---|
[135486d] | 329 | static int usbmast_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
|
---|
[4802dd7] | 330 | {
|
---|
| 331 | return EOK;
|
---|
| 332 | }
|
---|
[ff65e91] | 333 |
|
---|
[4802dd7] | 334 | /** Close device. */
|
---|
| 335 | static int usbmast_bd_close(bd_srv_t *bd)
|
---|
| 336 | {
|
---|
| 337 | return EOK;
|
---|
| 338 | }
|
---|
[ff65e91] | 339 |
|
---|
[4802dd7] | 340 | /** Read blocks from the device. */
|
---|
| 341 | static int usbmast_bd_read_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt, void *buf,
|
---|
| 342 | size_t size)
|
---|
| 343 | {
|
---|
| 344 | usbmast_fun_t *mfun = bd_srv_usbmast(bd);
|
---|
| 345 |
|
---|
| 346 | if (size < cnt * mfun->block_size)
|
---|
| 347 | return EINVAL;
|
---|
| 348 |
|
---|
| 349 | return usbmast_read(mfun, ba, cnt, buf);
|
---|
| 350 | }
|
---|
| 351 |
|
---|
[dd8b6a8] | 352 | /** Synchronize blocks to nonvolatile storage. */
|
---|
| 353 | static int usbmast_bd_sync_cache(bd_srv_t *bd, uint64_t ba, size_t cnt)
|
---|
| 354 | {
|
---|
| 355 | usbmast_fun_t *mfun = bd_srv_usbmast(bd);
|
---|
| 356 |
|
---|
| 357 | return usbmast_sync_cache(mfun, ba, cnt);
|
---|
| 358 | }
|
---|
| 359 |
|
---|
[4802dd7] | 360 | /** Write blocks to the device. */
|
---|
| 361 | static int usbmast_bd_write_blocks(bd_srv_t *bd, uint64_t ba, size_t cnt,
|
---|
| 362 | const void *buf, size_t size)
|
---|
| 363 | {
|
---|
| 364 | usbmast_fun_t *mfun = bd_srv_usbmast(bd);
|
---|
| 365 |
|
---|
| 366 | if (size < cnt * mfun->block_size)
|
---|
| 367 | return EINVAL;
|
---|
| 368 |
|
---|
| 369 | return usbmast_write(mfun, ba, cnt, buf);
|
---|
[2715978] | 370 | }
|
---|
| 371 |
|
---|
[4802dd7] | 372 | /** Get device block size. */
|
---|
| 373 | static int usbmast_bd_get_block_size(bd_srv_t *bd, size_t *rsize)
|
---|
| 374 | {
|
---|
| 375 | usbmast_fun_t *mfun = bd_srv_usbmast(bd);
|
---|
| 376 | *rsize = mfun->block_size;
|
---|
| 377 | return EOK;
|
---|
| 378 | }
|
---|
| 379 |
|
---|
| 380 | /** Get number of blocks on device. */
|
---|
| 381 | static int usbmast_bd_get_num_blocks(bd_srv_t *bd, aoff64_t *rnb)
|
---|
| 382 | {
|
---|
| 383 | usbmast_fun_t *mfun = bd_srv_usbmast(bd);
|
---|
| 384 | *rnb = mfun->nblocks;
|
---|
| 385 | return EOK;
|
---|
| 386 | }
|
---|
| 387 |
|
---|
| 388 |
|
---|
[2715978] | 389 | /** USB mass storage driver ops. */
|
---|
[9871bca] | 390 | static const usb_driver_ops_t usbmast_driver_ops = {
|
---|
[1a4ea01d] | 391 | .device_add = usbmast_device_add,
|
---|
[9871bca] | 392 | .device_rem = usbmast_device_remove,
|
---|
[3002434] | 393 | .device_gone = usbmast_device_gone,
|
---|
[2715978] | 394 | };
|
---|
| 395 |
|
---|
| 396 | /** USB mass storage driver. */
|
---|
[9871bca] | 397 | static const usb_driver_t usbmast_driver = {
|
---|
[2715978] | 398 | .name = NAME,
|
---|
| 399 | .ops = &usbmast_driver_ops,
|
---|
| 400 | .endpoints = mast_endpoints
|
---|
| 401 | };
|
---|
| 402 |
|
---|
| 403 | int main(int argc, char *argv[])
|
---|
| 404 | {
|
---|
[920d0fc] | 405 | log_init(NAME);
|
---|
[7a1757e] | 406 | logctl_set_log_level(NAME, LVL_NOTE);
|
---|
[2715978] | 407 | return usb_driver_main(&usbmast_driver);
|
---|
| 408 | }
|
---|
| 409 |
|
---|
| 410 | /**
|
---|
| 411 | * @}
|
---|
| 412 | */
|
---|