Source
...
Target
......@@ -18,3 +18,4 @@
#define USBDriver_InsertTransfer 0x054a42
#define USBDriver_TransferComplete 0x054a43
#define USBDriver_ScheduleSoftInterrupt 0x054a44
#define USBDriver_Version 0x054a45
This diff is collapsed.
; Copyright 2011 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.
;
; Assembler version of port.c, for use with HAL version of the USB drivers
; See also usbhal.c for some bits which were easier done in C.
GET Hdr:ListOpts
GET Hdr:Macros
GET Hdr:System
GET Hdr:Machine.<Machine>
GET Hdr:ImageSize.<ImageSize>
GET Hdr.usbhal
sb RN 9
AREA |C$$code|, CODE, READONLY
; External interfaces to HAL code
IMPORT USBHAL_WorkspaceOffset
IMPORT HAL_CounterDelay
IMPORT snprintf
IMPORT printf
; Internal interfaces to rest of HAL USB code
EXPORT spltty
EXPORT splx
EXPORT splbio
EXPORT delay
EXPORT selrecord
EXPORT selwakeup
EXPORT config_deactivate
EXPORT uiomove
EXPORT psignal
EXPORT kthread_create
EXPORT kthread_create1
EXPORT kthread_exit
EXPORT device_probe_and_attach
EXPORT ratecheck
EXPORT malloc_contig
EXPORT free_contig
EXPORT min
EXPORT logprintf
EXPORT cold
EXPORT hz
EXPORT _snprintf
EXPORT malloc
EXPORT free
IMPORT HALHeap_GetArea
IMPORT HALHeap_GetAreaAligned
IMPORT HALHeap_FreeArea
cold
DCD 0
hz
DCD 1000
spltty
MRS a1, CPSR
AND a1, a1, #I32_bit
MOV pc, lr
splx
TST a1, #I32_bit
MRSEQ a2, CPSR
BICEQ a2, a2, #I32_bit
MSREQ CPSR_c, a2
MOV pc, lr
splbio
MRS a1, CPSR
ORR a2, a1, #I32_bit
AND a1, a1, #I32_bit
MSR CPSR_c, a2
MOV pc, lr
delay
B HAL_CounterDelay
logprintf
B printf
kthread_create1
config_deactivate
uiomove
kthread_create
ratecheck
MOV a1, #0
selrecord
selwakeup
psignal
kthread_exit
device_probe_and_attach
MOV pc, lr
min
CMP a1, a2
MOVGT a1, a2
MOV pc, lr
_snprintf
B snprintf
malloc
; Note that this is a vanilla implementation, i.e. no M_ZERO support
; (but the usbdriver sources already deal with that)
MOV r1, r0
LDR r2, =USBHAL_WorkspaceOffset+USBHAL_WS_Heap_Normal
LDR r0, [sb, r2]
B HALHeap_GetArea
free
MOV r1, r0
LDR r2, =USBHAL_WorkspaceOffset+USBHAL_WS_Heap_Normal
LDR r0, [sb, r2]
B HALHeap_FreeArea
malloc_contig
; R0 = length
; R1 = alignment
ADD r0, r0, #3 ; Make size multiple of 4 for easy memset
BIC r0, r0, #3
Push "r0,lr"
LDR r3, =USBHAL_WorkspaceOffset+USBHAL_WS_Heap_NCNB
MOV r2, r1
MOV r1, r0
LDR r0, [sb, r3]
BL HALHeap_GetAreaAligned
Pull "r1,lr"
CMP r0, #0
MOVEQ pc, lr
; Zero the memory
MOV ip, #0
10
SUBS r1, r1, #4
STR ip, [r0, r1]
BGT %BT10
MOV pc, lr
free_contig
; R0 = pointer to pointer
LDR r2, =USBHAL_WorkspaceOffset+USBHAL_WS_Heap_NCNB
LDR r1, [r0]
LDR r0, [sb, r2]
B HALHeap_FreeArea
END
......@@ -16,32 +16,43 @@
; trigger callbacks by calling OS_LeaveOS and OS_EnterOS
GET Hdr:ListOpts
OPT OptNoList
OPT OptNoList
GET Hdr:PublicWS
GET Hdr:Macros
GET Hdr:System
GET Hdr:OSRSI6
AREA |C$$code|, CODE, READONLY
AREA |C$$data|, DATA
ptr_IRQsema
DCD 0 ; Cached IRQsema ptr
EXPORT triggercbs
AREA |C$$code|, CODE, READONLY
EXPORT triggercbs
triggercbs
; MOV ip, lr ; seen cases of ip corrupted
stmfd r13!, {lr}
MOV lr, #0
; LDR lr, [lr,#&420] ; kernel's CDA semaphore
; MOVS lr, lr
; BNE %ft2
LDR lr, [lr,#IRQsema] ; kernel's IRQ semaphore
MOVS lr, lr
; BNE %ft1
LDMNEFD r13!,{pc} ; NZ is within IRQ.. so no CB allowed
SWI &7c
SWI &16
ldmfd r13!,{pc}
; MOV pc, ip
;2
; DCD &ff000000 ;illegal instr to abort to indicate
; attempt to trigger cb whilst cda threaded
;1
; DCD &ff000000 ;illegal instr to abort to indicate
; attempt to trigger CB in IRQ
stmfd r13!, {lr}
LDR r3, =ptr_IRQsema
LDR r1, [sl,#-536] ; Get relocation
ADD r3, r3, r1
LDR r2, [r3]
CMP r2, #0
BNE %FT10
MOV r0, #6
MOV r1, #0
MOV r2, #OSRSI6_IRQsema
SWI XOS_ReadSysInfo
MOVVS r2, #0
CMP r2, #0
MOVEQ r2, #Legacy_IRQsema
STR r2, [r3]
10
LDR lr, [r2]
MOVS lr, lr
LDMNEFD r13!,{pc} ; NZ is within IRQ.. so no CB allowed
SWI OS_LeaveOS
SWI OS_EnterOS
ldmfd r13!,{pc}
LTORG
END
END
This diff is collapsed.
/* $NetBSD: hid.c,v 1.23 2002/07/11 21:14:25 augustss Exp $ */
/* $NetBSD: hid.c,v 1.30 2010/05/14 17:32:57 plunky Exp $ */
/* $FreeBSD: src/sys/dev/usb/hid.c,v 1.11 1999/11/17 22:33:39 n_hibma Exp $ */
/*
......@@ -17,13 +17,6 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
......@@ -38,8 +31,13 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef __riscos
#include <dev/usb/usbhal.h>
#endif
#include <sys/cdefs.h>
//__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.23 2002/07/11 21:14:25 augustss Exp $");
#ifndef __riscos
__KERNEL_RCSID(0, "$NetBSD: hid.c,v 1.30 2010/05/14 17:32:57 plunky Exp $");
#endif
#include <sys/param.h>
#include <sys/systm.h>
......@@ -68,9 +66,9 @@ Static void hid_clear_local(struct hid_item *);
#define MAXUSAGE 256
struct hid_data {
u_char *start;
u_char *end;
u_char *p;
const u_char *start;
const u_char *end;
const u_char *p;
struct hid_item cur;
int32_t usages[MAXUSAGE];
int nu;
......@@ -98,7 +96,7 @@ hid_clear_local(struct hid_item *c)
}
struct hid_data *
hid_start_parse(void *d, int len, enum hid_kind kind)
hid_start_parse(const void *d, int len, enum hid_kind kind)
{
struct hid_data *s;
......@@ -108,7 +106,7 @@ hid_start_parse(void *d, int len, enum hid_kind kind)
memset(s, 0, sizeof *s);
#endif
s->start = s->p = d;
s->end = (void*) ((char *)d + len);
s->end = ((const u_char *)d) + len;
s->kind = kind;
return (s);
}
......@@ -131,9 +129,9 @@ hid_get_item(struct hid_data *s, struct hid_item *h)
struct hid_item *c = &s->cur;
unsigned int bTag, bType, bSize;
u_int32_t oldpos;
u_char *data;
const u_char *data;
int32_t dval;
u_char *p;
const u_char *p;
struct hid_item *hi;
int i;
enum hid_kind retkind;
......@@ -200,7 +198,7 @@ hid_get_item(struct hid_data *s, struct hid_item *h)
dval |= *data++ << 24;
break;
default:
printf("BAD LENGTH %d\n", bSize);
printf("BAD LENGTH %d\n", bSize);
continue;
}
......@@ -267,7 +265,7 @@ hid_get_item(struct hid_data *s, struct hid_item *h)
s->nu = 0;
return (1);
default:
printf("Main bTag=%d\n", bTag);
printf("Main bTag=%d\n", bTag);
break;
}
break;
......@@ -306,18 +304,18 @@ hid_get_item(struct hid_data *s, struct hid_item *h)
break;
case 10: /* Push */
hi = malloc(sizeof *hi, M_TEMP, M_WAITOK);
*hi = s->cur;
*hi = *c;
c->next = hi;
break;
case 11: /* Pop */
hi = c->next;
oldpos = c->loc.pos;
s->cur = *hi;
*c = *hi;
c->loc.pos = oldpos;
free(hi, M_TEMP);
break;
default:
printf("Global bTag=%d\n", bTag);
printf("Global bTag=%d\n", bTag);
break;
}
break;
......@@ -370,19 +368,19 @@ hid_get_item(struct hid_data *s, struct hid_item *h)
c->set_delimiter = dval;
break;
default:
printf("Local bTag=%d\n", bTag);
printf("Local bTag=%d\n", bTag);
break;
}
break;
default:
printf("default bType=%d\n", bType);
printf("default bType=%d\n", bType);
break;
}
}
}
int
hid_report_size(void *buf, int len, enum hid_kind k, u_int8_t id)
hid_report_size(const void *buf, int len, enum hid_kind k, u_int8_t id)
{
struct hid_data *d;
struct hid_item h;
......@@ -401,7 +399,7 @@ hid_report_size(void *buf, int len, enum hid_kind k, u_int8_t id)
lo = h.loc.pos;
#ifdef DIAGNOSTIC
if (lo != 0) {
printf("hid_report_size: lo != 0\n");
printf("hid_report_size: lo != 0\n");
}
#endif
}
......@@ -414,7 +412,7 @@ hid_report_size(void *buf, int len, enum hid_kind k, u_int8_t id)
}
int
hid_locate(void *desc, int size, u_int32_t u, u_int8_t id, enum hid_kind k,
hid_locate(const void *desc, int size, u_int32_t u, u_int8_t id, enum hid_kind k,
struct hid_location *loc, u_int32_t *flags)
{
struct hid_data *d;
......@@ -440,41 +438,73 @@ hid_locate(void *desc, int size, u_int32_t u, u_int8_t id, enum hid_kind k,
return (0);
}
long
hid_get_data(const u_char *buf, const struct hid_location *loc)
{
u_int hsize = loc->size;
u_long data;
if (hsize == 0)
return (0);
data = hid_get_udata(buf, loc);
if (data < (1 << (hsize - 1)))
return (data);
return data - (1 << hsize);
}
u_long
hid_get_data(u_char *buf, struct hid_location *loc)
hid_get_udata(const u_char *buf, const struct hid_location *loc)
{
u_int hpos = loc->pos;
u_int hsize = loc->size;
u_int32_t data;
int i, s;
DPRINTFN(10, ("hid_get_data: loc %d/%d\n", hpos, hsize));
u_int i, num, off;
u_long data;
if (hsize == 0)
return (0);
data = 0;
s = hpos / 8;
for (i = hpos; i < hpos+hsize; i += 8)
data |= buf[i / 8] << ((i / 8 - s) * 8);
off = hpos / 8;
num = (hpos + hsize + 7) / 8 - off;
for (i = 0; i < num; i++)
data |= buf[off + i] << (i * 8);
data >>= hpos % 8;
data &= (1 << hsize) - 1;
hsize = 32 - hsize;
/* Sign extend */
data = ((int32_t)data << hsize) >> hsize;
DPRINTFN(10,("hid_get_data: loc %d/%d = %lu\n",
loc->pos, loc->size, (long)data));
DPRINTFN(10,("hid_get_udata: loc %d/%d = %lu\n", hpos, hsize, data));
return (data);
}
/*
* hid_is_collection(desc, size, id, usage)
*
* This function is broken in the following way.
*
* It is used to discover if the given 'id' is part of 'usage' collection
* in the descriptor in order to match report id against device type.
*
* The semantics of hid_start_parse() means though, that only a single
* kind of report is considered. The current HID code that uses this for
* matching is actually only looking for input reports, so this works
* for now.
*
* This function could try all report kinds (input, output and feature)
* consecutively if necessary, but it may be better to integrate the
* libusbhid code which can consider multiple report kinds simultaneously
*
* Needs some thought.
*/
int
hid_is_collection(void *desc, int size, u_int8_t id, u_int32_t usage)
hid_is_collection(const void *desc, int size, u_int8_t id, u_int32_t usage)
{
struct hid_data *hd;
struct hid_item hi;
u_int32_t coll_usage = ~0;
hd = hid_start_parse(desc, size, hid_none);
hd = hid_start_parse(desc, size, hid_input);
if (hd == NULL)
return (0);
......@@ -483,10 +513,15 @@ hid_is_collection(void *desc, int size, u_int8_t id, u_int32_t usage)
DPRINTFN(2,("hid_is_collection: kind=%d id=%d usage=0x%x"
"(0x%x)\n",
hi.kind, hi.report_ID, hi.usage, coll_usage));
if (hi.kind == hid_collection &&
hi.collection == HCOLL_APPLICATION)
coll_usage = hi.usage;
if (hi.kind == hid_endcollection &&
if (hi.kind == hid_endcollection)
coll_usage = ~0;
if (hi.kind == hid_input &&
coll_usage == usage &&
hi.report_ID == id) {
DPRINTFN(2,("hid_is_collection: found\n"));
......
This diff is collapsed.
......@@ -42,6 +42,9 @@
* USB spec: http://www.usb.org/developers/docs/usbspec.zip
*/
#ifdef __riscos
#include <dev/usb/usbhal.h>
#endif
#include <sys/cdefs.h>
//__KERNEL_RCSID(0, "$NetBSD: uhub.c,v 1.74 2005/03/02 11:37:27 mycroft Exp $");
......@@ -109,7 +112,7 @@ Static bus_child_detached_t uhub_child_detached;
USB_DECLARE_DRIVER(uhub);
#if defined __riscos
/* Create the driver instance for the hub connected to hub case */
struct cfattach uhub_uhub_ca = {
halconst struct cfattach uhub_uhub_ca = {
sizeof(struct uhub_softc), uhub_match, uhub_attach,
uhub_detach, uhub_activate
};
......@@ -160,7 +163,9 @@ USB_ATTACH(uhub)
{
USB_ATTACH_START(uhub, sc, uaa);
usbd_device_handle dev = uaa->device;
#if !defined(__riscos) || defined(USB_DEBUG)
char devinfo[1024];
#endif
usbd_status err;
struct usbd_hub *hub = NULL;
usb_device_request_t req;
......@@ -172,6 +177,7 @@ USB_ATTACH(uhub)
DPRINTFN(1,("uhub_attach\n"));
sc->sc_hub = dev;
#if !defined(__riscos) || defined(USB_DEBUG)
usbd_devinfo(dev, 1, devinfo, sizeof(devinfo));
USB_ATTACH_SETUP;
printf("%s: %s\n", USBDEVNAME(sc->sc_dev), devinfo);
......@@ -182,6 +188,7 @@ USB_ATTACH(uhub)
UHUB_IS_SINGLE_TT(sc) ? "single" : "multiple",
UHUB_IS_SINGLE_TT(sc) ? "" : "s");
}
#endif
err = usbd_set_config_index(dev, 0, 1);
if (err) {
DPRINTF(("%s: configuration failed, error=%s\n",
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -38,6 +38,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef __riscos
#include <dev/usb/usbhal.h>
#endif
#include <sys/cdefs.h>
//__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.106 2004/10/24 12:52:40 augustss Exp $");
......@@ -91,6 +94,7 @@ Static void usbd_start_next(usbd_pipe_handle pipe);
Static usbd_status usbd_open_pipe_ival
(usbd_interface_handle, u_int8_t, u_int8_t, usbd_pipe_handle *, int);
#ifndef __riscos
Static int usbd_nbuses = 0;
void
......@@ -104,6 +108,10 @@ usbd_finish(void)
{
--usbd_nbuses;
}
#else
void usbd_init(void) {}
void usbd_finish(void) {}
#endif
static __inline int
usbd_xfer_isread(usbd_xfer_handle xfer)
......@@ -338,7 +346,7 @@ usbd_transfer(usbd_xfer_handle xfer)
/* Copy data if going out. */
if (!(xfer->flags & USBD_NO_COPY) && size != 0 &&
!usbd_xfer_isread(xfer))
#ifdef __riscos
#if defined(__riscos) && !defined(USBHAL)
{
/* the buffer pointer is actually a buffermanager private ID */
if (xfer->rqflags & URQ_RISCOS_BUF)
......@@ -346,7 +354,7 @@ usbd_transfer(usbd_xfer_handle xfer)
else
#endif
memcpy(KERNADDR(dmap, 0), xfer->buffer, size);
#ifdef __riscos
#if defined(__riscos) && !defined(USBHAL)
}
#endif
......@@ -612,7 +620,7 @@ usbd_clear_endpoint_stall(usbd_pipe_handle pipe)
usbd_device_handle dev = pipe->device;
#endif
usb_device_request_t req;
usbd_status err;
usbd_status err = USBD_NORMAL_COMPLETION;
DPRINTFN(8, ("usbd_clear_endpoint_stall\n"));
......@@ -910,7 +918,7 @@ usb_transfer_complete(usbd_xfer_handle xfer)
xfer->actlen = xfer->length;
}
#endif
#ifdef __riscos
#if defined(__riscos) && !defined(USBHAL)
/* the buffer pointer is actually a buffermanager private ID,
but this is sorted out in the code */
if (xfer->rqflags & URQ_RISCOS_BUF)
......
......@@ -37,6 +37,9 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef __riscos
#include <dev/usb/usbhal.h>
#endif
#include <sys/cdefs.h>
//__KERNEL_RCSID(0, "$NetBSD: usbdi_util.c,v 1.43 2005/04/12 13:10:14 itohy Exp $");
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.