GitLab has been upgraded to 13.3.6. If you encounter any issues mail code@riscosopen.org

Commit 8d9d1841 authored by ROOL's avatar ROOL 🤖

Internationalised

Detail:
  Add support for standalone messages registration, and actually use the messages rather than just exporting them in ROM builds.
  Changed to use allocated error bases rather than 0.
  Sync with other HC for ease of comparison where possible.
Admin:
  Submission for USB bounty.
  Tested on a BBxM.

Version 0.28. Tagged as 'MUSBDriver-0_28'
parent ea60d17e
| Copyright 2016 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 standalone CFLAGS="-ff" THROWBACK=-throwback
| Copyright 2009 Castle Technology Ltd
| Copyright 2016 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.
......@@ -13,4 +13,4 @@
| limitations under the License.
|
dir <obey$dir>
amu_machine all rom CFLAGS="-ff" THROWBACK=-throwback
amu_machine rom CFLAGS="-ff" THROWBACK=-throwback
......@@ -17,10 +17,10 @@
# $Id$
COMPONENT = MUSBDriver
RES_OBJ = msgs
RES_AREA = resource_files
OBJS = cmodule call_veneer musb musb_debug musb_peri musb_root musb_usb musb_util port triggercbs tps
OBJS_HAL = o_hal.musb o_hal.musb_peri o_hal.musb_root o_hal.musb_usb o_hal.musb_util o_hal.tps o_hal.musb_hal
LIBS = ${CALLXLIB} ${ASMUTILS} ${TBOXLIBS}
LIBS = ${CALLXLIB} ${ASMUTILS} ${TBOXINTLIB}
CMHGFILE = modhead
HDRS =
USBDIR = <Lib$Dir>.USB
......@@ -38,7 +38,8 @@ endif
CFLAGS += -wp -wc
CDEFINES += -DKERNEL -D_KERNEL -Dpaddr_t=int -D__P(A)=A -DKLD_MODULE -DDISABLE_PACKED
CINCLUDES = -Itbox:,TCPIPLibs:,^.^.NetBSD.,OS:
ROMCDEFINES = -DROM
CINCLUDES = -ITCPIPLibs:,^.^.NetBSD.,OS:
CMHGDEFINES += -DCOMPONENT=${COMPONENT}
CMHGDEPENDS = cmodule musb tps
LDFLAGS = -Symbols rm.sym${TARGET}
......
E00:USB Pipe has timed out
E01:Cannot claim memory for USB
E02:USB Request failed (code %0)
E03:Invalid USB %0 descriptor
#{DictTokens}
#00:Global
E01:No MUSB devices found
E02:Couldn't claim veneer
E03:USBDriver too old
RHub:MUSBMHDRC root hub
DevN:RISC OS computer
/* (0.27)
/* (0.28)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.27
#define Module_MajorVersion_CMHG 0.28
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 02 May 2016
#define Module_Date_CMHG 17 Dec 2016
#define Module_MajorVersion "0.27"
#define Module_Version 27
#define Module_MajorVersion "0.28"
#define Module_Version 28
#define Module_MinorVersion ""
#define Module_Date "02 May 2016"
#define Module_Date "17 Dec 2016"
#define Module_ApplicationDate "02-May-16"
#define Module_ApplicationDate "17-Dec-16"
#define Module_ComponentName "MUSBDriver"
#define Module_ComponentPath "mixed/RiscOS/Sources/HWSupport/USB/Controllers/MUSBDriver"
#define Module_FullVersion "0.27"
#define Module_HelpVersion "0.27 (02 May 2016)"
#define Module_LibraryVersionInfo "0:27"
#define Module_FullVersion "0.28"
#define Module_HelpVersion "0.28 (17 Dec 2016)"
#define Module_LibraryVersionInfo "0:28"
......@@ -59,7 +59,7 @@ extern void* resource_files (void);
*****************************************************************************/
static int* magic = NULL;
static int hal_device = 0;
static int hal_device = -1;
static int instance = 0;
static int device_number;
......@@ -83,7 +83,10 @@ static _kernel_oserror* register_bus(void *in,struct device **out)
if(e)
return e;
if(version < RISCOS_USBDRIVER_API_VERSION)
return (_kernel_oserror*)"\0\0\0\0USBDriver too old";
{
return make_error (ErrorNumber_MUSB_USBTooOld, 0);
}
/* Now attempt to register */
registering = true;
e = _swix(USBDriver_RegisterBus, _INR(0,1)|_OUT(0),in,RISCOS_USBDRIVER_API_VERSION,out);
......@@ -212,7 +215,7 @@ static void shutdown_driver()
_kernel_oserror* module_init (const char *cmd_tail, int podule_base, void *pw)
{
_kernel_oserror* e = 0;
_kernel_oserror* e = NULL;
callx_init (pw);
......@@ -243,13 +246,29 @@ _kernel_oserror* module_init (const char *cmd_tail, int podule_base, void *pw)
hal_device = (int) strtol (cmd_tail, &endptr, 0);
if (endptr == cmd_tail)
{
return (_kernel_oserror*)
"\1\0\0\0"Module_Title" can't be reinitialised";
struct
{
int errnum;
char errtok[8];
} err_noreinit = { ErrorNumber_MUSB_NoReinit, "NumParm" };
return _swix (MessageTrans_ErrorLookup, _INR(0,2),
&err_noreinit, 0 /* Global messages */, 0 /* Internal buffer */);
}
}
else
{
#ifndef ROM
/* Only first instance registers the messages in ResourceFS */
e = _swix (ResourceFS_RegisterFiles, _IN (0), resource_files ());
if (e != NULL) return e;
#endif
}
// find the next possible controller
e = messages_file_open (Module_MessagesFile);
if (e) goto error_dereg;
/* find the next possible controller */
do {
struct
{
......@@ -260,28 +279,32 @@ _kernel_oserror* module_init (const char *cmd_tail, int podule_base, void *pw)
} usbinfo;
size_t usbinfolen;
hal_device++;
e = _swix(OS_Hardware, _INR(0,2)|_INR(8,9)|_OUT(0),
hal_device, &usbinfo, sizeof usbinfo,
0, EntryNo_HAL_USBControllerInfo,
&usbinfolen);
if (!e && (usbinfolen == sizeof(usbinfo)) && usbinfo.type == 2)
if (!e && (usbinfolen == sizeof(usbinfo)) && (usbinfo.type == HALUSBControllerType_MUSBMHDRC))
{
device_number = usbinfo.devno;
musb_base = usbinfo.hw;
break;
}
if(e || !usbinfolen)
{
device_number = usbinfo.devno;
musb_base = usbinfo.hw;
break;
}
else
hal_device++;
if(e) return e;
if(!usbinfolen)
return (_kernel_oserror*) "\0\0\0\0No MUSB devices found";
/* Reached end of list */
e = make_error (ErrorNumber_MUSB_NoMUSB, 0);
goto error;
}
} while (1);
dprintf (("", "Found MUSB controller on device %d\n", hal_device));
if ((magic = init_veneer ()) == NULL)
{
return (_kernel_oserror*) "\0\0\0\0Couldn't claim magic";
e = make_error (ErrorNumber_MUSB_ClaimVeneer, 0);
goto error;
}
dprintf (("", "magic at %p", magic));
......@@ -291,9 +314,18 @@ _kernel_oserror* module_init (const char *cmd_tail, int podule_base, void *pw)
/* try and start a new instance to catch any more controllers on the bus */
callx_add_callback (new_instance, 0);
callx_add_callback (new_instance, 0);
return 0;
return NULL;
error:
dprintf (("", "Failed initialisation: %s\n", e->errmess));
messages_file_close ();
error_dereg:
#ifndef ROM
if (podule_base == 0) _swix (ResourceFS_DeregisterFiles, _IN(0), resource_files ());
#endif
return e;
}
_kernel_oserror *module_final(int fatal, int podule, void *pw)
......@@ -312,13 +344,15 @@ _kernel_oserror *module_final(int fatal, int podule, void *pw)
if (magic) _swix (OS_Module, _IN(0)|_IN(2), 7, magic);
//#ifdef STANDALONE
// /* only remove files for last instantiation */
// if (podule == 0)
// {
// _swix (ResourceFS_DeregisterFiles, _IN (0), resource_files ());
// }
//#endif
messages_file_close ();
#ifndef ROM
/* only remove files for last instantiation */
if (podule == 0)
{
_swix (ResourceFS_DeregisterFiles, _IN(0), resource_files ());
}
#endif
return NULL;
}
......@@ -363,7 +397,12 @@ void module_services(int service_number, _kernel_swi_regs *r, void *pw)
dprintf (("", "Svce prereset %x %x\n",Service_PreReset,service_number));
shutdown_driver(); /* Should be safe to do this without deregistering the bus */
break;
default:break;
#ifndef ROM
case Service_ResourceFSStarting:
/* Re-register the messages */
(*(void (*)(void *, void *, void *, void *))r->r[2]) (resource_files (), 0, 0, (void *)r->r[3]);
break;
#endif
}
}
......
......@@ -129,7 +129,7 @@ static int musb_ep0_peri_handle(musb_softc_t *sc)
int len = UGETW(req->wLength);
int value = UGETW(req->wValue);
// int index = UGETW(req->wIndex);
char name[USB_MAX_STRING_LEN];
void *buf = sc->peri_ep0_rxbuf;
int l;
......@@ -207,7 +207,9 @@ static int musb_ep0_peri_handle(musb_softc_t *sc)
sc->peri_ep0_txremain = musb_str(buf, len, sc->peri_vendor);
break;
case 2: /* Product */
sc->peri_ep0_txremain = musb_str(buf, len, "RISC OS computer");
value = sizeof(name);
messages_file_lookup("DevN", name, &value, 0);
sc->peri_ep0_txremain = musb_str(buf, len, name);
break;
}
return 0;
......
......@@ -169,6 +169,7 @@ musb_root_ctrl_start(usbd_xfer_handle xfer)
usb_config_descriptor_t confd;
usbd_status err;
int devctl,power;
char name[USB_MAX_STRING_LEN];
volatile musb_regs *musb_base = sc->musb_base;
#ifdef DIAGNOSTIC
......@@ -287,7 +288,9 @@ musb_root_ctrl_start(usbd_xfer_handle xfer)
totlen = musb_str(buf, len, sc->sc_vendor);
break;
case 2: /* Product */
totlen = musb_str(buf, len, "MUSBMHDRC root hub");
value = sizeof(name);
messages_file_lookup("RHub", name, &value, 0);
totlen = musb_str(buf, len, name);
break;
}
break;
......
......@@ -21,7 +21,8 @@ initialisation-code: module_init
finalisation-code: module_final
service-call-handler: module_services Service_USB,
Service_PreReset
Service_PreReset,
Service_ResourceFSStarting
title-string: COMPONENT
......
......@@ -17,6 +17,12 @@
#define NOTUSED(V) ((V)=(V))
#define ErrorBase_MUSBDriver 0x820A80
#define ErrorNumber_MUSB_NoReinit (ErrorBase_MUSBDriver+0)
#define ErrorNumber_MUSB_NoMUSB (ErrorBase_MUSBDriver+1)
#define ErrorNumber_MUSB_ClaimVeneer (ErrorBase_MUSBDriver+2)
#define ErrorNumber_MUSB_USBTooOld (ErrorBase_MUSBDriver+3)
#ifndef USBHAL
extern void* private_word;
extern void build_veneer (int* vn, int* st, size_t sz);
......
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