Commit 4f630de0 authored by Robert Sprowson's avatar Robert Sprowson

Sync with a known NetBSD copy

Wrap the RISC OS-isms with #ifdef __riscos, and some noisy tab/whitespace changes.
Removed sc_sense from umass_softc (never set), was added in SCSISoftUSB-0_07, but appears to be left over from a future version - it'll be back later.
Contemporary with umass.c revision 1.95 from NetBSD.
Tagged as SCSISoftUSB-0_25-netbsd-1_95.
parent 9e055246
/*****************************************************************************
* $Id$
* $Name$
*
* Author(s): Ben Avison
* Project(s):
*
* ----------------------------------------------------------------------------
* Purpose: USB mass storage general-purpose code, adapted from BSD sources
*
* ----------------------------------------------------------------------------
* History: See source control system log
*
*****************************************************************************/
/* $NetBSD: umass.c,v 1.95 2003/02/16 23:14:06 augustss Exp $ */
/*-
* Copyright (c) 1999 MAEKAWA Masahide <bishop@rr.iij4u.or.jp>,
......@@ -167,7 +152,8 @@ __KERNEL_RCSID(0, "$NetBSD: umass.c,v 1.95 2003/02/16 23:14:06 augustss Exp $");
#ifdef UMASS_DEBUG
#include <stdio.h>
int umassdebug = 9;//;0
int umassdebug = 0;
char *states[TSTATE_STATES+1] = {
/* should be kept in sync with the list at transfer_state */
"Idle",
......@@ -437,8 +423,7 @@ USB_ATTACH(umass)
#ifdef __riscos
if (sc->sc_wire == UMASS_WPROTO_UNSPEC) {
switch (InterfaceProtocol)
{
switch (InterfaceProtocol) {
#else
id = usbd_get_interface_descriptor(sc->sc_iface);
if (id == NULL)
......@@ -454,9 +439,7 @@ USB_ATTACH(umass)
sc->sc_wire = UMASS_WPROTO_CBI_I;
break;
case UIPROTO_MASS_BBB:
#ifdef __riscos
// case UIPROTO_MASS_BBB_P:
#else
#ifndef __riscos
case UIPROTO_MASS_BBB_OLD:
#endif
sc->sc_wire = UMASS_WPROTO_BBB;
......@@ -466,14 +449,12 @@ USB_ATTACH(umass)
DPRINTF(UDMASS_GEN,
("%s: Unsupported wire protocol %u\n",
USBDEVNAME(sc->sc_dev),
InterfaceProtocol
));
InterfaceProtocol));
#else
DPRINTF(UDMASS_GEN,
("%s: Unsupported wire protocol %u\n",
USBDEVNAME(sc->sc_dev),
id->bInterfaceProtocol
));
id->bInterfaceProtocol));
#endif
USB_ATTACH_ERROR_RETURN;
}
......@@ -563,16 +544,6 @@ USB_ATTACH(umass)
printf("%s: using %s over %s\n", USBDEVNAME(sc->sc_dev), sCommand,
sWire);
if (quirk != NULL && quirk->uq_init != NULL) {
err = (*quirk->uq_init)(sc);
if (err) {
printf("%s: quirk init failed\n",
USBDEVNAME(sc->sc_dev));
umass_disco(sc);
USB_ATTACH_ERROR_RETURN;
}
}
/*
* In addition to the Control endpoint the following endpoints
* are required:
......@@ -763,28 +734,28 @@ USB_ATTACH(umass)
switch (sc->sc_cmd) {
case UMASS_CPROTO_RBC:
case UMASS_CPROTO_SCSI:
#if NSCSIBUS > 0
#if NSCSIBUS > 0
error = umass_scsi_attach(sc);
#else
#else
printf("%s: atapibus not configured\n", USBDEVNAME(sc->sc_dev));
#endif
#endif
break;
case UMASS_CPROTO_UFI:
case UMASS_CPROTO_ATAPI:
#if NATAPIBUS > 0
#if NATAPIBUS > 0
error = umass_atapi_attach(sc);
#else
#else
printf("%s: scsibus not configured\n", USBDEVNAME(sc->sc_dev));
#endif
#endif
break;
case UMASS_CPROTO_ISD_ATA:
#if NWD > 0
#if NWD > 0
error = umass_isdata_attach(sc);
#else
#else
printf("%s: isdata not configured\n", USBDEVNAME(sc->sc_dev));
#endif
#endif
break;
default:
......@@ -1056,7 +1027,7 @@ umass_bbb_reset(struct umass_softc *sc, int transfer_status
DPRINTF(UDMASS_BBB, ("%s: Bulk Reset\n",
USBDEVNAME(sc->sc_dev)));
sc->transfer_state = TSTATE_BBB_RESET1;
sc->transfer_state = TSTATE_BBB_RESET1;
sc->transfer_status = transfer_status;
#ifdef __riscos
......@@ -1066,12 +1037,12 @@ umass_bbb_reset(struct umass_softc *sc, int transfer_status
* JB20050621
*/
sc->transfer_state = TSTATE_BBB_RESET2;
sc->transfer_status = transfer_status;
#ifdef __riscos
*err =
#endif
umass_clear_endpoint_stall(sc, UMASS_BULKIN );
umass_clear_endpoint_stall(sc, UMASS_BULKIN);
#else
sc->transfer_state = TSTATE_BBB_RESET1;
/* reset is a class specific interface write */
sc->sc_req.bmRequestType = UT_WRITE_CLASS_INTERFACE;
sc->sc_req.bRequest = UR_BBB_RESET;
......@@ -1186,7 +1157,7 @@ umass_bbb_transfer(struct umass_softc *sc, int lun, const void *cmd, int cmdlen,
sc->cbw.bCBWLUN = lun;
sc->cbw.bCDBLength = cmdlen;
memcpy(sc->cbw.CBWCDB, cmd, cmdlen);
DPRINTF(UDMASS_BBB,("\n here \n"));
DIF(UDMASS_BBB, umass_bbb_dump_cbw(sc, &sc->cbw));
/* store the details for the data transfer phase */
......@@ -2142,16 +2113,17 @@ 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) ||
sc->sc_sense)
if (sc->sbl.ufi.asc == 0 && sc->sbl.ufi.ascq == 0)
status = STATUS_CMD_OK;
else
status = STATUS_CMD_FAILED;
/* No sense, command successful */
sc->transfer_state = TSTATE_IDLE;
sc->transfer_cb(sc, sc->transfer_priv,
sc->transfer_datalen - sc->transfer_actlen, status);
#ifdef __riscos
sc->transfer_state = TSTATE_IDLE;
sc->transfer_cb(sc, sc->transfer_priv,
sc->transfer_datalen - sc->transfer_actlen, status);
#endif
} else {
/* Command Interrupt Data Block */
DPRINTF(UDMASS_CBI, ("%s: type=0x%02x, value=0x%02x\n",
......@@ -2175,7 +2147,7 @@ umass_cbi_state(
sc->transfer_state = TSTATE_IDLE;
sc->transfer_cb(sc, sc->transfer_priv,
sc->transfer_datalen,
sc->transfer_datalen,
err);
}
}
......@@ -2201,21 +2173,19 @@ umass_cbi_state(
return;
case TSTATE_CBI_SCLEAR:
if (RISCOSSTAR err){ /* should not occur */
#ifndef __riscos
if (err) /* should not occur */
printf("%s: CBI intr-in stall clear failed, %s\n",
USBDEVNAME(sc->sc_dev), usbd_errstr(RISCOSSTAR err));
#endif
umass_cbi_reset(sc, STATUS_WIRE_FAILED
#ifdef __riscos
, err
USBDEVNAME(sc->sc_dev), usbd_errstr(err));
#else
if (RISCOSSTAR err) { /* should not occur */
umass_cbi_reset(sc, STATUS_WIRE_FAILED, err);
} else {
sc->transfer_state = TSTATE_IDLE;
sc->transfer_cb(sc, sc->transfer_priv,
sc->transfer_datalen, STATUS_CMD_FAILED);
}
#endif
);
} else {
sc->transfer_state = TSTATE_IDLE;
sc->transfer_cb(sc, sc->transfer_priv,
sc->transfer_datalen, STATUS_CMD_FAILED);
}
/* Something really bad is going on. Reset the device */
umass_cbi_reset(sc, STATUS_CMD_FAILED
#ifdef __riscos
......@@ -2371,7 +2341,11 @@ Static void
umass_bbb_dump_csw(struct umass_softc *sc, umass_bbb_csw_t *csw)
{
int sig = UGETDW(csw->dCSWSignature);
int tag = UGETDW(csw->dCSWTag);
#ifdef __riscos
int tag = UGETDW(csw->dCSWTag);
#else
int tag = UGETW(csw->dCSWTag);
#endif
int res = UGETDW(csw->dCSWDataResidue);
int status = csw->bCSWStatus;
......
/*****************************************************************************
* $Id$
* $Name$
*
* Author(s): Ben Avison
* Project(s):
*
* ----------------------------------------------------------------------------
* Purpose: USB mass storage quirks header file, adapted from BSD sources
*
* ----------------------------------------------------------------------------
* History: See source control system log
*
*****************************************************************************/
/* $NetBSD: umass_quirks.h,v 1.3.4.1 2002/01/10 19:59:01 thorpej Exp $ */
/* $NetBSD: umass_quirks.h,v 1.3 2001/12/29 13:46:23 augustss Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
......@@ -67,13 +52,6 @@
typedef usbd_status (*umass_init_quirk)(struct umass_softc *);
typedef void (*umass_fixup_quirk)(struct umass_softc *);
//#ifdef __riscos
//struct usb_devno {
// u_int16_t vendor;
// u_int16_t product;
//};
//#endif
struct umass_quirk {
struct usb_devno uq_dev;
......
/*****************************************************************************
* $Id$
* $Name$
*
* Author(s): Ben Avison
* Project(s):
*
* ----------------------------------------------------------------------------
* Purpose: USB mass storage general-purpose header file, adapted from BSD sources
*
* ----------------------------------------------------------------------------
* History: See source control system log
*
*****************************************************************************/
/* $NetBSD: umassvar.h,v 1.19 2003/02/22 05:18:50 tsutsui Exp $ */
/*-
* Copyright (c) 1999 MAEKAWA Masahide <bishop@rr.iij4u.or.jp>,
......@@ -319,7 +304,6 @@ 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