Commit 368ea7b5 authored by Jeffrey Lee's avatar Jeffrey Lee

Make SCSISoftUSB's 'PopUpDelay' configurable, improve robustness of device registration

Detail:
  c/global, c/module, cmhg/header, h/global - The new command *SCSISoftUSB_PopUpDelay can now be used to control the popup delay value. Additionally, no delay is used if outside the desktop.
  Makefile, Resources/UK/Messages - Added resources file containing text for the new * command
  c/module, cmhg/header - Devices are now registered with SCSISwitch from a callback instead of from a ticker event. This ensures the registration won't fail due to insufficient RMA space (e.g. as is often the case for devices detected during OMAP ROM initialisation)
Admin:
  Tested in ROM on rev C2 beagleboard, and in RAM on Iyonix.
  Messages file needs translating!


Version 0.12. Tagged as 'SCSISoftUSB-0_12'
parent 5204687d
......@@ -25,7 +25,7 @@ COMPONENT = SCSISoftUSB
TARGET = SCSISoftUSB
DIRS = local_dirs
CFLAGS = -ffah -wp -wc -we -zM -zps1 -ITCPIPLibs:,C:USB -DDISABLE_PACKED -D_KERNEL ${DEFINES}
RAM_OBJS = o.module ${OBJS}
RAM_OBJS = o.module ${OBJS} o.resmess
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
......@@ -36,6 +36,7 @@ DBG_MODULE = drm.${TARGET}
EXPORTS =
#MERGEDMDIR = o.${MACHINE}._Messages_
#MERGEDMSGS = ${MERGEDMDIR}.${TARGET}
RESDIR = <resource$dir>.Resources2.SCSISoftUSB
include Makefiles:StdTools
include Makefiles:ModuleLibs
......@@ -100,9 +101,14 @@ do.glue: modhdr.h
moduleROM.o: module.c modhdr.h
${CC} ${CFLAGS} -DROM_MODULE -o moduleROM.o module.c
#resmess.o: ${MERGEDMSGS}
# ResGen resmess_ResourcesFiles o.resmess ${MERGEDMSGS} Resources.SCSISoftUSB.Messages
#
resources:
${MKDIR} ${RESDIR}
${CP} LocalRes:Messages ${RESDIR}.Messages ${CPFLAGS}
@echo SCSISoftUSB: Resources copied to Messages module
resmess.o: ${MERGEDMSGS}
ResGen resmess_ResourcesFiles o.resmess LocalRes:Messages Resources.SCSISoftUSB.Messages
#${MERGEDMSGS}:
# ${MKDIR} ${MERGEDMDIR}
# IfThere LocalRes:Messages Then ${CP} LocalRes:Messages $@ ${CPFLAGS} Else Create $@
......
/* (0.11)
/* (0.12)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.11
#define Module_MajorVersion_CMHG 0.12
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 22 Oct 2009
#define Module_Date_CMHG 22 Apr 2010
#define Module_MajorVersion "0.11"
#define Module_Version 11
#define Module_MajorVersion "0.12"
#define Module_Version 12
#define Module_MinorVersion ""
#define Module_Date "22 Oct 2009"
#define Module_Date "22 Apr 2010"
#define Module_ApplicationDate "22-Oct-09"
#define Module_ApplicationDate "22-Apr-10"
#define Module_ComponentName "SCSISoftUSB"
#define Module_ComponentPath "mixed/RiscOS/Sources/HWSupport/SCSI/SCSISoftUSB"
#define Module_FullVersion "0.11"
#define Module_HelpVersion "0.11 (22 Oct 2009)"
#define Module_LibraryVersionInfo "0:11"
#define Module_FullVersion "0.12"
#define Module_HelpVersion "0.12 (22 Apr 2010)"
#define Module_LibraryVersionInfo "0:12"
......@@ -63,6 +63,8 @@ _kernel_stack_chunk *global_RTSupportStack = 0; /* RTSupport stack chunk */
int global_RTSupportHandle = 0; /* RTSupport handle */
callback_type global_CallbackType = callback_NONE; /* Type of our registered callback, if any */
uint32_t global_PopUpDelay = 400; /* Delay before SCSIFS gets told about new devices */
/*****************************************************************************
* Function prototypes - Private to this file
*****************************************************************************/
......
......@@ -57,11 +57,7 @@
/*****************************************************************************
* MACROS
*****************************************************************************/
#undef MESSAGES /* don't need any at the moment */
/* delay after arrival of mass storage device before we tell the scsi system */
/* delay increased to 4 secs from 2 secs in response to beta feedback */
#define PopUpDelay 4*100
#define MESSAGES
/*****************************************************************************
* New type definitions
......@@ -313,7 +309,7 @@ _kernel_oserror *module_Final(int fatal, int podule, void *pw)
module_scsiregister_handler,
global_PrivateWord);
_swix(OS_RemoveCallBack, _INR(0,1),
module_scsiregister_handler,
module_scsiregister_cb_handler,
global_PrivateWord);
_swix(OS_RemoveCallBack, _INR(0,1),
module_callback_from_init,
......@@ -393,7 +389,7 @@ void module_Service(int service_number, _kernel_swi_regs *r, void *pw)
device->registered = false;
}
_swix(OS_CallAfter, _INR(0,2),
PopUpDelay, /* wait n secs */
1, /* No point using a long delay if SCSIdriver has only just started */
module_scsiregister_handler,
global_PrivateWord);
......@@ -443,6 +439,7 @@ 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
*/
......@@ -452,12 +449,27 @@ _kernel_oserror *module_SCSIRegister(_kernel_swi_regs *r, void *pw)
IGNORE(pw);
if(Registering) /* come back later for another pass */
{
_swix(OS_AddCallBack, _INR(0,1),
_swix(OS_CallAfter, _INR(0,2),
10,
module_scsiregister_handler,
global_PrivateWord);
return NULL;
}
/* Instead of registering the devices directly from this ticker event, register them from a callback. This ensures SCSIdriver's malloc()s can enlarge the RMA if needed. */
Registering = true;
_swix(OS_AddCallBack, _INR(0,1),
module_scsiregister_cb_handler,
global_PrivateWord);
return NULL;
}
/* module_SCSIRegister_cb
* register any unregistered devices on the list from a callback
*/
_kernel_oserror *module_SCSIRegister_cb(_kernel_swi_regs *r, void *pw)
{
IGNORE(r);
IGNORE(pw);
for (my_usb_device_t *device = global_DeviceList; device != NULL; device = device->next)
{
if(!device->registered)
......@@ -472,7 +484,6 @@ _kernel_oserror *module_SCSIRegister(_kernel_swi_regs *r, void *pw)
}
#if 0
/*****************************************************************************
* module_Commands
*
......@@ -501,33 +512,28 @@ _kernel_oserror *module_Commands(const char *arg_string, int argc, int cmd_no, v
IGNORE(pw);
switch (cmd_no)
{
case 0:
for (my_usb_device_t *device = global_DeviceList; device != NULL; device = device->next)
case CMD_SCSISoftUSB_PopUpDelay:
if(argc)
{
printf("%s interface %d alternate %d endpoints %02X %02X %02X using %s protocol"
" has %d LUN%s and is attached to SCSI handle %p\n",
device->devicefs_name,
device->interface,
device->alternate,
device->bulk_in_endpoint,
device->bulk_out_endpoint,
device->interrupt_endpoint,
device->protocol == 0x50 ? "bulk-only" :
device->protocol == 0 ? "CBI (with interrupt)" : "CBI (with no interrupt)",
device->maxlun + 1,
device->maxlun == 0 ? "" : "s",
device);
uint32_t delay;
/* Use something that will generate an error if the user got it wrong! */
e = _swix(OS_ReadUnsigned,_INR(0,1)|_OUT(2),10,arg_string,&delay);
if(e)
return e;
global_PopUpDelay = delay;
}
else
{
const char *msg;
e = _swix(MessageTrans_Lookup,_INR(0,2)|_OUT(2),&global_MessageFD,"CDELAY",NULL,&msg);
if(e)
return e;
printf(msg,global_PopUpDelay,'\n'); /* What would be worse - using two fixed-size buffers to prepare the message string, or this atrocity? */
}
e = NULL;
break;
default:
assert(false /* unserviced star command */);
break;
}
return e;
}
#endif
/*****************************************************************************
* RegisterSCSIDevice
......@@ -761,9 +767,13 @@ static _kernel_oserror *CheckConnectedDevice(const USBServiceCall *service_call_
_swix(OS_RemoveTickerEvent, _INR(0,1),
module_scsiregister_handler,
global_PrivateWord);
device->registered = false;
device->registered = false;
char *state = getenv("Wimp$State");
uint32_t delay = global_PopUpDelay;
if(!delay || !state || strcmp(state,"desktop"))
delay = 1; /* Use shortest possible delay when outside the desktop (or if user specified delay of 0!) */
_swix(OS_CallAfter, _INR(0,2),
PopUpDelay, /* wait n secs */
delay,
module_scsiregister_handler,
global_PrivateWord);
}
......
......@@ -47,13 +47,12 @@ help-string: SCSISoftUSB Module_MajorVersion_CMHG Module_MinorVersion_CMHG
date-string: Module_Date_CMHG
;command-keyword-table: module_Commands massstorage(,
; min-args: 0,
; max-args: 0,
; international:,
; invalid-syntax: "SPFCCLT",
; help-text: "HPFCCLT"
; )
command-keyword-table: module_Commands
SCSISoftUSB_PopUpDelay( min-args: 0, max-args: 1,
international:,
invalid-syntax: "SPOPUP",
help-text: "HPOPUP")
international-help-file:"Resources:$.Resources.SCSISoftUSB.Messages"
......@@ -61,4 +60,5 @@ generic-veneers: module_callback_from_init/module_CallbackFromInit,
module_scsi_handler/module_SCSIHandler,
module_tickerv_handler/module_TickerVHandler,
module_upcallv_handler/module_UpCallVHandler,
module_scsiregister_handler/module_SCSIRegister
module_scsiregister_handler/module_SCSIRegister,
module_scsiregister_cb_handler/module_SCSIRegister_cb
......@@ -188,6 +188,7 @@ extern int global_RTSupportPollword; /* RTSupport pollword */
extern _kernel_stack_chunk *global_RTSupportStack; /* RTSupport stack chunk */
extern int global_RTSupportHandle; /* RTSupport handle */
extern callback_type global_CallbackType; /* Type of our registered callback, if any */
extern uint32_t global_PopUpDelay; /* Delay before SCSIFS gets told about new devices */
#ifdef UMASS_DEBUG
extern char *states[];
#endif
......
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