Commit 856c4169 authored by John Ballance's avatar John Ballance

Extend device coverage and better startup

Detail:
	now checks any mass storage device for usability .. nolonger
	restricts to types 8-5 and 8-6
	delays scsi registration for 2 seconds beyond point where
	module has finished initialising (overcomes issue seen with some
	devices that fail an inquiry command if sent immediately after
	device is enabled)
Admin:
	castle added IP. tested locally. now a release candidate to
	be checked via the beta software site.


Version 0.07. Tagged as 'SCSISoftUSB-0_07'
parent 655facbc
/* (0.06)
/* (0.07)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.2.
*
*/
#define Module_MajorVersion_CMHG 0.06
#define Module_MajorVersion_CMHG 0.07
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 05 Mar 2005
#define Module_Date_CMHG 24 Jun 2005
#define Module_MajorVersion "0.06"
#define Module_Version 6
#define Module_MajorVersion "0.07"
#define Module_Version 7
#define Module_MinorVersion ""
#define Module_Date "05 Mar 2005"
#define Module_Date "24 Jun 2005"
#define Module_ApplicationDate "05-Mar-05"
#define Module_ApplicationDate "24-Jun-05"
#define Module_ComponentName "SCSISoftUSB"
#define Module_ComponentPath "RiscOS/Sources/HWSupport/SCSI/SCSISoftUSB"
#define Module_FullVersion "0.06"
#define Module_HelpVersion "0.06 (05 Mar 2005)"
#define Module_LibraryVersionInfo "0:6"
#define Module_FullVersion "0.07"
#define Module_HelpVersion "0.07 (24 Jun 2005)"
#define Module_LibraryVersionInfo "0:7"
......@@ -148,10 +148,12 @@ bool glue_AttachDevice(my_usb_device_t *device, uint8_t *maxlun)
uaa.product = device->product;
uaa.device = (usbd_device_handle) device;
uaa.iface = (usbd_interface_handle) device;
DEBUGf("using protocol %x\n,",device->protocol);
bool result = umass_attach_riscos(softc, &uaa, device->subclass, device->protocol);
*maxlun = softc->maxlun;
DEBUGf("AttachDevice done\n");
return result;
}
......@@ -227,6 +229,12 @@ void glue_ResetBus(my_usb_device_t *device)
*
* Returns
* NOTHING
*
* 20050621 .. note many BBB mass storage devices do not appreciate
* having UR_BBB_RESET issued to them. wire->methods->reset
* (wire_bbb_reset) is now modified to omit the bulk reset
* command and go straight to clr pipe stall stuff (riscos)
*
*****************************************************************************/
void glue_ResetDevice(my_usb_device_t *device, int reason)
{
......@@ -874,7 +882,8 @@ static void GetOffTickerV(my_usb_device_t *device)
*****************************************************************************/
usbd_status usbd_do_request(usbd_device_handle pipe, usb_device_request_t *req, void *data)
{
DEBUGf("do_request()\n");
DEBUGf("do_request(%x %x)\n",*(uint32_t *)req,
*((uint32_t *)req+1));
_kernel_oserror *e = _swix(DeviceFS_CallDevice, _INR(0,1)|_INR(3,6),
DeviceCall_ExternalBase + 0,
((my_usb_device_t *)pipe)->devicefs_name,
......
......@@ -58,6 +58,8 @@
*****************************************************************************/
#undef MESSAGES /* don't need any at the moment */
/* delay after arrival of mass storage device before we tell the scsi system */
#define PopUpDelay 2*100
/*****************************************************************************
* New type definitions
......@@ -72,7 +74,7 @@
/*****************************************************************************
* File scope Global variables
*****************************************************************************/
static bool Registering;
/*****************************************************************************
* Function prototypes - Private to this file
......@@ -124,6 +126,8 @@ _kernel_oserror *module_Init(const char *cmd_tail, int podule_base, void *pw)
bool CallbackSet = false;
IGNORE(cmd_tail);
IGNORE(podule_base);
Registering = false;
debug_initialise("SCSISoftUSB", "null:", 0);
// debug_set_taskname_prefix(true);
......@@ -268,6 +272,12 @@ _kernel_oserror *module_Final(int fatal, int podule, void *pw)
if (!e)
{
_swix(OS_RemoveTickerEvent, _INR(0,1),
module_scsiregister_handler,
global_PrivateWord);
_swix(OS_RemoveCallBack, _INR(0,1),
module_scsiregister_handler,
global_PrivateWord);
_swix(OS_RemoveCallBack, _INR(0,1),
module_callback_from_init,
global_PrivateWord);
......@@ -326,10 +336,18 @@ void module_Service(int service_number, _kernel_swi_regs *r, void *pw)
case Service_ModulePostInit:
if (strcmp((const char *)r->r[2], "SCSIdriver") == 0)
{
_swix(OS_RemoveTickerEvent, _INR(0,1),
module_scsiregister_handler,
global_PrivateWord);
for (my_usb_device_t *device = global_DeviceList; device != NULL; device = device->next)
{
device->scsi_driver_handle = RegisterSCSIDevice(device);
device->registered = false;
}
_swix(OS_CallAfter, _INR(0,2),
PopUpDelay, /* wait n secs */
module_scsiregister_handler,
global_PrivateWord);
}
break;
......@@ -372,6 +390,34 @@ void module_Service(int service_number, _kernel_swi_regs *r, void *pw)
}
return;
}
/* module_SCSIRegister
* register any unregistered devices on the list from a callback
*/
_kernel_oserror *module_SCSIRegister(_kernel_swi_regs *r, void *pw)
{
IGNORE(r);
IGNORE(pw);
if(Registering) /* come back later for another pass */
{
_swix(OS_AddCallBack, _INR(0,1),
module_scsiregister_handler,
global_PrivateWord);
return NULL;
}
Registering = true;
for (my_usb_device_t *device = global_DeviceList; device != NULL; device = device->next)
{
if(!device->registered)
{
dprintf(("","Registering scsi device for %x \n",device));
device->scsi_driver_handle =RegisterSCSIDevice(device);
device->registered = true;
}
}
Registering = false;
return NULL;
}
#if 0
/*****************************************************************************
......@@ -456,6 +502,7 @@ static uint32_t RegisterSCSIDevice(void *device)
global_PrivateWord,
device,
&scsi_driver_handle);
dprintf(("","Got scsi device handle %x \n",scsi_driver_handle));
return scsi_driver_handle;
}
......@@ -479,6 +526,7 @@ static uint32_t RegisterSCSIDevice(void *device)
*****************************************************************************/
static void DeregisterSCSIDevice(void *device, uint32_t scsi_driver_handle)
{
dprintf(("","DeRegister scsi handle %x \n",scsi_driver_handle));
_swix(SCSI_Deregister, _INR(0,3),
scsi_driver_handle,
module_scsi_handler,
......@@ -563,6 +611,7 @@ static _kernel_oserror *CheckConnectedDevice(const USBServiceCall *service_call_
{
const usb_interface_descriptor_t *interface = (const usb_interface_descriptor_t *) ptr;
if (interface->bInterfaceClass == 8 /* mass storage class */
#ifdef LIMITED_SCOPE
&& (interface->bInterfaceSubClass == 6 /* SCSI */
|| interface->bInterfaceSubClass == 5 /* floppy */
)
......@@ -570,6 +619,7 @@ static _kernel_oserror *CheckConnectedDevice(const USBServiceCall *service_call_
|| interface->bInterfaceProtocol == 1 /* control/bulk/interrupt without command completion interrupt */
|| interface->bInterfaceProtocol == 0x50 /* bulk-only */
)
#endif
)
{
my_usb_device_t *device = (my_usb_device_t *)((char *) calloc(1, sizeof *device) - 4);
......@@ -654,8 +704,15 @@ static _kernel_oserror *CheckConnectedDevice(const USBServiceCall *service_call_
break;
}
}
glue_ResetDevice(device, 0);
device->scsi_driver_handle = RegisterSCSIDevice(device);
// glue_ResetDevice(device, 0);
_swix(OS_RemoveTickerEvent, _INR(0,1),
module_scsiregister_handler,
global_PrivateWord);
device->registered = false;
_swix(OS_CallAfter, _INR(0,2),
PopUpDelay, /* wait n secs */
module_scsiregister_handler,
global_PrivateWord);
}
else
{
......
......@@ -1058,9 +1058,22 @@ 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
/* Issuing UR_BBB_RESET to many devices causes a lockout.
* windows only does the clr endpoint stall stuff
* so for now we'll go straight into that
* JB20050621
*/
sc->transfer_state = TSTATE_BBB_RESET2;
#ifdef __riscos
*err =
#endif
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;
......@@ -1075,6 +1088,7 @@ umass_bbb_reset(struct umass_softc *sc, int transfer_status
, 0, 0, sc->transfer_xfer[XFER_BBB_RESET1]
#endif
);
#endif
}
Static void
......
......@@ -59,4 +59,5 @@ international-help-file:"Resources:$.Resources.SCSISoftUSB.Messages"
generic-veneers: module_callback_from_init/module_CallbackFromInit,
module_scsi_handler/module_SCSIHandler,
module_tickerv_handler/module_TickerVHandler,
module_upcallv_handler/module_UpCallVHandler
module_upcallv_handler/module_UpCallVHandler,
module_scsiregister_handler/module_SCSIRegister
......@@ -39,6 +39,13 @@
#include "tboxlibs/toolbox.h"
/*****************************************************************************
* Scope limiting
* if LIMITED_SCOPE is defined, then the module will only recognise
* a limited subset of devices instead of anything which responds
*****************************************************************************/
//#define LIMITED_SCOPE 1
/*****************************************************************************
* MACROS
*****************************************************************************/
......@@ -94,6 +101,7 @@ typedef struct my_usb_device
struct my_usb_device *next;
bool dying;
bool registered;
uint8_t interface;
uint8_t alternate;
......
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