Commit 1b91f527 authored by Ben Avison's avatar Ben Avison
Browse files

Initial import of SCSISoftUSB, a driver for USB mass storage devices that use...

Initial import of SCSISoftUSB, a driver for USB mass storage devices that use a SCSI command set over bulk-only or control-bulk-interrupt protocols.
| Copyright 2003 Tematic 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 clean
stripdepnd
| Copyright 2003 Tematic 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
| Copyright 2003 Tematic 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 rom
s/** gitlab-language=armasm linguist-language=armasm linguist-detectable=true
c/** gitlab-language=c linguist-language=c linguist-detectable=true
h/** gitlab-language=c linguist-language=c linguist-detectable=true
cmhg/** gitlab-language=cmhg linguist-language=cmhg linguist-detectable=true
Some source code is distributed under the Original BSD License:
Copyright (c) 2001 The NetBSD Foundation, Inc.
All rights reserved.
This code is derived from software contributed to The NetBSD Foundation
by MAEKAWA Masahide (gehenna@NetBSD.org).
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
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
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
Some source code is distributed under the Simplified BSD License:
Copyright (c) 1999 MAEKAWA Masahide <bishop@rr.iij4u.or.jp>,
Nick Hibma <n_hibma@freebsd.org>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
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.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Some source code is distributed under the Apache License:
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
# Copyright 2003 Tematic 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.
#
# Makefile for SCSISoftUSB
#
# ***********************************
# *** C h a n g e L i s t ***
# ***********************************
# Date Name Description
# ---- ---- -----------
# 29-Apr-2003 BJGA Created.
COMPONENT = SCSISoftUSB
TARGET = SCSISoftUSB
DIRS = local_dirs
CFLAGS = -ffah -wp -wc -we -zM -zps1 -ITCPIPLibs:,C:USB -DDISABLE_PACKED ${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_MODULE = drm.${TARGET}
EXPORTS =
#MERGEDMDIR = o.${MACHINE}._Messages_
#MERGEDMSGS = ${MERGEDMDIR}.${TARGET}
include Makefiles:StdTools
include Makefiles:ModuleLibs
include Makefiles:ModStdRule
include Makefiles:RAMCModule
include Makefiles:ROMCModule
.SUFFIXES: .do
.c.do:; ${CC} ${CFLAGS} -DDEBUGLIB -o $@ $<
local_dirs:
${MKDIR} do
${MKDIR} o
export: ${EXPORTS}
@${ECHO} ${COMPONENT}: export complete
${EXPORTS}:
#resources: Messages${CMDHELP}
# ${MKDIR} ${RESDIR}.${COMPONENT}
# ${CP} Messages${CMDHELP} ${RESDIR}.${COMPONENT}.Messages ${CPFLAGS}
# ${RM} Messages${CMDHELP}
# @${ECHO} ${COMPONENT}: resource files copied
clean:
${RM} Messages
${RM} h.modhdr
ifthere linked then wipe linked ${WFLAGS}
ifthere aof then wipe aof ${WFLAGS}
ifthere drm then wipe drm ${WFLAGS}
ifthere do then wipe do ${WFLAGS}
ifthere rm then wipe rm ${WFLAGS}
ifthere o then wipe o ${WFLAGS}
@${ECHO} ${COMPONENT}: cleaned
debug: ${DBG_MODULE}
@${ECHO} ${COMPONENT}: debug module built
${DBG_MODULE}: ${DBG_OBJS} ${DBG_LIBS} ${CLIB} ${DIRS}
${MKDIR} drm
${LD} ${LDFLAGS} -o $@ -rmf ${DBG_OBJS} ${DBG_LIBS} ${CLIB}
${CHMOD} -R a+rx drm
o.module: modhdr.h
do.module: modhdr.h
o.glue: modhdr.h
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
#
#${MERGEDMSGS}:
# ${MKDIR} ${MERGEDMDIR}
# IfThere LocalRes:Messages Then ${CP} LocalRes:Messages $@ ${CPFLAGS} Else Create $@
# IfThere LocalRes:CmdHelp Then FAppend $@ $@ LocalRes:CmdHelp
# Dynamic dependencies:
/* (0.00)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.67.
*
*/
#define Module_MajorVersion_CMHG 0.00
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 28 Apr 2803
#define Module_MajorVersion "0.00"
#define Module_Version 0
#define Module_MinorVersion ""
#define Module_Date "28 Apr 2803"
#define Module_ApplicationDate2 "28-Apr-03"
#define Module_ApplicationDate4 "28-Apr-2803"
#define Module_ComponentName "SCSISoftUSB"
#define Module_ComponentPath "RiscOS/Sources/HWSupport/SCSI/SCSISoftUSB"
#define Module_FullVersion "0.00"
#define Module_HelpVersion "0.00 (28 Apr 2803)"
#define Module_LibraryVersionInfo "0:00"
/* Copyright 2003 Tematic 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.
*/
/*****************************************************************************
* $Id$
* $Name$
*
* Author(s): Ben Avison
* Project(s):
*
* ----------------------------------------------------------------------------
* Purpose: Global variables
*
* ----------------------------------------------------------------------------
* History: See source control system log
*
*****************************************************************************/
/*****************************************************************************
* Include header files
*****************************************************************************/
#include "global.h"
/*****************************************************************************
* MACROS
*****************************************************************************/
/*****************************************************************************
* New type definitions
*****************************************************************************/
/*****************************************************************************
* Constants
*****************************************************************************/
/*****************************************************************************
* File scope Global variables
*****************************************************************************/
void *global_PrivateWord; /* so we don't have to worry about passing pw around */
MessagesFD global_MessageFD; /* message file descriptor */
my_usb_device_t *global_DeviceList = NULL; /* list of usb device info */
my_usb_device_t *global_TickerList = NULL; /* list of devices using TickerV */
/*****************************************************************************
* Function prototypes - Private to this file
*****************************************************************************/
/*****************************************************************************
* Functions
*****************************************************************************/
/*****************************************************************************
* END OF FILE
*****************************************************************************/
This diff is collapsed.
This diff is collapsed.
/* Copyright 2003 Tematic 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.
*/
/* -*-C-*-
*
* svcprint.c
*
* print debugging information down the TML tube link.
*
* provides:
* %s - string
* %C - character in range 20->7F (space printed if outside range)
* %c - any character
* %X - reverses order of bytes if >2 (or >4) specified as width
* %x - hex
* %B - reverses order of bytes if >2 (or >4) specified as width
* %b - binary
* %D - reverses order of bytes if >2 (or >4) specified as width
* %d - decimal
*
* field width can be specified by placing a decimal number after the "%"
* character... if the width is started by a "0" then numbers are padded
* with "0"...
*
* standard format specifiers o,u,e,f and g are NOT supported
*/
#include "kernel.h"
#include "swis.h"
#include "debug.h"
#ifndef NULL
# define NULL ((void *)0)
#endif
/**********************************************************************/
static unsigned short ntohs(unsigned short n)
{
return(((n << 8) & 0xff00) | ((n >> 8) & 0x00ff));
}
/**********************************************************************/
static unsigned long ntohl(unsigned long n)
{
return(((n >> 24) & 0x000000ff) | ((n >> 8) & 0x0000ff00) |
((n << 8) & 0x00ff0000) | ((n << 24) & 0xff000000) );
}
/**********************************************************************/
/*
* call processor mode independant character output routine
*/
static void oswrch(unsigned char ch)
{
_kernel_swi_regs regset;
/*
* use HostFS_WriteC (SWI 0x40102) to print the character
*/
regset.r[0] = ch;
(void)_kernel_swi(0x40102, &regset, &regset);
}
/**********************************************************************/
/*
* Printn prints a number n in base b, minimum width w adding pad chars
* if needed.
*/
static void printn(unsigned n, unsigned b, int w, char pad)
{
if( n >= b )
{
printn(n / b, b, --w, pad);
oswrch("0123456789abcdef"[n % b]);
}
else
{
while (--w > 0)
oswrch(pad);
oswrch("0123456789abcdef"[n]);
}
}
/**********************************************************************/
static void prf(char *format, unsigned *argp, ...)
{
register int b; /* base to be used when displaying numbers */
register int c; /* current character read from format string */
register int w; /* field width */
char pad; /* field padding character */
unsigned val; /* value of argument */
loop:
val = *argp;
w = 0;
pad = ' ';
while( (c = *format++) != '%' )
{
if( c == '\0' )
return;
if( c == '\n' )
oswrch('\r');
oswrch(c);
}
again:
/*
* we have a special format command
*/
c = *format++;
switch( c )
{
case 's':
{
/* string */
char *p = (char *)*argp++;
int width = 0;
if (p != NULL)
{
/* NOT a NULL pointer */
while (*p)
{
oswrch(*p++);
width++;
}
}
while( width++ < w )
oswrch(' ');
goto loop;
}
case 'C':
if( (*argp < ' ') || (*argp > '~') )
{
oswrch(' ');
argp++;
goto loop;
}
case 'c':
/* character */
oswrch(*argp++);
goto loop;
case '0':
if (w == 0)
pad = '0';
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
/* field width */
w = (w * 10) + ((int) c - '0');
goto again;
case 'X':
/* hex number */
if (w > 4)
val = (unsigned)ntohl(val);
else
{
if (w > 2)
val = (unsigned)ntohs(val);
}
/*
* NB
*
* fall through to set base
*/
case 'x':
/* hex number */
b = 16;
goto number;
case 'B':
/* binary number */
if (w > 4)
val = (unsigned)ntohl(val);
else
{
if( w > 2 )
val = (unsigned)ntohs(val);
}
/*
* NB
*
* fall through to set base
*/
case 'b':
/* binary number */
b = 2;
goto number;
case 'D':
/* decimal number */
if (w > 4)
val = (unsigned)ntohl(val);
else
{
if (w > 2)
val = (unsigned)ntohs(val);
}
/*
* NB
*
* fall through to set base
*/
case 'd':
b = 10;
/*
* NB
*
* fall through to write number
*/
number:
printn(val,b,w,pad);
argp++;
break;
} /* switch */
goto loop;
}
/**********************************************************************/
#if 0
# define USETUBE
#endif /* 0/1 */
void Printf(char *format, ...)
{
unsigned *argp = (unsigned *)&format;
#ifdef USETUBE
_kernel_swi_regs reglist;
_kernel_oserror *err;
reglist.r[0] = (int)"HostVDU";
if( (err = _kernel_swi(OS_CLI, &reglist, &reglist)) != NULL )
{
prf("HostVDU: ", 0);
prf(err->errmess, 0);
return;
}
#endif /* USETUBE */
prf(format, (argp + 1));
#ifdef USETUBE
reglist.r[0] = (int)"TubeVDU";
if( (err = _kernel_swi(OS_CLI, &reglist, &reglist)) != NULL )
{
prf("TubeVDU: ", 0);
prf(err->errmess, 0);
return;
}
#endif /* USETUBE */
}
/**********************************************************************/
/* EOF svcprint.c */
This diff is collapsed.
/*****************************************************************************
* $Id$
* $Name$
*
* Author(s): Ben Avison
* Project(s):
*
* ----------------------------------------------------------------------------
* Purpose: USB mass storage quirks code, adapted from BSD sources
*
* ----------------------------------------------------------------------------
* History: See source control system log
*
*****************************************************************************/
/* $NetBSD: umass_quirks.c,v 1.37 2003/04/18 23:38:18 uwe Exp $ */
/*
* Copyright (c) 2001 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by MAEKAWA Masahide (gehenna@NetBSD.org).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __riscos
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/buf.h>
#include <dev/scsipi/scsipi_all.h> /* for scsiconf.h below */
#include <dev/scsipi/scsiconf.h> /* for quirks defines */
#endif
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdevs.h>
#ifdef __riscos
#include "umassvar.h"
#include "umass_quirks.h"
#else
#include <dev/usb/umassvar.h>
#include <dev/usb/umass_quirks.h>
#endif
#ifdef __riscos
#define NO_QUIRKS_THAT_USE_CODE
#endif
#ifndef NO_QUIRKS_THAT_USE_CODE
Static usbd_status umass_init_insystem(struct umass_softc *);
Static usbd_status umass_init_shuttle(struct umass_softc *);
Static void umass_fixup_sony(struct umass_softc *);
Static void umass_fixup_yedata(struct umass_softc *);
#endif
#ifdef __riscos
extern const struct umass_quirk umass_quirks[];
#endif
Static const struct umass_quirk umass_quirks[] = {
{ { USB_VENDOR_ATI, USB_PRODUCT_ATI2_205 },
UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
0,
0,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
{ { USB_VENDOR_DMI, USB_PRODUCT_DMI_SA2_0 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOMODESENSE,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
{ { USB_VENDOR_EASYDISK, USB_PRODUCT_EASYDISK_EASYDISK },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOMODESENSE,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
{ { USB_VENDOR_FUJIPHOTO, USB_PRODUCT_FUJIPHOTO_MASS0100 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_NO_START_STOP,
PQUIRK_NOTUR | PQUIRK_NOSENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_ADAPTERV2 },
UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
0,
0,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_ATAPI },
UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
0,
0,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_DRIVEV2_5 },
UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
0,
0,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_IDEUSB2 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOMODESENSE,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
#ifndef NO_QUIRKS_THAT_USE_CODE
{ { USB_VENDOR_INSYSTEM, USB_PRODUCT_INSYSTEM_USBCABLE },
UMASS_WPROTO_CBI, UMASS_CPROTO_ATAPI,
UMASS_QUIRK_NO_START_STOP,
PQUIRK_NOTUR,
UMATCH_VENDOR_PRODUCT,
umass_init_insystem, NULL
},
#endif
#ifndef __riscos
{ { USB_VENDOR_IODATA2, USB_PRODUCT_IODATA2_USB2SC },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
0,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
#endif
{ { USB_VENDOR_IOMEGA, USB_PRODUCT_IOMEGA_ZIP100 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOTUR,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
{ { USB_VENDOR_IOMEGA, USB_PRODUCT_IOMEGA_ZIP250 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOTUR,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
#ifndef __riscos
{ { USB_VENDOR_MELCO, USB_PRODUCT_MELCO_DUBPXXG },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_FORCE_SHORT_INQUIRY | UMASS_QUIRK_NO_START_STOP,
PQUIRK_NOMODESENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
#endif
{ { USB_VENDOR_MICROTECH, USB_PRODUCT_MICROTECH_DPCM },
UMASS_WPROTO_CBI, UMASS_CPROTO_ATAPI,
0,
0,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
{ { USB_VENDOR_MINOLTA, USB_PRODUCT_MINOLTA_S304 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_NO_MAX_LUN | UMASS_QUIRK_NO_START_STOP,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
{ { USB_VENDOR_MINOLTA, USB_PRODUCT_MINOLTA_X },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_NO_MAX_LUN | UMASS_QUIRK_NO_START_STOP,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
{ { USB_VENDOR_MSYSTEMS, USB_PRODUCT_MSYSTEMS_DISKONKEY },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_NO_MAX_LUN,
PQUIRK_NOMODESENSE | PQUIRK_NODOORLOCK | PQUIRK_NOBIGMODESENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
#ifndef __riscos
{ { USB_VENDOR_NEODIO, USB_PRODUCT_NEODIO_ND3050 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOMODESENSE | PQUIRK_FORCELUNS,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
#endif
{ { USB_VENDOR_NEODIO, USB_PRODUCT_NEODIO_ND5010 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOMODESENSE | PQUIRK_FORCELUNS,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
{ { USB_VENDOR_OLYMPUS, USB_PRODUCT_OLYMPUS_C1 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_WRONG_CSWSIG,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
{ { USB_VENDOR_ONSPEC, USB_PRODUCT_ONSPEC_MD1II },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_NO_MAX_LUN | UMASS_QUIRK_NO_START_STOP,
PQUIRK_NOMODESENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
{ { USB_VENDOR_ONSPEC, USB_PRODUCT_ONSPEC_MD2 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOMODESENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
{ { USB_VENDOR_OTI, USB_PRODUCT_OTI_SOLID },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOMODESENSE | PQUIRK_NOBIGMODESENSE,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
{ { USB_VENDOR_PEN, USB_PRODUCT_PEN_USBDISK },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_NO_MAX_LUN | UMASS_QUIRK_NO_START_STOP,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
#ifndef __riscos
{ { USB_VENDOR_PEN, USB_PRODUCT_PEN_USBREADER },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOMODESENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
{ { USB_VENDOR_PILOTECH, USB_PRODUCT_PILOTECH_CRW600 },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOMODESENSE | PQUIRK_FORCELUNS,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
#endif
{ { USB_VENDOR_PQI, USB_PRODUCT_PQI_TRAVELFLASH },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOMODESENSE | PQUIRK_NODOORLOCK,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
{ { USB_VENDOR_SCANLOGIC, USB_PRODUCT_SCANLOGIC_SL11R },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UFI,
UMASS_QUIRK_WRONG_CSWTAG,
0,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
#ifndef NO_QUIRKS_THAT_USE_CODE
{ { USB_VENDOR_SHUTTLE, USB_PRODUCT_SHUTTLE_EUSB },
UMASS_WPROTO_CBI_I, UMASS_CPROTO_ATAPI,
UMASS_QUIRK_NO_START_STOP,
PQUIRK_NOTUR,
UMATCH_VENDOR_PRODUCT,
umass_init_shuttle, NULL
},
#endif
{ { USB_VENDOR_SHUTTLE, USB_PRODUCT_SHUTTLE_ZIOMMC },
UMASS_WPROTO_CBI_I, UMASS_CPROTO_ATAPI,
UMASS_QUIRK_NO_START_STOP,
PQUIRK_NOTUR,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
#ifndef __riscos
{ { USB_VENDOR_SIIG, USB_PRODUCT_SIIG_MULTICARDREADER },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_NO_START_STOP,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL,NULL
},
#endif
{ { USB_VENDOR_SONY, USB_PRODUCT_SONY_DRIVEV2 },
UMASS_WPROTO_BBB, UMASS_CPROTO_ISD_ATA,
0,
0,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
#ifndef NO_QUIRKS_THAT_USE_CODE
{ { USB_VENDOR_SONY, USB_PRODUCT_SONY_DSC },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
0,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, umass_fixup_sony
},
#endif
{ { USB_VENDOR_SONY, USB_PRODUCT_SONY_MSC },
UMASS_WPROTO_CBI, UMASS_CPROTO_UFI,
UMASS_QUIRK_FORCE_SHORT_INQUIRY | UMASS_QUIRK_RS_NO_CLEAR_UA,
PQUIRK_NOMODESENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
{ { USB_VENDOR_TEAC, USB_PRODUCT_TEAC_FD05PUB },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
0,
PQUIRK_NOMODESENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
{ { USB_VENDOR_TRUMPION, USB_PRODUCT_TRUMPION_XXX1100 },
UMASS_WPROTO_CBI, UMASS_CPROTO_ATAPI,
0,
0,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
{ { USB_VENDOR_YANO, USB_PRODUCT_YANO_U640MO },
UMASS_WPROTO_CBI_I, UMASS_CPROTO_ATAPI,
UMASS_QUIRK_FORCE_SHORT_INQUIRY,
0,
UMATCH_VENDOR_PRODUCT,
NULL, NULL
},
#ifndef NO_QUIRKS_THAT_USE_CODE
{ { USB_VENDOR_YEDATA, USB_PRODUCT_YEDATA_FLASHBUSTERU },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UFI,
UMASS_QUIRK_RS_NO_CLEAR_UA,
PQUIRK_NOMODESENSE,
UMATCH_VENDOR_PRODUCT_REV,
NULL, umass_fixup_yedata
},
#endif
{ { USB_VENDOR_GENESYS,USB_PRODUCT_GENESYS_GL641USB },
UMASS_WPROTO_UNSPEC, UMASS_CPROTO_UNSPEC,
UMASS_QUIRK_FORCE_SHORT_INQUIRY | UMASS_QUIRK_NO_START_STOP,
PQUIRK_NOMODESENSE,
UMATCH_DEVCLASS_DEVSUBCLASS_DEVPROTO,
NULL, NULL
},
};
#ifdef __riscos
static const struct umass_quirk *usb_lookup(const struct umass_quirk *table, u_int16_t vendor, u_int16_t product)
{
int count = sizeof umass_quirks / sizeof *umass_quirks;
while (count-- > 0)
{
if (table->uq_dev.vendor == vendor &&
table->uq_dev.product == product) return table;
table++;
}
return NULL;
}
#endif
const struct umass_quirk *
umass_lookup(u_int16_t vendor, u_int16_t product)
{
return ((const struct umass_quirk *)
usb_lookup(umass_quirks, vendor, product));
}
#ifndef NO_QUIRKS_THAT_USE_CODE
Static usbd_status
umass_init_insystem(struct umass_softc *sc)
{
usbd_status err;
err = usbd_set_interface(sc->sc_iface, 1);
if (err) {
DPRINTF(UDMASS_USB,
("%s: could not switch to Alt Interface 1\n",
USBDEVNAME(sc->sc_dev)));
return (err);
}
return (USBD_NORMAL_COMPLETION);
}
Static usbd_status
umass_init_shuttle(struct umass_softc *sc)
{
usb_device_request_t req;
u_int8_t status[2];
/* The Linux driver does this */
req.bmRequestType = UT_READ_VENDOR_DEVICE;
req.bRequest = 1;
USETW(req.wValue, 0);
USETW(req.wIndex, sc->sc_ifaceno);
USETW(req.wLength, sizeof(status));
return (usbd_do_request(sc->sc_udev, &req, &status));
}
Static void
umass_fixup_sony(struct umass_softc *sc)
{
usb_interface_descriptor_t *id;
id = usbd_get_interface_descriptor(sc->sc_iface);
if (id->bInterfaceSubClass == 0xff) {
sc->sc_cmd = UMASS_CPROTO_RBC;
}
}
Static void
umass_fixup_yedata(struct umass_softc *sc)
{
usb_device_descriptor_t *dd;
dd = usbd_get_device_descriptor(sc->sc_udev);
/*
* Revisions < 1.28 do not handle the interrupt endpoint very well.
*/
if (UGETW(dd->bcdDevice) < 0x128)
sc->sc_wire = UMASS_WPROTO_CBI;
else
sc->sc_wire = UMASS_WPROTO_CBI_I;
/*
* Revisions < 1.28 do not have the TEST UNIT READY command
* Revisions == 1.28 have a broken TEST UNIT READY
*/
if (UGETW(dd->bcdDevice) <= 0x128)
sc->sc_busquirks |= PQUIRK_NOTUR;
}
#endif
; Copyright 2003 Tematic 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.
;
;*****************************************************************************
; $Id$
; $Name$
;
; Author(s): Ben Avison
; Project(s):
;
; ----------------------------------------------------------------------------
; Purpose: CMHG file
;
; ----------------------------------------------------------------------------
; History: See source control system log
;
;****************************************************************************/
#include "Global/Services.h"
#include "VersionNum"
initialisation-code: module_Init
finalisation-code: module_Final
service-call-handler: module_Service Service_MessageFileClosed,
Service_ModulePostInit,
Service_ModulePostFinal,
Service_USB,
Service_DeviceDead
title-string: SCSISoftUSB
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"
; )
international-help-file:"Resources:$.Resources.SCSISoftUSB.Messages"
generic-veneers: module_callback_from_init/module_CallbackFromInit,
module_scsi_handler/module_SCSIHandler,
module_tickerv_handler/module_TickerVHandler,
module_upcallv_handler/module_UpCallVHandler
/* Copyright 2003 Tematic 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.
*/
#if !defined(SCSISOFTUSB_ASM_H) /* file used if not already included */
#define SCSISOFTUSB_ASM_H
/*****************************************************************************
* $Id$
* $Name$
*
* Author(s): Ben Avison
* Project(s):
*
* ----------------------------------------------------------------------------
* Purpose: Assembler stubs
*
* ----------------------------------------------------------------------------
* History: See source control system log
*
*****************************************************************************/
/*****************************************************************************
* Include header files
*****************************************************************************/
#include <stdlib.h>
#include <stdint.h>
#include "kernel.h"
/*****************************************************************************
* MACROS
*****************************************************************************/
#define INSERT_BLOCK(buffer_id, block, length) do { asm_CallBufferManager(1, buffer_id, block, length, static_BufManWS, static_BufManRout); } while(0)
#define REMOVE_BLOCK(buffer_id, block, length) do { asm_CallBufferManager(3, buffer_id, block, length, static_BufManWS, static_BufManRout); } while(0)
#define USED_SPACE(buffer_id) asm_CallBufferManager(6, buffer_id, 0, 0, static_BufManWS, static_BufManRout)
#define FREE_SPACE(buffer_id) asm_CallBufferManager(6, buffer_id, 0, 0, static_BufManWS, static_BufManRout)
/*****************************************************************************
* New type definitions
*****************************************************************************/
/*****************************************************************************
* Constants
*****************************************************************************/
/*****************************************************************************
* Global variables
*****************************************************************************/
/*****************************************************************************
* Function prototypes
*****************************************************************************/
/*****************************************************************************
* asm_DoTransferCompleteCallback
*
* Calls back to SCSIDriver when a transfer has finished.
*
* Assumptions
* NONE
*
* Inputs
* Various parameters required by the callback, and the address to call.
*
* Outputs
* NONE
*
* Returns
* NOTHING
*****************************************************************************/
extern void asm_DoTransferCompleteCallback(_kernel_oserror *error, uint32_t status_byte, void (*callback)(void), size_t amount_not_transferred, void *priv, void *workspace);
/*****************************************************************************
* asm_CallBufferManager
*
* Wrapper to Buffer Manager direct-access routines. Use the above macros instead.
*
* Assumptions
* NONE
*
* Inputs
* Parameters to routine, and address of routine.
*
* Outputs
* NONE
*
* Returns
* NOTHING
*****************************************************************************/
extern uint32_t asm_CallBufferManager(uint32_t reason, uint32_t buffer_id, void *block, size_t length, void *ws, void (*rout)(void));
/*****************************************************************************
* asm_UpCallHandler
*
* A transiently-installed routine to catch the registers in UpCall 10.
* Not designed to be called directly from C.
*
* Assumptions
* NONE
*
* Inputs
* NONE
*
* Outputs
* NONE
*
* Returns
* NOTHING
*****************************************************************************/
extern void asm_UpCallHandler(void);
#endif /* end of sentry #ifdef */
/*****************************************************************************
* END OF FILE
*****************************************************************************/
/* Copyright 2003 Tematic 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.
*/
#if 1
#define DEBUGf(...)
#else
extern void Printf(char *format,...);
#define DEBUGf Printf
#endif
/* EOF debug.h */
/* Copyright 2003 Tematic 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.
*/
#if !defined(SCSISOFTUSB_GLOBAL_H) /* file used if not already included */
#define SCSISOFTUSB_GLOBAL_H
/*****************************************************************************
* $Id$
* $Name$
*
* Author(s): Ben Avison
* Project(s):
*
* ----------------------------------------------------------------------------
* Purpose: Global variables
*
* ----------------------------------------------------------------------------
* History: See source control system log
*
*****************************************************************************/
/*****************************************************************************
* Include header files
*****************************************************************************/
#include <stdbool.h>
#include <stdint.h>
#include "tboxlibs/toolbox.h"
/*****************************************************************************
* MACROS
*****************************************************************************/
#ifndef IGNORE
#define IGNORE(x) do { (void)(x); } while(0)
#endif
#ifndef MIN
#define MIN(x,y) ((x)<(y)?(x):(y))
#endif
#ifndef MAX
#define MAX(x,y) ((x)>(y)?(x):(y))
#endif
#ifndef RETURN_ERROR
#define RETURN_ERROR(error_returning_statement) \
{ \
_kernel_oserror *returnerror_error = (error_returning_statement); \
if (returnerror_error != NULL) \
{ \
return returnerror_error; \
} \
}
#endif
/*****************************************************************************
* New type definitions
*****************************************************************************/
typedef struct
{
char *start;
size_t length;
}
scatter_entry_t;
typedef struct
{
uint32_t handle; /* FileSwitch handle */
uint32_t buffer; /* BufferManager internal buffer ID */
uint32_t devicedriverstreamhandle;
bool write; /* direction */
struct my_usb_device *device; /* for getting back to device handle */
uint16_t maxpacket; /* max packet size */
}
pipe_block_t;
typedef struct my_usb_device
{
uint32_t padding; /* to get from quad-word alignment to start of RMA block */
struct my_usb_device *next;
uint8_t interface;
uint8_t alternate;
uint8_t subclass;
uint8_t protocol;
uint8_t bulk_in_endpoint;
uint8_t bulk_out_endpoint;
uint8_t interrupt_endpoint;
uint16_t bulk_in_maxpacketsize;
uint16_t bulk_out_maxpacketsize;
uint16_t interrupt_maxpacketsize;
uint16_t vendor;
uint16_t product;
uint8_t maxlun;
char devicefs_name[20];
uint32_t scsi_driver_handle;
void *softc;
pipe_block_t *current_pipe;
pipe_block_t pipe[3 /* == UMASS_NEP */];
scatter_entry_t fake_list; /* for making a scatter list when there wan't one */
struct my_usb_device *next_ticker; /* list of devices to poll from TickerV */
uint32_t status; /* actually the usbd_status value */
bool command_active; /* active at any phase */
bool ticker_semaphore; /* paranoid ticker re-entrancy semaphore */
bool background_transfer_active; /* active and at a phase involving a bulk pipe */
scatter_entry_t *orig_scatterlist; /* scatterlist pointer st start of background xfer */
size_t orig_transferlength; /* to-do count at start of background xfer */
scatter_entry_t *curr_scatterlist; /* working scatterlist pointer */
size_t curr_offset; /* offset into first entry in working scatterlist */
size_t curr_transferlength; /* working to-do count */
void (*callback)(void); /* callback to SCSIDriver */
void *callback_pw; /* private word (R5) for the above */
void *callback_wp; /* workspace pointer (R12) for the above */
_kernel_oserror *callback_error;
uint32_t callback_status_byte;
size_t callback_not_transferred;
}
my_usb_device_t;
/*****************************************************************************
* Constants
*****************************************************************************/
enum
{
data_NONE = 0 << 24, /* By happy coincidence, these are the same */
data_READ = 1 << 24, /* as the symbols used for the same purpose */
data_WRITE = 2 << 24 /* by the BSD code (except for the shift). */
};
/*****************************************************************************
* Global variables
*****************************************************************************/
extern void *global_PrivateWord; /* so we don't have to worry about passing pw around */
extern MessagesFD global_MessageFD; /* message file descriptor */
extern my_usb_device_t *global_DeviceList; /* list of usb device info */
extern my_usb_device_t *global_TickerList; /* list of devices using TickerV */
/*****************************************************************************
* Function prototypes
*****************************************************************************/
#endif /* end of sentry #ifdef */
/*****************************************************************************
* END OF FILE
*****************************************************************************/
/* Copyright 2003 Tematic 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.
*/
#if !defined(SCSISOFTUSB_GLUE_H) /* file used if not already included */
#define SCSISOFTUSB_GLUE_H
/*****************************************************************************
* $Id$
* $Name$
*
* Author(s): Ben Avison
* Project(s):
*
* ----------------------------------------------------------------------------
* Purpose: Glue between RISC OS world and BSD code
*
* ----------------------------------------------------------------------------
* History: See source control system log
*
*****************************************************************************/
/*****************************************************************************
* Include header files
*****************************************************************************/
#include <stdint.h>
/*****************************************************************************
* MACROS
*****************************************************************************/
/*****************************************************************************
* New type definitions
*****************************************************************************/
/*****************************************************************************
* Constants
*****************************************************************************/
/*****************************************************************************
* Global variables
*****************************************************************************/
/*****************************************************************************
* Function prototypes
*****************************************************************************/
/*****************************************************************************
* glue_AttachDevice
*
* Makes a mass storage USB interface ready for use.
*
* Assumptions
* NONE
*
* Inputs
* device: struct describing the interface to attach
*
* Outputs
* maxlun: maximum USB logical unit number of device
*
* Returns
* true if attached succesfully
*****************************************************************************/
extern bool glue_AttachDevice(my_usb_device_t *device, uint8_t *maxlun);
/*****************************************************************************
* glue_DetachDevice
*
* Closes down a mass storage USB interface.
*
* Assumptions
* device is already delinked (so the stream closed service call won't re-open it)
*
* Inputs
* device: struct describing the interface to detach
*
* Outputs
* NONE
*
* Returns
* NOTHING
*****************************************************************************/
extern void glue_DetachDevice(my_usb_device_t *device);
/* extern void glue_ResetBus(my_usb_device_t *device); */
/*****************************************************************************
* glue_ResetDevice
*
* Initiates a reset of a mass storage USB interface.
* Callback is called for any active command.
* Might someday return before the reset is complete.
*
* Assumptions
* NONE
*
* Inputs
* device: struct describing the interface to reset
*
* Outputs
* NONE
*
* Returns
* NOTHING
*****************************************************************************/
extern void glue_ResetDevice(my_usb_device_t *device);
/*****************************************************************************
* glue_DoCommand
*
* Initiates a SCSI command addressed to a mass storage USB interface.
* Can return before the command is complete.
*
* Assumptions
* NONE
*
* Inputs
* device: struct describing the interface to address
* lun: logical unit number (at the USB transport layer) to address
* direction: direction code in bits 24/25, as for SCSI_Op
* control_block: pointer to SCSI control block
* control_block_length: length of SCSI control block
* scatter_list: pointer to scatter list describing data
* transfer_length: total amount of data to transfer
* callback: address of callback routine
* callback_pw: R5 (private word) for callback
* callback_wp: R12 (workspace pointer) for callback
*
* Outputs
* NONE
*
* Returns
* RISC OS error pointer (eg if previous command is still active) or NULL
*****************************************************************************/
extern _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);
/*****************************************************************************
* glue_Tick
*
* Background processing entry point to handle a specific device.
*
* Assumptions
* Interrupts are disabled
*
* Inputs
* device: struct describing the interface to process
*
* Outputs
* NONE
*
* Returns
* NOTHING
*****************************************************************************/
extern void glue_Tick(my_usb_device_t *device);
/*****************************************************************************
* glue_ReopenStream
*
* Try to cope with our streams having been closed
*
* Assumptions
* NONE
*
* Inputs
* file_handle: handle of stream which has been closed
*
* Outputs
* NONE
*
* Returns
* NOTHING
*****************************************************************************/
extern void glue_ReopenStream(uint32_t file_handle);
#endif /* end of sentry #ifdef */
/*****************************************************************************
* END OF FILE
*****************************************************************************/
/* Copyright 2003 Tematic 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.
*/
/* An intentionally empty file */
/* Copyright 2003 Tematic 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.
*/
#if !defined(BAVISON_RESMESS_H) /* file used if not already included */
#define BAVISON_RESMESS_H
/*****************************************************************************
* $Id$
* $Name$
*
* Author(s): Ben Avison
* Project(s):
*
* ----------------------------------------------------------------------------
* Purpose: Resource file embedding for RAM builds
*
* ----------------------------------------------------------------------------
* History: See source control system log
*
*****************************************************************************/
/*****************************************************************************
* Include header files
*****************************************************************************/
/*****************************************************************************
* MACROS
*****************************************************************************/
/*****************************************************************************
* New type definitions
*****************************************************************************/
/*****************************************************************************
* Constants
*****************************************************************************/
/*****************************************************************************
* Global variables
*****************************************************************************/
/*****************************************************************************
* Function prototypes
*****************************************************************************/
/*****************************************************************************
* resmess_ResourcesFiles
*
* Does nothing.
* Whatever you do, DON'T declare this as a variable and use its address -
* the ResGen documentation is wrong!
*
* Assumptions
* NONE
*
* Inputs
* NONE
*
* Outputs
* NONE
*
* Returns
* pointer to the resource file data within the image
*****************************************************************************/
extern void *resmess_ResourcesFiles(void);
#endif /* end of sentry #ifdef */
/*****************************************************************************
* END OF FILE
*****************************************************************************/
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