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

Commit 21123a25 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 controller hunting loop with other HC for ease of comparison.
Admin:
  Submission for USB bounty.
  Tested on a Pi 2.

Version 0.29. Tagged as 'DWCDriver-0_29'
parent ff0f490e
| 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 2012 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 = DWCDriver
RES_OBJ = msgs
RES_AREA = resource_files
OBJS = cmodule call_veneer triggercbs dwc_common_riscos dwc_otg_riscos softc_root softc_device port regaccess
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 dwc_otg_riscos softc_root softc_device
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 DWC devices found
E02:Couldn't claim veneer
E03:USBDriver too old
E08:Failed to init HCD
E09:Failed to start HCD
E0a:Incorrect device parameters
RHub:Synopsys DWC OTG root hub
/* (0.28)
/* (0.29)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.28
#define Module_MajorVersion_CMHG 0.29
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 15 Jun 2016
#define Module_Date_CMHG 17 Dec 2016
#define Module_MajorVersion "0.28"
#define Module_Version 28
#define Module_MajorVersion "0.29"
#define Module_Version 29
#define Module_MinorVersion ""
#define Module_Date "15 Jun 2016"
#define Module_Date "17 Dec 2016"
#define Module_ApplicationDate "15-Jun-16"
#define Module_ApplicationDate "17-Dec-16"
#define Module_ComponentName "DWCDriver"
#define Module_ComponentPath "mixed/RiscOS/Sources/HWSupport/USB/Controllers/DWCDriver"
#define Module_FullVersion "0.28"
#define Module_HelpVersion "0.28 (15 Jun 2016)"
#define Module_LibraryVersionInfo "0:28"
#define Module_FullVersion "0.29"
#define Module_HelpVersion "0.29 (17 Dec 2016)"
#define Module_LibraryVersionInfo "0:29"
......@@ -35,6 +35,7 @@
#include "Interface/USBDriver.h"
#include "callx/callx.h"
#include "cmodule.h"
#include "tboxlibint/messages.h"
/* Have to avoid including stdio as there's a clash with the BSD stuff */
#define __stdio_h
......@@ -66,7 +67,7 @@ static int instance = 0; /* Module instance no. */
static int* veneer_code = NULL; /* Pointer to USBDriver call veneer code */
static int hal_device = 0; /* Index of USB device in HAL */
static int hal_device = -1; /* Index of USB device in HAL */
static int usb_device_number; /* USB IRQ number */
static void *dwc_base=NULL; /* HW registers */
static void *mphi_base=NULL; /* MPHI registers */
......@@ -95,7 +96,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_DWC_USBTooOld, 0);
}
/* Now attempt to register */
registering = true;
e = _swix(USBDriver_RegisterBus, _INR(0,1)|_OUT(0),in,RISCOS_USBDRIVER_API_VERSION,out);
......@@ -243,13 +247,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_DWC_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
}
e = messages_file_open (Module_MessagesFile);
if (e) goto error_dereg;
// find the next possible controller
/* find the next possible controller */
do {
struct
{
......@@ -263,6 +283,8 @@ _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,
......@@ -276,18 +298,20 @@ _kernel_oserror* module_init (const char *cmd_tail, int podule_base, void *pw)
mphi_device_number = usbinfo.devno_mphi;
break;
}
else
hal_device++;
if(e) return e;
if(!usbinfolen)
return (_kernel_oserror*) "\0\0\0\0No DWC devices found";
if(e || !usbinfolen)
{
/* Reached end of list */
e = make_error (ErrorNumber_DWC_NoDWC, 0);
goto error;
}
} while (1);
dprintf (("", "Found DWC controller at %08x IRQ %d on device %d\n", dwc_base, usb_device_number, hal_device));
if ((veneer_code = init_veneer ()) == NULL)
{
return (_kernel_oserror*) "\0\0\0\0Couldn't claim veneer memory";
e = make_error (ErrorNumber_DWC_ClaimVeneer, 0);
goto error;
}
dprintf (("", "veneer_code at %p\n", veneer_code));
......@@ -305,7 +329,16 @@ _kernel_oserror* module_init (const char *cmd_tail, int podule_base, void *pw)
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)
......@@ -324,6 +357,15 @@ _kernel_oserror *module_final(int fatal, int podule, void *pw)
if (veneer_code) _swix (OS_Module, _IN(0)|_IN(2), 7, veneer_code);
messages_file_close ();
#ifndef ROM
/* only remove files for last instantiation */
if (podule == 0)
{
_swix (ResourceFS_DeregisterFiles, _IN(0), resource_files ());
}
#endif
return NULL;
}
......@@ -408,8 +450,12 @@ void module_services(int service_number, _kernel_swi_regs *r, void *pw)
}
}
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
}
}
......
......@@ -31,6 +31,7 @@
#include "kernel.h"
#include "swis.h"
#include "cmodule.h"
#include "tboxlibint/messages.h"
#include "modhead.h"
#include "Global/HALEntries.h"
#include "Global/Services.h"
......@@ -599,7 +600,7 @@ _kernel_oserror *dwc_otg_riscos_init(const uint32_t *hw_base,const uint8_t *mphi
if(ret)
{
dwc_otg_cil_remove(softc->dwc_dev.core_if);
return (_kernel_oserror *) "\0\0\0\0Incorrect device parameters";
return make_error(ErrorNumber_DWC_BadDevParms, 0);
}
/* Disable global interrupts */
......@@ -634,7 +635,7 @@ _kernel_oserror *dwc_otg_riscos_init(const uint32_t *hw_base,const uint8_t *mphi
if(ret)
{
/* DWCTODO - Tidy up properly */
return (_kernel_oserror *) "\0\0\0\0Failed to init HCD";
return make_error(ErrorNumber_DWC_FailInitHCD, 0);
}
/* Get port number */
......@@ -677,7 +678,7 @@ _kernel_oserror *dwc_otg_riscos_init(const uint32_t *hw_base,const uint8_t *mphi
if(ret)
{
/* DWCTODO - Tidy up properly */
return (_kernel_oserror *) "\0\0\0\0Failed to start HCD";
return make_error(ErrorNumber_DWC_FailStartHCD, 0);
}
if (use_fiq_fix)
......
......@@ -41,6 +41,7 @@
#include "kernel.h"
#include "swis.h"
#include "cmodule.h"
#include "tboxlibint/messages.h"
#include "modhead.h"
#include <sys/callout.h>
......@@ -158,6 +159,7 @@ usbd_status softc_root_ctrl_start(usbd_xfer_handle xfer)
usb_config_descriptor_t confd;
usbd_status err;
int devctl,power;
char name[USB_MAX_STRING_LEN];
#ifdef DIAGNOSTIC
if (!(xfer->rqflags & URQ_REQUEST))
......@@ -275,7 +277,9 @@ usbd_status softc_root_ctrl_start(usbd_xfer_handle xfer)
totlen = softc_str(buf, len, sc->sc_vendor);
break;
case 2: /* Product */
totlen = softc_str(buf, len, "Synopsys DWC OTG root hub");
value = sizeof(name);
messages_file_lookup("RHub", name, &value, 0);
totlen = softc_str(buf, len, name);
break;
}
break;
......
......@@ -24,7 +24,8 @@ service-call-handler: module_services Service_USB,
Service_PreReset,
Service_ModulePostFinal,
Service_ClaimFIQ,
Service_ReleaseFIQ
Service_ReleaseFIQ,
Service_ResourceFSStarting
title-string: COMPONENT
......
......@@ -17,6 +17,16 @@
#define NOTUSED(V) ((V)=(V))
#define ErrorBase_DWCDriver 0x820AC0
#define ErrorNumber_DWC_NoReinit (ErrorBase_DWCDriver+0)
#define ErrorNumber_DWC_NoDWC (ErrorBase_DWCDriver+1)
#define ErrorNumber_DWC_ClaimVeneer (ErrorBase_DWCDriver+2)
#define ErrorNumber_DWC_USBTooOld (ErrorBase_DWCDriver+3)
/* Skip a few for common HC errors */
#define ErrorNumber_DWC_FailInitHCD (ErrorBase_DWCDriver+8)
#define ErrorNumber_DWC_FailStartHCD (ErrorBase_DWCDriver+9)
#define ErrorNumber_DWC_BadDevParms (ErrorBase_DWCDriver+10)
#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