Commit 655facbc authored by John Ballance's avatar John Ballance

Numerous updates to improve working.

	Re-synced with NetBSD mass storage
	Added part sector fill/ignore needed by SCSIFS

Detail:
Admin:  tested at castle.. to go to beta site.. Castle added IP


Version 0.06. Tagged as 'SCSISoftUSB-0_06'
parent 085e67d9
| Copyright 2005 Castle Technology Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine debug THROWBACK=-throwback
......@@ -14,3 +14,4 @@
|
Dir <Obey$Dir>
amu_machine all THROWBACK=-throwback
| Copyright 2005 Castle Technology Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
| You may obtain a copy of the License at
|
| http://www.apache.org/licenses/LICENSE-2.0
|
| Unless required by applicable law or agreed to in writing, software
| distributed under the License is distributed on an "AS IS" BASIS,
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
| See the License for the specific language governing permissions and
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine all THROWBACK=-throwback
amu_machine gpa.SCSISoftUSB THROWBACK=-throwback
......@@ -24,14 +24,14 @@
COMPONENT = SCSISoftUSB
TARGET = SCSISoftUSB
DIRS = local_dirs
CFLAGS = -ffah -wp -wc -we -zM -zps1 -ITCPIPLibs:,C:USB -DDISABLE_PACKED ${DEFINES}
CFLAGS = -ffah -wp -wc -we -zM -zps1 -ITCPIPLibs:,C:USB -DDISABLE_PACKED -D_KERNEL ${DEFINES}
RAM_OBJS = o.module ${OBJS}
ROM_OBJS = o.moduleROM ${OBJS}
OBJS = o.svcprint o.glue o.umass o.umass_quirks o.global o.asm o.modhdr #o.resmess
DBG_OBJS = do.module do.svcprint do.glue do.umass do.umass_quirks do.global o.asm o.modhdr #o.resmess
LIBDIR = <Lib$Dir>
LIBS =
DBG_LIBS = ${LIBS} ${LIBDIR}.DebugLib.o.debuglibzm TCPIPLibs:o.socklib5zm TCPIPLibs:o.inetlibzm
DBG_LIBS = ${DEBUGLIB} ${LIBS} ${MODMALLOCLIB} ${WILDLIB} ${DDTLIB} ${DESKLIB} ${CALLXLIB} ${ASMUTILS} ${TBOXLIBS} ${LIBDIR}.DebugLib.o.debuglibzm TCPIPLibs:o.socklib5zm TCPIPLibs:o.inetlibzm
DBG_MODULE = drm.${TARGET}
EXPORTS =
#MERGEDMDIR = o.${MACHINE}._Messages_
......@@ -44,9 +44,11 @@ include Makefiles:RAMCModule
include Makefiles:ROMCModule
.SUFFIXES: .do
.c.do:; ${CC} ${CFLAGS} -DDEBUGLIB -o $@ $<
.c.do:; ${CC} ${CFLAGS} -DDEBUGLIB -DUMASS_DEBUG -o $@ $<
local_dirs:
${MKDIR} gpa
${MKDIR} aif
${MKDIR} do
${MKDIR} o
......@@ -61,11 +63,21 @@ ${EXPORTS}:
# ${RM} Messages${CMDHELP}
# @${ECHO} ${COMPONENT}: resource files copied
aif.${COMPONENT}: ${RAM_OBJS} ${RAM_LIBS} ${CLIB} ${DIRS}
link -base 0 -aif -bin -d -o $@ ${RAM_OBJS} ${RAM_LIBS} ${CLIB}
gpa.${COMPONENT}: aif.${COMPONENT}
togpa -s aif.${COMPONENT} $@
clean:
${RM} Messages
${RM} h.modhdr
ifthere linked then wipe linked ${WFLAGS}
ifthere aof then wipe aof ${WFLAGS}
ifthere aif then wipe aif ${WFLAGS}
ifthere gpa then wipe gpa ${WFLAGS}
ifthere drm then wipe drm ${WFLAGS}
ifthere do then wipe do ${WFLAGS}
ifthere rm then wipe rm ${WFLAGS}
......
/* (0.05)
/* (0.06)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.68.
* Last processed by srccommit version: 1.2.
*
*/
#define Module_MajorVersion_CMHG 0.05
#define Module_MajorVersion_CMHG 0.06
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 16 Jun 2003
#define Module_Date_CMHG 05 Mar 2005
#define Module_MajorVersion "0.05"
#define Module_Version 5
#define Module_MajorVersion "0.06"
#define Module_Version 6
#define Module_MinorVersion ""
#define Module_Date "16 Jun 2003"
#define Module_Date "05 Mar 2005"
#define Module_ApplicationDate "16-Jun-03"
#define Module_ApplicationDate "05-Mar-05"
#define Module_ComponentName "SCSISoftUSB"
#define Module_ComponentPath "RiscOS/Sources/HWSupport/SCSI/SCSISoftUSB"
#define Module_FullVersion "0.05"
#define Module_HelpVersion "0.05 (16 Jun 2003)"
#define Module_LibraryVersionInfo "0:5"
#define Module_FullVersion "0.06"
#define Module_HelpVersion "0.06 (05 Mar 2005)"
#define Module_LibraryVersionInfo "0:6"
......@@ -138,7 +138,9 @@ bool glue_AttachDevice(my_usb_device_t *device, uint8_t *maxlun)
softc->sc_maxpacket[UMASS_BULKIN] = device->bulk_in_maxpacketsize;
softc->sc_maxpacket[UMASS_BULKOUT] = device->bulk_out_maxpacketsize;
softc->sc_maxpacket[UMASS_INTRIN] = device->interrupt_maxpacketsize;
/* claim packet buffers, since Glue_Tick may have trouble claimig them */
softc->scbulkoutbuf=malloc(device->bulk_out_maxpacketsize);
struct usb_attach_arg uaa;
memset(&uaa, 0, sizeof uaa);
uaa.ifaceno = device->interface;
......@@ -177,6 +179,7 @@ void glue_DetachDevice(my_usb_device_t *device)
struct umass_softc *softc = (struct umass_softc *)device->softc;
if (device->command_active && softc->transfer_priv != NULL)
{
softc->transfer_priv = NULL; /* if we're interrupting ticker processing, no longer try to do a callback at end of ticker */
DEBUGf("Calling SCSIdriver from DetachDevice\n");
asm_DoTransferCompleteCallback((_kernel_oserror *)(ErrorNumber_SCSI_Died & 0xFF),
0,
......@@ -184,8 +187,8 @@ void glue_DetachDevice(my_usb_device_t *device)
softc->transfer_datalen,
device->callback_pw,
device->callback_wp);
softc->transfer_priv = NULL; /* if we're interrupting ticker processing, no longer try to do a callback at end of ticker */
}
if(softc->scbulkoutbuf) free (softc->scbulkoutbuf);
umass_detach((struct device *)softc, 0);
}
......@@ -298,7 +301,27 @@ void glue_ResetDevice(my_usb_device_t *device, int reason)
*****************************************************************************/
_kernel_oserror *glue_DoCommand(my_usb_device_t *device, uint32_t lun, uint32_t data_direction, const char *control_block, size_t control_block_length, scatter_entry_t *scatter_list, size_t transfer_length, void (*callback)(void), void *callback_pw, void *callback_wp)
{
DEBUGf("DoCommand\n");
DEBUGf("\nDoCommand\n");
#ifdef DEBUGLIB
DEBUGf("CDB: %02x %02x %02x %02x %02x %02x ",
control_block[0],
control_block[1],
control_block[2],
control_block[3],
control_block[4],
control_block[5]);
if(control_block_length==10)DEBUGf("%02x %02x %02x %02x ",
control_block[6],
control_block[7],
control_block[8],
control_block[9]);
DEBUGf("\nscat %p, tl %x\n",scatter_list, transfer_length);
if(scatter_list)
{
DEBUGf(" %x:%x %x:%x \n",scatter_list->start, scatter_list->length,
(scatter_list+1)->start, (scatter_list+1)->length);
}
#endif
if (device->dying) return (_kernel_oserror *)(ErrorNumber_SCSI_Died & 0xFF);
struct umass_softc *softc = (struct umass_softc *)device->softc;
......@@ -314,9 +337,33 @@ _kernel_oserror *glue_DoCommand(my_usb_device_t *device, uint32_t lun, uint32_t
device->ticker_semaphore = true; /* prevent TickerV from doing anything */
if (!irqs_were_off) _kernel_irqs_on();
device->background_transfer_active = false;
device->current_fill=0;
if (data_direction != DIR_NONE << 24)
{
uint32_t maxpacket = device->current_pipe->maxpacket;
/* check whether command is block oriented */
/* and thus whether block complete is needed */
switch(control_block[0])
{
case 0x08:
case 0x28: /* read command */
case 0x0a:
case 0x2a: /* write command */
case 0x0f:
case 0x2f: /* verify command */
DEBUGf(" Need part packet correction check left:%x mp:%x\n",transfer_length & (maxpacket-1),maxpacket);
if((transfer_length & (maxpacket-1)) > 0)
{
device->current_fill=maxpacket-(transfer_length & (maxpacket-1));
transfer_length=(transfer_length&~(maxpacket-1)) + maxpacket;
}
break;
default:
break;
}
DEBUGf(" Using fill of %x\n",device->current_fill);
/* Skip any leading null-length entries in the scatter list */
while (scatter_list->length == 0)
{
......@@ -331,8 +378,10 @@ _kernel_oserror *glue_DoCommand(my_usb_device_t *device, uint32_t lun, uint32_t
device->callback = callback; /* remember the address to call in SCSIDriver */
device->callback_pw = callback_pw;
device->callback_wp = callback_wp;
softc->sc_methods->wire_xfer(softc, lun, control_block, control_block_length, scatter_list, transfer_length, data_direction >> 24, Callback, (void *)device, (usbd_status *)&device->status);
DEBUGf("using length %x in wire_xfer\n",transfer_length);
softc->sc_methods->wire_xfer(softc, lun, control_block, control_block_length,
scatter_list, transfer_length, data_direction >> 24,
Callback, (void *)device, (usbd_status *)&device->status);
DEBUGf("going into wire_state, state, status = %x %x\n", softc->transfer_state, device->status);
while (softc->transfer_state != TSTATE_IDLE && !device->background_transfer_active)
{
......@@ -376,6 +425,9 @@ _kernel_oserror *glue_DoCommand(my_usb_device_t *device, uint32_t lun, uint32_t
*
* Assumptions
* Interrupts are disabled
* which means that we cannot rely on any memory claims
* including auto allocate of 'unknown' quantities of buffer
* hence all buffers used must have been pre-allocated
*
* Inputs
* device: struct describing the interface to process
......@@ -388,30 +440,31 @@ _kernel_oserror *glue_DoCommand(my_usb_device_t *device, uint32_t lun, uint32_t
*****************************************************************************/
void glue_Tick(my_usb_device_t *device)
{
DEBUGf("Tick\n");
/* Semaphore check .. out quickly if already here */
if (device->ticker_semaphore) return;
device->ticker_semaphore = true;
DEBUGf("\nTick ");
struct umass_softc *softc = (struct umass_softc *)device->softc;
DEBUGf("Initial state, status = %x %x\n", softc->transfer_state, device->status);
DEBUGf("Initial state, status = %x %x ", softc->transfer_state, device->status);
/* Assume interrupts are disabled on entry - */
/* this will be true for TickerV, for any events (we're most likely to use Event_OutputEmpty) */
/* and (as a special case for upcalls) for UpCall_DeviceThresAbove/Below */
/* There may be reentrancy problems with the events and upcalls - defer implementation until this is investigated */
/* Semaphore check */
if (device->ticker_semaphore) return;
device->ticker_semaphore = true;
_kernel_oserror *e;
size_t buffer_used;
/* Behaviour is different for reads and writes */
if (device->current_pipe->write)
{
/* === WRITING === */
DEBUGf(" WritePipe\n");
/* Check the buffer occupancy (because MonitorTx purges the buffer if there's an error), */
/* check for errors, then write as much as possible */
buffer_used = USED_SPACE(device->current_pipe->buffer);
DEBUGf("USED_SPACE = %x\n", buffer_used);
DEBUGf("TXused_space = %x, TXfree=%x\n", buffer_used,FREE_SPACE(device->current_pipe->buffer));
uint32_t maxpacket = device->current_pipe->maxpacket;
size_t buffer_free = (BUFFER_SIZE - 1) - buffer_used;
if (buffer_free < device->curr_transferlength)
......@@ -427,17 +480,17 @@ void glue_Tick(my_usb_device_t *device)
_kernel_irqs_on();
if (!e)
{
char packet[maxpacket]; /* for building up packet-size chunks */
size_t pindex = 0; /* current index into the packet */
while (buffer_free > 0 && device->curr_transferlength > 0)
{
size_t contig_len = MIN(buffer_free, MIN(device->curr_transferlength, device->curr_scatterlist->length - device->curr_offset));
DEBUGf("TX write contig_len:%x\n",contig_len);
if (pindex > 0)
{
while (pindex < maxpacket && contig_len > 0)
{
packet[pindex++] = device->curr_scatterlist->start[device->curr_offset];
softc->scbulkoutbuf[pindex++] = device->curr_scatterlist->start[device->curr_offset];
contig_len --;
buffer_free --;
buffer_used ++;
......@@ -449,7 +502,7 @@ void glue_Tick(my_usb_device_t *device)
{
device->curr_scatterlist++;
device->curr_offset = 0;
if ((uint32_t) device->curr_scatterlist->start >= 0xFFFF00000u)
if ((uint32_t) device->curr_scatterlist->start >= 0xFFFF0000u)
{
device->curr_scatterlist = (scatter_entry_t *) ((char *) device->curr_scatterlist + (int32_t) device->curr_scatterlist->start);
}
......@@ -458,7 +511,7 @@ void glue_Tick(my_usb_device_t *device)
}
if (pindex == maxpacket)
{
INSERT_BLOCK(device->current_pipe->buffer, packet, maxpacket);
INSERT_BLOCK(device->current_pipe->buffer, softc->scbulkoutbuf, maxpacket);
pindex = 0;
}
}
......@@ -478,7 +531,7 @@ void glue_Tick(my_usb_device_t *device)
{
device->curr_scatterlist++;
device->curr_offset = 0;
if ((uint32_t) device->curr_scatterlist->start >= 0xFFFF00000u)
if ((uint32_t) device->curr_scatterlist->start >= 0xFFFF0000u)
{
device->curr_scatterlist = (scatter_entry_t *) ((char *) device->curr_scatterlist + (int32_t) device->curr_scatterlist->start);
}
......@@ -488,7 +541,7 @@ void glue_Tick(my_usb_device_t *device)
while (contig_len > 0)
{
packet[pindex++] = device->curr_scatterlist->start[device->curr_offset];
softc->scbulkoutbuf[pindex++] = device->curr_scatterlist->start[device->curr_offset];
contig_len --;
buffer_free --;
buffer_used ++;
......@@ -500,7 +553,7 @@ void glue_Tick(my_usb_device_t *device)
{
device->curr_scatterlist++;
device->curr_offset = 0;
if ((uint32_t) device->curr_scatterlist->start >= 0xFFFF00000u)
if ((uint32_t) device->curr_scatterlist->start >= 0xFFFF0000u)
{
device->curr_scatterlist = (scatter_entry_t *) ((char *) device->curr_scatterlist + (int32_t) device->curr_scatterlist->start);
}
......@@ -509,7 +562,7 @@ void glue_Tick(my_usb_device_t *device)
}
if (pindex == maxpacket || device->curr_transferlength == 0)
{
INSERT_BLOCK(device->current_pipe->buffer, packet, pindex);
INSERT_BLOCK(device->current_pipe->buffer, softc->scbulkoutbuf, pindex);
pindex = 0;
}
......@@ -519,18 +572,21 @@ void glue_Tick(my_usb_device_t *device)
else
{
/* === READING === */
DEBUGf(" ReadPipe\n");
/* Repeatedly read as much as possible, *then* check for errors, to minimise data loss */
while ((buffer_used = USED_SPACE(device->current_pipe->buffer)) > 0 && device->curr_transferlength > 0)
{
DEBUGf("USED_SPACE = %x\n", buffer_used);
DEBUGf("RXused_space = %x RXfree=%x\n", buffer_used,FREE_SPACE(device->current_pipe->buffer));
_kernel_irqs_on();
DEBUGf("RX data needed = %x, ", device->curr_transferlength);
while (buffer_used > 0 && device->curr_transferlength > 0)
{
size_t contig_len = MIN(buffer_used, MIN(device->curr_transferlength, device->curr_scatterlist->length - device->curr_offset));
REMOVE_BLOCK(device->current_pipe->buffer, device->curr_scatterlist->start + device->curr_offset, contig_len);
buffer_used -= contig_len;
device->curr_transferlength -= contig_len;
DEBUGf("RX still to go = %x, ", device->curr_transferlength);
device->curr_offset += contig_len;
if (device->curr_transferlength > 0)
{
......@@ -538,7 +594,7 @@ void glue_Tick(my_usb_device_t *device)
{
device->curr_scatterlist++;
device->curr_offset = 0;
if ((uint32_t) device->curr_scatterlist->start >= 0xFFFF00000u)
if ((uint32_t) device->curr_scatterlist->start >= 0xFFFF0000u)
{
device->curr_scatterlist = (scatter_entry_t *) ((char *) device->curr_scatterlist + (int32_t) device->curr_scatterlist->start);
}
......@@ -547,7 +603,7 @@ void glue_Tick(my_usb_device_t *device)
}
_kernel_irqs_off();
}
DEBUGf("USED_SPACE = %x, ", buffer_used);
DEBUGf("Still in RX buffer: = %x, ", buffer_used);
e = _swix(DeviceFS_CallDevice, _INR(0,2),
DeviceCall_MonitorRX,
device->devicefs_name,
......@@ -735,6 +791,7 @@ static void GetOnTickerV(my_usb_device_t *device)
TickerV,
module_tickerv_handler,
global_PrivateWord);
DEBUGf("\n hello tickerV ");
}
if (!irqs_were_off) _kernel_irqs_on();
}
......@@ -772,6 +829,7 @@ static void GetOffTickerV(my_usb_device_t *device)
{
if ((global_TickerList = ptr->next_ticker) == NULL)
{
DEBUGf("\n byebye tickerV ");
_swix(OS_Release, _INR(0,2),
TickerV,
module_tickerv_handler,
......@@ -816,6 +874,7 @@ 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");
_kernel_oserror *e = _swix(DeviceFS_CallDevice, _INR(0,1)|_INR(3,6),
DeviceCall_ExternalBase + 0,
((my_usb_device_t *)pipe)->devicefs_name,
......@@ -856,12 +915,13 @@ usbd_status usbd_open_pipe(usbd_interface_handle iface, u_int8_t address, u_int8
char filename[sizeof "USBxxxxxxxxxxxxxxxx#interfacexxx;alternatexxx;endpointxxx;bulk;sizexxxxxx:" + 1];
if (pipe) *pipe = 0; /* in case of error */
sprintf(filename, "%s#interface%d;alternate%d;endpoint%d;bulk;size%d:",
sprintf(filename, "%s#alternate%d;interface%d;endpoint%d;bulk;size%d:",
device->devicefs_name,
device->interface,
device->alternate,
address & 0x7F,
BUFFER_SIZE);
DEBUGf("\n usbd_open_pipe %s\n",filename);
_swix(OS_Claim, _INR(0,2),
UpCallV,
asm_UpCallHandler,
......@@ -876,6 +936,7 @@ usbd_status usbd_open_pipe(usbd_interface_handle iface, u_int8_t address, u_int8
&device->pipe[flags].devicedriverstreamhandle);
if (e)
{
DEBUGf("\n usbd_open_pipe error %s\n",e->errmess);
switch (e->errnum)
{
case ErrorBase_USBDriver + 4: return USBD_IN_USE;
......@@ -968,6 +1029,7 @@ usbd_status umass_setup_transfer(struct umass_softc *sc, usbd_pipe_handle pipeh,
IGNORE(sc);
pipe_block_t *pipe = (pipe_block_t *)pipeh;
my_usb_device_t *device = pipe->device;
DEBUGf("umass_setup_transfer ");
if (!pipe->write)
{
......@@ -990,9 +1052,9 @@ usbd_status umass_setup_transfer(struct umass_softc *sc, usbd_pipe_handle pipeh,
{
device->orig_scatterlist = buffer;
}
device->orig_transferlength = buflen;
device->curr_scatterlist = device->orig_scatterlist;
device->curr_offset = 0;
device->orig_transferlength = buflen+device->current_fill;
device->curr_transferlength = buflen;
device->background_transfer_active = true;
return USBD_NORMAL_COMPLETION;
......@@ -1021,6 +1083,7 @@ usbd_status umass_setup_transfer(struct umass_softc *sc, usbd_pipe_handle pipeh,
usbd_status umass_clear_endpoint_stall(struct umass_softc *sc, int endpt)
{
bool irqs_were_off = _kernel_irqs_disabled();
DEBUGf("umass_clear_endpoint_stall ");
if (!irqs_were_off) _kernel_irqs_off();
my_usb_device_t *device = global_DeviceList;
while (device != NULL)
......@@ -1040,6 +1103,54 @@ usbd_status umass_clear_endpoint_stall(struct umass_softc *sc, int endpt)
return USBD_IOERROR;
}
#ifdef UMASS_DEBUG
#include <stdarg.h>
#include "DebugLib/DebugLib.h"
Static const char * const usbd_error_strs[] = {
"NORMAL_COMPLETION",
"IN_PROGRESS",
"PENDING_REQUESTS",
"NOT_STARTED",
"INVAL",
"NOMEM",
"CANCELLED",
"BAD_ADDRESS",
"IN_USE",
"NO_ADDR",
"SET_ADDR_FAILED",
"NO_POWER",
"TOO_DEEP",
"IOERROR",
"NOT_CONFIGURED",
"TIMEOUT",
"SHORT_XFER",
"STALLED",
"INTERRUPTED",
"XXX",
};
const char *
usbd_errstr(usbd_status err)
{
static char buffer[5];
if (err < USBD_ERROR_MAX) {
return usbd_error_strs[err];
} else {
snprintf(buffer, sizeof buffer, "%d", err);
return buffer;
}
}
void logprintf (char* format, ...)
{
va_list p;
va_start (p, format);
dvprintf (("", format, p));
}
#endif
/*****************************************************************************
* END OF FILE
*****************************************************************************/
......@@ -31,6 +31,8 @@
/*****************************************************************************
* Include header files
*****************************************************************************/
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
......@@ -46,7 +48,7 @@
#include "USB/USBDevFS.h"
#include "global.h"
#include "glue.h"
#include "glue.h"
#include "modhdr.h"
#include "resmess.h"
......@@ -76,7 +78,7 @@
* Function prototypes - Private to this file
*****************************************************************************/
static uint32_t RegisterSCSIDevice(void *device);
static void DeregisterSCSIDevice(void *device, uint32_t scsi_driver_handle);
//static void DeregisterSCSIDevice(void *device, uint32_t scsi_driver_handle);
static _kernel_oserror *SearchForDevices(void);
static _kernel_oserror *CheckConnectedDevice(const USBServiceCall *service_call_block);
static _kernel_oserror *CheckDisconnectedDevice(const char *device_name);
......@@ -123,14 +125,19 @@ _kernel_oserror *module_Init(const char *cmd_tail, int podule_base, void *pw)
IGNORE(cmd_tail);
IGNORE(podule_base);
debug_initialise("SCSISoftUSB", "null:", "");
debug_atexit();
debug_set_taskname_prefix(false);
debug_set_area_level_prefix(true);
debug_set_area_pad_limit(0);
debug_set_device(NULL_OUTPUT);
debug_set_raw_device(NULL_OUTPUT);
debug_set_trace_device(NULL_OUTPUT);
debug_initialise("SCSISoftUSB", "null:", 0);
// debug_set_taskname_prefix(true);
// debug_set_area_level_prefix(true);
// debug_set_area_pad_limit(0);
debug_set_unbuffered_files (TRUE);
debug_set_stamp_debug (TRUE);
debug_set_device( DEBUGIT_OUTPUT);
// debug_set_device( PRINTF_OUTPUT);
// debug_set_raw_device( DEBUGIT_OUTPUT);
// debug_set_trace_device(DEBUGIT_OUTPUT);
// debug_set_device(NULL_OUTPUT);
// debug_set_raw_device(NULL_OUTPUT);
// debug_set_trace_device(NULL_OUTPUT);
global_PrivateWord = pw;
......@@ -156,8 +163,6 @@ _kernel_oserror *module_Init(const char *cmd_tail, int podule_base, void *pw)
{
MessagesOpen = true;
#endif
e = SearchForDevices();
}
if (!e)
{
......@@ -221,6 +226,8 @@ _kernel_oserror *module_CallbackFromInit(_kernel_swi_regs *r, void *pw)
{
IGNORE(r);
IGNORE(pw);
/* lets see what is there .. */
SearchForDevices();
return NULL;
}
......@@ -251,13 +258,12 @@ _kernel_oserror *module_Final(int fatal, int podule, void *pw)
/* For safety, ensure we're no longer on TickerV */
_kernel_irqs_off();
for (my_usb_device_t *device = global_TickerList; device != NULL; device = device->next_ticker)
{
_swix(OS_Release, _INR(0,2),
TickerV,
module_tickerv_handler,
global_PrivateWord);
}
global_TickerList=NULL;
_swix(OS_Release, _INR(0,2),
TickerV,
module_tickerv_handler,
global_PrivateWord);
_kernel_irqs_on();
if (!e)
......@@ -534,7 +540,7 @@ static _kernel_oserror *SearchForDevices(void)
* NONE
*
* Returns
* NULL if successful; otherwise pointer to error block
* NULL
*****************************************************************************/
static _kernel_oserror *CheckConnectedDevice(const USBServiceCall *service_call_block)
{
......@@ -556,11 +562,15 @@ static _kernel_oserror *CheckConnectedDevice(const USBServiceCall *service_call_
else if (((usb_descriptor_t *)ptr)->bDescriptorType == UDESC_INTERFACE)
{
const usb_interface_descriptor_t *interface = (const usb_interface_descriptor_t *) ptr;
if (interface->bInterfaceClass == 8 /* mass storage class */ &&
interface->bInterfaceSubClass == 6 /* SCSI */ &&
(interface->bInterfaceProtocol == 0 /* control/bulk/interrupt with command completion interrupt */ ||
interface->bInterfaceProtocol == 1 /* control/bulk/interrupt without command completion interrupt */ ||
interface->bInterfaceProtocol == 0x50 /* bulk-only */))
if (interface->bInterfaceClass == 8 /* mass storage class */
&& (interface->bInterfaceSubClass == 6 /* SCSI */
|| interface->bInterfaceSubClass == 5 /* floppy */
)
&& (interface->bInterfaceProtocol == 0 /* control/bulk/interrupt with command completion interrupt */
|| interface->bInterfaceProtocol == 1 /* control/bulk/interrupt without command completion interrupt */
|| interface->bInterfaceProtocol == 0x50 /* bulk-only */
)
)
{
my_usb_device_t *device = (my_usb_device_t *)((char *) calloc(1, sizeof *device) - 4);
if (device != NULL)
......@@ -737,10 +747,29 @@ static _kernel_oserror *RemoveAllDevices(void)
{
for (my_usb_device_t *device = global_DeviceList; device != NULL; device = global_DeviceList)
{
device->dying = true;
glue_DetachDevice(device);
DeregisterSCSIDevice(device, device->scsi_driver_handle);
global_DeviceList = device->next;
char buf[32]; /* *USBReset + sizeof(my_usb_device.devicefs_name) */
char *p=device->devicefs_name;
int i;
for(i=0;i<32;i++)
{
if(isalpha(*p))
{
buf[i]=*(p++);
}
else
{
buf[i] = 0;
break;
}
}
strcat(buf,"Reset ");strcat(buf,p);
dprintf(("",buf));