1147955Simp/* $FreeBSD: releng/11.0/sys/boot/usb/storage/umass_common.c 291401 2015-11-27 18:16:10Z zbb $ */ 2147955Simp/*- 3147955Simp * Copyright (c) 2014 Hans Petter Selasky <hselasky@FreeBSD.org> 4147955Simp * All rights reserved. 5147955Simp * 6147955Simp * This software was developed by SRI International and the University of 7147955Simp * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) 8147955Simp * ("CTSRD"), as part of the DARPA CRASH research programme. 9147955Simp * 10147955Simp * Redistribution and use in source and binary forms, with or without 11147955Simp * modification, are permitted provided that the following conditions 12147955Simp * are met: 13147955Simp * 1. Redistributions of source code must retain the above copyright 14147955Simp * notice, this list of conditions and the following disclaimer. 15147955Simp * 2. Redistributions in binary form must reproduce the above copyright 16147955Simp * notice, this list of conditions and the following disclaimer in the 17147955Simp * documentation and/or other materials provided with the distribution. 18147955Simp * 19147955Simp * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 20147955Simp * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21147955Simp * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22147955Simp * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 23147955Simp * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24147955Simp * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25147955Simp * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26147955Simp * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27147955Simp * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28147955Simp * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29147955Simp * SUCH DAMAGE. 30147955Simp */ 31147955Simp 32147955Simp#include USB_GLOBAL_INCLUDE_FILE 33147955Simp 34147955Simp#include "umass_common.h" 35147955Simp 36147955Simpstruct usb_attach_arg umass_uaa; 37147955Simp 38147955Simpstatic device_probe_t umass_probe; 39147955Simpstatic device_attach_t umass_attach; 40147955Simpstatic device_detach_t umass_detach; 41147955Simp 42147955Simpstatic devclass_t umass_devclass; 43147955Simp 44147955Simpstatic device_method_t umass_methods[] = { 45147955Simp /* Device interface */ 46147955Simp DEVMETHOD(device_probe, umass_probe), 47147955Simp DEVMETHOD(device_attach, umass_attach), 48147955Simp DEVMETHOD(device_detach, umass_detach), 49147955Simp 50147955Simp DEVMETHOD_END 51147955Simp}; 52147955Simp 53147955Simpstatic driver_t umass_driver = { 54147955Simp .name = "umass", 55147955Simp .methods = umass_methods, 56147955Simp}; 57147955Simp 58147955SimpDRIVER_MODULE(umass, uhub, umass_driver, umass_devclass, NULL, 0); 59147955Simp 60147955Simpstatic int 61147955Simpumass_probe(device_t dev) 62147955Simp{ 63147955Simp struct usb_attach_arg *uaa = device_get_ivars(dev); 64147955Simp 65147955Simp if (uaa->usb_mode != USB_MODE_HOST || 66147955Simp uaa->info.bInterfaceClass != UICLASS_MASS || 67147955Simp uaa->info.bInterfaceSubClass != UISUBCLASS_SCSI || 68147955Simp uaa->info.bInterfaceProtocol != UIPROTO_MASS_BBB || 69147955Simp device_get_unit(dev) != 0) 70147955Simp return (ENXIO); 71147955Simp return (0); 72147955Simp} 73147955Simp 74147955Simpstatic int 75147955Simpumass_attach(device_t dev) 76147955Simp{ 77147955Simp struct usb_attach_arg *uaa = device_get_ivars(dev); 78147955Simp umass_uaa = *uaa; 79147955Simp return (0); /* success */ 80147955Simp} 81147955Simp 82147955Simpstatic int 83147955Simpumass_detach(device_t dev) 84147955Simp{ 85147955Simp 86147955Simp#ifdef USB_DEBUG 87147955Simp memset(&umass_uaa, 0, sizeof(umass_uaa)); 88147955Simp#endif 89147955Simp return (0); 90147955Simp} 91147955Simp