Commit d797c29e authored by Robert Sprowson's avatar Robert Sprowson

Update a few versions

Contemporary with umass.c revision 1.102 from NetBSD.
Tagged as SCSISoftUSB-0_25-netbsd-1_102.
parent 9906b41c
/* $NetBSD: umass.c,v 1.99 2003/09/08 19:57:32 mycroft Exp $ */
/* $NetBSD: umass.c,v 1.102 2003/09/10 05:42:18 mycroft Exp $ */
/*
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Charles M. Hamnnum.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*-
* Copyright (c) 1999 MAEKAWA Masahide <bishop@rr.iij4u.or.jp>,
* Nick Hibma <n_hibma@freebsd.org>
......@@ -463,10 +500,6 @@ USB_ATTACH(umass)
}
}
/* XXX - Now unsupported CBI with CCI */
if (sc->sc_wire == UMASS_WPROTO_CBI_I)
sc->sc_wire = UMASS_WPROTO_CBI;
if (sc->sc_cmd == UMASS_CPROTO_UNSPEC) {
#ifdef __riscos
switch (InterfaceSubClass) {
......@@ -614,6 +647,9 @@ USB_ATTACH(umass)
}
/* Open the bulk-in and -out pipe */
DPRINTF(UDMASS_USB, ("%s: opening iface %p epaddr %d for BULKOUT\n",
USBDEVNAME(sc->sc_dev), sc->sc_iface,
sc->sc_epaddr[UMASS_BULKOUT]));
err = usbd_open_pipe(sc->sc_iface, sc->sc_epaddr[UMASS_BULKOUT],
#ifdef __riscos
UMASS_BULKOUT,
......@@ -627,6 +663,9 @@ USB_ATTACH(umass)
umass_disco(sc);
USB_ATTACH_ERROR_RETURN;
}
DPRINTF(UDMASS_USB, ("%s: opening iface %p epaddr %d for BULKIN\n",
USBDEVNAME(sc->sc_dev), sc->sc_iface,
sc->sc_epaddr[UMASS_BULKIN]));
err = usbd_open_pipe(sc->sc_iface, sc->sc_epaddr[UMASS_BULKIN],
#ifdef __riscos
UMASS_BULKIN,
......@@ -653,6 +692,9 @@ USB_ATTACH(umass)
* arriving concurrently.
*/
if (sc->sc_wire == UMASS_WPROTO_CBI_I) {
DPRINTF(UDMASS_USB, ("%s: opening iface %p epaddr %d for INTRIN\n",
USBDEVNAME(sc->sc_dev), sc->sc_iface,
sc->sc_epaddr[UMASS_INTRIN]));
err = usbd_open_pipe(sc->sc_iface, sc->sc_epaddr[UMASS_INTRIN],
#ifdef __riscos
UMASS_INTRIN,
......@@ -1382,6 +1424,8 @@ umass_bbb_state(
}
}
/* FALLTHROUGH, err == 0 (no data phase or successful) */
case TSTATE_BBB_DCLEAR: /* stall clear after data phase */
#ifndef __riscos
if (sc->transfer_dir == DIR_IN)
memcpy(sc->transfer_data, sc->data_buffer,
......@@ -1393,7 +1437,6 @@ umass_bbb_state(
sc->transfer_datalen, 48));
/* FALLTHROUGH, err == 0 (no data phase or successful) */
case TSTATE_BBB_DCLEAR: /* stall clear after data phase */
case TSTATE_BBB_SCLEAR: /* stall clear after status phase */
/* Reading of CSW after bulk stall condition in data phase
* (TSTATE_BBB_DATA2) or bulk-in stall condition after
......@@ -1958,43 +2001,11 @@ umass_cbi_state(
#endif
);
} else if (sc->sc_wire == UMASS_WPROTO_CBI_I) {
DPRINTF(UDMASS_CBI, ("%s: no data phase\n",
USBDEVNAME(sc->sc_dev)));
sc->transfer_state = TSTATE_CBI_STATUS;
#ifdef __riscos /* I assume it's worthwhile doing this here too */
memset(&sc->sbl, 0, sizeof(sc->sbl));
#endif
if (
#ifdef __riscos
(*err =
#endif
umass_setup_transfer(sc, sc->sc_pipe[UMASS_INTRIN],
&sc->sbl, sizeof(sc->sbl),
0 /* fixed length transfer */
#ifdef __riscos
)) != USBD_NORMAL_COMPLETION)
#else
, sc->transfer_xfer[XFER_CBI_STATUS]))
#endif
{
umass_cbi_reset(sc, STATUS_WIRE_FAILED
#ifdef __riscos
, err
#endif
);
}
} else {
DPRINTF(UDMASS_CBI, ("%s: no data phase\n",
USBDEVNAME(sc->sc_dev)));
/* No command completion interrupt. Request
* sense data.
*/
sc->transfer_state = TSTATE_IDLE;
sc->transfer_cb(sc, sc->transfer_priv,
0, STATUS_CMD_UNKNOWN);
goto dostatus;
}
return;
case TSTATE_CBI_DATA:
......@@ -2043,6 +2054,7 @@ umass_cbi_state(
umass_dump_buffer(sc, sc->transfer_data,
sc->transfer_actlen, 48));
dostatus:
if (sc->sc_wire == UMASS_WPROTO_CBI_I) {
sc->transfer_state = TSTATE_CBI_STATUS;
memset(&sc->sbl, 0, sizeof(sc->sbl));
......@@ -2058,13 +2070,11 @@ umass_cbi_state(
#else
, sc->transfer_xfer[XFER_CBI_STATUS]))
#endif
{
umass_cbi_reset(sc, STATUS_WIRE_FAILED
#ifdef __riscos
, err
#endif
);
}
} else {
/* No command completion interrupt. Request
* sense to get status of command.
......@@ -2105,6 +2115,17 @@ umass_cbi_state(
/* Dissect the information in the buffer */
{
#ifndef __riscos
u_int32_t actlen;
usbd_get_xfer_status(xfer,NULL,NULL,&actlen,NULL);
#endif
DPRINTF(UDMASS_CBI, ("%s: CBI_STATUS actlen=%d\n",
USBDEVNAME(sc->sc_dev), actlen));
if (actlen != 2)
break;
}
if (sc->sc_cmd == UMASS_CPROTO_UFI) {
int status;
......@@ -2118,42 +2139,42 @@ umass_cbi_state(
USBDEVNAME(sc->sc_dev),
sc->sbl.ufi.asc, sc->sbl.ufi.ascq));
if (sc->sbl.ufi.asc == 0 && sc->sbl.ufi.ascq == 0)
if ((sc->sbl.ufi.asc == 0 && sc->sbl.ufi.ascq == 0) ||
sc->sc_sense)
status = STATUS_CMD_OK;
else
status = STATUS_CMD_FAILED;
/* No sense, command successful */
#ifdef __riscos
/* No autosense, command successful */
sc->transfer_state = TSTATE_IDLE;
sc->transfer_cb(sc, sc->transfer_priv,
sc->transfer_datalen - sc->transfer_actlen, status);
#endif
sc->transfer_datalen - sc->transfer_actlen, status);
} else {
int status;
/* Command Interrupt Data Block */
DPRINTF(UDMASS_CBI, ("%s: type=0x%02x, value=0x%02x\n",
USBDEVNAME(sc->sc_dev),
sc->sbl.common.type, sc->sbl.common.value));
if (sc->sbl.common.type == IDB_TYPE_CCI) {
int err;
if ((sc->sbl.common.value&IDB_VALUE_STATUS_MASK)
== IDB_VALUE_PASS) {
err = STATUS_CMD_OK;
} else if ((sc->sbl.common.value & IDB_VALUE_STATUS_MASK)
== IDB_VALUE_FAIL ||
(sc->sbl.common.value & IDB_VALUE_STATUS_MASK)
== IDB_VALUE_PERSISTENT) {
err = STATUS_CMD_FAILED;
} else {
err = STATUS_WIRE_FAILED;
switch (sc->sbl.common.value & IDB_VALUE_STATUS_MASK) {
case IDB_VALUE_PASS:
status = STATUS_CMD_OK;
break;
case IDB_VALUE_FAIL:
case IDB_VALUE_PERSISTENT:
status = STATUS_CMD_FAILED;
break;
case IDB_VALUE_PHASE:
status = STATUS_WIRE_FAILED;
break;
}
sc->transfer_state = TSTATE_IDLE;
sc->transfer_cb(sc, sc->transfer_priv,
sc->transfer_datalen,
err);
sc->transfer_datalen - sc->transfer_actlen, status);
}
}
return;
......
/* $NetBSD: umass_quirks.c,v 1.51 2003/09/09 01:35:47 mycroft Exp $ */
/* $NetBSD: umass_quirks.c,v 1.54 2003/09/10 05:25:44 mycroft Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
......@@ -39,7 +39,7 @@
#include <sys/cdefs.h>
#ifndef __riscos
__KERNEL_RCSID(0, "$NetBSD: umass_quirks.c,v 1.51 2003/09/09 01:35:47 mycroft Exp $");
__KERNEL_RCSID(0, "$NetBSD: umass_quirks.c,v 1.54 2003/09/10 05:25:44 mycroft Exp $");
#include <sys/param.h>
#include <sys/systm.h>
......@@ -71,7 +71,6 @@ Static usbd_status umass_init_insystem(struct umass_softc *);
Static usbd_status umass_init_shuttle(struct umass_softc *);
Static void umass_fixup_sony(struct umass_softc *);
Static void umass_fixup_yedata(struct umass_softc *);
#endif
#ifdef __riscos
......@@ -112,15 +111,6 @@ Static const struct umass_quirk umass_quirks[] = {
NULL, NULL
},
{ { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_DUBPXXG },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_FORCE_SHORT_INQUIRY,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
{ { USB_VENDOR_OLYMPUS, USB_PRODUCT_OLYMPUS_C1 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_WRONG_CSWSIG,
......@@ -164,46 +154,12 @@ Static const struct umass_quirk umass_quirks[] = {
NULL, umass_fixup_sony
},
{ { USB_VENDOR_SONY, USB_PRODUCT_SONY_MSC_U03 },
UMASS_WPROTO_CBI, UMASS_CPROTO_UFI,
0,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, umass_fixup_sony
},
#endif
{ { USB_VENDOR_SONY, USB_PRODUCT_SONY_MSC },
UMASS_WPROTO_CBI, UMASS_CPROTO_UFI,
UMASS_QUIRK_FORCE_SHORT_INQUIRY | UMASS_QUIRK_RS_NO_CLEAR_UA,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
{ { USB_VENDOR_YANO, USB_PRODUCT_YANO_U640MO },
UMASS_WPROTO_CBI_I, UMASS_CPROTO_ATAPI,
UMASS_QUIRK_FORCE_SHORT_INQUIRY,
0,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
#ifndef NO_QUIRKS_THAT_USE_CODE
{ { USB_VENDOR_YEDATA, USB_PRODUCT_YEDATA_FLASHBUSTERU },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UFI,
UMASS_QUIRK_RS_NO_CLEAR_UA,
0,
UMATCH_VENDOR_PRODUCT_REV,
NULL, umass_fixup_yedata
},
#endif
{ { USB_VENDOR_GENESYS,USB_PRODUCT_GENESYS_GL641USB },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_FORCE_SHORT_INQUIRY,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
};
......@@ -271,31 +227,7 @@ umass_fixup_sony(struct umass_softc *sc)
usb_interface_descriptor_t *id;
id = usbd_get_interface_descriptor(sc->sc_iface);
if (id->bInterfaceSubClass == 0xff) {
sc->sc_cmd = UMASS_CPROTO_RBC;
}
}
Static void
umass_fixup_yedata(struct umass_softc *sc)
{
usb_device_descriptor_t *dd;
dd = usbd_get_device_descriptor(sc->sc_udev);
/*
* Revisions < 1.28 do not handle the interrupt endpoint very well.
*/
if (UGETW(dd->bcdDevice) < 0x128)
sc->sc_wire = UMASS_WPROTO_CBI;
else
sc->sc_wire = UMASS_WPROTO_CBI_I;
/*
* Revisions < 1.28 do not have the TEST UNIT READY command
* Revisions == 1.28 have a broken TEST UNIT READY
*/
if (UGETW(dd->bcdDevice) <= 0x128)
sc->sc_busquirks |= PQUIRK_NOTUR;
if (id->bInterfaceSubClass == 0xff)
sc->sc_cmd = UMASS_CPROTO_SCSI;
}
#endif
/* $NetBSD: umassvar.h,v 1.20 2003/09/08 19:31:01 mycroft Exp $ */
/* $NetBSD: umassvar.h,v 1.22 2003/09/10 05:25:44 mycroft Exp $ */
/*-
* Copyright (c) 1999 MAEKAWA Masahide <bishop@rr.iij4u.or.jp>,
* Nick Hibma <n_hibma@freebsd.org>
......@@ -212,10 +212,8 @@ struct umass_softc {
#define UMASS_CPROTO_ISD_ATA 5
u_int32_t sc_quirks;
#define UMASS_QUIRK_RS_NO_CLEAR_UA 0x00000001
#define UMASS_QUIRK_FORCE_SHORT_INQUIRY 0x00000002
#define UMASS_QUIRK_WRONG_CSWSIG 0x00000004
#define UMASS_QUIRK_WRONG_CSWTAG 0x00000008
#define UMASS_QUIRK_WRONG_CSWSIG 0x00000001
#define UMASS_QUIRK_WRONG_CSWTAG 0x00000002
u_int32_t sc_busquirks;
......@@ -302,6 +300,7 @@ struct umass_softc {
int sc_xfer_flags;
char sc_dying;
int sc_refcnt;
int sc_sense;
struct umassbus_softc *bus; /* bus dependent data */
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment