mirror of https://github.com/PCSX2/pcsx2.git
Copy USBqemu from the legacy plugins folder (to preserve history)
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4896 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
9314c5fed7
commit
a9d59b1b66
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* QEMU USB emulation
|
||||
*
|
||||
* Copyright (c) 2005 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
|
@ -0,0 +1,342 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Library General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Library General
|
||||
Public License instead of this License.
|
||||
|
||||
|
|
@ -0,0 +1,809 @@
|
|||
#ifndef __PS2EDEFS_H__
|
||||
#define __PS2EDEFS_H__
|
||||
|
||||
/*
|
||||
* PS2E Definitions v0.6.2 (beta)
|
||||
*
|
||||
* Author: linuzappz@hotmail.com
|
||||
* shadowpcsx2@yahoo.gr
|
||||
* florinsasu@hotmail.com
|
||||
*/
|
||||
|
||||
/*
|
||||
Notes:
|
||||
* Since this is still beta things may change.
|
||||
|
||||
* OSflags:
|
||||
__LINUX__ (linux OS)
|
||||
__WIN32__ (win32 OS)
|
||||
|
||||
* common return values (for ie. GSinit):
|
||||
0 - success
|
||||
-1 - error
|
||||
|
||||
* reserved keys:
|
||||
F1 to F10 are reserved for the emulator
|
||||
|
||||
* plugins should NOT change the current
|
||||
working directory.
|
||||
(on win32, add flag OFN_NOCHANGEDIR for
|
||||
GetOpenFileName)
|
||||
|
||||
*/
|
||||
|
||||
#include "PS2Etypes.h"
|
||||
|
||||
#ifdef __LINUX__
|
||||
#define CALLBACK
|
||||
#else
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/* common defines */
|
||||
|
||||
#if defined(GSdefs) || defined(PADdefs) || defined(SIOdefs) || \
|
||||
defined(SPU2defs) || defined(CDVDdefs) || defined(DEV9defs) || \
|
||||
defined(USBdefs) || defined(FWdefs)
|
||||
#define COMMONdefs
|
||||
#endif
|
||||
|
||||
// PS2EgetLibType returns (may be OR'd)
|
||||
#define PS2E_LT_GS 0x01
|
||||
#define PS2E_LT_PAD 0x02 // -=[ OBSOLETE ]=-
|
||||
#define PS2E_LT_SPU2 0x04
|
||||
#define PS2E_LT_CDVD 0x08
|
||||
#define PS2E_LT_DEV9 0x10
|
||||
#define PS2E_LT_USB 0x20
|
||||
#define PS2E_LT_FW 0x40
|
||||
#define PS2E_LT_SIO 0x80
|
||||
|
||||
// PS2EgetLibVersion2 (high 16 bits)
|
||||
#define PS2E_GS_VERSION 0x0006
|
||||
#define PS2E_PAD_VERSION 0x0002 // -=[ OBSOLETE ]=-
|
||||
#define PS2E_SPU2_VERSION 0x0005
|
||||
#define PS2E_CDVD_VERSION 0x0005
|
||||
#define PS2E_DEV9_VERSION 0x0003
|
||||
#define PS2E_USB_VERSION 0x0003
|
||||
#define PS2E_FW_VERSION 0x0002
|
||||
#define PS2E_SIO_VERSION 0x0001
|
||||
#ifdef COMMONdefs
|
||||
|
||||
u32 CALLBACK PS2EgetLibType(void);
|
||||
u32 CALLBACK PS2EgetLibVersion2(u32 type);
|
||||
char* CALLBACK PS2EgetLibName(void);
|
||||
|
||||
#endif
|
||||
|
||||
// key values:
|
||||
/* key values must be OS dependant:
|
||||
win32: the VK_XXX will be used (WinUser)
|
||||
linux: the XK_XXX will be used (XFree86)
|
||||
*/
|
||||
|
||||
// event values:
|
||||
#define KEYPRESS 1
|
||||
#define KEYRELEASE 2
|
||||
|
||||
typedef struct {
|
||||
u32 key;
|
||||
u32 event;
|
||||
} keyEvent;
|
||||
|
||||
// plugin types
|
||||
#define SIO_TYPE_PAD 0x00000001
|
||||
#define SIO_TYPE_MTAP 0x00000004
|
||||
#define SIO_TYPE_RM 0x00000040
|
||||
#define SIO_TYPE_MC 0x00000100
|
||||
|
||||
typedef int (CALLBACK * SIOchangeSlotCB)(int slot);
|
||||
|
||||
typedef struct {
|
||||
u8 ctrl:4; // control and mode bits
|
||||
u8 mode:4; // control and mode bits
|
||||
u8 trackNum; // current track number (1 to 99)
|
||||
u8 trackIndex; // current index within track (0 to 99)
|
||||
u8 trackM; // current minute location on the disc (BCD encoded)
|
||||
u8 trackS; // current sector location on the disc (BCD encoded)
|
||||
u8 trackF; // current frame location on the disc (BCD encoded)
|
||||
u8 pad; // unused
|
||||
u8 discM; // current minute offset from first track (BCD encoded)
|
||||
u8 discS; // current sector offset from first track (BCD encoded)
|
||||
u8 discF; // current frame offset from first track (BCD encoded)
|
||||
} cdvdSubQ;
|
||||
|
||||
typedef struct { // NOT bcd coded
|
||||
u32 lsn;
|
||||
u8 type;
|
||||
} cdvdTD;
|
||||
|
||||
typedef struct {
|
||||
u8 strack; //number of the first track (usually 1)
|
||||
u8 etrack; //number of the last track
|
||||
} cdvdTN;
|
||||
|
||||
// CDVDreadTrack mode values:
|
||||
#define CDVD_MODE_2352 0 // full 2352 bytes
|
||||
#define CDVD_MODE_2340 1 // skip sync (12) bytes
|
||||
#define CDVD_MODE_2328 2 // skip sync+head+sub (24) bytes
|
||||
#define CDVD_MODE_2048 3 // skip sync+head+sub (24) bytes
|
||||
#define CDVD_MODE_2368 4 // full 2352 bytes + 16 subq
|
||||
|
||||
// CDVDgetDiskType returns:
|
||||
#define CDVD_TYPE_ILLEGAL 0xff // Illegal Disc
|
||||
#define CDVD_TYPE_DVDV 0xfe // DVD Video
|
||||
#define CDVD_TYPE_CDDA 0xfd // Audio CD
|
||||
#define CDVD_TYPE_PS2DVD 0x14 // PS2 DVD
|
||||
#define CDVD_TYPE_PS2CDDA 0x13 // PS2 CD (with audio)
|
||||
#define CDVD_TYPE_PS2CD 0x12 // PS2 CD
|
||||
#define CDVD_TYPE_PSCDDA 0x11 // PS CD (with audio)
|
||||
#define CDVD_TYPE_PSCD 0x10 // PS CD
|
||||
#define CDVD_TYPE_UNKNOWN 0x05 // Unknown
|
||||
#define CDVD_TYPE_DETCTDVDD 0x04 // Detecting Dvd Dual Sided
|
||||
#define CDVD_TYPE_DETCTDVDS 0x03 // Detecting Dvd Single Sided
|
||||
#define CDVD_TYPE_DETCTCD 0x02 // Detecting Cd
|
||||
#define CDVD_TYPE_DETCT 0x01 // Detecting
|
||||
#define CDVD_TYPE_NODISC 0x00 // No Disc
|
||||
|
||||
// CDVDgetTrayStatus returns:
|
||||
#define CDVD_TRAY_CLOSE 0x00
|
||||
#define CDVD_TRAY_OPEN 0x01
|
||||
|
||||
// cdvdTD.type (track types for cds)
|
||||
#define CDVD_AUDIO_TRACK 0x01
|
||||
#define CDVD_MODE1_TRACK 0x41
|
||||
#define CDVD_MODE2_TRACK 0x61
|
||||
|
||||
#define CDVD_AUDIO_MASK 0x00
|
||||
#define CDVD_DATA_MASK 0x40
|
||||
// CDROM_DATA_TRACK 0x04 //do not enable this! (from linux kernel)
|
||||
|
||||
typedef void (*DEV9callback)(int cycles);
|
||||
typedef int (*DEV9handler)(void);
|
||||
|
||||
typedef void (*USBcallback)(int cycles);
|
||||
typedef int (*USBhandler)(void);
|
||||
|
||||
// freeze modes:
|
||||
#define FREEZE_LOAD 0
|
||||
#define FREEZE_SAVE 1
|
||||
#define FREEZE_SIZE 2
|
||||
|
||||
typedef struct {
|
||||
char name[8];
|
||||
void *common;
|
||||
} GSdriverInfo;
|
||||
|
||||
#ifdef __WIN32__
|
||||
typedef struct { // unsupported values must be set to zero
|
||||
HWND hWnd;
|
||||
HMENU hMenu;
|
||||
HWND hStatusWnd;
|
||||
} winInfo;
|
||||
#endif
|
||||
|
||||
/* GS plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef GSdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK GSinit();
|
||||
s32 CALLBACK GSopen(void *pDsp, char *Title, int multithread);
|
||||
void CALLBACK GSclose();
|
||||
void CALLBACK GSshutdown();
|
||||
void CALLBACK GSvsync(int field);
|
||||
void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr);
|
||||
void CALLBACK GSgifTransfer2(u32 *pMem, u32 size);
|
||||
void CALLBACK GSgifTransfer3(u32 *pMem, u32 size);
|
||||
void CALLBACK GSgifSoftReset(u32 mask);
|
||||
void CALLBACK GSreadFIFO(u64 *mem);
|
||||
void CALLBACK GSreadFIFO2(u64 *mem, int qwc);
|
||||
|
||||
// extended funcs
|
||||
|
||||
// GSkeyEvent gets called when there is a keyEvent from the PAD plugin
|
||||
void CALLBACK GSkeyEvent(keyEvent *ev);
|
||||
void CALLBACK GSchangeSaveState(int, const char* filename);
|
||||
void CALLBACK GSmakeSnapshot(char *path);
|
||||
void CALLBACK GSmakeSnapshot2(char *pathname, int* snapdone, int savejpg);
|
||||
void CALLBACK GSirqCallback(void (*callback)());
|
||||
void CALLBACK GSprintf(int timeout, char *fmt, ...);
|
||||
void CALLBACK GSsetBaseMem(void*);
|
||||
void CALLBACK GSsetGameCRC(int);
|
||||
|
||||
// controls frame skipping in the GS, if this routine isn't present, frame skipping won't be done
|
||||
void CALLBACK GSsetFrameSkip(int frameskip);
|
||||
|
||||
void CALLBACK GSreset();
|
||||
void CALLBACK GSwriteCSR(u32 value);
|
||||
void CALLBACK GSgetDriverInfo(GSdriverInfo *info);
|
||||
#ifdef __WIN32__
|
||||
s32 CALLBACK GSsetWindowInfo(winInfo *info);
|
||||
#endif
|
||||
s32 CALLBACK GSfreeze(int mode, freezeData *data);
|
||||
void CALLBACK GSconfigure();
|
||||
void CALLBACK GSabout();
|
||||
s32 CALLBACK GStest();
|
||||
|
||||
#endif
|
||||
|
||||
/* PAD plugin API -=[ OBSOLETE ]=- */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef PADdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK PADinit(u32 flags);
|
||||
s32 CALLBACK PADopen(void *pDsp);
|
||||
void CALLBACK PADclose();
|
||||
void CALLBACK PADshutdown();
|
||||
// PADkeyEvent is called every vsync (return NULL if no event)
|
||||
keyEvent* CALLBACK PADkeyEvent();
|
||||
u8 CALLBACK PADstartPoll(int pad);
|
||||
u8 CALLBACK PADpoll(u8 value);
|
||||
// returns: 1 if supported pad1
|
||||
// 2 if supported pad2
|
||||
// 3 if both are supported
|
||||
u32 CALLBACK PADquery();
|
||||
|
||||
// extended funcs
|
||||
|
||||
void CALLBACK PADgsDriverInfo(GSdriverInfo *info);
|
||||
void CALLBACK PADconfigure();
|
||||
void CALLBACK PADabout();
|
||||
s32 CALLBACK PADtest();
|
||||
|
||||
#endif
|
||||
|
||||
/* SIO plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef SIOdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK SIOinit(u32 port, u32 slot, SIOchangeSlotCB f);
|
||||
s32 CALLBACK SIOopen(void *pDsp);
|
||||
void CALLBACK SIOclose();
|
||||
void CALLBACK SIOshutdown();
|
||||
u8 CALLBACK SIOstartPoll(u8 value);
|
||||
u8 CALLBACK SIOpoll(u8 value);
|
||||
// returns: SIO_TYPE_{PAD,MTAP,RM,MC}
|
||||
u32 CALLBACK SIOquery();
|
||||
|
||||
// extended funcs
|
||||
|
||||
void CALLBACK SIOconfigure();
|
||||
void CALLBACK SIOabout();
|
||||
s32 CALLBACK SIOtest();
|
||||
|
||||
#endif
|
||||
|
||||
/* SPU2 plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef SPU2defs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK SPU2init();
|
||||
s32 CALLBACK SPU2open(void *pDsp);
|
||||
void CALLBACK SPU2close();
|
||||
void CALLBACK SPU2shutdown();
|
||||
void CALLBACK SPU2write(u32 mem, u16 value);
|
||||
u16 CALLBACK SPU2read(u32 mem);
|
||||
void CALLBACK SPU2readDMA4Mem(u16 *pMem, int size);
|
||||
void CALLBACK SPU2writeDMA4Mem(u16 *pMem, int size);
|
||||
void CALLBACK SPU2interruptDMA4();
|
||||
void CALLBACK SPU2readDMA7Mem(u16* pMem, int size);
|
||||
void CALLBACK SPU2writeDMA7Mem(u16 *pMem, int size);
|
||||
void CALLBACK SPU2interruptDMA7();
|
||||
u32 CALLBACK SPU2ReadMemAddr(int core);
|
||||
void CALLBACK SPU2WriteMemAddr(int core,u32 value);
|
||||
void CALLBACK SPU2irqCallback(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)());
|
||||
// extended funcs
|
||||
|
||||
void CALLBACK SPU2async(u32 cycles);
|
||||
s32 CALLBACK SPU2freeze(int mode, freezeData *data);
|
||||
void CALLBACK SPU2configure();
|
||||
void CALLBACK SPU2about();
|
||||
s32 CALLBACK SPU2test();
|
||||
|
||||
#endif
|
||||
|
||||
/* CDVD plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef CDVDdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK CDVDinit();
|
||||
s32 CALLBACK CDVDopen();
|
||||
void CALLBACK CDVDclose();
|
||||
void CALLBACK CDVDshutdown();
|
||||
s32 CALLBACK CDVDreadTrack(u32 lsn, int mode);
|
||||
|
||||
// return can be NULL (for async modes)
|
||||
u8* CALLBACK CDVDgetBuffer();
|
||||
|
||||
s32 CALLBACK CDVDreadSubQ(u32 lsn, cdvdSubQ* subq);//read subq from disc (only cds have subq data)
|
||||
s32 CALLBACK CDVDgetTN(cdvdTN *Buffer); //disk information
|
||||
s32 CALLBACK CDVDgetTD(u8 Track, cdvdTD *Buffer); //track info: min,sec,frame,type
|
||||
s32 CALLBACK CDVDgetTOC(void* toc); //gets ps2 style toc from disc
|
||||
s32 CALLBACK CDVDgetDiskType(); //CDVD_TYPE_xxxx
|
||||
s32 CALLBACK CDVDgetTrayStatus(); //CDVD_TRAY_xxxx
|
||||
s32 CALLBACK CDVDctrlTrayOpen(); //open disc tray
|
||||
s32 CALLBACK CDVDctrlTrayClose(); //close disc tray
|
||||
|
||||
// extended funcs
|
||||
|
||||
void CALLBACK CDVDconfigure();
|
||||
void CALLBACK CDVDabout();
|
||||
s32 CALLBACK CDVDtest();
|
||||
void CALLBACK CDVDnewDiskCB(void (*callback)());
|
||||
|
||||
#endif
|
||||
|
||||
/* DEV9 plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef DEV9defs
|
||||
|
||||
// basic funcs
|
||||
|
||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
s32 CALLBACK DEV9init();
|
||||
s32 CALLBACK DEV9open(void *pDsp);
|
||||
void CALLBACK DEV9close();
|
||||
void CALLBACK DEV9shutdown();
|
||||
u8 CALLBACK DEV9read8(u32 addr);
|
||||
u16 CALLBACK DEV9read16(u32 addr);
|
||||
u32 CALLBACK DEV9read32(u32 addr);
|
||||
void CALLBACK DEV9write8(u32 addr, u8 value);
|
||||
void CALLBACK DEV9write16(u32 addr, u16 value);
|
||||
void CALLBACK DEV9write32(u32 addr, u32 value);
|
||||
void CALLBACK DEV9readDMA8Mem(u32 *pMem, int size);
|
||||
void CALLBACK DEV9writeDMA8Mem(u32 *pMem, int size);
|
||||
// cycles = IOP cycles before calling callback,
|
||||
// if callback returns 1 the irq is triggered, else not
|
||||
void CALLBACK DEV9irqCallback(DEV9callback callback);
|
||||
DEV9handler CALLBACK DEV9irqHandler(void);
|
||||
|
||||
// extended funcs
|
||||
|
||||
s32 CALLBACK DEV9freeze(int mode, freezeData *data);
|
||||
void CALLBACK DEV9configure();
|
||||
void CALLBACK DEV9about();
|
||||
s32 CALLBACK DEV9test();
|
||||
|
||||
#endif
|
||||
|
||||
/* USB plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef USBdefs
|
||||
|
||||
// basic funcs
|
||||
|
||||
s32 CALLBACK USBinit();
|
||||
s32 CALLBACK USBopen(void *pDsp);
|
||||
void CALLBACK USBclose();
|
||||
void CALLBACK USBshutdown();
|
||||
u8 CALLBACK USBread8(u32 addr);
|
||||
u16 CALLBACK USBread16(u32 addr);
|
||||
u32 CALLBACK USBread32(u32 addr);
|
||||
void CALLBACK USBwrite8(u32 addr, u8 value);
|
||||
void CALLBACK USBwrite16(u32 addr, u16 value);
|
||||
void CALLBACK USBwrite32(u32 addr, u32 value);
|
||||
void CALLBACK USBasync(u32 cycles);
|
||||
|
||||
// cycles = IOP cycles before calling callback,
|
||||
// if callback returns 1 the irq is triggered, else not
|
||||
void CALLBACK USBirqCallback(USBcallback callback);
|
||||
USBhandler CALLBACK USBirqHandler(void);
|
||||
void CALLBACK USBsetRAM(void *mem);
|
||||
|
||||
// extended funcs
|
||||
|
||||
s32 CALLBACK USBfreeze(int mode, freezeData *data);
|
||||
void CALLBACK USBconfigure();
|
||||
void CALLBACK USBabout();
|
||||
s32 CALLBACK USBtest();
|
||||
|
||||
#endif
|
||||
|
||||
/* FW plugin API */
|
||||
|
||||
// if this file is included with this define
|
||||
// the next api will not be skipped by the compiler
|
||||
#ifdef FWdefs
|
||||
// basic funcs
|
||||
|
||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
s32 CALLBACK FWinit();
|
||||
s32 CALLBACK FWopen(void *pDsp);
|
||||
void CALLBACK FWclose();
|
||||
void CALLBACK FWshutdown();
|
||||
u32 CALLBACK FWread32(u32 addr);
|
||||
void CALLBACK FWwrite32(u32 addr, u32 value);
|
||||
void CALLBACK FWirqCallback(void (*callback)());
|
||||
|
||||
// extended funcs
|
||||
|
||||
s32 CALLBACK FWfreeze(int mode, freezeData *data);
|
||||
void CALLBACK FWconfigure();
|
||||
void CALLBACK FWabout();
|
||||
s32 CALLBACK FWtest();
|
||||
#endif
|
||||
|
||||
// might be useful for emulators
|
||||
#ifdef PLUGINtypedefs
|
||||
|
||||
typedef u32 (CALLBACK* _PS2EgetLibType)(void);
|
||||
typedef u32 (CALLBACK* _PS2EgetLibVersion2)(u32 type);
|
||||
typedef char*(CALLBACK* _PS2EgetLibName)(void);
|
||||
|
||||
// GS
|
||||
// NOTE: GSreadFIFOX/GSwriteCSR functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
typedef s32 (CALLBACK* _GSinit)();
|
||||
typedef s32 (CALLBACK* _GSopen)(void *pDsp, char *Title, int multithread);
|
||||
typedef void (CALLBACK* _GSclose)();
|
||||
typedef void (CALLBACK* _GSshutdown)();
|
||||
typedef void (CALLBACK* _GSvsync)(int field);
|
||||
typedef void (CALLBACK* _GSgifTransfer1)(u32 *pMem, u32 addr);
|
||||
typedef void (CALLBACK* _GSgifTransfer2)(u32 *pMem, u32 size);
|
||||
typedef void (CALLBACK* _GSgifTransfer3)(u32 *pMem, u32 size);
|
||||
typedef void (CALLBACK* _GSgifSoftReset)(u32 mask);
|
||||
typedef void (CALLBACK* _GSreadFIFO)(u64 *pMem);
|
||||
typedef void (CALLBACK* _GSreadFIFO2)(u64 *pMem, int qwc);
|
||||
|
||||
typedef void (CALLBACK* _GSkeyEvent)(keyEvent* ev);
|
||||
typedef void (CALLBACK* _GSchangeSaveState)(int, const char* filename);
|
||||
typedef void (CALLBACK* _GSirqCallback)(void (*callback)());
|
||||
typedef void (CALLBACK* _GSprintf)(int timeout, char *fmt, ...);
|
||||
typedef void (CALLBACK* _GSsetBaseMem)(void*);
|
||||
typedef void (CALLBACK* _GSsetGameCRC)(int);
|
||||
typedef void (CALLBACK* _GSsetFrameSkip)(int frameskip);
|
||||
typedef void (CALLBACK* _GSreset)();
|
||||
typedef void (CALLBACK* _GSwriteCSR)(u32 value);
|
||||
typedef void (CALLBACK* _GSgetDriverInfo)(GSdriverInfo *info);
|
||||
#ifdef __WIN32__
|
||||
typedef s32 (CALLBACK* _GSsetWindowInfo)(winInfo *info);
|
||||
#endif
|
||||
typedef void (CALLBACK* _GSmakeSnapshot)(char *path);
|
||||
typedef void (CALLBACK* _GSmakeSnapshot2)(char *path, int*, int);
|
||||
typedef s32 (CALLBACK* _GSfreeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _GSconfigure)();
|
||||
typedef s32 (CALLBACK* _GStest)();
|
||||
typedef void (CALLBACK* _GSabout)();
|
||||
|
||||
// PAD
|
||||
typedef s32 (CALLBACK* _PADinit)(u32 flags);
|
||||
typedef s32 (CALLBACK* _PADopen)(void *pDsp);
|
||||
typedef void (CALLBACK* _PADclose)();
|
||||
typedef void (CALLBACK* _PADshutdown)();
|
||||
typedef keyEvent* (CALLBACK* _PADkeyEvent)();
|
||||
typedef u8 (CALLBACK* _PADstartPoll)(int pad);
|
||||
typedef u8 (CALLBACK* _PADpoll)(u8 value);
|
||||
typedef u32 (CALLBACK* _PADquery)();
|
||||
|
||||
typedef void (CALLBACK* _PADgsDriverInfo)(GSdriverInfo *info);
|
||||
typedef void (CALLBACK* _PADconfigure)();
|
||||
typedef s32 (CALLBACK* _PADtest)();
|
||||
typedef void (CALLBACK* _PADabout)();
|
||||
|
||||
// SIO
|
||||
typedef s32 (CALLBACK* _SIOinit)(u32 port, u32 slot, SIOchangeSlotCB f);
|
||||
typedef s32 (CALLBACK* _SIOopen)(void *pDsp);
|
||||
typedef void (CALLBACK* _SIOclose)();
|
||||
typedef void (CALLBACK* _SIOshutdown)();
|
||||
typedef u8 (CALLBACK* _SIOstartPoll)(u8 value);
|
||||
typedef u8 (CALLBACK* _SIOpoll)(u8 value);
|
||||
typedef u32 (CALLBACK* _SIOquery)();
|
||||
|
||||
typedef void (CALLBACK* _SIOconfigure)();
|
||||
typedef s32 (CALLBACK* _SIOtest)();
|
||||
typedef void (CALLBACK* _SIOabout)();
|
||||
|
||||
// SPU2
|
||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
typedef s32 (CALLBACK* _SPU2init)();
|
||||
typedef s32 (CALLBACK* _SPU2open)(void *pDsp);
|
||||
typedef void (CALLBACK* _SPU2close)();
|
||||
typedef void (CALLBACK* _SPU2shutdown)();
|
||||
typedef void (CALLBACK* _SPU2write)(u32 mem, u16 value);
|
||||
typedef u16 (CALLBACK* _SPU2read)(u32 mem);
|
||||
typedef void (CALLBACK* _SPU2readDMA4Mem)(u16 *pMem, int size);
|
||||
typedef void (CALLBACK* _SPU2writeDMA4Mem)(u16 *pMem, int size);
|
||||
typedef void (CALLBACK* _SPU2interruptDMA4)();
|
||||
typedef void (CALLBACK* _SPU2readDMA7Mem)(u16 *pMem, int size);
|
||||
typedef void (CALLBACK* _SPU2writeDMA7Mem)(u16 *pMem, int size);
|
||||
typedef void (CALLBACK* _SPU2interruptDMA7)();
|
||||
typedef void (CALLBACK* _SPU2irqCallback)(void (*SPU2callback)(),void (*DMA4callback)(),void (*DMA7callback)());
|
||||
typedef u32 (CALLBACK* _SPU2ReadMemAddr)(int core);
|
||||
typedef void (CALLBACK* _SPU2WriteMemAddr)(int core,u32 value);
|
||||
typedef void (CALLBACK* _SPU2async)(u32 cycles);
|
||||
typedef s32 (CALLBACK* _SPU2freeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _SPU2configure)();
|
||||
typedef s32 (CALLBACK* _SPU2test)();
|
||||
typedef void (CALLBACK* _SPU2about)();
|
||||
|
||||
// CDVD
|
||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
typedef s32 (CALLBACK* _CDVDinit)();
|
||||
typedef s32 (CALLBACK* _CDVDopen)();
|
||||
typedef void (CALLBACK* _CDVDclose)();
|
||||
typedef void (CALLBACK* _CDVDshutdown)();
|
||||
typedef s32 (CALLBACK* _CDVDreadTrack)(u32 lsn, int mode);
|
||||
typedef u8* (CALLBACK* _CDVDgetBuffer)();
|
||||
typedef s32 (CALLBACK* _CDVDreadSubQ)(u32 lsn, cdvdSubQ* subq);
|
||||
typedef s32 (CALLBACK* _CDVDgetTN)(cdvdTN *Buffer);
|
||||
typedef s32 (CALLBACK* _CDVDgetTD)(u8 Track, cdvdTD *Buffer);
|
||||
typedef s32 (CALLBACK* _CDVDgetTOC)(void* toc);
|
||||
typedef s32 (CALLBACK* _CDVDgetDiskType)();
|
||||
typedef s32 (CALLBACK* _CDVDgetTrayStatus)();
|
||||
typedef s32 (CALLBACK* _CDVDctrlTrayOpen)();
|
||||
typedef s32 (CALLBACK* _CDVDctrlTrayClose)();
|
||||
|
||||
typedef void (CALLBACK* _CDVDconfigure)();
|
||||
typedef s32 (CALLBACK* _CDVDtest)();
|
||||
typedef void (CALLBACK* _CDVDabout)();
|
||||
typedef void (CALLBACK* _CDVDnewDiskCB)(void (*callback)());
|
||||
|
||||
// DEV9
|
||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
typedef s32 (CALLBACK* _DEV9init)();
|
||||
typedef s32 (CALLBACK* _DEV9open)(void *pDsp);
|
||||
typedef void (CALLBACK* _DEV9close)();
|
||||
typedef void (CALLBACK* _DEV9shutdown)();
|
||||
typedef u8 (CALLBACK* _DEV9read8)(u32 mem);
|
||||
typedef u16 (CALLBACK* _DEV9read16)(u32 mem);
|
||||
typedef u32 (CALLBACK* _DEV9read32)(u32 mem);
|
||||
typedef void (CALLBACK* _DEV9write8)(u32 mem, u8 value);
|
||||
typedef void (CALLBACK* _DEV9write16)(u32 mem, u16 value);
|
||||
typedef void (CALLBACK* _DEV9write32)(u32 mem, u32 value);
|
||||
typedef void (CALLBACK* _DEV9readDMA8Mem)(u32 *pMem, int size);
|
||||
typedef void (CALLBACK* _DEV9writeDMA8Mem)(u32 *pMem, int size);
|
||||
typedef void (CALLBACK* _DEV9irqCallback)(DEV9callback callback);
|
||||
typedef DEV9handler (CALLBACK* _DEV9irqHandler)(void);
|
||||
|
||||
typedef s32 (CALLBACK* _DEV9freeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _DEV9configure)();
|
||||
typedef s32 (CALLBACK* _DEV9test)();
|
||||
typedef void (CALLBACK* _DEV9about)();
|
||||
|
||||
// USB
|
||||
// NOTE: The read/write functions CANNOT use XMM/MMX regs
|
||||
// If you want to use them, need to save and restore current ones
|
||||
typedef s32 (CALLBACK* _USBinit)();
|
||||
typedef s32 (CALLBACK* _USBopen)(void *pDsp);
|
||||
typedef void (CALLBACK* _USBclose)();
|
||||
typedef void (CALLBACK* _USBshutdown)();
|
||||
typedef u8 (CALLBACK* _USBread8)(u32 mem);
|
||||
typedef u16 (CALLBACK* _USBread16)(u32 mem);
|
||||
typedef u32 (CALLBACK* _USBread32)(u32 mem);
|
||||
typedef void (CALLBACK* _USBwrite8)(u32 mem, u8 value);
|
||||
typedef void (CALLBACK* _USBwrite16)(u32 mem, u16 value);
|
||||
typedef void (CALLBACK* _USBwrite32)(u32 mem, u32 value);
|
||||
typedef void (CALLBACK* _USBirqCallback)(USBcallback callback);
|
||||
typedef USBhandler (CALLBACK* _USBirqHandler)(void);
|
||||
typedef void (CALLBACK* _USBsetRAM)(void *mem);
|
||||
typedef void (CALLBACK* _USBasync)(u32 cycles);
|
||||
|
||||
typedef s32 (CALLBACK* _USBfreeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _USBconfigure)();
|
||||
typedef s32 (CALLBACK* _USBtest)();
|
||||
typedef void (CALLBACK* _USBabout)();
|
||||
|
||||
//FW
|
||||
typedef s32 (CALLBACK* _FWinit)();
|
||||
typedef s32 (CALLBACK* _FWopen)(void *pDsp);
|
||||
typedef void (CALLBACK* _FWclose)();
|
||||
typedef void (CALLBACK* _FWshutdown)();
|
||||
typedef u32 (CALLBACK* _FWread32)(u32 mem);
|
||||
typedef void (CALLBACK* _FWwrite32)(u32 mem, u32 value);
|
||||
typedef void (CALLBACK* _FWirqCallback)(void (*callback)());
|
||||
|
||||
typedef s32 (CALLBACK* _FWfreeze)(int mode, freezeData *data);
|
||||
typedef void (CALLBACK* _FWconfigure)();
|
||||
typedef s32 (CALLBACK* _FWtest)();
|
||||
typedef void (CALLBACK* _FWabout)();
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef PLUGINfuncs
|
||||
|
||||
// GS
|
||||
_GSinit GSinit;
|
||||
_GSopen GSopen;
|
||||
_GSclose GSclose;
|
||||
_GSshutdown GSshutdown;
|
||||
_GSvsync GSvsync;
|
||||
_GSgifTransfer1 GSgifTransfer1;
|
||||
_GSgifTransfer2 GSgifTransfer2;
|
||||
_GSgifTransfer3 GSgifTransfer3;
|
||||
_GSgifSoftReset GSgifSoftReset;
|
||||
_GSreadFIFO GSreadFIFO;
|
||||
_GSreadFIFO2 GSreadFIFO2;
|
||||
|
||||
_GSkeyEvent GSkeyEvent;
|
||||
_GSchangeSaveState GSchangeSaveState;
|
||||
_GSmakeSnapshot GSmakeSnapshot;
|
||||
_GSmakeSnapshot2 GSmakeSnapshot2;
|
||||
_GSirqCallback GSirqCallback;
|
||||
_GSprintf GSprintf;
|
||||
_GSsetBaseMem GSsetBaseMem;
|
||||
_GSsetGameCRC GSsetGameCRC;
|
||||
_GSsetFrameSkip GSsetFrameSkip;
|
||||
_GSreset GSreset;
|
||||
_GSwriteCSR GSwriteCSR;
|
||||
_GSgetDriverInfo GSgetDriverInfo;
|
||||
#ifdef __WIN32__
|
||||
_GSsetWindowInfo GSsetWindowInfo;
|
||||
#endif
|
||||
_GSfreeze GSfreeze;
|
||||
_GSconfigure GSconfigure;
|
||||
_GStest GStest;
|
||||
_GSabout GSabout;
|
||||
|
||||
// PAD1
|
||||
_PADinit PAD1init;
|
||||
_PADopen PAD1open;
|
||||
_PADclose PAD1close;
|
||||
_PADshutdown PAD1shutdown;
|
||||
_PADkeyEvent PAD1keyEvent;
|
||||
_PADstartPoll PAD1startPoll;
|
||||
_PADpoll PAD1poll;
|
||||
_PADquery PAD1query;
|
||||
|
||||
_PADgsDriverInfo PAD1gsDriverInfo;
|
||||
_PADconfigure PAD1configure;
|
||||
_PADtest PAD1test;
|
||||
_PADabout PAD1about;
|
||||
|
||||
// PAD2
|
||||
_PADinit PAD2init;
|
||||
_PADopen PAD2open;
|
||||
_PADclose PAD2close;
|
||||
_PADshutdown PAD2shutdown;
|
||||
_PADkeyEvent PAD2keyEvent;
|
||||
_PADstartPoll PAD2startPoll;
|
||||
_PADpoll PAD2poll;
|
||||
_PADquery PAD2query;
|
||||
|
||||
_PADgsDriverInfo PAD2gsDriverInfo;
|
||||
_PADconfigure PAD2configure;
|
||||
_PADtest PAD2test;
|
||||
_PADabout PAD2about;
|
||||
|
||||
// SIO[2]
|
||||
_SIOinit SIOinit[2][9];
|
||||
_SIOopen SIOopen[2][9];
|
||||
_SIOclose SIOclose[2][9];
|
||||
_SIOshutdown SIOshutdown[2][9];
|
||||
_SIOstartPoll SIOstartPoll[2][9];
|
||||
_SIOpoll SIOpoll[2][9];
|
||||
_SIOquery SIOquery[2][9];
|
||||
|
||||
_SIOconfigure SIOconfigure[2][9];
|
||||
_SIOtest SIOtest[2][9];
|
||||
_SIOabout SIOabout[2][9];
|
||||
|
||||
// SPU2
|
||||
_SPU2init SPU2init;
|
||||
_SPU2open SPU2open;
|
||||
_SPU2close SPU2close;
|
||||
_SPU2shutdown SPU2shutdown;
|
||||
_SPU2write SPU2write;
|
||||
_SPU2read SPU2read;
|
||||
_SPU2readDMA4Mem SPU2readDMA4Mem;
|
||||
_SPU2writeDMA4Mem SPU2writeDMA4Mem;
|
||||
_SPU2interruptDMA4 SPU2interruptDMA4;
|
||||
_SPU2readDMA7Mem SPU2readDMA7Mem;
|
||||
_SPU2writeDMA7Mem SPU2writeDMA7Mem;
|
||||
_SPU2interruptDMA7 SPU2interruptDMA7;
|
||||
_SPU2ReadMemAddr SPU2ReadMemAddr;
|
||||
_SPU2WriteMemAddr SPU2WriteMemAddr;
|
||||
_SPU2irqCallback SPU2irqCallback;
|
||||
|
||||
_SPU2async SPU2async;
|
||||
_SPU2freeze SPU2freeze;
|
||||
_SPU2configure SPU2configure;
|
||||
_SPU2test SPU2test;
|
||||
_SPU2about SPU2about;
|
||||
|
||||
// CDVD
|
||||
_CDVDinit CDVDinit;
|
||||
_CDVDopen CDVDopen;
|
||||
_CDVDclose CDVDclose;
|
||||
_CDVDshutdown CDVDshutdown;
|
||||
_CDVDreadTrack CDVDreadTrack;
|
||||
_CDVDgetBuffer CDVDgetBuffer;
|
||||
_CDVDreadSubQ CDVDreadSubQ;
|
||||
_CDVDgetTN CDVDgetTN;
|
||||
_CDVDgetTD CDVDgetTD;
|
||||
_CDVDgetTOC CDVDgetTOC;
|
||||
_CDVDgetDiskType CDVDgetDiskType;
|
||||
_CDVDgetTrayStatus CDVDgetTrayStatus;
|
||||
_CDVDctrlTrayOpen CDVDctrlTrayOpen;
|
||||
_CDVDctrlTrayClose CDVDctrlTrayClose;
|
||||
|
||||
_CDVDconfigure CDVDconfigure;
|
||||
_CDVDtest CDVDtest;
|
||||
_CDVDabout CDVDabout;
|
||||
_CDVDnewDiskCB CDVDnewDiskCB;
|
||||
|
||||
// DEV9
|
||||
_DEV9init DEV9init;
|
||||
_DEV9open DEV9open;
|
||||
_DEV9close DEV9close;
|
||||
_DEV9shutdown DEV9shutdown;
|
||||
_DEV9read8 DEV9read8;
|
||||
_DEV9read16 DEV9read16;
|
||||
_DEV9read32 DEV9read32;
|
||||
_DEV9write8 DEV9write8;
|
||||
_DEV9write16 DEV9write16;
|
||||
_DEV9write32 DEV9write32;
|
||||
_DEV9readDMA8Mem DEV9readDMA8Mem;
|
||||
_DEV9writeDMA8Mem DEV9writeDMA8Mem;
|
||||
_DEV9irqCallback DEV9irqCallback;
|
||||
_DEV9irqHandler DEV9irqHandler;
|
||||
|
||||
_DEV9configure DEV9configure;
|
||||
_DEV9freeze DEV9freeze;
|
||||
_DEV9test DEV9test;
|
||||
_DEV9about DEV9about;
|
||||
|
||||
// USB
|
||||
_USBinit USBinit;
|
||||
_USBopen USBopen;
|
||||
_USBclose USBclose;
|
||||
_USBshutdown USBshutdown;
|
||||
_USBread8 USBread8;
|
||||
_USBread16 USBread16;
|
||||
_USBread32 USBread32;
|
||||
_USBwrite8 USBwrite8;
|
||||
_USBwrite16 USBwrite16;
|
||||
_USBwrite32 USBwrite32;
|
||||
_USBirqCallback USBirqCallback;
|
||||
_USBirqHandler USBirqHandler;
|
||||
_USBsetRAM USBsetRAM;
|
||||
_USBasync USBasync;
|
||||
|
||||
_USBconfigure USBconfigure;
|
||||
_USBfreeze USBfreeze;
|
||||
_USBtest USBtest;
|
||||
_USBabout USBabout;
|
||||
|
||||
// FW
|
||||
_FWinit FWinit;
|
||||
_FWopen FWopen;
|
||||
_FWclose FWclose;
|
||||
_FWshutdown FWshutdown;
|
||||
_FWread32 FWread32;
|
||||
_FWwrite32 FWwrite32;
|
||||
_FWirqCallback FWirqCallback;
|
||||
|
||||
_FWconfigure FWconfigure;
|
||||
_FWfreeze FWfreeze;
|
||||
_FWtest FWtest;
|
||||
_FWabout FWabout;
|
||||
#endif
|
||||
|
||||
#endif /* __PS2EDEFS_H__ */
|
|
@ -0,0 +1,75 @@
|
|||
#ifndef __PS2ETYPES_H__
|
||||
#define __PS2ETYPES_H__
|
||||
|
||||
#ifndef ARRAYSIZE
|
||||
#define ARRAYSIZE(x) (sizeof(x)/sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
#if defined (__linux__) // some distributions are lower case
|
||||
#define __LINUX__
|
||||
#endif
|
||||
|
||||
// Basic types
|
||||
#if defined(_WIN32)
|
||||
|
||||
typedef __int8 s8;
|
||||
typedef __int16 s16;
|
||||
typedef __int32 s32;
|
||||
typedef __int64 s64;
|
||||
|
||||
typedef unsigned __int8 u8;
|
||||
typedef unsigned __int16 u16;
|
||||
typedef unsigned __int32 u32;
|
||||
typedef unsigned __int64 u64;
|
||||
|
||||
#if defined(__x86_64__)
|
||||
typedef u64 uptr;
|
||||
#else
|
||||
typedef u32 uptr;
|
||||
#endif
|
||||
|
||||
#define PCSX2_ALIGNED16(x) __declspec(align(16)) x
|
||||
|
||||
#else
|
||||
|
||||
typedef char s8;
|
||||
typedef short s16;
|
||||
typedef int s32;
|
||||
typedef long long s64;
|
||||
|
||||
typedef unsigned char u8;
|
||||
typedef unsigned short u16;
|
||||
typedef unsigned int u32;
|
||||
typedef unsigned long long u64;
|
||||
|
||||
#if defined(__x86_64__)
|
||||
typedef u64 uptr;
|
||||
#else
|
||||
typedef u32 uptr;
|
||||
#endif
|
||||
|
||||
#ifdef __LINUX__
|
||||
typedef union _LARGE_INTEGER
|
||||
{
|
||||
long long QuadPart;
|
||||
} LARGE_INTEGER;
|
||||
#endif
|
||||
|
||||
#if defined(__MINGW32__)
|
||||
#define PCSX2_ALIGNED16(x) __declspec(align(16)) x
|
||||
#else
|
||||
#define PCSX2_ALIGNED16(x) x __attribute((aligned(16)))
|
||||
#endif
|
||||
|
||||
#ifndef __forceinline
|
||||
#define __forceinline inline
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int size;
|
||||
s8 *data;
|
||||
} freezeData;
|
||||
|
||||
#endif /* __PS2ETYPES_H__ */
|
|
@ -0,0 +1,26 @@
|
|||
USBlinuz v0.1
|
||||
-------------
|
||||
|
||||
This is an extension to use with play station2 emulators
|
||||
as PCSX2 (only one right now).
|
||||
The plugin is free open source code.
|
||||
|
||||
Usage:
|
||||
-----
|
||||
Place the file "usblinuz.dll" (win32) or usblinuz_64.dll (win64)
|
||||
at the Plugin directory of the Emulator to use it.
|
||||
|
||||
Changes:
|
||||
-------
|
||||
v0.1 (gigaherz)
|
||||
* First Release
|
||||
* Tested with Pcsx2 32 and 64bit
|
||||
|
||||
Authors:
|
||||
-------
|
||||
|
||||
linuzappz <linuzappz@hotmail.com>
|
||||
shadow <shadowpcsx2@yahoo.gr>
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,252 @@
|
|||
/* USBlinuz
|
||||
* Copyright (C) 2002-2004 USBlinuz Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "qemu-usb/vl.h"
|
||||
#include "USB.h"
|
||||
|
||||
const unsigned char version = PS2E_USB_VERSION;
|
||||
const unsigned char revision = 0;
|
||||
const unsigned char build = 1; // increase that with each version
|
||||
|
||||
static char *libraryName = "Qemu USB Driver by Gigaherz"
|
||||
#ifdef _DEBUG
|
||||
" (debug)"
|
||||
#endif
|
||||
;
|
||||
|
||||
OHCIState *qemu_ohci;
|
||||
|
||||
Config conf;
|
||||
|
||||
HWND gsWnd=NULL;
|
||||
|
||||
u8 *usbR;
|
||||
u8 *ram;
|
||||
usbStruct usb;
|
||||
USBcallback _USBirq;
|
||||
FILE *usbLog;
|
||||
int64_t usb_frame_time;
|
||||
int64_t usb_bit_time;
|
||||
|
||||
s64 clocks;
|
||||
|
||||
u32 CALLBACK PS2EgetLibType() {
|
||||
return PS2E_LT_USB;
|
||||
}
|
||||
|
||||
char* CALLBACK PS2EgetLibName() {
|
||||
return libraryName;
|
||||
}
|
||||
|
||||
u32 CALLBACK PS2EgetLibVersion2(u32 type) {
|
||||
return (version<<16) | (revision<<8) | build;
|
||||
}
|
||||
|
||||
void __Log(char *fmt, ...) {
|
||||
va_list list;
|
||||
|
||||
if (!conf.Log) return;
|
||||
|
||||
va_start(list, fmt);
|
||||
vfprintf(usbLog, fmt, list);
|
||||
va_end(list);
|
||||
}
|
||||
|
||||
void USBirq(int cycles)
|
||||
{
|
||||
USB_LOG("USBirq.\n");
|
||||
|
||||
_USBirq(cycles);
|
||||
}
|
||||
|
||||
s32 CALLBACK USBinit() {
|
||||
LoadConfig();
|
||||
if (conf.Log)
|
||||
{
|
||||
usbLog = fopen("logs/usbLog.txt", "w");
|
||||
setvbuf(usbLog, NULL, _IONBF, 0);
|
||||
USB_LOG("usblinuz plugin version %d,%d\n",revision,build);
|
||||
USB_LOG("USBinit\n");
|
||||
}
|
||||
|
||||
qemu_ohci = ohci_create(0x1f801600,2);
|
||||
qemu_ohci->rhport[0].port.attach(&(qemu_ohci->rhport[0].port),usb_keyboard_init());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CALLBACK USBshutdown() {
|
||||
|
||||
qemu_ohci->rhport[0].port.dev->handle_destroy(qemu_ohci->rhport[0].port.dev);
|
||||
|
||||
free(qemu_ohci);
|
||||
|
||||
#ifdef _DEBUG
|
||||
fclose(usbLog);
|
||||
#endif
|
||||
}
|
||||
|
||||
s32 CALLBACK USBopen(void *pDsp) {
|
||||
USB_LOG("USBopen\n");
|
||||
|
||||
HWND hWnd=(HWND)pDsp;
|
||||
|
||||
if (!IsWindow (hWnd) && !IsBadReadPtr ((u32*)hWnd, 4))
|
||||
hWnd = *(HWND*)hWnd;
|
||||
if (!IsWindow (hWnd))
|
||||
hWnd = NULL;
|
||||
else
|
||||
{
|
||||
while (GetWindowLong (hWnd, GWL_STYLE) & WS_CHILD)
|
||||
hWnd = GetParent (hWnd);
|
||||
}
|
||||
gsWnd = hWnd;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CALLBACK USBclose() {
|
||||
}
|
||||
|
||||
u8 CALLBACK USBread8(u32 addr) {
|
||||
USB_LOG("* Invalid 8bit read at address %lx\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u16 CALLBACK USBread16(u32 addr) {
|
||||
USB_LOG("* Invalid 16bit read at address %lx\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 CALLBACK USBread32(u32 addr) {
|
||||
u32 hard;
|
||||
|
||||
hard=ohci_mem_read(qemu_ohci,addr);
|
||||
|
||||
USB_LOG("* Known 32bit read at address %lx: %lx\n", addr, hard);
|
||||
|
||||
return hard;
|
||||
}
|
||||
|
||||
void CALLBACK USBwrite8(u32 addr, u8 value) {
|
||||
USB_LOG("* Invalid 8bit write at address %lx value %x\n", addr, value);
|
||||
}
|
||||
|
||||
void CALLBACK USBwrite16(u32 addr, u16 value) {
|
||||
USB_LOG("* Invalid 16bit write at address %lx value %x\n", addr, value);
|
||||
}
|
||||
|
||||
void CALLBACK USBwrite32(u32 addr, u32 value) {
|
||||
USB_LOG("* Known 32bit write at address %lx value %lx\n", addr, value);
|
||||
ohci_mem_write(qemu_ohci,addr,value);
|
||||
}
|
||||
|
||||
void CALLBACK USBirqCallback(USBcallback callback) {
|
||||
_USBirq = callback;
|
||||
}
|
||||
|
||||
extern u32 bits;
|
||||
|
||||
int CALLBACK _USBirqHandler(void)
|
||||
{
|
||||
//fprintf(stderr," * USB: IRQ Acknowledged.\n");
|
||||
//qemu_ohci->intr_status&=~bits;
|
||||
return 1;
|
||||
}
|
||||
|
||||
USBhandler CALLBACK USBirqHandler(void) {
|
||||
return (USBhandler)_USBirqHandler;
|
||||
}
|
||||
|
||||
void CALLBACK USBsetRAM(void *mem) {
|
||||
ram = (u8*)mem;
|
||||
}
|
||||
|
||||
// extended funcs
|
||||
|
||||
char USBfreezeID[] = "USB STv0";
|
||||
|
||||
typedef struct {
|
||||
OHCIState t;
|
||||
} USBfreezeData;
|
||||
|
||||
s32 CALLBACK USBfreeze(int mode, freezeData *data) {
|
||||
USBfreezeData *usbd;
|
||||
|
||||
if (mode == FREEZE_LOAD) {
|
||||
usbd = (USBfreezeData*)data->data;
|
||||
if (data->size != sizeof(USBfreezeData)) return -1;
|
||||
|
||||
memcpy(qemu_ohci, usbd, sizeof(OHCIState));
|
||||
} else
|
||||
if (mode == FREEZE_SAVE) {
|
||||
data->size = sizeof(USBfreezeData);
|
||||
data->data = (s8*)malloc(data->size);
|
||||
if (data->data == NULL) return -1;
|
||||
usbd = (USBfreezeData*)data->data;
|
||||
memcpy(usbd, qemu_ohci, sizeof(OHCIState));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CALLBACK USBasync(u32 cycles)
|
||||
{
|
||||
clocks+=cycles;
|
||||
if(qemu_ohci->eof_timer>0)
|
||||
{
|
||||
while(cycles>=qemu_ohci->eof_timer)
|
||||
{
|
||||
cycles-=qemu_ohci->eof_timer;
|
||||
qemu_ohci->eof_timer=0;
|
||||
ohci_frame_boundary(qemu_ohci);
|
||||
}
|
||||
if((cycles>0)&&(qemu_ohci->eof_timer>0))
|
||||
qemu_ohci->eof_timer-=cycles;
|
||||
}
|
||||
}
|
||||
|
||||
s32 CALLBACK USBtest() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cpu_physical_memory_rw(u32 addr, u8 *buf,
|
||||
int len, int is_write)
|
||||
{
|
||||
if(is_write)
|
||||
memcpy(&(ram[addr]),buf,len);
|
||||
else
|
||||
memcpy(buf,&(ram[addr]),len);
|
||||
}
|
||||
|
||||
s64 get_clock()
|
||||
{
|
||||
return clocks;
|
||||
}
|
||||
|
||||
void *qemu_mallocz(uint32_t size)
|
||||
{
|
||||
void *m=malloc(size);
|
||||
if(!m) return NULL;
|
||||
memset(m,0,size);
|
||||
return m;
|
||||
}
|
|
@ -0,0 +1,313 @@
|
|||
/* USBlinuz
|
||||
* Copyright (C) 2002-2004 USBlinuz Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __USB_H__
|
||||
#define __USB_H__
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#define USBdefs
|
||||
#include "PS2Edefs.h"
|
||||
|
||||
#ifdef __WIN32__
|
||||
|
||||
#define usleep(x) Sleep(x / 1000)
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#define __inline inline
|
||||
|
||||
#endif
|
||||
|
||||
#define USB_LOG __Log
|
||||
|
||||
typedef struct {
|
||||
int Log;
|
||||
} Config;
|
||||
|
||||
extern Config conf;
|
||||
|
||||
extern u8 *usbR;
|
||||
extern u8 *ram;
|
||||
|
||||
typedef struct {
|
||||
int unused;
|
||||
} usbStruct;
|
||||
|
||||
extern usbStruct usb;
|
||||
|
||||
#define usbRs8(mem) usbR[(mem) & 0xffff]
|
||||
#define usbRs16(mem) (*(s16*)&usbR[(mem) & 0xffff])
|
||||
#define usbRs32(mem) (*(s32*)&usbR[(mem) & 0xffff])
|
||||
#define usbRu8(mem) (*(u8*) &usbR[(mem) & 0xffff])
|
||||
#define usbRu16(mem) (*(u16*)&usbR[(mem) & 0xffff])
|
||||
#define usbRu32(mem) (*(u32*)&usbR[(mem) & 0xffff])
|
||||
|
||||
#define PSXCLK 36864000 /* 36.864 Mhz */
|
||||
|
||||
extern USBcallback _USBirq;
|
||||
void USBirq(int);
|
||||
|
||||
void SaveConfig();
|
||||
void LoadConfig();
|
||||
|
||||
extern FILE *usbLog;
|
||||
void __Log(char *fmt, ...);
|
||||
|
||||
void SysMessage(char *fmt, ...);
|
||||
|
||||
#include "qemu-usb/vl.h"
|
||||
|
||||
#define DEBUG_OHCI
|
||||
/* Dump packet contents. */
|
||||
//#define DEBUG_PACKET
|
||||
/* This causes frames to occur 1000x slower */
|
||||
//#define OHCI_TIME_WARP 1
|
||||
|
||||
/* Number of Downstream Ports on the root hub. */
|
||||
|
||||
#define OHCI_MAX_PORTS 15
|
||||
|
||||
extern int64_t usb_frame_time;
|
||||
extern int64_t usb_bit_time;
|
||||
|
||||
typedef struct OHCIPort {
|
||||
USBPort port;
|
||||
uint32_t ctrl;
|
||||
} OHCIPort;
|
||||
|
||||
typedef uint32_t target_phys_addr_t;
|
||||
|
||||
typedef struct {
|
||||
target_phys_addr_t mem_base;
|
||||
int mem;
|
||||
int num_ports;
|
||||
|
||||
uint64_t eof_timer;
|
||||
int64_t sof_time;
|
||||
|
||||
/* OHCI state */
|
||||
/* Control partition */
|
||||
uint32_t ctl, status;
|
||||
uint32_t intr_status;
|
||||
uint32_t intr;
|
||||
|
||||
/* memory pointer partition */
|
||||
uint32_t hcca;
|
||||
uint32_t ctrl_head, ctrl_cur;
|
||||
uint32_t bulk_head, bulk_cur;
|
||||
uint32_t per_cur;
|
||||
uint32_t done;
|
||||
int done_count;
|
||||
|
||||
/* Frame counter partition */
|
||||
uint32_t fsmps:15;
|
||||
uint32_t fit:1;
|
||||
uint32_t fi:14;
|
||||
uint32_t frt:1;
|
||||
uint16_t frame_number;
|
||||
uint16_t padding;
|
||||
uint32_t pstart;
|
||||
uint32_t lst;
|
||||
|
||||
/* Root Hub partition */
|
||||
uint32_t rhdesc_a, rhdesc_b;
|
||||
uint32_t rhstatus;
|
||||
OHCIPort rhport[OHCI_MAX_PORTS];
|
||||
} OHCIState;
|
||||
|
||||
/* Host Controller Communications Area */
|
||||
struct ohci_hcca {
|
||||
uint32_t intr[32];
|
||||
uint16_t frame, pad;
|
||||
uint32_t done;
|
||||
};
|
||||
|
||||
/* Bitfields for the first word of an Endpoint Desciptor. */
|
||||
#define OHCI_ED_FA_SHIFT 0
|
||||
#define OHCI_ED_FA_MASK (0x7f<<OHCI_ED_FA_SHIFT)
|
||||
#define OHCI_ED_EN_SHIFT 7
|
||||
#define OHCI_ED_EN_MASK (0xf<<OHCI_ED_EN_SHIFT)
|
||||
#define OHCI_ED_D_SHIFT 11
|
||||
#define OHCI_ED_D_MASK (3<<OHCI_ED_D_SHIFT)
|
||||
#define OHCI_ED_S (1<<13)
|
||||
#define OHCI_ED_K (1<<14)
|
||||
#define OHCI_ED_F (1<<15)
|
||||
#define OHCI_ED_MPS_SHIFT 7
|
||||
#define OHCI_ED_MPS_MASK (0xf<<OHCI_ED_FA_SHIFT)
|
||||
|
||||
/* Flags in the head field of an Endpoint Desciptor. */
|
||||
#define OHCI_ED_H 1
|
||||
#define OHCI_ED_C 2
|
||||
|
||||
/* Bitfields for the first word of a Transfer Desciptor. */
|
||||
#define OHCI_TD_R (1<<18)
|
||||
#define OHCI_TD_DP_SHIFT 19
|
||||
#define OHCI_TD_DP_MASK (3<<OHCI_TD_DP_SHIFT)
|
||||
#define OHCI_TD_DI_SHIFT 21
|
||||
#define OHCI_TD_DI_MASK (7<<OHCI_TD_DI_SHIFT)
|
||||
#define OHCI_TD_T0 (1<<24)
|
||||
#define OHCI_TD_T1 (1<<24)
|
||||
#define OHCI_TD_EC_SHIFT 26
|
||||
#define OHCI_TD_EC_MASK (3<<OHCI_TD_EC_SHIFT)
|
||||
#define OHCI_TD_CC_SHIFT 28
|
||||
#define OHCI_TD_CC_MASK (0xf<<OHCI_TD_CC_SHIFT)
|
||||
|
||||
#define OHCI_DPTR_MASK 0xfffffff0
|
||||
|
||||
#define OHCI_BM(val, field) \
|
||||
(((val) & OHCI_##field##_MASK) >> OHCI_##field##_SHIFT)
|
||||
|
||||
#define OHCI_SET_BM(val, field, newval) do { \
|
||||
val &= ~OHCI_##field##_MASK; \
|
||||
val |= ((newval) << OHCI_##field##_SHIFT) & OHCI_##field##_MASK; \
|
||||
} while(0)
|
||||
|
||||
/* endpoint descriptor */
|
||||
struct ohci_ed {
|
||||
uint32_t flags;
|
||||
uint32_t tail;
|
||||
uint32_t head;
|
||||
uint32_t next;
|
||||
};
|
||||
|
||||
/* General transfer descriptor */
|
||||
struct ohci_td {
|
||||
uint32_t flags;
|
||||
uint32_t cbp;
|
||||
uint32_t next;
|
||||
uint32_t be;
|
||||
};
|
||||
|
||||
#define USB_HZ 12000000
|
||||
|
||||
/* OHCI Local stuff */
|
||||
#define OHCI_CTL_CBSR ((1<<0)|(1<<1))
|
||||
#define OHCI_CTL_PLE (1<<2)
|
||||
#define OHCI_CTL_IE (1<<3)
|
||||
#define OHCI_CTL_CLE (1<<4)
|
||||
#define OHCI_CTL_BLE (1<<5)
|
||||
#define OHCI_CTL_HCFS ((1<<6)|(1<<7))
|
||||
#define OHCI_USB_RESET 0x00
|
||||
#define OHCI_USB_RESUME 0x40
|
||||
#define OHCI_USB_OPERATIONAL 0x80
|
||||
#define OHCI_USB_SUSPEND 0xc0
|
||||
#define OHCI_CTL_IR (1<<8)
|
||||
#define OHCI_CTL_RWC (1<<9)
|
||||
#define OHCI_CTL_RWE (1<<10)
|
||||
|
||||
#define OHCI_STATUS_HCR (1<<0)
|
||||
#define OHCI_STATUS_CLF (1<<1)
|
||||
#define OHCI_STATUS_BLF (1<<2)
|
||||
#define OHCI_STATUS_OCR (1<<3)
|
||||
#define OHCI_STATUS_SOC ((1<<6)|(1<<7))
|
||||
|
||||
#define OHCI_INTR_SO (1<<0) /* Scheduling overrun */
|
||||
#define OHCI_INTR_WD (1<<1) /* HcDoneHead writeback */
|
||||
#define OHCI_INTR_SF (1<<2) /* Start of frame */
|
||||
#define OHCI_INTR_RD (1<<3) /* Resume detect */
|
||||
#define OHCI_INTR_UE (1<<4) /* Unrecoverable error */
|
||||
#define OHCI_INTR_FNO (1<<5) /* Frame number overflow */
|
||||
#define OHCI_INTR_RHSC (1<<6) /* Root hub status change */
|
||||
#define OHCI_INTR_OC (1<<30) /* Ownership change */
|
||||
#define OHCI_INTR_MIE (1<<31) /* Master Interrupt Enable */
|
||||
|
||||
#define OHCI_HCCA_SIZE 0x100
|
||||
#define OHCI_HCCA_MASK 0xffffff00
|
||||
|
||||
#define OHCI_EDPTR_MASK 0xfffffff0
|
||||
|
||||
#define OHCI_FMI_FI 0x00003fff
|
||||
#define OHCI_FMI_FSMPS 0xffff0000
|
||||
#define OHCI_FMI_FIT 0x80000000
|
||||
|
||||
#define OHCI_FR_RT (1<<31)
|
||||
|
||||
#define OHCI_LS_THRESH 0x628
|
||||
|
||||
#define OHCI_RHA_RW_MASK 0x00000000 /* Mask of supported features. */
|
||||
#define OHCI_RHA_PSM (1<<8)
|
||||
#define OHCI_RHA_NPS (1<<9)
|
||||
#define OHCI_RHA_DT (1<<10)
|
||||
#define OHCI_RHA_OCPM (1<<11)
|
||||
#define OHCI_RHA_NOCP (1<<12)
|
||||
#define OHCI_RHA_POTPGT_MASK 0xff000000
|
||||
|
||||
#define OHCI_RHS_LPS (1<<0)
|
||||
#define OHCI_RHS_OCI (1<<1)
|
||||
#define OHCI_RHS_DRWE (1<<15)
|
||||
#define OHCI_RHS_LPSC (1<<16)
|
||||
#define OHCI_RHS_OCIC (1<<17)
|
||||
#define OHCI_RHS_CRWE (1<<31)
|
||||
|
||||
#define OHCI_PORT_CCS (1<<0)
|
||||
#define OHCI_PORT_PES (1<<1)
|
||||
#define OHCI_PORT_PSS (1<<2)
|
||||
#define OHCI_PORT_POCI (1<<3)
|
||||
#define OHCI_PORT_PRS (1<<4)
|
||||
#define OHCI_PORT_PPS (1<<8)
|
||||
#define OHCI_PORT_LSDA (1<<9)
|
||||
#define OHCI_PORT_CSC (1<<16)
|
||||
#define OHCI_PORT_PESC (1<<17)
|
||||
#define OHCI_PORT_PSSC (1<<18)
|
||||
#define OHCI_PORT_OCIC (1<<19)
|
||||
#define OHCI_PORT_PRSC (1<<20)
|
||||
#define OHCI_PORT_WTC (OHCI_PORT_CSC|OHCI_PORT_PESC|OHCI_PORT_PSSC \
|
||||
|OHCI_PORT_OCIC|OHCI_PORT_PRSC)
|
||||
|
||||
#define OHCI_TD_DIR_SETUP 0x0
|
||||
#define OHCI_TD_DIR_OUT 0x1
|
||||
#define OHCI_TD_DIR_IN 0x2
|
||||
#define OHCI_TD_DIR_RESERVED 0x3
|
||||
|
||||
#define OHCI_CC_NOERROR 0x0
|
||||
#define OHCI_CC_CRC 0x1
|
||||
#define OHCI_CC_BITSTUFFING 0x2
|
||||
#define OHCI_CC_DATATOGGLEMISMATCH 0x3
|
||||
#define OHCI_CC_STALL 0x4
|
||||
#define OHCI_CC_DEVICENOTRESPONDING 0x5
|
||||
#define OHCI_CC_PIDCHECKFAILURE 0x6
|
||||
#define OHCI_CC_UNDEXPETEDPID 0x7
|
||||
#define OHCI_CC_DATAOVERRUN 0x8
|
||||
#define OHCI_CC_DATAUNDERRUN 0x9
|
||||
#define OHCI_CC_BUFFEROVERRUN 0xc
|
||||
#define OHCI_CC_BUFFERUNDERRUN 0xd
|
||||
|
||||
int64_t get_clock();
|
||||
|
||||
OHCIState *ohci_create(uint32_t base, int ports);
|
||||
|
||||
uint32_t ohci_mem_read(OHCIState *ohci, uint32_t addr );
|
||||
void ohci_mem_write(OHCIState *ohci, uint32_t addr, uint32_t value );
|
||||
void ohci_frame_boundary(void *opaque);
|
||||
|
||||
int ohci_bus_start(OHCIState *ohci);
|
||||
void ohci_bus_stop(OHCIState *ohci);
|
||||
|
||||
USBDevice *usb_hub_init(int nb_ports);
|
||||
USBDevice *usb_msd_init(const char *filename);
|
||||
USBDevice *eyetoy_init(void);
|
||||
USBDevice *usb_mouse_init(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,51 @@
|
|||
#include <stdlib.h>
|
||||
|
||||
#include "USB.h"
|
||||
|
||||
extern HINSTANCE hInst;
|
||||
void SaveConfig()
|
||||
{
|
||||
|
||||
Config *Conf1 = &conf;
|
||||
char *szTemp;
|
||||
char szIniFile[256], szValue[256];
|
||||
|
||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||
szTemp = strrchr(szIniFile, '\\');
|
||||
|
||||
if(!szTemp) return;
|
||||
strcpy(szTemp, "\\inis\\usblinuz.ini");
|
||||
sprintf(szValue,"%u",Conf1->Log);
|
||||
WritePrivateProfileString("Interface", "Logging",szValue,szIniFile);
|
||||
|
||||
}
|
||||
|
||||
void LoadConfig() {
|
||||
FILE *fp;
|
||||
|
||||
|
||||
Config *Conf1 = &conf;
|
||||
char *szTemp;
|
||||
char szIniFile[256], szValue[256];
|
||||
|
||||
GetModuleFileName(GetModuleHandle((LPCSTR)hInst), szIniFile, 256);
|
||||
szTemp = strrchr(szIniFile, '\\');
|
||||
|
||||
if(!szTemp) return ;
|
||||
strcpy(szTemp, "\\inis\\usblinuz.ini");
|
||||
fp=fopen("inis\\usblinuz.ini","rt");//check if usbnull.ini really exists
|
||||
if (!fp)
|
||||
{
|
||||
CreateDirectory("inis",NULL);
|
||||
memset(&conf, 0, sizeof(conf));
|
||||
conf.Log = 0;//default value
|
||||
SaveConfig();//save and return
|
||||
return ;
|
||||
}
|
||||
fclose(fp);
|
||||
GetPrivateProfileString("Interface", "Logging", NULL, szValue, 20, szIniFile);
|
||||
Conf1->Log = strtoul(szValue, NULL, 10);
|
||||
return ;
|
||||
|
||||
}
|
||||
|
Binary file not shown.
|
@ -0,0 +1,28 @@
|
|||
; USBlinuz.def : Declares the module parameters for the DLL.
|
||||
|
||||
LIBRARY "USBqemu"
|
||||
DESCRIPTION 'USBqemu Driver'
|
||||
|
||||
EXPORTS
|
||||
; Explicit exports can go here
|
||||
PS2EgetLibType @2
|
||||
PS2EgetLibName @3
|
||||
PS2EgetLibVersion2 @4
|
||||
USBinit @5
|
||||
USBshutdown @6
|
||||
USBopen @7
|
||||
USBclose @8
|
||||
USBread8 @9
|
||||
USBread16 @10
|
||||
USBread32 @11
|
||||
USBwrite8 @12
|
||||
USBwrite16 @13
|
||||
USBwrite32 @14
|
||||
USBirqCallback @15
|
||||
USBirqHandler @16
|
||||
USBsetRAM @17
|
||||
USBasync @18
|
||||
|
||||
USBconfigure @19
|
||||
USBtest @20
|
||||
USBabout @21
|
|
@ -0,0 +1,156 @@
|
|||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Spanish (Argentina) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ESS)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_SPANISH, SUBLANG_SPANISH_ARGENTINA
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_CONFIG DIALOGEX 0, 0, 212, 121
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "USBconfigure"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,48,100,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,113,100,50,14
|
||||
CONTROL "Enable Logging (for develop use only)",IDC_LOGGING,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,7,144,15
|
||||
COMBOBOX IDC_COMBO1,7,38,138,51,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Device in Port 1:",IDC_STATIC,8,30,54,8
|
||||
COMBOBOX IDC_COMBO2,7,63,138,51,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "Device in Port 2:",IDC_STATIC,8,55,54,8
|
||||
END
|
||||
|
||||
IDD_ABOUT DIALOGEX 0, 0, 177, 106
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "USBabout"
|
||||
FONT 8, "MS Sans Serif", 0, 0, 0x0
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,65,85,50,14
|
||||
LTEXT "USBqemu Driver",IDC_NAME,70,10,54,8
|
||||
GROUPBOX "",IDC_STATIC,5,35,170,40
|
||||
LTEXT "Author: gigaherz <gigaherz@pcsx2.net>",IDC_STATIC,20,20,141,10
|
||||
LTEXT "Parts of this code were originally from the QEMU project.",IDC_STATIC,14,44,149,26
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_CONFIG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 205
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 114
|
||||
END
|
||||
|
||||
IDD_ABOUT, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 170
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 99
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog Info
|
||||
//
|
||||
|
||||
IDD_CONFIG DLGINIT
|
||||
BEGIN
|
||||
IDC_COMBO1, 0x403, 10, 0
|
||||
0x6f4e, 0x4420, 0x7665, 0x6369, 0x0065,
|
||||
IDC_COMBO1, 0x403, 9, 0
|
||||
0x654b, 0x6279, 0x616f, 0x6472, "\000"
|
||||
IDC_COMBO1, 0x403, 6, 0
|
||||
0x6f4d, 0x7375, 0x0065,
|
||||
IDC_COMBO1, 0x403, 14, 0
|
||||
0x7945, 0x7465, 0x796f, 0x4320, 0x6d61, 0x7265, 0x0061,
|
||||
IDC_COMBO1, 0x403, 20, 0
|
||||
0x6953, 0x676e, 0x7473, 0x7261, 0x4d20, 0x6369, 0x6f72, 0x6870, 0x6e6f,
|
||||
0x0065,
|
||||
IDC_COMBO2, 0x403, 10, 0
|
||||
0x6f4e, 0x4420, 0x7665, 0x6369, 0x0065,
|
||||
IDC_COMBO2, 0x403, 9, 0
|
||||
0x654b, 0x6279, 0x616f, 0x6472, "\000"
|
||||
IDC_COMBO2, 0x403, 6, 0
|
||||
0x6f4d, 0x7375, 0x0065,
|
||||
IDC_COMBO2, 0x403, 14, 0
|
||||
0x7945, 0x7465, 0x796f, 0x4320, 0x6d61, 0x7265, 0x0061,
|
||||
IDC_COMBO2, 0x403, 20, 0
|
||||
0x6953, 0x676e, 0x7473, 0x7261, 0x4d20, 0x6369, 0x6f72, 0x6870, 0x6e6f,
|
||||
0x0065,
|
||||
0
|
||||
END
|
||||
|
||||
#endif // Spanish (Argentina) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "USBlinuz", "USBlinuz_vc2005.vcproj", "{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|x64.Build.0 = Debug|x64
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|Win32.Build.0 = Release|Win32
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|x64.ActiveCfg = Release|x64
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,669 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Name="USBlinuz"
|
||||
ProjectGUID="{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}"
|
||||
RootNamespace="USBlinuz"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="__WIN32__"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\bin\USBqemu_d.dll"
|
||||
LinkIncremental="2"
|
||||
ModuleDefinitionFile="USBlinuz.def"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\bin\$(TargetName).pdb"
|
||||
SubSystem="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/USBlinuz.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="__WIN32__"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\bin\USBqemu.dll"
|
||||
LinkIncremental="1"
|
||||
ModuleDefinitionFile="USBlinuz.def"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/USBlinuz.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="__WIN32__"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\bin\USBqemu_d_64.dll"
|
||||
LinkIncremental="2"
|
||||
ModuleDefinitionFile="USBlinuz.def"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\bin\$(TargetName).pdb"
|
||||
SubSystem="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/USBlinuz.lib"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="__WIN32__"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\bin\USBqemu_64.dll"
|
||||
LinkIncremental="1"
|
||||
ModuleDefinitionFile="USBlinuz.def"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/USBlinuz.lib"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Config.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\USB.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="USBlinuz.def"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Win32.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<Filter
|
||||
Name="qemu-usb"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-base.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\usb-eyetoy\usb-eyetoy.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-hid.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-hub.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-kbd.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\usb-mic\usb-mic-dummy.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-ohci.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\vl.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\PS2Edefs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PS2Etypes.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\USB.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="qemu-usb"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\vl.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
>
|
||||
<File
|
||||
RelativePath="USBlinuz.rc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,26 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "USBlinuz", "USBlinuz_vc2005_x64.vcproj", "{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|x64.Build.0 = Debug|x64
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|Win32.Build.0 = Release|Win32
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|x64.ActiveCfg = Release|x64
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,669 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="8,00"
|
||||
Name="USBlinuz"
|
||||
ProjectGUID="{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}"
|
||||
RootNamespace="USBlinuz"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="__WIN32__"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\bin\USBqemu_d.dll"
|
||||
LinkIncremental="2"
|
||||
ModuleDefinitionFile="USBlinuz.def"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\bin\$(TargetName).pdb"
|
||||
SubSystem="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/USBlinuz.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="__WIN32__"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\bin\USBqemu.dll"
|
||||
LinkIncremental="1"
|
||||
ModuleDefinitionFile="USBlinuz.def"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/USBlinuz.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="__WIN32__"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\bin\USBqemu_d_64.dll"
|
||||
LinkIncremental="2"
|
||||
ModuleDefinitionFile="USBlinuz.def"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\bin\$(TargetName).pdb"
|
||||
SubSystem="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/USBlinuz.lib"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="__WIN32__"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\bin\USBqemu_64.dll"
|
||||
LinkIncremental="1"
|
||||
ModuleDefinitionFile="USBlinuz.def"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/USBlinuz.lib"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Config.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\USB.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="USBlinuz.def"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Win32.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<Filter
|
||||
Name="qemu-usb"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-base.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\usb-eyetoy\usb-eyetoy.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-hid.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-hub.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-kbd.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\usb-mic\usb-mic-dummy.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-ohci.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\vl.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\PS2Edefs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PS2Etypes.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\USB.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="qemu-usb"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\vl.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
>
|
||||
<File
|
||||
RelativePath="USBlinuz.rc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,25 @@
|
|||
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||
# Visual Studio 2008
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "USBlinuz", "USBlinuz_vc2008b2.vcproj", "{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|x64.Build.0 = Debug|x64
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|Win32.Build.0 = Release|Win32
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|x64.ActiveCfg = Release|x64
|
||||
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,669 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9,00"
|
||||
Name="USBlinuz"
|
||||
ProjectGUID="{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}"
|
||||
RootNamespace="USBlinuz"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="__WIN32__"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\bin\USBqemu_d.dll"
|
||||
LinkIncremental="2"
|
||||
ModuleDefinitionFile="USBlinuz.def"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\bin\$(TargetName).pdb"
|
||||
SubSystem="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/USBlinuz.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="__WIN32__"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="4"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\bin\USBqemu_d_64.dll"
|
||||
LinkIncremental="2"
|
||||
ModuleDefinitionFile="USBlinuz.def"
|
||||
GenerateDebugInformation="true"
|
||||
ProgramDatabaseFile=".\bin\$(TargetName).pdb"
|
||||
SubSystem="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/USBlinuz.lib"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="__WIN32__"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\bin\USBqemu.dll"
|
||||
LinkIncremental="1"
|
||||
ModuleDefinitionFile="USBlinuz.def"
|
||||
GenerateDebugInformation="false"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/USBlinuz.lib"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
OmitFramePointers="true"
|
||||
AdditionalIncludeDirectories="..\"
|
||||
PreprocessorDefinitions="__WIN32__"
|
||||
StringPooling="true"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
CompileAs="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile=".\bin\USBqemu_64.dll"
|
||||
LinkIncremental="1"
|
||||
ModuleDefinitionFile="USBlinuz.def"
|
||||
SubSystem="2"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
ImportLibrary="$(OutDir)/USBlinuz.lib"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\Config.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\USB.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="USBlinuz.def"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Win32.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<Filter
|
||||
Name="qemu-usb"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-base.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\usb-eyetoy\usb-eyetoy.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-hid.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
ExcludedFromBuild="true"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-hub.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-kbd.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\usb-mic\usb-mic-dummy.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb-ohci.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\vl.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|x64"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
CompileAs="0"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\PS2Edefs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PS2Etypes.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="resource.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\USB.h"
|
||||
>
|
||||
</File>
|
||||
<Filter
|
||||
Name="qemu-usb"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\usb.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\qemu-usb\vl.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
>
|
||||
<File
|
||||
RelativePath="USBlinuz.rc"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,80 @@
|
|||
#include <stdio.h>
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
|
||||
#include "USB.h"
|
||||
#include "resource.h"
|
||||
|
||||
HINSTANCE hInst;
|
||||
|
||||
void SysMessage(char *fmt, ...) {
|
||||
va_list list;
|
||||
char tmp[512];
|
||||
|
||||
va_start(list,fmt);
|
||||
vsprintf(tmp,fmt,list);
|
||||
va_end(list);
|
||||
MessageBox(0, tmp, "USBlinuz Msg", 0);
|
||||
}
|
||||
|
||||
BOOL CALLBACK ConfigureDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
|
||||
switch(uMsg) {
|
||||
case WM_INITDIALOG:
|
||||
LoadConfig();
|
||||
if (conf.Log) CheckDlgButton(hW, IDC_LOGGING, TRUE);
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch(LOWORD(wParam)) {
|
||||
case IDCANCEL:
|
||||
EndDialog(hW, TRUE);
|
||||
return TRUE;
|
||||
case IDOK:
|
||||
if (IsDlgButtonChecked(hW, IDC_LOGGING))
|
||||
conf.Log = 1;
|
||||
else conf.Log = 0;
|
||||
SaveConfig();
|
||||
EndDialog(hW, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||
switch(uMsg) {
|
||||
case WM_INITDIALOG:
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch(LOWORD(wParam)) {
|
||||
case IDOK:
|
||||
EndDialog(hW, FALSE);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void CALLBACK USBconfigure() {
|
||||
DialogBox(hInst,
|
||||
MAKEINTRESOURCE(IDD_CONFIG),
|
||||
GetActiveWindow(),
|
||||
(DLGPROC)ConfigureDlgProc);
|
||||
}
|
||||
|
||||
void CALLBACK USBabout() {
|
||||
DialogBox(hInst,
|
||||
MAKEINTRESOURCE(IDD_ABOUT),
|
||||
GetActiveWindow(),
|
||||
(DLGPROC)AboutDlgProc);
|
||||
}
|
||||
|
||||
BOOL APIENTRY DllMain(HANDLE hModule, // DLL INIT
|
||||
DWORD dwReason,
|
||||
LPVOID lpReserved) {
|
||||
hInst = (HINSTANCE)hModule;
|
||||
return TRUE; // very quick :)
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Visual C++ generated include file.
|
||||
// Used by USBlinuz.rc
|
||||
//
|
||||
#define IDD_CONFDLG 101
|
||||
#define IDD_CONFIG 101
|
||||
#define IDD_ABOUT 103
|
||||
#define IDC_NAME 1000
|
||||
#define IDC_CHECK1 1007
|
||||
#define IDC_LOGGING 1007
|
||||
#define IDC_COMBO1 1008
|
||||
#define IDC_COMBO2 1009
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 106
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1009
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,193 @@
|
|||
/*
|
||||
* QEMU USB emulation
|
||||
*
|
||||
* Copyright (c) 2005 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include "vl.h"
|
||||
|
||||
void usb_attach(USBPort *port, USBDevice *dev)
|
||||
{
|
||||
port->attach(port, dev);
|
||||
}
|
||||
|
||||
/**********************/
|
||||
/* generic USB device helpers (you are not forced to use them when
|
||||
writing your USB device driver, but they help handling the
|
||||
protocol)
|
||||
*/
|
||||
|
||||
#define SETUP_STATE_IDLE 0
|
||||
#define SETUP_STATE_DATA 1
|
||||
#define SETUP_STATE_ACK 2
|
||||
|
||||
int usb_generic_handle_packet(USBDevice *s, int pid,
|
||||
uint8_t devaddr, uint8_t devep,
|
||||
uint8_t *data, int len)
|
||||
{
|
||||
int l, ret = 0;
|
||||
|
||||
switch(pid) {
|
||||
case USB_MSG_ATTACH:
|
||||
s->state = USB_STATE_ATTACHED;
|
||||
break;
|
||||
case USB_MSG_DETACH:
|
||||
s->state = USB_STATE_NOTATTACHED;
|
||||
break;
|
||||
case USB_MSG_RESET:
|
||||
s->remote_wakeup = 0;
|
||||
s->addr = 0;
|
||||
s->state = USB_STATE_DEFAULT;
|
||||
s->handle_reset(s);
|
||||
break;
|
||||
case USB_TOKEN_SETUP:
|
||||
if (s->state < USB_STATE_DEFAULT || devaddr != s->addr)
|
||||
return USB_RET_NODEV;
|
||||
if (len != 8)
|
||||
goto fail;
|
||||
memcpy(s->setup_buf, data, 8);
|
||||
s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
|
||||
s->setup_index = 0;
|
||||
if (s->setup_buf[0] & USB_DIR_IN) {
|
||||
ret = s->handle_control(s,
|
||||
(s->setup_buf[0] << 8) | s->setup_buf[1],
|
||||
(s->setup_buf[3] << 8) | s->setup_buf[2],
|
||||
(s->setup_buf[5] << 8) | s->setup_buf[4],
|
||||
s->setup_len,
|
||||
s->data_buf);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
if (ret < s->setup_len)
|
||||
s->setup_len = ret;
|
||||
s->setup_state = SETUP_STATE_DATA;
|
||||
} else {
|
||||
if (s->setup_len == 0)
|
||||
s->setup_state = SETUP_STATE_ACK;
|
||||
else
|
||||
s->setup_state = SETUP_STATE_DATA;
|
||||
}
|
||||
break;
|
||||
case USB_TOKEN_IN:
|
||||
if (s->state < USB_STATE_DEFAULT || devaddr != s->addr)
|
||||
return USB_RET_NODEV;
|
||||
switch(devep) {
|
||||
case 0:
|
||||
switch(s->setup_state) {
|
||||
case SETUP_STATE_ACK:
|
||||
if (!(s->setup_buf[0] & USB_DIR_IN)) {
|
||||
s->setup_state = SETUP_STATE_IDLE;
|
||||
ret = s->handle_control(s,
|
||||
(s->setup_buf[0] << 8) | s->setup_buf[1],
|
||||
(s->setup_buf[3] << 8) | s->setup_buf[2],
|
||||
(s->setup_buf[5] << 8) | s->setup_buf[4],
|
||||
s->setup_len,
|
||||
s->data_buf);
|
||||
if (ret > 0)
|
||||
ret = 0;
|
||||
} else {
|
||||
/* return 0 byte */
|
||||
}
|
||||
break;
|
||||
case SETUP_STATE_DATA:
|
||||
if (s->setup_buf[0] & USB_DIR_IN) {
|
||||
l = s->setup_len - s->setup_index;
|
||||
if (l > len)
|
||||
l = len;
|
||||
memcpy(data, s->data_buf + s->setup_index, l);
|
||||
s->setup_index += l;
|
||||
if (s->setup_index >= s->setup_len)
|
||||
s->setup_state = SETUP_STATE_ACK;
|
||||
ret = l;
|
||||
} else {
|
||||
s->setup_state = SETUP_STATE_IDLE;
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret = s->handle_data(s, pid, devep, data, len);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case USB_TOKEN_OUT:
|
||||
if (s->state < USB_STATE_DEFAULT || devaddr != s->addr)
|
||||
return USB_RET_NODEV;
|
||||
switch(devep) {
|
||||
case 0:
|
||||
switch(s->setup_state) {
|
||||
case SETUP_STATE_ACK:
|
||||
if (s->setup_buf[0] & USB_DIR_IN) {
|
||||
s->setup_state = SETUP_STATE_IDLE;
|
||||
/* transfer OK */
|
||||
} else {
|
||||
/* ignore additionnal output */
|
||||
}
|
||||
break;
|
||||
case SETUP_STATE_DATA:
|
||||
if (!(s->setup_buf[0] & USB_DIR_IN)) {
|
||||
l = s->setup_len - s->setup_index;
|
||||
if (l > len)
|
||||
l = len;
|
||||
memcpy(s->data_buf + s->setup_index, data, l);
|
||||
s->setup_index += l;
|
||||
if (s->setup_index >= s->setup_len)
|
||||
s->setup_state = SETUP_STATE_ACK;
|
||||
ret = l;
|
||||
} else {
|
||||
s->setup_state = SETUP_STATE_IDLE;
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
ret = s->handle_data(s, pid, devep, data, len);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
fail:
|
||||
ret = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* XXX: fix overflow */
|
||||
int set_usb_string(uint8_t *buf, const char *str)
|
||||
{
|
||||
int len, i;
|
||||
uint8_t *q;
|
||||
|
||||
q = buf;
|
||||
len = strlen(str);
|
||||
*q++ = 2 * len + 2;
|
||||
*q++ = 3;
|
||||
for(i = 0; i < len; i++) {
|
||||
*q++ = str[i];
|
||||
*q++ = 0;
|
||||
}
|
||||
return q - buf;
|
||||
}
|
|
@ -0,0 +1,551 @@
|
|||
/*
|
||||
* QEMU USB HID devices
|
||||
*
|
||||
* Copyright (c) 2005 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include "vl.h"
|
||||
|
||||
/* HID interface requests */
|
||||
#define GET_REPORT 0xa101
|
||||
#define GET_IDLE 0xa102
|
||||
#define GET_PROTOCOL 0xa103
|
||||
#define SET_IDLE 0x210a
|
||||
#define SET_PROTOCOL 0x210b
|
||||
|
||||
#define USB_MOUSE 1
|
||||
#define USB_TABLET 2
|
||||
|
||||
typedef struct USBMouseState {
|
||||
USBDevice dev;
|
||||
int dx, dy, dz, buttons_state;
|
||||
int x, y;
|
||||
int kind;
|
||||
int mouse_grabbed;
|
||||
} USBMouseState;
|
||||
|
||||
/* mostly the same values as the Bochs USB Mouse device */
|
||||
static const uint8_t qemu_mouse_dev_descriptor[] = {
|
||||
0x12, /* u8 bLength; */
|
||||
0x01, /* u8 bDescriptorType; Device */
|
||||
0x10, 0x00, /* u16 bcdUSB; v1.0 */
|
||||
|
||||
0x00, /* u8 bDeviceClass; */
|
||||
0x00, /* u8 bDeviceSubClass; */
|
||||
0x00, /* u8 bDeviceProtocol; [ low/full speeds only ] */
|
||||
0x08, /* u8 bMaxPacketSize0; 8 Bytes */
|
||||
|
||||
0x27, 0x06, /* u16 idVendor; */
|
||||
0x01, 0x00, /* u16 idProduct; */
|
||||
0x00, 0x00, /* u16 bcdDevice */
|
||||
|
||||
0x03, /* u8 iManufacturer; */
|
||||
0x02, /* u8 iProduct; */
|
||||
0x01, /* u8 iSerialNumber; */
|
||||
0x01 /* u8 bNumConfigurations; */
|
||||
};
|
||||
|
||||
static const uint8_t qemu_mouse_config_descriptor[] = {
|
||||
/* one configuration */
|
||||
0x09, /* u8 bLength; */
|
||||
0x02, /* u8 bDescriptorType; Configuration */
|
||||
0x22, 0x00, /* u16 wTotalLength; */
|
||||
0x01, /* u8 bNumInterfaces; (1) */
|
||||
0x01, /* u8 bConfigurationValue; */
|
||||
0x04, /* u8 iConfiguration; */
|
||||
0xa0, /* u8 bmAttributes;
|
||||
Bit 7: must be set,
|
||||
6: Self-powered,
|
||||
5: Remote wakeup,
|
||||
4..0: resvd */
|
||||
50, /* u8 MaxPower; */
|
||||
|
||||
/* USB 1.1:
|
||||
* USB 2.0, single TT organization (mandatory):
|
||||
* one interface, protocol 0
|
||||
*
|
||||
* USB 2.0, multiple TT organization (optional):
|
||||
* two interfaces, protocols 1 (like single TT)
|
||||
* and 2 (multiple TT mode) ... config is
|
||||
* sometimes settable
|
||||
* NOT IMPLEMENTED
|
||||
*/
|
||||
|
||||
/* one interface */
|
||||
0x09, /* u8 if_bLength; */
|
||||
0x04, /* u8 if_bDescriptorType; Interface */
|
||||
0x00, /* u8 if_bInterfaceNumber; */
|
||||
0x00, /* u8 if_bAlternateSetting; */
|
||||
0x01, /* u8 if_bNumEndpoints; */
|
||||
0x03, /* u8 if_bInterfaceClass; */
|
||||
0x01, /* u8 if_bInterfaceSubClass; */
|
||||
0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */
|
||||
0x05, /* u8 if_iInterface; */
|
||||
|
||||
/* HID descriptor */
|
||||
0x09, /* u8 bLength; */
|
||||
0x21, /* u8 bDescriptorType; */
|
||||
0x01, 0x00, /* u16 HID_class */
|
||||
0x00, /* u8 country_code */
|
||||
0x01, /* u8 num_descriptors */
|
||||
0x22, /* u8 type; Report */
|
||||
50, 0, /* u16 len */
|
||||
|
||||
/* one endpoint (status change endpoint) */
|
||||
0x07, /* u8 ep_bLength; */
|
||||
0x05, /* u8 ep_bDescriptorType; Endpoint */
|
||||
0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */
|
||||
0x03, /* u8 ep_bmAttributes; Interrupt */
|
||||
0x03, 0x00, /* u16 ep_wMaxPacketSize; */
|
||||
0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */
|
||||
};
|
||||
|
||||
static const uint8_t qemu_tablet_config_descriptor[] = {
|
||||
/* one configuration */
|
||||
0x09, /* u8 bLength; */
|
||||
0x02, /* u8 bDescriptorType; Configuration */
|
||||
0x22, 0x00, /* u16 wTotalLength; */
|
||||
0x01, /* u8 bNumInterfaces; (1) */
|
||||
0x01, /* u8 bConfigurationValue; */
|
||||
0x04, /* u8 iConfiguration; */
|
||||
0xa0, /* u8 bmAttributes;
|
||||
Bit 7: must be set,
|
||||
6: Self-powered,
|
||||
5: Remote wakeup,
|
||||
4..0: resvd */
|
||||
50, /* u8 MaxPower; */
|
||||
|
||||
/* USB 1.1:
|
||||
* USB 2.0, single TT organization (mandatory):
|
||||
* one interface, protocol 0
|
||||
*
|
||||
* USB 2.0, multiple TT organization (optional):
|
||||
* two interfaces, protocols 1 (like single TT)
|
||||
* and 2 (multiple TT mode) ... config is
|
||||
* sometimes settable
|
||||
* NOT IMPLEMENTED
|
||||
*/
|
||||
|
||||
/* one interface */
|
||||
0x09, /* u8 if_bLength; */
|
||||
0x04, /* u8 if_bDescriptorType; Interface */
|
||||
0x00, /* u8 if_bInterfaceNumber; */
|
||||
0x00, /* u8 if_bAlternateSetting; */
|
||||
0x01, /* u8 if_bNumEndpoints; */
|
||||
0x03, /* u8 if_bInterfaceClass; */
|
||||
0x01, /* u8 if_bInterfaceSubClass; */
|
||||
0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */
|
||||
0x05, /* u8 if_iInterface; */
|
||||
|
||||
/* HID descriptor */
|
||||
0x09, /* u8 bLength; */
|
||||
0x21, /* u8 bDescriptorType; */
|
||||
0x01, 0x00, /* u16 HID_class */
|
||||
0x00, /* u8 country_code */
|
||||
0x01, /* u8 num_descriptors */
|
||||
0x22, /* u8 type; Report */
|
||||
74, 0, /* u16 len */
|
||||
|
||||
/* one endpoint (status change endpoint) */
|
||||
0x07, /* u8 ep_bLength; */
|
||||
0x05, /* u8 ep_bDescriptorType; Endpoint */
|
||||
0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */
|
||||
0x03, /* u8 ep_bmAttributes; Interrupt */
|
||||
0x08, 0x00, /* u16 ep_wMaxPacketSize; */
|
||||
0x03, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */
|
||||
};
|
||||
|
||||
static const uint8_t qemu_mouse_hid_report_descriptor[] = {
|
||||
0x05, 0x01, 0x09, 0x02, 0xA1, 0x01, 0x09, 0x01,
|
||||
0xA1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03,
|
||||
0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01,
|
||||
0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01,
|
||||
0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81,
|
||||
0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06,
|
||||
0xC0, 0xC0,
|
||||
};
|
||||
|
||||
static const uint8_t qemu_tablet_hid_report_descriptor[] = {
|
||||
0x05, 0x01, /* Usage Page Generic Desktop */
|
||||
0x09, 0x01, /* Usage Mouse */
|
||||
0xA1, 0x01, /* Collection Application */
|
||||
0x09, 0x01, /* Usage Pointer */
|
||||
0xA1, 0x00, /* Collection Physical */
|
||||
0x05, 0x09, /* Usage Page Button */
|
||||
0x19, 0x01, /* Usage Minimum Button 1 */
|
||||
0x29, 0x03, /* Usage Maximum Button 3 */
|
||||
0x15, 0x00, /* Logical Minimum 0 */
|
||||
0x25, 0x01, /* Logical Maximum 1 */
|
||||
0x95, 0x03, /* Report Count 3 */
|
||||
0x75, 0x01, /* Report Size 1 */
|
||||
0x81, 0x02, /* Input (Data, Var, Abs) */
|
||||
0x95, 0x01, /* Report Count 1 */
|
||||
0x75, 0x05, /* Report Size 5 */
|
||||
0x81, 0x01, /* Input (Cnst, Var, Abs) */
|
||||
0x05, 0x01, /* Usage Page Generic Desktop */
|
||||
0x09, 0x30, /* Usage X */
|
||||
0x09, 0x31, /* Usage Y */
|
||||
0x15, 0x00, /* Logical Minimum 0 */
|
||||
0x26, 0xFF, 0x7F, /* Logical Maximum 0x7fff */
|
||||
0x35, 0x00, /* Physical Minimum 0 */
|
||||
0x46, 0xFE, 0x7F, /* Physical Maximum 0x7fff */
|
||||
0x75, 0x10, /* Report Size 16 */
|
||||
0x95, 0x02, /* Report Count 2 */
|
||||
0x81, 0x02, /* Input (Data, Var, Abs) */
|
||||
0x05, 0x01, /* Usage Page Generic Desktop */
|
||||
0x09, 0x38, /* Usage Wheel */
|
||||
0x15, 0x81, /* Logical Minimum -127 */
|
||||
0x25, 0x7F, /* Logical Maximum 127 */
|
||||
0x35, 0x00, /* Physical Minimum 0 (same as logical) */
|
||||
0x45, 0x00, /* Physical Maximum 0 (same as logical) */
|
||||
0x75, 0x08, /* Report Size 8 */
|
||||
0x95, 0x01, /* Report Count 1 */
|
||||
0x81, 0x02, /* Input (Data, Var, Rel) */
|
||||
0xC0, /* End Collection */
|
||||
0xC0, /* End Collection */
|
||||
};
|
||||
|
||||
static void usb_mouse_event(void *opaque,
|
||||
int dx1, int dy1, int dz1, int buttons_state)
|
||||
{
|
||||
USBMouseState *s = opaque;
|
||||
|
||||
s->dx += dx1;
|
||||
s->dy += dy1;
|
||||
s->dz += dz1;
|
||||
s->buttons_state = buttons_state;
|
||||
}
|
||||
|
||||
static void usb_tablet_event(void *opaque,
|
||||
int x, int y, int dz, int buttons_state)
|
||||
{
|
||||
USBMouseState *s = opaque;
|
||||
|
||||
s->x = x;
|
||||
s->y = y;
|
||||
s->dz += dz;
|
||||
s->buttons_state = buttons_state;
|
||||
}
|
||||
|
||||
static inline int int_clamp(int val, int vmin, int vmax)
|
||||
{
|
||||
if (val < vmin)
|
||||
return vmin;
|
||||
else if (val > vmax)
|
||||
return vmax;
|
||||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len)
|
||||
{
|
||||
int dx, dy, dz, b, l;
|
||||
|
||||
if (!s->mouse_grabbed) {
|
||||
qemu_add_mouse_event_handler(usb_mouse_event, s, 0);
|
||||
s->mouse_grabbed = 1;
|
||||
}
|
||||
|
||||
dx = int_clamp(s->dx, -128, 127);
|
||||
dy = int_clamp(s->dy, -128, 127);
|
||||
dz = int_clamp(s->dz, -128, 127);
|
||||
|
||||
s->dx -= dx;
|
||||
s->dy -= dy;
|
||||
s->dz -= dz;
|
||||
|
||||
b = 0;
|
||||
if (s->buttons_state & MOUSE_EVENT_LBUTTON)
|
||||
b |= 0x01;
|
||||
if (s->buttons_state & MOUSE_EVENT_RBUTTON)
|
||||
b |= 0x02;
|
||||
if (s->buttons_state & MOUSE_EVENT_MBUTTON)
|
||||
b |= 0x04;
|
||||
|
||||
buf[0] = b;
|
||||
buf[1] = dx;
|
||||
buf[2] = dy;
|
||||
l = 3;
|
||||
if (len >= 4) {
|
||||
buf[3] = dz;
|
||||
l = 4;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
static int usb_tablet_poll(USBMouseState *s, uint8_t *buf, int len)
|
||||
{
|
||||
int dz, b, l;
|
||||
|
||||
if (!s->mouse_grabbed) {
|
||||
qemu_add_mouse_event_handler(usb_tablet_event, s, 1);
|
||||
s->mouse_grabbed = 1;
|
||||
}
|
||||
|
||||
dz = int_clamp(s->dz, -128, 127);
|
||||
s->dz -= dz;
|
||||
|
||||
/* Appears we have to invert the wheel direction */
|
||||
dz = 0 - dz;
|
||||
b = 0;
|
||||
if (s->buttons_state & MOUSE_EVENT_LBUTTON)
|
||||
b |= 0x01;
|
||||
if (s->buttons_state & MOUSE_EVENT_RBUTTON)
|
||||
b |= 0x02;
|
||||
if (s->buttons_state & MOUSE_EVENT_MBUTTON)
|
||||
b |= 0x04;
|
||||
|
||||
buf[0] = b;
|
||||
buf[1] = s->x & 0xff;
|
||||
buf[2] = s->x >> 8;
|
||||
buf[3] = s->y & 0xff;
|
||||
buf[4] = s->y >> 8;
|
||||
buf[5] = dz;
|
||||
l = 6;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
static void usb_mouse_handle_reset(USBDevice *dev)
|
||||
{
|
||||
USBMouseState *s = (USBMouseState *)dev;
|
||||
|
||||
s->dx = 0;
|
||||
s->dy = 0;
|
||||
s->dz = 0;
|
||||
s->x = 0;
|
||||
s->y = 0;
|
||||
s->buttons_state = 0;
|
||||
}
|
||||
|
||||
static int usb_mouse_handle_control(USBDevice *dev, int request, int value,
|
||||
int index, int length, uint8_t *data)
|
||||
{
|
||||
USBMouseState *s = (USBMouseState *)dev;
|
||||
int ret = 0;
|
||||
|
||||
switch(request) {
|
||||
case DeviceRequest | USB_REQ_GET_STATUS:
|
||||
data[0] = (1 << USB_DEVICE_SELF_POWERED) |
|
||||
(dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
|
||||
data[1] = 0x00;
|
||||
ret = 2;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
|
||||
if (value == USB_DEVICE_REMOTE_WAKEUP) {
|
||||
dev->remote_wakeup = 0;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_FEATURE:
|
||||
if (value == USB_DEVICE_REMOTE_WAKEUP) {
|
||||
dev->remote_wakeup = 1;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_ADDRESS:
|
||||
dev->addr = value;
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
|
||||
switch(value >> 8) {
|
||||
case USB_DT_DEVICE:
|
||||
memcpy(data, qemu_mouse_dev_descriptor,
|
||||
sizeof(qemu_mouse_dev_descriptor));
|
||||
ret = sizeof(qemu_mouse_dev_descriptor);
|
||||
break;
|
||||
case USB_DT_CONFIG:
|
||||
if (s->kind == USB_MOUSE) {
|
||||
memcpy(data, qemu_mouse_config_descriptor,
|
||||
sizeof(qemu_mouse_config_descriptor));
|
||||
ret = sizeof(qemu_mouse_config_descriptor);
|
||||
} else if (s->kind == USB_TABLET) {
|
||||
memcpy(data, qemu_tablet_config_descriptor,
|
||||
sizeof(qemu_tablet_config_descriptor));
|
||||
ret = sizeof(qemu_tablet_config_descriptor);
|
||||
}
|
||||
break;
|
||||
case USB_DT_STRING:
|
||||
switch(value & 0xff) {
|
||||
case 0:
|
||||
/* language ids */
|
||||
data[0] = 4;
|
||||
data[1] = 3;
|
||||
data[2] = 0x09;
|
||||
data[3] = 0x04;
|
||||
ret = 4;
|
||||
break;
|
||||
case 1:
|
||||
/* serial number */
|
||||
ret = set_usb_string(data, "1");
|
||||
break;
|
||||
case 2:
|
||||
/* product description */
|
||||
if (s->kind == USB_MOUSE)
|
||||
ret = set_usb_string(data, "QEMU USB Mouse");
|
||||
else if (s->kind == USB_TABLET)
|
||||
ret = set_usb_string(data, "QEMU USB Tablet");
|
||||
break;
|
||||
case 3:
|
||||
/* vendor description */
|
||||
ret = set_usb_string(data, "PCSX2/QEMU");
|
||||
break;
|
||||
case 4:
|
||||
ret = set_usb_string(data, "HID Mouse");
|
||||
break;
|
||||
case 5:
|
||||
ret = set_usb_string(data, "Endpoint1 Interrupt Pipe");
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
|
||||
data[0] = 1;
|
||||
ret = 1;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_INTERFACE:
|
||||
data[0] = 0;
|
||||
ret = 1;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_INTERFACE:
|
||||
ret = 0;
|
||||
break;
|
||||
/* hid specific requests */
|
||||
case InterfaceRequest | USB_REQ_GET_DESCRIPTOR:
|
||||
switch(value >> 8) {
|
||||
case 0x22:
|
||||
if (s->kind == USB_MOUSE) {
|
||||
memcpy(data, qemu_mouse_hid_report_descriptor,
|
||||
sizeof(qemu_mouse_hid_report_descriptor));
|
||||
ret = sizeof(qemu_mouse_hid_report_descriptor);
|
||||
} else if (s->kind == USB_TABLET) {
|
||||
memcpy(data, qemu_tablet_hid_report_descriptor,
|
||||
sizeof(qemu_tablet_hid_report_descriptor));
|
||||
ret = sizeof(qemu_tablet_hid_report_descriptor);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case GET_REPORT:
|
||||
if (s->kind == USB_MOUSE)
|
||||
ret = usb_mouse_poll(s, data, length);
|
||||
else if (s->kind == USB_TABLET)
|
||||
ret = usb_tablet_poll(s, data, length);
|
||||
break;
|
||||
case SET_IDLE:
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
fail:
|
||||
ret = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int usb_mouse_handle_data(USBDevice *dev, int pid,
|
||||
uint8_t devep, uint8_t *data, int len)
|
||||
{
|
||||
USBMouseState *s = (USBMouseState *)dev;
|
||||
int ret = 0;
|
||||
|
||||
switch(pid) {
|
||||
case USB_TOKEN_IN:
|
||||
if (devep == 1) {
|
||||
if (s->kind == USB_MOUSE)
|
||||
ret = usb_mouse_poll(s, data, len);
|
||||
else if (s->kind == USB_TABLET)
|
||||
ret = usb_tablet_poll(s, data, len);
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case USB_TOKEN_OUT:
|
||||
default:
|
||||
fail:
|
||||
ret = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void usb_mouse_handle_destroy(USBDevice *dev)
|
||||
{
|
||||
USBMouseState *s = (USBMouseState *)dev;
|
||||
|
||||
qemu_add_mouse_event_handler(NULL, NULL, 0);
|
||||
free(s);
|
||||
}
|
||||
|
||||
USBDevice *usb_tablet_init(void)
|
||||
{
|
||||
USBMouseState *s;
|
||||
|
||||
s = qemu_mallocz(sizeof(USBMouseState));
|
||||
if (!s)
|
||||
return NULL;
|
||||
s->dev.speed = USB_SPEED_FULL;
|
||||
s->dev.handle_packet = usb_generic_handle_packet;
|
||||
|
||||
s->dev.handle_reset = usb_mouse_handle_reset;
|
||||
s->dev.handle_control = usb_mouse_handle_control;
|
||||
s->dev.handle_data = usb_mouse_handle_data;
|
||||
s->dev.handle_destroy = usb_mouse_handle_destroy;
|
||||
s->kind = USB_TABLET;
|
||||
|
||||
pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Tablet");
|
||||
|
||||
return (USBDevice *)s;
|
||||
}
|
||||
|
||||
USBDevice *usb_mouse_init(void)
|
||||
{
|
||||
USBMouseState *s;
|
||||
|
||||
s = qemu_mallocz(sizeof(USBMouseState));
|
||||
if (!s)
|
||||
return NULL;
|
||||
s->dev.speed = USB_SPEED_FULL;
|
||||
s->dev.handle_packet = usb_generic_handle_packet;
|
||||
|
||||
s->dev.handle_reset = usb_mouse_handle_reset;
|
||||
s->dev.handle_control = usb_mouse_handle_control;
|
||||
s->dev.handle_data = usb_mouse_handle_data;
|
||||
s->dev.handle_destroy = usb_mouse_handle_destroy;
|
||||
s->kind = USB_MOUSE;
|
||||
|
||||
pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Mouse");
|
||||
|
||||
return (USBDevice *)s;
|
||||
}
|
|
@ -0,0 +1,565 @@
|
|||
/*
|
||||
* QEMU USB HUB emulation
|
||||
*
|
||||
* Copyright (c) 2005 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include "vl.h"
|
||||
|
||||
//#define DEBUG
|
||||
|
||||
#define MAX_PORTS 8
|
||||
|
||||
typedef struct USBHubPort {
|
||||
USBPort port;
|
||||
uint16_t wPortStatus;
|
||||
uint16_t wPortChange;
|
||||
} USBHubPort;
|
||||
|
||||
typedef struct USBHubState {
|
||||
USBDevice dev;
|
||||
int nb_ports;
|
||||
USBHubPort ports[MAX_PORTS];
|
||||
} USBHubState;
|
||||
|
||||
#define ClearHubFeature (0x2000 | USB_REQ_CLEAR_FEATURE)
|
||||
#define ClearPortFeature (0x2300 | USB_REQ_CLEAR_FEATURE)
|
||||
#define GetHubDescriptor (0xa000 | USB_REQ_GET_DESCRIPTOR)
|
||||
#define GetHubStatus (0xa000 | USB_REQ_GET_STATUS)
|
||||
#define GetPortStatus (0xa300 | USB_REQ_GET_STATUS)
|
||||
#define SetHubFeature (0x2000 | USB_REQ_SET_FEATURE)
|
||||
#define SetPortFeature (0x2300 | USB_REQ_SET_FEATURE)
|
||||
|
||||
#define PORT_STAT_CONNECTION 0x0001
|
||||
#define PORT_STAT_ENABLE 0x0002
|
||||
#define PORT_STAT_SUSPEND 0x0004
|
||||
#define PORT_STAT_OVERCURRENT 0x0008
|
||||
#define PORT_STAT_RESET 0x0010
|
||||
#define PORT_STAT_POWER 0x0100
|
||||
#define PORT_STAT_LOW_SPEED 0x0200
|
||||
#define PORT_STAT_HIGH_SPEED 0x0400
|
||||
#define PORT_STAT_TEST 0x0800
|
||||
#define PORT_STAT_INDICATOR 0x1000
|
||||
|
||||
#define PORT_STAT_C_CONNECTION 0x0001
|
||||
#define PORT_STAT_C_ENABLE 0x0002
|
||||
#define PORT_STAT_C_SUSPEND 0x0004
|
||||
#define PORT_STAT_C_OVERCURRENT 0x0008
|
||||
#define PORT_STAT_C_RESET 0x0010
|
||||
|
||||
#define PORT_CONNECTION 0
|
||||
#define PORT_ENABLE 1
|
||||
#define PORT_SUSPEND 2
|
||||
#define PORT_OVERCURRENT 3
|
||||
#define PORT_RESET 4
|
||||
#define PORT_POWER 8
|
||||
#define PORT_LOWSPEED 9
|
||||
#define PORT_HIGHSPEED 10
|
||||
#define PORT_C_CONNECTION 16
|
||||
#define PORT_C_ENABLE 17
|
||||
#define PORT_C_SUSPEND 18
|
||||
#define PORT_C_OVERCURRENT 19
|
||||
#define PORT_C_RESET 20
|
||||
#define PORT_TEST 21
|
||||
#define PORT_INDICATOR 22
|
||||
|
||||
/* same as Linux kernel root hubs */
|
||||
|
||||
static const uint8_t qemu_hub_dev_descriptor[] = {
|
||||
0x12, /* u8 bLength; */
|
||||
0x01, /* u8 bDescriptorType; Device */
|
||||
0x10, 0x01, /* u16 bcdUSB; v1.1 */
|
||||
|
||||
0x09, /* u8 bDeviceClass; HUB_CLASSCODE */
|
||||
0x00, /* u8 bDeviceSubClass; */
|
||||
0x00, /* u8 bDeviceProtocol; [ low/full speeds only ] */
|
||||
0x08, /* u8 bMaxPacketSize0; 8 Bytes */
|
||||
|
||||
0x00, 0x00, /* u16 idVendor; */
|
||||
0x00, 0x00, /* u16 idProduct; */
|
||||
0x01, 0x01, /* u16 bcdDevice */
|
||||
|
||||
0x03, /* u8 iManufacturer; */
|
||||
0x02, /* u8 iProduct; */
|
||||
0x01, /* u8 iSerialNumber; */
|
||||
0x01 /* u8 bNumConfigurations; */
|
||||
};
|
||||
|
||||
/* XXX: patch interrupt size */
|
||||
static const uint8_t qemu_hub_config_descriptor[] = {
|
||||
|
||||
/* one configuration */
|
||||
0x09, /* u8 bLength; */
|
||||
0x02, /* u8 bDescriptorType; Configuration */
|
||||
0x19, 0x00, /* u16 wTotalLength; */
|
||||
0x01, /* u8 bNumInterfaces; (1) */
|
||||
0x01, /* u8 bConfigurationValue; */
|
||||
0x00, /* u8 iConfiguration; */
|
||||
0xc0, /* u8 bmAttributes;
|
||||
Bit 7: must be set,
|
||||
6: Self-powered,
|
||||
5: Remote wakeup,
|
||||
4..0: resvd */
|
||||
0x00, /* u8 MaxPower; */
|
||||
|
||||
/* USB 1.1:
|
||||
* USB 2.0, single TT organization (mandatory):
|
||||
* one interface, protocol 0
|
||||
*
|
||||
* USB 2.0, multiple TT organization (optional):
|
||||
* two interfaces, protocols 1 (like single TT)
|
||||
* and 2 (multiple TT mode) ... config is
|
||||
* sometimes settable
|
||||
* NOT IMPLEMENTED
|
||||
*/
|
||||
|
||||
/* one interface */
|
||||
0x09, /* u8 if_bLength; */
|
||||
0x04, /* u8 if_bDescriptorType; Interface */
|
||||
0x00, /* u8 if_bInterfaceNumber; */
|
||||
0x00, /* u8 if_bAlternateSetting; */
|
||||
0x01, /* u8 if_bNumEndpoints; */
|
||||
0x09, /* u8 if_bInterfaceClass; HUB_CLASSCODE */
|
||||
0x00, /* u8 if_bInterfaceSubClass; */
|
||||
0x00, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */
|
||||
0x00, /* u8 if_iInterface; */
|
||||
|
||||
/* one endpoint (status change endpoint) */
|
||||
0x07, /* u8 ep_bLength; */
|
||||
0x05, /* u8 ep_bDescriptorType; Endpoint */
|
||||
0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */
|
||||
0x03, /* u8 ep_bmAttributes; Interrupt */
|
||||
0x02, 0x00, /* u16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */
|
||||
0xff /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */
|
||||
};
|
||||
|
||||
static const uint8_t qemu_hub_hub_descriptor[] =
|
||||
{
|
||||
0x00, /* u8 bLength; patched in later */
|
||||
0x29, /* u8 bDescriptorType; Hub-descriptor */
|
||||
0x00, /* u8 bNbrPorts; (patched later) */
|
||||
0x0a, /* u16 wHubCharacteristics; */
|
||||
0x00, /* (per-port OC, no power switching) */
|
||||
0x01, /* u8 bPwrOn2pwrGood; 2ms */
|
||||
0x00 /* u8 bHubContrCurrent; 0 mA */
|
||||
|
||||
/* DeviceRemovable and PortPwrCtrlMask patched in later */
|
||||
};
|
||||
|
||||
static void usb_hub_attach(USBPort *port1, USBDevice *dev)
|
||||
{
|
||||
USBHubState *s =(USBHubState *) port1->opaque;
|
||||
USBHubPort *port = (USBHubPort *)&s->ports[port1->index];
|
||||
|
||||
if (dev) {
|
||||
if (port->port.dev)
|
||||
usb_attach(port1, NULL);
|
||||
|
||||
port->wPortStatus |= PORT_STAT_CONNECTION;
|
||||
port->wPortChange |= PORT_STAT_C_CONNECTION;
|
||||
if (dev->speed == USB_SPEED_LOW)
|
||||
port->wPortStatus |= PORT_STAT_LOW_SPEED;
|
||||
else
|
||||
port->wPortStatus &= ~PORT_STAT_LOW_SPEED;
|
||||
port->port.dev = dev;
|
||||
/* send the attach message */
|
||||
dev->handle_packet(dev,
|
||||
USB_MSG_ATTACH, 0, 0, NULL, 0);
|
||||
} else {
|
||||
dev = port->port.dev;
|
||||
if (dev) {
|
||||
port->wPortStatus &= ~PORT_STAT_CONNECTION;
|
||||
port->wPortChange |= PORT_STAT_C_CONNECTION;
|
||||
if (port->wPortStatus & PORT_STAT_ENABLE) {
|
||||
port->wPortStatus &= ~PORT_STAT_ENABLE;
|
||||
port->wPortChange |= PORT_STAT_C_ENABLE;
|
||||
}
|
||||
/* send the detach message */
|
||||
dev->handle_packet(dev,
|
||||
USB_MSG_DETACH, 0, 0, NULL, 0);
|
||||
port->port.dev = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void usb_hub_handle_reset(USBDevice *dev)
|
||||
{
|
||||
/* XXX: do it */
|
||||
}
|
||||
|
||||
static int usb_hub_handle_control(USBDevice *dev, int request, int value,
|
||||
int index, int length, uint8_t *data)
|
||||
{
|
||||
USBHubState *s = (USBHubState *)dev;
|
||||
int ret;
|
||||
|
||||
switch(request) {
|
||||
case DeviceRequest | USB_REQ_GET_STATUS:
|
||||
data[0] = (1 << USB_DEVICE_SELF_POWERED) |
|
||||
(dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
|
||||
data[1] = 0x00;
|
||||
ret = 2;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
|
||||
if (value == USB_DEVICE_REMOTE_WAKEUP) {
|
||||
dev->remote_wakeup = 0;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
|
||||
if (value == 0 && index != 0x81) { /* clear ep halt */
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_FEATURE:
|
||||
if (value == USB_DEVICE_REMOTE_WAKEUP) {
|
||||
dev->remote_wakeup = 1;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_ADDRESS:
|
||||
dev->addr = value;
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
|
||||
switch(value >> 8) {
|
||||
case USB_DT_DEVICE:
|
||||
memcpy(data, qemu_hub_dev_descriptor,
|
||||
sizeof(qemu_hub_dev_descriptor));
|
||||
ret = sizeof(qemu_hub_dev_descriptor);
|
||||
break;
|
||||
case USB_DT_CONFIG:
|
||||
memcpy(data, qemu_hub_config_descriptor,
|
||||
sizeof(qemu_hub_config_descriptor));
|
||||
|
||||
/* status change endpoint size based on number
|
||||
* of ports */
|
||||
data[22] = (s->nb_ports + 1 + 7) / 8;
|
||||
|
||||
ret = sizeof(qemu_hub_config_descriptor);
|
||||
break;
|
||||
case USB_DT_STRING:
|
||||
switch(value & 0xff) {
|
||||
case 0:
|
||||
/* language ids */
|
||||
data[0] = 4;
|
||||
data[1] = 3;
|
||||
data[2] = 0x09;
|
||||
data[3] = 0x04;
|
||||
ret = 4;
|
||||
break;
|
||||
case 1:
|
||||
/* serial number */
|
||||
ret = set_usb_string(data, "314159");
|
||||
break;
|
||||
case 2:
|
||||
/* product description */
|
||||
ret = set_usb_string(data, "QEMU USB Hub");
|
||||
break;
|
||||
case 3:
|
||||
/* vendor description */
|
||||
ret = set_usb_string(data, "PCSX2/QEMU");
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
|
||||
data[0] = 1;
|
||||
ret = 1;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_INTERFACE:
|
||||
data[0] = 0;
|
||||
ret = 1;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_INTERFACE:
|
||||
ret = 0;
|
||||
break;
|
||||
/* usb specific requests */
|
||||
case GetHubStatus:
|
||||
data[0] = 0;
|
||||
data[1] = 0;
|
||||
data[2] = 0;
|
||||
data[3] = 0;
|
||||
ret = 4;
|
||||
break;
|
||||
case GetPortStatus:
|
||||
{
|
||||
unsigned int n = index - 1;
|
||||
USBHubPort *port;
|
||||
if (n >= s->nb_ports)
|
||||
goto fail;
|
||||
port = &s->ports[n];
|
||||
data[0] = port->wPortStatus;
|
||||
data[1] = port->wPortStatus >> 8;
|
||||
data[2] = port->wPortChange;
|
||||
data[3] = port->wPortChange >> 8;
|
||||
ret = 4;
|
||||
}
|
||||
break;
|
||||
case SetHubFeature:
|
||||
case ClearHubFeature:
|
||||
if (value == 0 || value == 1) {
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case SetPortFeature:
|
||||
{
|
||||
unsigned int n = index - 1;
|
||||
USBHubPort *port;
|
||||
USBDevice *dev;
|
||||
if (n >= s->nb_ports)
|
||||
goto fail;
|
||||
port = &s->ports[n];
|
||||
dev = port->port.dev;
|
||||
switch(value) {
|
||||
case PORT_SUSPEND:
|
||||
port->wPortStatus |= PORT_STAT_SUSPEND;
|
||||
break;
|
||||
case PORT_RESET:
|
||||
if (dev) {
|
||||
dev->handle_packet(dev,
|
||||
USB_MSG_RESET, 0, 0, NULL, 0);
|
||||
port->wPortChange |= PORT_STAT_C_RESET;
|
||||
/* set enable bit */
|
||||
port->wPortStatus |= PORT_STAT_ENABLE;
|
||||
}
|
||||
break;
|
||||
case PORT_POWER:
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
case ClearPortFeature:
|
||||
{
|
||||
unsigned int n = index - 1;
|
||||
USBHubPort *port;
|
||||
USBDevice *dev;
|
||||
if (n >= s->nb_ports)
|
||||
goto fail;
|
||||
port = &s->ports[n];
|
||||
dev = port->port.dev;
|
||||
switch(value) {
|
||||
case PORT_ENABLE:
|
||||
port->wPortStatus &= ~PORT_STAT_ENABLE;
|
||||
break;
|
||||
case PORT_C_ENABLE:
|
||||
port->wPortChange &= ~PORT_STAT_C_ENABLE;
|
||||
break;
|
||||
case PORT_SUSPEND:
|
||||
port->wPortStatus &= ~PORT_STAT_SUSPEND;
|
||||
break;
|
||||
case PORT_C_SUSPEND:
|
||||
port->wPortChange &= ~PORT_STAT_C_SUSPEND;
|
||||
break;
|
||||
case PORT_C_CONNECTION:
|
||||
port->wPortChange &= ~PORT_STAT_C_CONNECTION;
|
||||
break;
|
||||
case PORT_C_OVERCURRENT:
|
||||
port->wPortChange &= ~PORT_STAT_C_OVERCURRENT;
|
||||
break;
|
||||
case PORT_C_RESET:
|
||||
port->wPortChange &= ~PORT_STAT_C_RESET;
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
case GetHubDescriptor:
|
||||
{
|
||||
unsigned int n, limit, var_hub_size = 0;
|
||||
memcpy(data, qemu_hub_hub_descriptor,
|
||||
sizeof(qemu_hub_hub_descriptor));
|
||||
data[2] = s->nb_ports;
|
||||
|
||||
/* fill DeviceRemovable bits */
|
||||
limit = ((s->nb_ports + 1 + 7) / 8) + 7;
|
||||
for (n = 7; n < limit; n++) {
|
||||
data[n] = 0x00;
|
||||
var_hub_size++;
|
||||
}
|
||||
|
||||
/* fill PortPwrCtrlMask bits */
|
||||
limit = limit + ((s->nb_ports + 7) / 8);
|
||||
for (;n < limit; n++) {
|
||||
data[n] = 0xff;
|
||||
var_hub_size++;
|
||||
}
|
||||
|
||||
ret = sizeof(qemu_hub_hub_descriptor) + var_hub_size;
|
||||
data[0] = ret;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
fail:
|
||||
ret = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int usb_hub_handle_data(USBDevice *dev, int pid,
|
||||
uint8_t devep, uint8_t *data, int len)
|
||||
{
|
||||
USBHubState *s = (USBHubState *)dev;
|
||||
int ret;
|
||||
|
||||
switch(pid) {
|
||||
case USB_TOKEN_IN:
|
||||
if (devep == 1) {
|
||||
USBHubPort *port;
|
||||
unsigned int status;
|
||||
int i, n;
|
||||
n = (s->nb_ports + 1 + 7) / 8;
|
||||
if (len == 1) { /* FreeBSD workaround */
|
||||
n = 1;
|
||||
} else if (n > len) {
|
||||
return USB_RET_BABBLE;
|
||||
}
|
||||
status = 0;
|
||||
for(i = 0; i < s->nb_ports; i++) {
|
||||
port = &s->ports[i];
|
||||
if (port->wPortChange)
|
||||
status |= (1 << (i + 1));
|
||||
}
|
||||
if (status != 0) {
|
||||
for(i = 0; i < n; i++) {
|
||||
data[i] = status >> (8 * i);
|
||||
}
|
||||
ret = n;
|
||||
} else {
|
||||
ret = USB_RET_NAK; /* usb11 11.13.1 */
|
||||
}
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case USB_TOKEN_OUT:
|
||||
default:
|
||||
fail:
|
||||
ret = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int usb_hub_broadcast_packet(USBHubState *s, int pid,
|
||||
uint8_t devaddr, uint8_t devep,
|
||||
uint8_t *data, int len)
|
||||
{
|
||||
USBHubPort *port;
|
||||
USBDevice *dev;
|
||||
int i, ret;
|
||||
|
||||
for(i = 0; i < s->nb_ports; i++) {
|
||||
port = &s->ports[i];
|
||||
dev = port->port.dev;
|
||||
if (dev && (port->wPortStatus & PORT_STAT_ENABLE)) {
|
||||
ret = dev->handle_packet(dev, pid,
|
||||
devaddr, devep,
|
||||
data, len);
|
||||
if (ret != USB_RET_NODEV) {
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
return USB_RET_NODEV;
|
||||
}
|
||||
|
||||
static int usb_hub_handle_packet(USBDevice *dev, int pid,
|
||||
uint8_t devaddr, uint8_t devep,
|
||||
uint8_t *data, int len)
|
||||
{
|
||||
USBHubState *s = (USBHubState *)dev;
|
||||
|
||||
#if defined(DEBUG) && 0
|
||||
printf("usb_hub: pid=0x%x\n", pid);
|
||||
#endif
|
||||
if (dev->state == USB_STATE_DEFAULT &&
|
||||
dev->addr != 0 &&
|
||||
devaddr != dev->addr &&
|
||||
(pid == USB_TOKEN_SETUP ||
|
||||
pid == USB_TOKEN_OUT ||
|
||||
pid == USB_TOKEN_IN)) {
|
||||
/* broadcast the packet to the devices */
|
||||
return usb_hub_broadcast_packet(s, pid, devaddr, devep, data, len);
|
||||
}
|
||||
return usb_generic_handle_packet(dev, pid, devaddr, devep, data, len);
|
||||
}
|
||||
|
||||
static void usb_hub_handle_destroy(USBDevice *dev)
|
||||
{
|
||||
USBHubState *s = (USBHubState *)dev;
|
||||
|
||||
free(s);
|
||||
}
|
||||
|
||||
USBDevice *usb_hub_init(int nb_ports)
|
||||
{
|
||||
USBHubState *s;
|
||||
USBHubPort *port;
|
||||
int i;
|
||||
|
||||
if (nb_ports > MAX_PORTS)
|
||||
return NULL;
|
||||
s = (USBHubState *)qemu_mallocz(sizeof(USBHubState));
|
||||
if (!s)
|
||||
return NULL;
|
||||
s->dev.speed = USB_SPEED_FULL;
|
||||
s->dev.handle_packet = usb_hub_handle_packet;
|
||||
|
||||
/* generic USB device init */
|
||||
s->dev.handle_reset = usb_hub_handle_reset;
|
||||
s->dev.handle_control = usb_hub_handle_control;
|
||||
s->dev.handle_data = usb_hub_handle_data;
|
||||
s->dev.handle_destroy = usb_hub_handle_destroy;
|
||||
|
||||
strncpy(s->dev.devname, "QEMU USB Hub", sizeof(s->dev.devname));
|
||||
|
||||
s->nb_ports = nb_ports;
|
||||
for(i = 0; i < s->nb_ports; i++) {
|
||||
port = &s->ports[i];
|
||||
port->port.opaque = s;
|
||||
port->port.index = i;
|
||||
port->port.attach = usb_hub_attach;
|
||||
port->wPortStatus = PORT_STAT_POWER;
|
||||
port->wPortChange = 0;
|
||||
}
|
||||
return (USBDevice *)s;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,402 @@
|
|||
/*
|
||||
* USB Mass Storage Device emulation
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery.
|
||||
* Written by Paul Brook
|
||||
*
|
||||
* This code is licenced under the LGPL.
|
||||
*/
|
||||
|
||||
#include "vl.h"
|
||||
|
||||
//#define DEBUG_MSD
|
||||
|
||||
#ifdef DEBUG_MSD
|
||||
#define DPRINTF(fmt, args...) \
|
||||
do { printf("usb-msd: " fmt , ##args); } while (0)
|
||||
#else
|
||||
#define DPRINTF(fmt, args...) do {} while(0)
|
||||
#endif
|
||||
|
||||
/* USB requests. */
|
||||
#define MassStorageReset 0xff
|
||||
#define GetMaxLun 0xfe
|
||||
|
||||
enum USBMSDMode {
|
||||
USB_MSDM_CBW, /* Command Block. */
|
||||
USB_MSDM_DATAOUT, /* Tranfer data to device. */
|
||||
USB_MSDM_DATAIN, /* Transfer data from device. */
|
||||
USB_MSDM_CSW /* Command Status. */
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
USBDevice dev;
|
||||
enum USBMSDMode mode;
|
||||
uint32_t data_len;
|
||||
uint32_t tag;
|
||||
SCSIDevice *scsi_dev;
|
||||
int result;
|
||||
} MSDState;
|
||||
|
||||
static const uint8_t qemu_msd_dev_descriptor[] = {
|
||||
0x12, /* u8 bLength; */
|
||||
0x01, /* u8 bDescriptorType; Device */
|
||||
0x10, 0x00, /* u16 bcdUSB; v1.0 */
|
||||
|
||||
0x00, /* u8 bDeviceClass; */
|
||||
0x00, /* u8 bDeviceSubClass; */
|
||||
0x00, /* u8 bDeviceProtocol; [ low/full speeds only ] */
|
||||
0x08, /* u8 bMaxPacketSize0; 8 Bytes */
|
||||
|
||||
/* Vendor and product id are arbitrary. */
|
||||
0x00, 0x00, /* u16 idVendor; */
|
||||
0x00, 0x00, /* u16 idProduct; */
|
||||
0x00, 0x00, /* u16 bcdDevice */
|
||||
|
||||
0x01, /* u8 iManufacturer; */
|
||||
0x02, /* u8 iProduct; */
|
||||
0x03, /* u8 iSerialNumber; */
|
||||
0x01 /* u8 bNumConfigurations; */
|
||||
};
|
||||
|
||||
static const uint8_t qemu_msd_config_descriptor[] = {
|
||||
|
||||
/* one configuration */
|
||||
0x09, /* u8 bLength; */
|
||||
0x02, /* u8 bDescriptorType; Configuration */
|
||||
0x20, 0x00, /* u16 wTotalLength; */
|
||||
0x01, /* u8 bNumInterfaces; (1) */
|
||||
0x01, /* u8 bConfigurationValue; */
|
||||
0x00, /* u8 iConfiguration; */
|
||||
0xc0, /* u8 bmAttributes;
|
||||
Bit 7: must be set,
|
||||
6: Self-powered,
|
||||
5: Remote wakeup,
|
||||
4..0: resvd */
|
||||
0x00, /* u8 MaxPower; */
|
||||
|
||||
/* one interface */
|
||||
0x09, /* u8 if_bLength; */
|
||||
0x04, /* u8 if_bDescriptorType; Interface */
|
||||
0x00, /* u8 if_bInterfaceNumber; */
|
||||
0x00, /* u8 if_bAlternateSetting; */
|
||||
0x02, /* u8 if_bNumEndpoints; */
|
||||
0x08, /* u8 if_bInterfaceClass; MASS STORAGE */
|
||||
0x06, /* u8 if_bInterfaceSubClass; SCSI */
|
||||
0x50, /* u8 if_bInterfaceProtocol; Bulk Only */
|
||||
0x00, /* u8 if_iInterface; */
|
||||
|
||||
/* Bulk-In endpoint */
|
||||
0x07, /* u8 ep_bLength; */
|
||||
0x05, /* u8 ep_bDescriptorType; Endpoint */
|
||||
0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */
|
||||
0x02, /* u8 ep_bmAttributes; Bulk */
|
||||
0x40, 0x00, /* u16 ep_wMaxPacketSize; */
|
||||
0x00, /* u8 ep_bInterval; */
|
||||
|
||||
/* Bulk-Out endpoint */
|
||||
0x07, /* u8 ep_bLength; */
|
||||
0x05, /* u8 ep_bDescriptorType; Endpoint */
|
||||
0x02, /* u8 ep_bEndpointAddress; OUT Endpoint 2 */
|
||||
0x02, /* u8 ep_bmAttributes; Bulk */
|
||||
0x40, 0x00, /* u16 ep_wMaxPacketSize; */
|
||||
0x00 /* u8 ep_bInterval; */
|
||||
};
|
||||
|
||||
static void usb_msd_command_complete(void *opaque, uint32_t tag, int fail)
|
||||
{
|
||||
MSDState *s = (MSDState *)opaque;
|
||||
|
||||
DPRINTF("Command complete\n");
|
||||
s->result = fail;
|
||||
s->mode = USB_MSDM_CSW;
|
||||
}
|
||||
|
||||
static void usb_msd_handle_reset(USBDevice *dev)
|
||||
{
|
||||
MSDState *s = (MSDState *)dev;
|
||||
|
||||
DPRINTF("Reset\n");
|
||||
s->mode = USB_MSDM_CBW;
|
||||
}
|
||||
|
||||
static int usb_msd_handle_control(USBDevice *dev, int request, int value,
|
||||
int index, int length, uint8_t *data)
|
||||
{
|
||||
MSDState *s = (MSDState *)dev;
|
||||
int ret = 0;
|
||||
|
||||
switch (request) {
|
||||
case DeviceRequest | USB_REQ_GET_STATUS:
|
||||
data[0] = (1 << USB_DEVICE_SELF_POWERED) |
|
||||
(dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
|
||||
data[1] = 0x00;
|
||||
ret = 2;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
|
||||
if (value == USB_DEVICE_REMOTE_WAKEUP) {
|
||||
dev->remote_wakeup = 0;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_FEATURE:
|
||||
if (value == USB_DEVICE_REMOTE_WAKEUP) {
|
||||
dev->remote_wakeup = 1;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_ADDRESS:
|
||||
dev->addr = value;
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
|
||||
switch(value >> 8) {
|
||||
case USB_DT_DEVICE:
|
||||
memcpy(data, qemu_msd_dev_descriptor,
|
||||
sizeof(qemu_msd_dev_descriptor));
|
||||
ret = sizeof(qemu_msd_dev_descriptor);
|
||||
break;
|
||||
case USB_DT_CONFIG:
|
||||
memcpy(data, qemu_msd_config_descriptor,
|
||||
sizeof(qemu_msd_config_descriptor));
|
||||
ret = sizeof(qemu_msd_config_descriptor);
|
||||
break;
|
||||
case USB_DT_STRING:
|
||||
switch(value & 0xff) {
|
||||
case 0:
|
||||
/* language ids */
|
||||
data[0] = 4;
|
||||
data[1] = 3;
|
||||
data[2] = 0x09;
|
||||
data[3] = 0x04;
|
||||
ret = 4;
|
||||
break;
|
||||
case 1:
|
||||
/* vendor description */
|
||||
ret = set_usb_string(data, "QEMU " QEMU_VERSION);
|
||||
break;
|
||||
case 2:
|
||||
/* product description */
|
||||
ret = set_usb_string(data, "QEMU USB HARDDRIVE");
|
||||
break;
|
||||
case 3:
|
||||
/* serial number */
|
||||
ret = set_usb_string(data, "1");
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
|
||||
data[0] = 1;
|
||||
ret = 1;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_INTERFACE:
|
||||
data[0] = 0;
|
||||
ret = 1;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_INTERFACE:
|
||||
ret = 0;
|
||||
break;
|
||||
case EndpointOutRequest | USB_REQ_CLEAR_FEATURE:
|
||||
if (value == 0 && index != 0x81) { /* clear ep halt */
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
/* Class specific requests. */
|
||||
case MassStorageReset:
|
||||
/* Reset state ready for the next CBW. */
|
||||
s->mode = USB_MSDM_CBW;
|
||||
ret = 0;
|
||||
break;
|
||||
case GetMaxLun:
|
||||
data[0] = 0;
|
||||
ret = 1;
|
||||
break;
|
||||
default:
|
||||
fail:
|
||||
ret = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct usb_msd_cbw {
|
||||
uint32_t sig;
|
||||
uint32_t tag;
|
||||
uint32_t data_len;
|
||||
uint8_t flags;
|
||||
uint8_t lun;
|
||||
uint8_t cmd_len;
|
||||
uint8_t cmd[16];
|
||||
};
|
||||
|
||||
struct usb_msd_csw {
|
||||
uint32_t sig;
|
||||
uint32_t tag;
|
||||
uint32_t residue;
|
||||
uint8_t status;
|
||||
};
|
||||
|
||||
static int usb_msd_handle_data(USBDevice *dev, int pid, uint8_t devep,
|
||||
uint8_t *data, int len)
|
||||
{
|
||||
MSDState *s = (MSDState *)dev;
|
||||
int ret = 0;
|
||||
struct usb_msd_cbw cbw;
|
||||
struct usb_msd_csw csw;
|
||||
|
||||
switch (pid) {
|
||||
case USB_TOKEN_OUT:
|
||||
if (devep != 2)
|
||||
goto fail;
|
||||
|
||||
switch (s->mode) {
|
||||
case USB_MSDM_CBW:
|
||||
if (len != 31) {
|
||||
fprintf(stderr, "usb-msd: Bad CBW size");
|
||||
goto fail;
|
||||
}
|
||||
memcpy(&cbw, data, 31);
|
||||
if (le32_to_cpu(cbw.sig) != 0x43425355) {
|
||||
fprintf(stderr, "usb-msd: Bad signature %08x\n",
|
||||
le32_to_cpu(cbw.sig));
|
||||
goto fail;
|
||||
}
|
||||
DPRINTF("Command on LUN %d\n", cbw.lun);
|
||||
if (cbw.lun != 0) {
|
||||
fprintf(stderr, "usb-msd: Bad LUN %d\n", cbw.lun);
|
||||
goto fail;
|
||||
}
|
||||
s->tag = le32_to_cpu(cbw.tag);
|
||||
s->data_len = le32_to_cpu(cbw.data_len);
|
||||
if (s->data_len == 0) {
|
||||
s->mode = USB_MSDM_CSW;
|
||||
} else if (cbw.flags & 0x80) {
|
||||
s->mode = USB_MSDM_DATAIN;
|
||||
} else {
|
||||
s->mode = USB_MSDM_DATAOUT;
|
||||
}
|
||||
DPRINTF("Command tag 0x%x flags %08x len %d data %d\n",
|
||||
s->tag, cbw.flags, cbw.cmd_len, s->data_len);
|
||||
scsi_send_command(s->scsi_dev, s->tag, cbw.cmd, 0);
|
||||
ret = len;
|
||||
break;
|
||||
|
||||
case USB_MSDM_DATAOUT:
|
||||
DPRINTF("Data out %d/%d\n", len, s->data_len);
|
||||
if (len > s->data_len)
|
||||
goto fail;
|
||||
|
||||
if (scsi_write_data(s->scsi_dev, data, len))
|
||||
goto fail;
|
||||
|
||||
s->data_len -= len;
|
||||
if (s->data_len == 0)
|
||||
s->mode = USB_MSDM_CSW;
|
||||
ret = len;
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINTF("Unexpected write (len %d)\n", len);
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
|
||||
case USB_TOKEN_IN:
|
||||
if (devep != 1)
|
||||
goto fail;
|
||||
|
||||
switch (s->mode) {
|
||||
case USB_MSDM_CSW:
|
||||
DPRINTF("Command status %d tag 0x%x, len %d\n",
|
||||
s->result, s->tag, len);
|
||||
if (len < 13)
|
||||
goto fail;
|
||||
|
||||
csw.sig = cpu_to_le32(0x53425355);
|
||||
csw.tag = cpu_to_le32(s->tag);
|
||||
csw.residue = 0;
|
||||
csw.status = s->result;
|
||||
memcpy(data, &csw, 13);
|
||||
ret = 13;
|
||||
s->mode = USB_MSDM_CBW;
|
||||
break;
|
||||
|
||||
case USB_MSDM_DATAIN:
|
||||
DPRINTF("Data in %d/%d\n", len, s->data_len);
|
||||
if (len > s->data_len)
|
||||
len = s->data_len;
|
||||
|
||||
if (scsi_read_data(s->scsi_dev, data, len))
|
||||
goto fail;
|
||||
|
||||
s->data_len -= len;
|
||||
if (s->data_len == 0)
|
||||
s->mode = USB_MSDM_CSW;
|
||||
ret = len;
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINTF("Unexpected read (len %d)\n", len);
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
DPRINTF("Bad token\n");
|
||||
fail:
|
||||
ret = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void usb_msd_handle_destroy(USBDevice *dev)
|
||||
{
|
||||
MSDState *s = (MSDState *)dev;
|
||||
|
||||
scsi_disk_destroy(s->scsi_dev);
|
||||
qemu_free(s);
|
||||
}
|
||||
|
||||
USBDevice *usb_msd_init(const char *filename)
|
||||
{
|
||||
MSDState *s;
|
||||
BlockDriverState *bdrv;
|
||||
|
||||
s = qemu_mallocz(sizeof(MSDState));
|
||||
if (!s)
|
||||
return NULL;
|
||||
|
||||
bdrv = bdrv_new("usb");
|
||||
bdrv_open(bdrv, filename, 0);
|
||||
|
||||
s->dev.speed = USB_SPEED_FULL;
|
||||
s->dev.handle_packet = usb_generic_handle_packet;
|
||||
|
||||
s->dev.handle_reset = usb_msd_handle_reset;
|
||||
s->dev.handle_control = usb_msd_handle_control;
|
||||
s->dev.handle_data = usb_msd_handle_data;
|
||||
s->dev.handle_destroy = usb_msd_handle_destroy;
|
||||
|
||||
snprintf(s->dev.devname, sizeof(s->dev.devname), "QEMU USB MSD(%.16s)",
|
||||
filename);
|
||||
|
||||
s->scsi_dev = scsi_disk_init(bdrv, usb_msd_command_complete, s);
|
||||
usb_msd_handle_reset((USBDevice *)s);
|
||||
return (USBDevice *)s;
|
||||
}
|
|
@ -0,0 +1,985 @@
|
|||
/*
|
||||
* QEMU USB OHCI Emulation
|
||||
* Copyright (c) 2004 Gianni Tedesco
|
||||
* Copyright (c) 2006 CodeSourcery
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* TODO:
|
||||
* o Isochronous transfers
|
||||
* o Allocate bandwidth in frames properly
|
||||
* o Disable timers when nothing needs to be done, or remove timer usage
|
||||
* all together.
|
||||
* o Handle unrecoverable errors properly
|
||||
* o BIOS work to boot from USB storage
|
||||
*/
|
||||
|
||||
//typedef CPUReadMemoryFunc
|
||||
|
||||
#include "vl.h"
|
||||
#include "../USB.h"
|
||||
|
||||
uint32_t bits = 0;
|
||||
uint32_t need_interrupt = 0;
|
||||
|
||||
extern FILE* usbLog;
|
||||
|
||||
int dprintf(const char *fmt,...)
|
||||
{
|
||||
#ifdef DEBUG_OHCI
|
||||
int t;
|
||||
va_list list;
|
||||
|
||||
va_start(list, fmt);
|
||||
t=vfprintf(stderr, fmt, list);
|
||||
va_end(list);
|
||||
|
||||
if(usbLog)
|
||||
{
|
||||
va_start(list, fmt);
|
||||
vfprintf(usbLog, fmt, list);
|
||||
va_end(list);
|
||||
}
|
||||
|
||||
return t;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Update IRQ levels */
|
||||
static inline void ohci_intr_update(OHCIState *ohci)
|
||||
{
|
||||
bits = (ohci->intr_status & ohci->intr) & 0x7fffffff;
|
||||
|
||||
if ((ohci->intr & OHCI_INTR_MIE) && (bits!=0)) // && (ohci->ctl & OHCI_CTL_HCFS))
|
||||
{
|
||||
/*
|
||||
static char reasons[1024];
|
||||
int first=1;
|
||||
|
||||
reasons[0]=0;
|
||||
|
||||
#define reason_add(p,t) if(bits&(p)) { if(!first) strcat_s(reasons,1024,", "); first=0; strcat_s(reasons,1024,t); }
|
||||
reason_add(OHCI_INTR_SO,"Scheduling overrun");
|
||||
reason_add(OHCI_INTR_WD,"HcDoneHead writeback");
|
||||
reason_add(OHCI_INTR_SF,"Start of frame");
|
||||
reason_add(OHCI_INTR_RD,"Resume detect");
|
||||
reason_add(OHCI_INTR_UE,"Unrecoverable error");
|
||||
reason_add(OHCI_INTR_FNO,"Frame number overflow");
|
||||
reason_add(OHCI_INTR_RHSC,"Root hub status change");
|
||||
reason_add(OHCI_INTR_OC,"Ownership change");
|
||||
*/
|
||||
if((ohci->ctl & OHCI_CTL_HCFS)==OHCI_USB_OPERATIONAL)
|
||||
{
|
||||
USBirq(1);
|
||||
//dprintf("usb-ohci: Interrupt Called. Reason(s): %s\n",reasons);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Set an interrupt */
|
||||
static inline void ohci_set_interrupt(OHCIState *ohci, uint32_t intr)
|
||||
{
|
||||
ohci->intr_status |= intr;
|
||||
ohci_intr_update(ohci);
|
||||
}
|
||||
|
||||
//static void usb_attach(USBPort *port, USBDevice *dev)
|
||||
//{
|
||||
// port->attach(port,dev);
|
||||
//}
|
||||
|
||||
/* Attach or detach a device on a root hub port. */
|
||||
static void ohci_attach(USBPort *port1, USBDevice *dev)
|
||||
{
|
||||
OHCIState *s = (OHCIState *)port1->opaque;
|
||||
OHCIPort *port = (OHCIPort *)&s->rhport[port1->index];
|
||||
uint32_t old_state = port->ctrl;
|
||||
|
||||
if (dev) {
|
||||
if (port->port.dev) {
|
||||
usb_attach(port1, NULL);
|
||||
}
|
||||
/* set connect status */
|
||||
port->ctrl |= OHCI_PORT_CCS | OHCI_PORT_CSC;
|
||||
|
||||
/* update speed */
|
||||
if (dev->speed == USB_SPEED_LOW)
|
||||
port->ctrl |= OHCI_PORT_LSDA;
|
||||
else
|
||||
port->ctrl &= ~OHCI_PORT_LSDA;
|
||||
port->port.dev = dev;
|
||||
/* send the attach message */
|
||||
dev->handle_packet(dev,
|
||||
USB_MSG_ATTACH, 0, 0, NULL, 0);
|
||||
dprintf("usb-ohci: Attached port %d\n", port1->index);
|
||||
} else {
|
||||
/* set connect status */
|
||||
if (port->ctrl & OHCI_PORT_CCS) {
|
||||
port->ctrl &= ~OHCI_PORT_CCS;
|
||||
port->ctrl |= OHCI_PORT_CSC;
|
||||
}
|
||||
/* disable port */
|
||||
if (port->ctrl & OHCI_PORT_PES) {
|
||||
port->ctrl &= ~OHCI_PORT_PES;
|
||||
port->ctrl |= OHCI_PORT_PESC;
|
||||
}
|
||||
dev = port->port.dev;
|
||||
if (dev) {
|
||||
/* send the detach message */
|
||||
dev->handle_packet(dev,
|
||||
USB_MSG_DETACH, 0, 0, NULL, 0);
|
||||
}
|
||||
port->port.dev = NULL;
|
||||
dprintf("usb-ohci: Detached port %d\n", port1->index);
|
||||
}
|
||||
|
||||
if (old_state != port->ctrl)
|
||||
ohci_set_interrupt(s, OHCI_INTR_RHSC);
|
||||
}
|
||||
|
||||
/* Reset the controller */
|
||||
static void ohci_reset(OHCIState *ohci)
|
||||
{
|
||||
OHCIPort *port;
|
||||
int i;
|
||||
|
||||
ohci->ctl = 0;
|
||||
ohci->status = 0;
|
||||
ohci->intr_status = 0;
|
||||
ohci->intr = OHCI_INTR_MIE;
|
||||
|
||||
|
||||
|
||||
ohci->hcca = 0;
|
||||
ohci->ctrl_head = ohci->ctrl_cur = 0;
|
||||
ohci->bulk_head = ohci->bulk_cur = 0;
|
||||
ohci->per_cur = 0;
|
||||
ohci->done = 0;
|
||||
ohci->done_count = 7;
|
||||
|
||||
/* FSMPS is marked TBD in OCHI 1.0, what gives ffs?
|
||||
* I took the value linux sets ...
|
||||
*/
|
||||
ohci->fsmps = 0x2778;
|
||||
ohci->fi = 0x2edf;
|
||||
ohci->fit = 0;
|
||||
ohci->frt = 0;
|
||||
ohci->frame_number = 0;
|
||||
ohci->pstart = 0;
|
||||
ohci->lst = OHCI_LS_THRESH;
|
||||
|
||||
ohci->rhdesc_a = OHCI_RHA_NPS | ohci->num_ports;
|
||||
ohci->rhdesc_b = 0x0; /* Impl. specific */
|
||||
ohci->rhstatus = 0;
|
||||
|
||||
for (i = 0; i < ohci->num_ports; i++)
|
||||
{
|
||||
port = &ohci->rhport[i];
|
||||
port->ctrl = 0;
|
||||
if (port->port.dev)
|
||||
ohci_attach(&port->port, port->port.dev);
|
||||
}
|
||||
dprintf("usb-ohci: Reset.\n");
|
||||
}
|
||||
|
||||
#define le32_to_cpu(x) (x)
|
||||
#define cpu_to_le32(x) (x)
|
||||
|
||||
/* Get an array of dwords from main memory */
|
||||
static inline int get_dwords(uint32_t addr, uint32_t *buf, int num)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {
|
||||
cpu_physical_memory_rw(addr, (uint8_t *)buf, sizeof(*buf), 0);
|
||||
*buf = le32_to_cpu(*buf);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Put an array of dwords in to main memory */
|
||||
static inline int put_dwords(uint32_t addr, uint32_t *buf, int num)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < num; i++, buf++, addr += sizeof(*buf)) {
|
||||
uint32_t tmp = cpu_to_le32(*buf);
|
||||
cpu_physical_memory_rw(addr, (uint8_t *)&tmp, sizeof(tmp), 1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int ohci_read_ed(uint32_t addr, struct ohci_ed *ed)
|
||||
{
|
||||
return get_dwords(addr, (uint32_t *)ed, sizeof(*ed) >> 2);
|
||||
}
|
||||
|
||||
static inline int ohci_read_td(uint32_t addr, struct ohci_td *td)
|
||||
{
|
||||
return get_dwords(addr, (uint32_t *)td, sizeof(*td) >> 2);
|
||||
}
|
||||
|
||||
static inline int ohci_put_ed(uint32_t addr, struct ohci_ed *ed)
|
||||
{
|
||||
return put_dwords(addr, (uint32_t *)ed, sizeof(*ed) >> 2);
|
||||
}
|
||||
|
||||
static inline int ohci_put_td(uint32_t addr, struct ohci_td *td)
|
||||
{
|
||||
return put_dwords(addr, (uint32_t *)td, sizeof(*td) >> 2);
|
||||
}
|
||||
|
||||
/* Read/Write the contents of a TD from/to main memory. */
|
||||
static void ohci_copy_td(struct ohci_td *td, uint8_t *buf, int len, int write)
|
||||
{
|
||||
uint32_t ptr;
|
||||
uint32_t n;
|
||||
|
||||
ptr = td->cbp;
|
||||
n = 0x1000 - (ptr & 0xfff);
|
||||
if (n > len)
|
||||
n = len;
|
||||
cpu_physical_memory_rw(ptr, buf, n, write);
|
||||
if (n == len)
|
||||
return;
|
||||
ptr = td->be & ~0xfffu;
|
||||
buf += n;
|
||||
cpu_physical_memory_rw(ptr, buf, len - n, write);
|
||||
}
|
||||
|
||||
/* Service a transport descriptor.
|
||||
Returns nonzero to terminate processing of this endpoint. */
|
||||
|
||||
static int ohci_service_td(OHCIState *ohci, struct ohci_ed *ed)
|
||||
{
|
||||
int dir;
|
||||
size_t len = 0;
|
||||
uint8_t buf[8192];
|
||||
char *str = NULL;
|
||||
int pid;
|
||||
int ret;
|
||||
int i;
|
||||
USBDevice *dev;
|
||||
struct ohci_td td;
|
||||
uint32_t addr;
|
||||
int flag_r;
|
||||
|
||||
addr = ed->head & OHCI_DPTR_MASK;
|
||||
if (!ohci_read_td(addr, &td)) {
|
||||
fprintf(stderr, "usb-ohci: TD read error at %x\n", addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
dir = OHCI_BM(ed->flags, ED_D);
|
||||
switch (dir) {
|
||||
case OHCI_TD_DIR_OUT:
|
||||
case OHCI_TD_DIR_IN:
|
||||
/* Same value. */
|
||||
break;
|
||||
default:
|
||||
dir = OHCI_BM(td.flags, TD_DP);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (dir) {
|
||||
case OHCI_TD_DIR_IN:
|
||||
str = "in";
|
||||
pid = USB_TOKEN_IN;
|
||||
break;
|
||||
case OHCI_TD_DIR_OUT:
|
||||
str = "out";
|
||||
pid = USB_TOKEN_OUT;
|
||||
break;
|
||||
case OHCI_TD_DIR_SETUP:
|
||||
str = "setup";
|
||||
pid = USB_TOKEN_SETUP;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "usb-ohci: Bad direction\n");
|
||||
return 1;
|
||||
}
|
||||
if (td.cbp && td.be) {
|
||||
if ((td.cbp & 0xfffff000) != (td.be & 0xfffff000)) {
|
||||
len = (td.be & 0xfff) + 0x1001 - (td.cbp & 0xfff);
|
||||
} else {
|
||||
len = (td.be - td.cbp) + 1;
|
||||
}
|
||||
|
||||
if (len && dir != OHCI_TD_DIR_IN) {
|
||||
ohci_copy_td(&td, buf, len, 0);
|
||||
}
|
||||
}
|
||||
|
||||
flag_r = (td.flags & OHCI_TD_R) != 0;
|
||||
#ifdef DEBUG_PACKET
|
||||
dprintf(" TD @ 0x%.8x %u bytes %s r=%d cbp=0x%.8x be=0x%.8x\n",
|
||||
addr, len, str, flag_r, td.cbp, td.be);
|
||||
|
||||
if (len >= 0 && dir != OHCI_TD_DIR_IN) {
|
||||
dprintf(" data:");
|
||||
for (i = 0; i < len; i++)
|
||||
printf(" %.2x", buf[i]);
|
||||
dprintf("\n");
|
||||
}
|
||||
#endif
|
||||
ret = USB_RET_NODEV;
|
||||
for (i = 0; i < ohci->num_ports; i++) {
|
||||
dev = ohci->rhport[i].port.dev;
|
||||
if ((ohci->rhport[i].ctrl & OHCI_PORT_PES) == 0)
|
||||
continue;
|
||||
|
||||
ret = dev->handle_packet(dev, pid, OHCI_BM(ed->flags, ED_FA),
|
||||
OHCI_BM(ed->flags, ED_EN), buf, len);
|
||||
if (ret != USB_RET_NODEV)
|
||||
break;
|
||||
}
|
||||
#ifdef DEBUG_PACKET
|
||||
dprintf("ret=%d\n", ret);
|
||||
#endif
|
||||
if (ret >= 0) {
|
||||
if (dir == OHCI_TD_DIR_IN) {
|
||||
ohci_copy_td(&td, buf, ret, 1);
|
||||
#ifdef DEBUG_PACKET
|
||||
dprintf(" data:");
|
||||
for (i = 0; i < ret; i++)
|
||||
printf(" %.2x", buf[i]);
|
||||
dprintf("\n");
|
||||
#endif
|
||||
} else {
|
||||
ret = len;
|
||||
}
|
||||
}
|
||||
|
||||
/* Writeback */
|
||||
if (ret == len || (dir == OHCI_TD_DIR_IN && ret >= 0 && flag_r)) {
|
||||
/* Transmission succeeded. */
|
||||
if (ret == len) {
|
||||
td.cbp = 0;
|
||||
} else {
|
||||
td.cbp += ret;
|
||||
if ((td.cbp & 0xfff) + ret > 0xfff) {
|
||||
td.cbp &= 0xfff;
|
||||
td.cbp |= td.be & ~0xfff;
|
||||
}
|
||||
}
|
||||
td.flags |= OHCI_TD_T1;
|
||||
td.flags ^= OHCI_TD_T0;
|
||||
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_NOERROR);
|
||||
OHCI_SET_BM(td.flags, TD_EC, 0);
|
||||
|
||||
ed->head &= ~OHCI_ED_C;
|
||||
if (td.flags & OHCI_TD_T0)
|
||||
ed->head |= OHCI_ED_C;
|
||||
} else {
|
||||
if (ret >= 0) {
|
||||
dprintf("usb-ohci: Underrun\n");
|
||||
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_DATAUNDERRUN);
|
||||
} else {
|
||||
switch (ret) {
|
||||
case USB_RET_NODEV:
|
||||
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_DEVICENOTRESPONDING);
|
||||
case USB_RET_NAK:
|
||||
dprintf("usb-ohci: got NAK\n");
|
||||
return 1;
|
||||
case USB_RET_STALL:
|
||||
dprintf("usb-ohci: got STALL\n");
|
||||
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_STALL);
|
||||
break;
|
||||
case USB_RET_BABBLE:
|
||||
dprintf("usb-ohci: got BABBLE\n");
|
||||
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_DATAOVERRUN);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "usb-ohci: Bad device response %d\n", ret);
|
||||
OHCI_SET_BM(td.flags, TD_CC, OHCI_CC_UNDEXPETEDPID);
|
||||
OHCI_SET_BM(td.flags, TD_EC, 3);
|
||||
break;
|
||||
}
|
||||
}
|
||||
ed->head |= OHCI_ED_H;
|
||||
}
|
||||
|
||||
/* Retire this TD */
|
||||
ed->head &= ~OHCI_DPTR_MASK;
|
||||
ed->head |= td.next & OHCI_DPTR_MASK;
|
||||
td.next = ohci->done;
|
||||
ohci->done = addr;
|
||||
i = OHCI_BM(td.flags, TD_DI);
|
||||
if (i < ohci->done_count)
|
||||
ohci->done_count = i;
|
||||
ohci_put_td(addr, &td);
|
||||
return OHCI_BM(td.flags, TD_CC) != OHCI_CC_NOERROR;
|
||||
}
|
||||
|
||||
/* Service an endpoint list. Returns nonzero if active TD were found. */
|
||||
static int ohci_service_ed_list(OHCIState *ohci, uint32_t head)
|
||||
{
|
||||
struct ohci_ed ed;
|
||||
uint32_t next_ed;
|
||||
uint32_t cur;
|
||||
int active;
|
||||
|
||||
active = 0;
|
||||
|
||||
if (head == 0)
|
||||
return 0;
|
||||
|
||||
for (cur = head; cur; cur = next_ed) {
|
||||
if (!ohci_read_ed(cur, &ed)) {
|
||||
fprintf(stderr, "usb-ohci: ED read error at %x\n", cur);
|
||||
return 0;
|
||||
}
|
||||
|
||||
next_ed = ed.next & OHCI_DPTR_MASK;
|
||||
|
||||
if ((ed.head & OHCI_ED_H) || (ed.flags & OHCI_ED_K))
|
||||
continue;
|
||||
|
||||
/* Skip isochronous endpoints. */
|
||||
if (ed.flags & OHCI_ED_F)
|
||||
continue;
|
||||
|
||||
while ((ed.head & OHCI_DPTR_MASK) != ed.tail) {
|
||||
#ifdef DEBUG_PACKET
|
||||
dprintf("ED @ 0x%.8x fa=%u en=%u d=%u s=%u k=%u f=%u mps=%u "
|
||||
"h=%u c=%u\n head=0x%.8x tailp=0x%.8x next=0x%.8x\n", cur,
|
||||
OHCI_BM(ed.flags, ED_FA), OHCI_BM(ed.flags, ED_EN),
|
||||
OHCI_BM(ed.flags, ED_D), (ed.flags & OHCI_ED_S)!= 0,
|
||||
(ed.flags & OHCI_ED_K) != 0, (ed.flags & OHCI_ED_F) != 0,
|
||||
OHCI_BM(ed.flags, ED_MPS), (ed.head & OHCI_ED_H) != 0,
|
||||
(ed.head & OHCI_ED_C) != 0, ed.head & OHCI_DPTR_MASK,
|
||||
ed.tail & OHCI_DPTR_MASK, ed.next & OHCI_DPTR_MASK);
|
||||
#endif
|
||||
active = 1;
|
||||
|
||||
if (ohci_service_td(ohci, &ed))
|
||||
break;
|
||||
}
|
||||
|
||||
ohci_put_ed(cur, &ed);
|
||||
}
|
||||
|
||||
return active;
|
||||
}
|
||||
|
||||
/* Generate a SOF event, and set a timer for EOF */
|
||||
static void ohci_sof(OHCIState *ohci)
|
||||
{
|
||||
ohci->sof_time = get_clock();
|
||||
ohci->eof_timer = usb_frame_time;
|
||||
ohci_set_interrupt(ohci, OHCI_INTR_SF);
|
||||
}
|
||||
|
||||
/* Do frame processing on frame boundary */
|
||||
void ohci_frame_boundary(void *opaque)
|
||||
{
|
||||
OHCIState *ohci = (OHCIState *)opaque;
|
||||
struct ohci_hcca hcca;
|
||||
|
||||
cpu_physical_memory_rw(ohci->hcca, (uint8_t *)&hcca, sizeof(hcca), 0);
|
||||
|
||||
/* Process all the lists at the end of the frame */
|
||||
if (ohci->ctl & OHCI_CTL_PLE) {
|
||||
int n;
|
||||
|
||||
n = ohci->frame_number & 0x1f;
|
||||
ohci_service_ed_list(ohci, le32_to_cpu(hcca.intr[n]));
|
||||
}
|
||||
if ((ohci->ctl & OHCI_CTL_CLE) && (ohci->status & OHCI_STATUS_CLF)) {
|
||||
if (ohci->ctrl_cur && ohci->ctrl_cur != ohci->ctrl_head)
|
||||
dprintf("usb-ohci: head %x, cur %x\n", ohci->ctrl_head, ohci->ctrl_cur);
|
||||
if (!ohci_service_ed_list(ohci, ohci->ctrl_head)) {
|
||||
ohci->ctrl_cur = 0;
|
||||
ohci->status &= ~OHCI_STATUS_CLF;
|
||||
}
|
||||
}
|
||||
|
||||
if ((ohci->ctl & OHCI_CTL_BLE) && (ohci->status & OHCI_STATUS_BLF)) {
|
||||
if (!ohci_service_ed_list(ohci, ohci->bulk_head)) {
|
||||
ohci->bulk_cur = 0;
|
||||
ohci->status &= ~OHCI_STATUS_BLF;
|
||||
}
|
||||
}
|
||||
|
||||
/* Frame boundary, so do EOF stuf here */
|
||||
ohci->frt = ohci->fit;
|
||||
|
||||
/* XXX: endianness */
|
||||
ohci->frame_number = (ohci->frame_number + 1) & 0xffff;
|
||||
hcca.frame = cpu_to_le32(ohci->frame_number);
|
||||
|
||||
if (ohci->done_count == 0 && !(ohci->intr_status & OHCI_INTR_WD)) {
|
||||
if (!ohci->done)
|
||||
abort();
|
||||
if (ohci->intr & ohci->intr_status)
|
||||
ohci->done |= 1;
|
||||
hcca.done = cpu_to_le32(ohci->done);
|
||||
ohci->done = 0;
|
||||
ohci->done_count = 7;
|
||||
ohci_set_interrupt(ohci, OHCI_INTR_WD);
|
||||
}
|
||||
|
||||
if (ohci->done_count != 7 && ohci->done_count != 0)
|
||||
ohci->done_count--;
|
||||
|
||||
/* Do SOF stuff here */
|
||||
ohci_sof(ohci);
|
||||
|
||||
/* Writeback HCCA */
|
||||
cpu_physical_memory_rw(ohci->hcca, (uint8_t *)&hcca, sizeof(hcca), 1);
|
||||
}
|
||||
|
||||
/* Start sending SOF tokens across the USB bus, lists are processed in
|
||||
* next frame
|
||||
*/
|
||||
int ohci_bus_start(OHCIState *ohci)
|
||||
{
|
||||
ohci->eof_timer = 0;
|
||||
|
||||
dprintf("usb-ohci: USB Operational\n");
|
||||
|
||||
ohci_sof(ohci);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Stop sending SOF tokens on the bus */
|
||||
void ohci_bus_stop(OHCIState *ohci)
|
||||
{
|
||||
if (ohci->eof_timer)
|
||||
ohci->eof_timer=0;
|
||||
}
|
||||
|
||||
/* Sets a flag in a port status register but only set it if the port is
|
||||
* connected, if not set ConnectStatusChange flag. If flag is enabled
|
||||
* return 1.
|
||||
*/
|
||||
static int ohci_port_set_if_connected(OHCIState *ohci, int i, uint32_t val)
|
||||
{
|
||||
int ret = 1;
|
||||
|
||||
/* writing a 0 has no effect */
|
||||
if (val == 0)
|
||||
return 0;
|
||||
|
||||
/* If CurrentConnectStatus is cleared we set
|
||||
* ConnectStatusChange
|
||||
*/
|
||||
if (!(ohci->rhport[i].ctrl & OHCI_PORT_CCS)) {
|
||||
ohci->rhport[i].ctrl |= OHCI_PORT_CSC;
|
||||
if (ohci->rhstatus & OHCI_RHS_DRWE) {
|
||||
/* TODO: CSC is a wakeup event */
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ohci->rhport[i].ctrl & val)
|
||||
ret = 0;
|
||||
|
||||
/* set the bit */
|
||||
ohci->rhport[i].ctrl |= val;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Set the frame interval - frame interval toggle is manipulated by the hcd only */
|
||||
static void ohci_set_frame_interval(OHCIState *ohci, uint16_t val)
|
||||
{
|
||||
val &= OHCI_FMI_FI;
|
||||
|
||||
if (val != ohci->fi) {
|
||||
dprintf("usb-ohci: FrameInterval = 0x%x (%u)\n", ohci->fi, ohci->fi);
|
||||
}
|
||||
|
||||
ohci->fi = val;
|
||||
}
|
||||
|
||||
static void ohci_port_power(OHCIState *ohci, int i, int p)
|
||||
{
|
||||
if (p) {
|
||||
ohci->rhport[i].ctrl |= OHCI_PORT_PPS;
|
||||
} else {
|
||||
ohci->rhport[i].ctrl &= ~(OHCI_PORT_PPS|
|
||||
OHCI_PORT_CCS|
|
||||
OHCI_PORT_PSS|
|
||||
OHCI_PORT_PRS);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set HcControlRegister */
|
||||
static void ohci_set_ctl(OHCIState *ohci, uint32_t val)
|
||||
{
|
||||
uint32_t old_state;
|
||||
uint32_t new_state;
|
||||
|
||||
old_state = ohci->ctl & OHCI_CTL_HCFS;
|
||||
ohci->ctl = val;
|
||||
new_state = ohci->ctl & OHCI_CTL_HCFS;
|
||||
|
||||
/* no state change */
|
||||
if (old_state == new_state)
|
||||
return;
|
||||
|
||||
switch (new_state) {
|
||||
case OHCI_USB_OPERATIONAL:
|
||||
ohci_bus_start(ohci);
|
||||
break;
|
||||
case OHCI_USB_SUSPEND:
|
||||
ohci_bus_stop(ohci);
|
||||
dprintf("usb-ohci: USB Suspended\n");
|
||||
break;
|
||||
case OHCI_USB_RESUME:
|
||||
dprintf("usb-ohci: USB Resume\n");
|
||||
break;
|
||||
case OHCI_USB_RESET:
|
||||
dprintf("usb-ohci: USB Reset\n");
|
||||
break;
|
||||
}
|
||||
ohci_intr_update(ohci);
|
||||
}
|
||||
|
||||
static uint32_t ohci_get_frame_remaining(OHCIState *ohci)
|
||||
{
|
||||
uint16_t fr;
|
||||
int64_t tks;
|
||||
|
||||
if ((ohci->ctl & OHCI_CTL_HCFS) != OHCI_USB_OPERATIONAL)
|
||||
return (ohci->frt << 31);
|
||||
|
||||
/* Being in USB operational state guarnatees sof_time was
|
||||
* set already.
|
||||
*/
|
||||
tks = get_clock() - ohci->sof_time;
|
||||
|
||||
/* avoid muldiv if possible */
|
||||
if (tks >= usb_frame_time)
|
||||
return (ohci->frt << 31);
|
||||
|
||||
tks = muldiv64(1, tks, usb_bit_time);
|
||||
fr = (uint16_t)(ohci->fi - tks);
|
||||
|
||||
return (ohci->frt << 31) | fr;
|
||||
}
|
||||
|
||||
|
||||
/* Set root hub status */
|
||||
static void ohci_set_hub_status(OHCIState *ohci, uint32_t val)
|
||||
{
|
||||
uint32_t old_state;
|
||||
|
||||
old_state = ohci->rhstatus;
|
||||
|
||||
/* write 1 to clear OCIC */
|
||||
if (val & OHCI_RHS_OCIC)
|
||||
ohci->rhstatus &= ~OHCI_RHS_OCIC;
|
||||
|
||||
if (val & OHCI_RHS_LPS) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ohci->num_ports; i++)
|
||||
ohci_port_power(ohci, i, 0);
|
||||
dprintf("usb-ohci: powered down all ports\n");
|
||||
}
|
||||
|
||||
if (val & OHCI_RHS_LPSC) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ohci->num_ports; i++)
|
||||
ohci_port_power(ohci, i, 1);
|
||||
dprintf("usb-ohci: powered up all ports\n");
|
||||
}
|
||||
|
||||
if (val & OHCI_RHS_DRWE)
|
||||
ohci->rhstatus |= OHCI_RHS_DRWE;
|
||||
|
||||
if (val & OHCI_RHS_CRWE)
|
||||
ohci->rhstatus &= ~OHCI_RHS_DRWE;
|
||||
|
||||
if (old_state != ohci->rhstatus)
|
||||
ohci_set_interrupt(ohci, OHCI_INTR_RHSC);
|
||||
}
|
||||
|
||||
/* Set root hub port status */
|
||||
static void ohci_port_set_status(OHCIState *ohci, int portnum, uint32_t val)
|
||||
{
|
||||
uint32_t old_state;
|
||||
OHCIPort *port;
|
||||
|
||||
port = &ohci->rhport[portnum];
|
||||
old_state = port->ctrl;
|
||||
|
||||
/* Write to clear CSC, PESC, PSSC, OCIC, PRSC */
|
||||
if (val & OHCI_PORT_WTC)
|
||||
port->ctrl &= ~(val & OHCI_PORT_WTC);
|
||||
|
||||
if (val & OHCI_PORT_CCS)
|
||||
port->ctrl &= ~OHCI_PORT_PES;
|
||||
|
||||
ohci_port_set_if_connected(ohci, portnum, val & OHCI_PORT_PES);
|
||||
|
||||
if (ohci_port_set_if_connected(ohci, portnum, val & OHCI_PORT_PSS))
|
||||
dprintf("usb-ohci: port %d: SUSPEND\n", portnum);
|
||||
|
||||
if (ohci_port_set_if_connected(ohci, portnum, val & OHCI_PORT_PRS)) {
|
||||
dprintf("usb-ohci: port %d: RESET\n", portnum);
|
||||
port->port.dev->handle_packet(port->port.dev, USB_MSG_RESET,
|
||||
0, 0, NULL, 0);
|
||||
port->ctrl &= ~OHCI_PORT_PRS;
|
||||
/* ??? Should this also set OHCI_PORT_PESC. */
|
||||
port->ctrl |= OHCI_PORT_PES | OHCI_PORT_PRSC;
|
||||
}
|
||||
|
||||
/* Invert order here to ensure in ambiguous case, device is
|
||||
* powered up...
|
||||
*/
|
||||
if (val & OHCI_PORT_LSDA)
|
||||
ohci_port_power(ohci, portnum, 0);
|
||||
if (val & OHCI_PORT_PPS)
|
||||
ohci_port_power(ohci, portnum, 1);
|
||||
|
||||
if (old_state != port->ctrl)
|
||||
ohci_set_interrupt(ohci, OHCI_INTR_RHSC);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t ohci_mem_read(OHCIState *ptr, uint32_t addr)
|
||||
{
|
||||
OHCIState *ohci = ptr;
|
||||
|
||||
addr -= ohci->mem_base;
|
||||
|
||||
/* Only aligned reads are allowed on OHCI */
|
||||
if (addr & 3) {
|
||||
fprintf(stderr, "usb-ohci: Mis-aligned read\n");
|
||||
return 0xffffffff;
|
||||
}
|
||||
|
||||
if (addr >= 0x54 && addr < 0x54 + ohci->num_ports * 4) {
|
||||
/* HcRhPortStatus */
|
||||
return ohci->rhport[(addr - 0x54) >> 2].ctrl | OHCI_PORT_PPS;
|
||||
}
|
||||
|
||||
switch (addr >> 2) {
|
||||
case 0: /* HcRevision */
|
||||
return 0x10;
|
||||
|
||||
case 1: /* HcControl */
|
||||
return ohci->ctl;
|
||||
|
||||
case 2: /* HcCommandStatus */
|
||||
return ohci->status;
|
||||
|
||||
case 3: /* HcInterruptStatus */
|
||||
return ohci->intr_status;
|
||||
|
||||
case 4: /* HcInterruptEnable */
|
||||
case 5: /* HcInterruptDisable */
|
||||
return ohci->intr;
|
||||
|
||||
case 6: /* HcHCCA */
|
||||
return ohci->hcca;
|
||||
|
||||
case 7: /* HcPeriodCurrentED */
|
||||
return ohci->per_cur;
|
||||
|
||||
case 8: /* HcControlHeadED */
|
||||
return ohci->ctrl_head;
|
||||
|
||||
case 9: /* HcControlCurrentED */
|
||||
return ohci->ctrl_cur;
|
||||
|
||||
case 10: /* HcBulkHeadED */
|
||||
return ohci->bulk_head;
|
||||
|
||||
case 11: /* HcBulkCurrentED */
|
||||
return ohci->bulk_cur;
|
||||
|
||||
case 12: /* HcDoneHead */
|
||||
return ohci->done;
|
||||
|
||||
case 13: /* HcFmInterval */
|
||||
return (ohci->fit << 31) | (ohci->fsmps << 16) | (ohci->fi);
|
||||
|
||||
case 14: /* HcFmRemaining */
|
||||
return ohci_get_frame_remaining(ohci);
|
||||
|
||||
case 15: /* HcFmNumber */
|
||||
return ohci->frame_number;
|
||||
|
||||
case 16: /* HcPeriodicStart */
|
||||
return ohci->pstart;
|
||||
|
||||
case 17: /* HcLSThreshold */
|
||||
return ohci->lst;
|
||||
|
||||
case 18: /* HcRhDescriptorA */
|
||||
return ohci->rhdesc_a;
|
||||
|
||||
case 19: /* HcRhDescriptorB */
|
||||
return ohci->rhdesc_b;
|
||||
|
||||
case 20: /* HcRhStatus */
|
||||
return ohci->rhstatus;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "ohci_read: Bad offset %x\n", (int)addr);
|
||||
return 0xffffffff;
|
||||
}
|
||||
}
|
||||
|
||||
void ohci_mem_write(OHCIState *ptr,uint32_t addr, uint32_t val)
|
||||
{
|
||||
OHCIState *ohci = ptr;
|
||||
|
||||
addr -= ohci->mem_base;
|
||||
|
||||
/* Only aligned reads are allowed on OHCI */
|
||||
if (addr & 3) {
|
||||
fprintf(stderr, "usb-ohci: Mis-aligned write\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((addr >= 0x54) && (addr < (0x54 + ohci->num_ports * 4))) {
|
||||
/* HcRhPortStatus */
|
||||
ohci_port_set_status(ohci, (addr - 0x54) >> 2, val);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (addr >> 2) {
|
||||
case 1: /* HcControl */
|
||||
ohci_set_ctl(ohci, val);
|
||||
break;
|
||||
|
||||
case 2: /* HcCommandStatus */
|
||||
/* SOC is read-only */
|
||||
val = (val & ~OHCI_STATUS_SOC);
|
||||
|
||||
/* Bits written as '0' remain unchanged in the register */
|
||||
ohci->status |= val;
|
||||
|
||||
if (ohci->status & OHCI_STATUS_HCR)
|
||||
ohci_reset(ohci);
|
||||
break;
|
||||
|
||||
case 3: /* HcInterruptStatus */
|
||||
ohci->intr_status &= ~val;
|
||||
ohci_intr_update(ohci);
|
||||
break;
|
||||
|
||||
case 4: /* HcInterruptEnable */
|
||||
ohci->intr |= val;
|
||||
ohci_intr_update(ohci);
|
||||
break;
|
||||
|
||||
case 5: /* HcInterruptDisable */
|
||||
ohci->intr &= ~val;
|
||||
ohci_intr_update(ohci);
|
||||
break;
|
||||
|
||||
case 6: /* HcHCCA */
|
||||
ohci->hcca = val & OHCI_HCCA_MASK;
|
||||
break;
|
||||
|
||||
case 8: /* HcControlHeadED */
|
||||
ohci->ctrl_head = val & OHCI_EDPTR_MASK;
|
||||
break;
|
||||
|
||||
case 9: /* HcControlCurrentED */
|
||||
ohci->ctrl_cur = val & OHCI_EDPTR_MASK;
|
||||
break;
|
||||
|
||||
case 10: /* HcBulkHeadED */
|
||||
ohci->bulk_head = val & OHCI_EDPTR_MASK;
|
||||
break;
|
||||
|
||||
case 11: /* HcBulkCurrentED */
|
||||
ohci->bulk_cur = val & OHCI_EDPTR_MASK;
|
||||
break;
|
||||
|
||||
case 13: /* HcFmInterval */
|
||||
ohci->fsmps = (val & OHCI_FMI_FSMPS) >> 16;
|
||||
ohci->fit = (val & OHCI_FMI_FIT) >> 31;
|
||||
ohci_set_frame_interval(ohci, val);
|
||||
break;
|
||||
|
||||
case 16: /* HcPeriodicStart */
|
||||
ohci->pstart = val & 0xffff;
|
||||
break;
|
||||
|
||||
case 17: /* HcLSThreshold */
|
||||
ohci->lst = val & 0xffff;
|
||||
break;
|
||||
|
||||
case 18: /* HcRhDescriptorA */
|
||||
ohci->rhdesc_a &= ~OHCI_RHA_RW_MASK;
|
||||
ohci->rhdesc_a |= val & OHCI_RHA_RW_MASK;
|
||||
break;
|
||||
|
||||
case 19: /* HcRhDescriptorB */
|
||||
break;
|
||||
|
||||
case 20: /* HcRhStatus */
|
||||
ohci_set_hub_status(ohci, val);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "ohci_write: Bad offset %x\n", (int)addr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
OHCIState *ohci_create(uint32_t base, int ports)
|
||||
{
|
||||
OHCIState *ohci=(OHCIState*)malloc(sizeof(OHCIState));
|
||||
int i;
|
||||
|
||||
const int ticks_per_sec = PSXCLK;
|
||||
|
||||
memset(ohci,0,sizeof(OHCIState));
|
||||
|
||||
ohci->mem_base=base;
|
||||
|
||||
if (usb_frame_time == 0) {
|
||||
#if OHCI_TIME_WARP
|
||||
usb_frame_time = ticks_per_sec;
|
||||
usb_bit_time = muldiv64(1, ticks_per_sec, USB_HZ/1000);
|
||||
#else
|
||||
usb_frame_time = muldiv64(1, ticks_per_sec, 1000);
|
||||
if (ticks_per_sec >= USB_HZ) {
|
||||
usb_bit_time = muldiv64(1, ticks_per_sec, USB_HZ);
|
||||
} else {
|
||||
usb_bit_time = 1;
|
||||
}
|
||||
#endif
|
||||
dprintf("usb-ohci: usb_bit_time=%lli usb_frame_time=%lli\n",
|
||||
usb_frame_time, usb_bit_time);
|
||||
}
|
||||
|
||||
ohci->num_ports = ports;
|
||||
for (i = 0; i < ports; i++) {
|
||||
ohci->rhport[i].port.opaque = ohci;
|
||||
ohci->rhport[i].port.index = i;
|
||||
ohci->rhport[i].port.attach = ohci_attach;
|
||||
}
|
||||
|
||||
ohci_reset(ohci);
|
||||
|
||||
return ohci;
|
||||
}
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* QEMU USB API
|
||||
*
|
||||
* Copyright (c) 2005 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#define USB_TOKEN_SETUP 0x2d
|
||||
#define USB_TOKEN_IN 0x69 /* device -> host */
|
||||
#define USB_TOKEN_OUT 0xe1 /* host -> device */
|
||||
|
||||
/* specific usb messages, also sent in the 'pid' parameter */
|
||||
#define USB_MSG_ATTACH 0x100
|
||||
#define USB_MSG_DETACH 0x101
|
||||
#define USB_MSG_RESET 0x102
|
||||
|
||||
#define USB_RET_NODEV (-1)
|
||||
#define USB_RET_NAK (-2)
|
||||
#define USB_RET_STALL (-3)
|
||||
#define USB_RET_BABBLE (-4)
|
||||
|
||||
#define USB_SPEED_LOW 0
|
||||
#define USB_SPEED_FULL 1
|
||||
#define USB_SPEED_HIGH 2
|
||||
|
||||
#define USB_STATE_NOTATTACHED 0
|
||||
#define USB_STATE_ATTACHED 1
|
||||
//#define USB_STATE_POWERED 2
|
||||
#define USB_STATE_DEFAULT 3
|
||||
//#define USB_STATE_ADDRESS 4
|
||||
//#define USB_STATE_CONFIGURED 5
|
||||
#define USB_STATE_SUSPENDED 6
|
||||
|
||||
#define USB_CLASS_AUDIO 1
|
||||
#define USB_CLASS_COMM 2
|
||||
#define USB_CLASS_HID 3
|
||||
#define USB_CLASS_PHYSICAL 5
|
||||
#define USB_CLASS_STILL_IMAGE 6
|
||||
#define USB_CLASS_PRINTER 7
|
||||
#define USB_CLASS_MASS_STORAGE 8
|
||||
#define USB_CLASS_HUB 9
|
||||
#define USB_CLASS_CDC_DATA 0x0a
|
||||
#define USB_CLASS_CSCID 0x0b
|
||||
#define USB_CLASS_CONTENT_SEC 0x0d
|
||||
#define USB_CLASS_APP_SPEC 0xfe
|
||||
#define USB_CLASS_VENDOR_SPEC 0xff
|
||||
|
||||
#define USB_DIR_OUT 0
|
||||
#define USB_DIR_IN 0x80
|
||||
|
||||
#define USB_TYPE_MASK (0x03 << 5)
|
||||
#define USB_TYPE_STANDARD (0x00 << 5)
|
||||
#define USB_TYPE_CLASS (0x01 << 5)
|
||||
#define USB_TYPE_VENDOR (0x02 << 5)
|
||||
#define USB_TYPE_RESERVED (0x03 << 5)
|
||||
|
||||
#define USB_RECIP_MASK 0x1f
|
||||
#define USB_RECIP_DEVICE 0x00
|
||||
#define USB_RECIP_INTERFACE 0x01
|
||||
#define USB_RECIP_ENDPOINT 0x02
|
||||
#define USB_RECIP_OTHER 0x03
|
||||
|
||||
#define DeviceRequest ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)
|
||||
#define DeviceOutRequest ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)
|
||||
#define InterfaceRequest \
|
||||
((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
|
||||
#define InterfaceOutRequest \
|
||||
((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
|
||||
#define EndpointRequest ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_ENDPOINT)<<8)
|
||||
#define EndpointOutRequest \
|
||||
((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_ENDPOINT)<<8)
|
||||
|
||||
#define USB_REQ_GET_STATUS 0x00
|
||||
#define USB_REQ_CLEAR_FEATURE 0x01
|
||||
#define USB_REQ_SET_FEATURE 0x03
|
||||
#define USB_REQ_SET_ADDRESS 0x05
|
||||
#define USB_REQ_GET_DESCRIPTOR 0x06
|
||||
#define USB_REQ_SET_DESCRIPTOR 0x07
|
||||
#define USB_REQ_GET_CONFIGURATION 0x08
|
||||
#define USB_REQ_SET_CONFIGURATION 0x09
|
||||
#define USB_REQ_GET_INTERFACE 0x0A
|
||||
#define USB_REQ_SET_INTERFACE 0x0B
|
||||
#define USB_REQ_SYNCH_FRAME 0x0C
|
||||
|
||||
#define USB_DEVICE_SELF_POWERED 0
|
||||
#define USB_DEVICE_REMOTE_WAKEUP 1
|
||||
|
||||
#define USB_DT_DEVICE 0x01
|
||||
#define USB_DT_CONFIG 0x02
|
||||
#define USB_DT_STRING 0x03
|
||||
#define USB_DT_INTERFACE 0x04
|
||||
#define USB_DT_ENDPOINT 0x05
|
||||
#define USB_DT_CLASS 0x24
|
||||
|
||||
typedef struct USBPort USBPort;
|
||||
typedef struct USBDevice USBDevice;
|
||||
|
||||
/* definition of a USB device */
|
||||
struct USBDevice {
|
||||
void *opaque;
|
||||
int (*handle_packet)(USBDevice *dev, int pid,
|
||||
uint8_t devaddr, uint8_t devep,
|
||||
uint8_t *data, int len);
|
||||
void (*handle_destroy)(USBDevice *dev);
|
||||
|
||||
int speed;
|
||||
|
||||
/* The following fields are used by the generic USB device
|
||||
layer. They are here just to avoid creating a new structure for
|
||||
them. */
|
||||
void (*handle_reset)(USBDevice *dev);
|
||||
int (*handle_control)(USBDevice *dev, int request, int value,
|
||||
int index, int length, uint8_t *data);
|
||||
int (*handle_data)(USBDevice *dev, int pid, uint8_t devep,
|
||||
uint8_t *data, int len);
|
||||
uint8_t addr;
|
||||
char devname[32];
|
||||
|
||||
int state;
|
||||
uint8_t setup_buf[8];
|
||||
uint8_t data_buf[1024];
|
||||
int remote_wakeup;
|
||||
int setup_state;
|
||||
int setup_len;
|
||||
int setup_index;
|
||||
};
|
||||
|
||||
typedef void (*usb_attachfn)(USBPort *port, USBDevice *dev);
|
||||
|
||||
/* USB port on which a device can be connected */
|
||||
struct USBPort {
|
||||
USBDevice *dev;
|
||||
usb_attachfn attach;
|
||||
void *opaque;
|
||||
int index; /* internal port index, may be used with the opaque */
|
||||
struct USBPort *next; /* Used internally by qemu. */
|
||||
};
|
||||
|
||||
void usb_attach(USBPort *port, USBDevice *dev);
|
||||
int usb_generic_handle_packet(USBDevice *s, int pid,
|
||||
uint8_t devaddr, uint8_t devep,
|
||||
uint8_t *data, int len);
|
||||
int set_usb_string(uint8_t *buf, const char *str);
|
||||
|
||||
/* usb hub */
|
||||
USBDevice *usb_hub_init(int nb_ports);
|
||||
|
||||
/* usb-ohci.c */
|
||||
void usb_ohci_init(void *bus, int num_ports, int devfn);
|
||||
|
||||
/* usb-hid.c */
|
||||
USBDevice *usb_mouse_init(void);
|
||||
|
||||
/* usb-kbd.c */
|
||||
USBDevice *usb_keyboard_init(void);
|
||||
|
||||
/* usb-msd.c */
|
||||
USBDevice *usb_msd_init(const char *filename);
|
|
@ -0,0 +1,42 @@
|
|||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
#include <malloc.h>
|
||||
#include "vl.h"
|
||||
|
||||
void cpu_physical_memory_rw(uint32_t addr, uint8_t *buf,
|
||||
int len, int is_write);
|
||||
|
||||
static inline void cpu_physical_memory_read(uint32_t addr,
|
||||
uint8_t *buf, int len)
|
||||
{
|
||||
cpu_physical_memory_rw(addr, buf, len, 0);
|
||||
}
|
||||
static inline void cpu_physical_memory_write(uint32_t addr,
|
||||
const uint8_t *buf, int len)
|
||||
{
|
||||
cpu_physical_memory_rw(addr, (uint8_t *)buf, len, 1);
|
||||
}
|
||||
|
||||
/* compute with 96 bit intermediate result: (a*b)/c */
|
||||
uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
|
||||
{
|
||||
union {
|
||||
uint64_t ll;
|
||||
struct {
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
uint32_t high, low;
|
||||
#else
|
||||
uint32_t low, high;
|
||||
#endif
|
||||
} l;
|
||||
} u, res;
|
||||
uint64_t rl, rh;
|
||||
|
||||
u.ll = a;
|
||||
rl = (uint64_t)u.l.low * (uint64_t)b;
|
||||
rh = (uint64_t)u.l.high * (uint64_t)b;
|
||||
rh += (rl >> 32);
|
||||
res.l.high = rh / c;
|
||||
res.l.low = (((rh % c) << 32) + (rl & 0xffffffff)) / c;
|
||||
return res.ll;
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* QEMU System Emulator header
|
||||
*
|
||||
* Copyright (c) 2003 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#ifndef VL_H
|
||||
#define VL_H
|
||||
|
||||
/* we put basic includes here to avoid repeating them in device drivers */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
|
||||
typedef signed __int8 int8_t;
|
||||
typedef signed __int16 int16_t;
|
||||
typedef signed __int32 int32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
#include <limits.h>
|
||||
#include <time.h>
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define inline __inline
|
||||
|
||||
#ifndef O_LARGEFILE
|
||||
#define O_LARGEFILE 0
|
||||
#endif
|
||||
#ifndef O_BINARY
|
||||
#define O_BINARY 0
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#define fsync _commit
|
||||
#define lseek _lseeki64
|
||||
#define ENOTSUP 4096
|
||||
extern int qemu_ftruncate64(int, int64_t);
|
||||
#define ftruncate qemu_ftruncate64
|
||||
|
||||
|
||||
static inline char *realpath(const char *path, char *resolved_path)
|
||||
{
|
||||
_fullpath(resolved_path, path, _MAX_PATH);
|
||||
return resolved_path;
|
||||
}
|
||||
|
||||
#define PRId64 "I64d"
|
||||
#define PRIx64 "I64x"
|
||||
#define PRIu64 "I64u"
|
||||
#define PRIo64 "I64o"
|
||||
#endif
|
||||
|
||||
#include "usb.h"
|
||||
|
||||
#ifndef glue
|
||||
#define xglue(x, y) x ## y
|
||||
#define glue(x, y) xglue(x, y)
|
||||
#define stringify(s) tostring(s)
|
||||
#define tostring(s) #s
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
|
||||
#endif
|
||||
#ifndef MAX
|
||||
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
/* vl.c */
|
||||
uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
|
||||
void cpu_physical_memory_rw(uint32_t addr, uint8_t *buf, int len, int is_write);
|
||||
static inline void cpu_physical_memory_read(uint32_t addr, uint8_t *buf, int len);
|
||||
static inline void cpu_physical_memory_write(uint32_t addr, const uint8_t *buf, int len);
|
||||
void *qemu_mallocz(uint32_t size);
|
||||
|
||||
#endif /* VL_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,30 @@
|
|||
/*----------------------------------------------------------------------------
|
||||
* U S B - K e r n e l
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: ADCUSER.H
|
||||
* Purpose: Audio Device Class Custom User Definitions
|
||||
* Version: V1.10
|
||||
*----------------------------------------------------------------------------
|
||||
* This software is supplied "AS IS" without any warranties, express,
|
||||
* implied or statutory, including but not limited to the implied
|
||||
* warranties of fitness for purpose, satisfactory quality and
|
||||
* noninfringement. Keil extends you a royalty-free right to reproduce
|
||||
* and distribute executable files created using this software for use
|
||||
* on Philips LPC2xxx microcontroller devices only. Nothing else gives
|
||||
* you the right to use this software.
|
||||
*
|
||||
* Copyright (c) 2005-2006 Keil Software.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __ADCUSER_H__
|
||||
#define __ADCUSER_H__
|
||||
|
||||
|
||||
/* Audio Device Class Requests Callback Functions */
|
||||
extern BOOL ADC_IF_GetRequest (void);
|
||||
extern BOOL ADC_IF_SetRequest (void);
|
||||
extern BOOL ADC_EP_GetRequest (void);
|
||||
extern BOOL ADC_EP_SetRequest (void);
|
||||
|
||||
|
||||
#endif /* __ADCUSER_H__ */
|
|
@ -0,0 +1,372 @@
|
|||
/*----------------------------------------------------------------------------
|
||||
* U S B - K e r n e l
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: AUDIO.H
|
||||
* Purpose: USB Audio Device Class Definitions
|
||||
* Version: V1.10
|
||||
*----------------------------------------------------------------------------
|
||||
* This software is supplied "AS IS" without any warranties, express,
|
||||
* implied or statutory, including but not limited to the implied
|
||||
* warranties of fitness for purpose, satisfactory quality and
|
||||
* noninfringement. Keil extends you a royalty-free right to reproduce
|
||||
* and distribute executable files created using this software for use
|
||||
* on Philips LPC2xxx microcontroller devices only. Nothing else gives
|
||||
* you the right to use this software.
|
||||
*
|
||||
* Copyright (c) 2005-2006 Keil Software.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __AUDIO_H__
|
||||
#define __AUDIO_H__
|
||||
|
||||
|
||||
/* Audio Interface Subclass Codes */
|
||||
#define AUDIO_SUBCLASS_UNDEFINED 0x00
|
||||
#define AUDIO_SUBCLASS_AUDIOCONTROL 0x01
|
||||
#define AUDIO_SUBCLASS_AUDIOSTREAMING 0x02
|
||||
#define AUDIO_SUBCLASS_MIDISTREAMING 0x03
|
||||
|
||||
/* Audio Interface Protocol Codes */
|
||||
#define AUDIO_PROTOCOL_UNDEFINED 0x00
|
||||
|
||||
|
||||
/* Audio Descriptor Types */
|
||||
#define AUDIO_UNDEFINED_DESCRIPTOR_TYPE 0x20
|
||||
#define AUDIO_DEVICE_DESCRIPTOR_TYPE 0x21
|
||||
#define AUDIO_CONFIGURATION_DESCRIPTOR_TYPE 0x22
|
||||
#define AUDIO_STRING_DESCRIPTOR_TYPE 0x23
|
||||
#define AUDIO_INTERFACE_DESCRIPTOR_TYPE 0x24
|
||||
#define AUDIO_ENDPOINT_DESCRIPTOR_TYPE 0x25
|
||||
|
||||
|
||||
/* Audio Control Interface Descriptor Subtypes */
|
||||
#define AUDIO_CONTROL_UNDEFINED 0x00
|
||||
#define AUDIO_CONTROL_HEADER 0x01
|
||||
#define AUDIO_CONTROL_INPUT_TERMINAL 0x02
|
||||
#define AUDIO_CONTROL_OUTPUT_TERMINAL 0x03
|
||||
#define AUDIO_CONTROL_MIXER_UNIT 0x04
|
||||
#define AUDIO_CONTROL_SELECTOR_UNIT 0x05
|
||||
#define AUDIO_CONTROL_FEATURE_UNIT 0x06
|
||||
#define AUDIO_CONTROL_PROCESSING_UNIT 0x07
|
||||
#define AUDIO_CONTROL_EXTENSION_UNIT 0x08
|
||||
|
||||
/* Audio Streaming Interface Descriptor Subtypes */
|
||||
#define AUDIO_STREAMING_UNDEFINED 0x00
|
||||
#define AUDIO_STREAMING_GENERAL 0x01
|
||||
#define AUDIO_STREAMING_FORMAT_TYPE 0x02
|
||||
#define AUDIO_STREAMING_FORMAT_SPECIFIC 0x03
|
||||
|
||||
/* Audio Endpoint Descriptor Subtypes */
|
||||
#define AUDIO_ENDPOINT_UNDEFINED 0x00
|
||||
#define AUDIO_ENDPOINT_GENERAL 0x01
|
||||
|
||||
|
||||
/* Audio Descriptor Sizes */
|
||||
#define AUDIO_CONTROL_INTERFACE_DESC_SZ(n) 0x08+n
|
||||
#define AUDIO_STREAMING_INTERFACE_DESC_SIZE 0x07
|
||||
#define AUDIO_INPUT_TERMINAL_DESC_SIZE 0x0C
|
||||
#define AUDIO_OUTPUT_TERMINAL_DESC_SIZE 0x09
|
||||
#define AUDIO_MIXER_UNIT_DESC_SZ(p,n) 0x0A+p+n
|
||||
#define AUDIO_SELECTOR_UNIT_DESC_SZ(p) 0x06+p
|
||||
#define AUDIO_FEATURE_UNIT_DESC_SZ(ch,n) 0x07+(ch+1)*n
|
||||
#define AUDIO_PROCESSING_UNIT_DESC_SZ(p,n,x) 0x0D+p+n+x
|
||||
#define AUDIO_EXTENSION_UNIT_DESC_SZ(p,n) 0x0D+p+n
|
||||
#define AUDIO_STANDARD_ENDPOINT_DESC_SIZE 0x09
|
||||
#define AUDIO_STREAMING_ENDPOINT_DESC_SIZE 0x07
|
||||
|
||||
|
||||
/* Audio Processing Unit Process Types */
|
||||
#define AUDIO_UNDEFINED_PROCESS 0x00
|
||||
#define AUDIO_UP_DOWN_MIX_PROCESS 0x01
|
||||
#define AUDIO_DOLBY_PROLOGIC_PROCESS 0x02
|
||||
#define AUDIO_3D_STEREO_PROCESS 0x03
|
||||
#define AUDIO_REVERBERATION_PROCESS 0x04
|
||||
#define AUDIO_CHORUS_PROCESS 0x05
|
||||
#define AUDIO_DYN_RANGE_COMP_PROCESS 0x06
|
||||
|
||||
|
||||
/* Audio Request Codes */
|
||||
#define AUDIO_REQUEST_UNDEFINED 0x00
|
||||
#define AUDIO_REQUEST_SET_CUR 0x01
|
||||
#define AUDIO_REQUEST_GET_CUR 0x81
|
||||
#define AUDIO_REQUEST_SET_MIN 0x02
|
||||
#define AUDIO_REQUEST_GET_MIN 0x82
|
||||
#define AUDIO_REQUEST_SET_MAX 0x03
|
||||
#define AUDIO_REQUEST_GET_MAX 0x83
|
||||
#define AUDIO_REQUEST_SET_RES 0x04
|
||||
#define AUDIO_REQUEST_GET_RES 0x84
|
||||
#define AUDIO_REQUEST_SET_MEM 0x05
|
||||
#define AUDIO_REQUEST_GET_MEM 0x85
|
||||
#define AUDIO_REQUEST_GET_STAT 0xFF
|
||||
|
||||
|
||||
/* Audio Control Selector Codes */
|
||||
#define AUDIO_CONTROL_UNDEFINED 0x00 /* Common Selector */
|
||||
|
||||
/* Terminal Control Selectors */
|
||||
#define AUDIO_COPY_PROTECT_CONTROL 0x01
|
||||
|
||||
/* Feature Unit Control Selectors */
|
||||
#define AUDIO_MUTE_CONTROL 0x01
|
||||
#define AUDIO_VOLUME_CONTROL 0x02
|
||||
#define AUDIO_BASS_CONTROL 0x03
|
||||
#define AUDIO_MID_CONTROL 0x04
|
||||
#define AUDIO_TREBLE_CONTROL 0x05
|
||||
#define AUDIO_GRAPHIC_EQUALIZER_CONTROL 0x06
|
||||
#define AUDIO_AUTOMATIC_GAIN_CONTROL 0x07
|
||||
#define AUDIO_DELAY_CONTROL 0x08
|
||||
#define AUDIO_BASS_BOOST_CONTROL 0x09
|
||||
#define AUDIO_LOUDNESS_CONTROL 0x0A
|
||||
|
||||
/* Processing Unit Control Selectors: */
|
||||
#define AUDIO_ENABLE_CONTROL 0x01 /* Common Selector */
|
||||
#define AUDIO_MODE_SELECT_CONTROL 0x02 /* Common Selector */
|
||||
|
||||
/* - Up/Down-mix Control Selectors */
|
||||
/* AUDIO_ENABLE_CONTROL 0x01 Common Selector */
|
||||
/* AUDIO_MODE_SELECT_CONTROL 0x02 Common Selector */
|
||||
|
||||
/* - Dolby Prologic Control Selectors */
|
||||
/* AUDIO_ENABLE_CONTROL 0x01 Common Selector */
|
||||
/* AUDIO_MODE_SELECT_CONTROL 0x02 Common Selector */
|
||||
|
||||
/* - 3D Stereo Extender Control Selectors */
|
||||
/* AUDIO_ENABLE_CONTROL 0x01 Common Selector */
|
||||
#define AUDIO_SPACIOUSNESS_CONTROL 0x02
|
||||
|
||||
/* - Reverberation Control Selectors */
|
||||
/* AUDIO_ENABLE_CONTROL 0x01 Common Selector */
|
||||
#define AUDIO_REVERB_LEVEL_CONTROL 0x02
|
||||
#define AUDIO_REVERB_TIME_CONTROL 0x03
|
||||
#define AUDIO_REVERB_FEEDBACK_CONTROL 0x04
|
||||
|
||||
/* - Chorus Control Selectors */
|
||||
/* AUDIO_ENABLE_CONTROL 0x01 Common Selector */
|
||||
#define AUDIO_CHORUS_LEVEL_CONTROL 0x02
|
||||
#define AUDIO_SHORUS_RATE_CONTROL 0x03
|
||||
#define AUDIO_CHORUS_DEPTH_CONTROL 0x04
|
||||
|
||||
/* - Dynamic Range Compressor Control Selectors */
|
||||
/* AUDIO_ENABLE_CONTROL 0x01 Common Selector */
|
||||
#define AUDIO_COMPRESSION_RATE_CONTROL 0x02
|
||||
#define AUDIO_MAX_AMPL_CONTROL 0x03
|
||||
#define AUDIO_THRESHOLD_CONTROL 0x04
|
||||
#define AUDIO_ATTACK_TIME_CONTROL 0x05
|
||||
#define AUDIO_RELEASE_TIME_CONTROL 0x06
|
||||
|
||||
/* Extension Unit Control Selectors */
|
||||
/* AUDIO_ENABLE_CONTROL 0x01 Common Selector */
|
||||
|
||||
/* Endpoint Control Selectors */
|
||||
#define AUDIO_SAMPLING_FREQ_CONTROL 0x01
|
||||
#define AUDIO_PITCH_CONTROL 0x02
|
||||
|
||||
|
||||
/* Audio Format Specific Control Selectors */
|
||||
|
||||
/* MPEG Control Selectors */
|
||||
#define AUDIO_MPEG_CONTROL_UNDEFINED 0x00
|
||||
#define AUDIO_MPEG_DUAL_CHANNEL_CONTROL 0x01
|
||||
#define AUDIO_MPEG_SECOND_STEREO_CONTROL 0x02
|
||||
#define AUDIO_MPEG_MULTILINGUAL_CONTROL 0x03
|
||||
#define AUDIO_MPEG_DYN_RANGE_CONTROL 0x04
|
||||
#define AUDIO_MPEG_SCALING_CONTROL 0x05
|
||||
#define AUDIO_MPEG_HILO_SCALING_CONTROL 0x06
|
||||
|
||||
/* AC-3 Control Selectors */
|
||||
#define AUDIO_AC3_CONTROL_UNDEFINED 0x00
|
||||
#define AUDIO_AC3_MODE_CONTROL 0x01
|
||||
#define AUDIO_AC3_DYN_RANGE_CONTROL 0x02
|
||||
#define AUDIO_AC3_SCALING_CONTROL 0x03
|
||||
#define AUDIO_AC3_HILO_SCALING_CONTROL 0x04
|
||||
|
||||
|
||||
/* Audio Format Types */
|
||||
#define AUDIO_FORMAT_TYPE_UNDEFINED 0x00
|
||||
#define AUDIO_FORMAT_TYPE_I 0x01
|
||||
#define AUDIO_FORMAT_TYPE_II 0x02
|
||||
#define AUDIO_FORMAT_TYPE_III 0x03
|
||||
|
||||
|
||||
/* Audio Format Type Descriptor Sizes */
|
||||
#define AUDIO_FORMAT_TYPE_I_DESC_SZ(n) 0x08+(n*3)
|
||||
#define AUDIO_FORMAT_TYPE_II_DESC_SZ(n) 0x09+(n*3)
|
||||
#define AUDIO_FORMAT_TYPE_III_DESC_SZ(n) 0x08+(n*3)
|
||||
#define AUDIO_FORMAT_MPEG_DESC_SIZE 0x09
|
||||
#define AUDIO_FORMAT_AC3_DESC_SIZE 0x0A
|
||||
|
||||
|
||||
/* Audio Data Format Codes */
|
||||
|
||||
/* Audio Data Format Type I Codes */
|
||||
#define AUDIO_FORMAT_TYPE_I_UNDEFINED 0x0000
|
||||
#define AUDIO_FORMAT_PCM 0x0001
|
||||
#define AUDIO_FORMAT_PCM8 0x0002
|
||||
#define AUDIO_FORMAT_IEEE_FLOAT 0x0003
|
||||
#define AUDIO_FORMAT_ALAW 0x0004
|
||||
#define AUDIO_FORMAT_MULAW 0x0005
|
||||
|
||||
/* Audio Data Format Type II Codes */
|
||||
#define AUDIO_FORMAT_TYPE_II_UNDEFINED 0x1000
|
||||
#define AUDIO_FORMAT_MPEG 0x1001
|
||||
#define AUDIO_FORMAT_AC3 0x1002
|
||||
|
||||
/* Audio Data Format Type III Codes */
|
||||
#define AUDIO_FORMAT_TYPE_III_UNDEFINED 0x2000
|
||||
#define AUDIO_FORMAT_IEC1937_AC3 0x2001
|
||||
#define AUDIO_FORMAT_IEC1937_MPEG1_L1 0x2002
|
||||
#define AUDIO_FORMAT_IEC1937_MPEG1_L2_3 0x2003
|
||||
#define AUDIO_FORMAT_IEC1937_MPEG2_NOEXT 0x2003
|
||||
#define AUDIO_FORMAT_IEC1937_MPEG2_EXT 0x2004
|
||||
#define AUDIO_FORMAT_IEC1937_MPEG2_L1_LS 0x2005
|
||||
#define AUDIO_FORMAT_IEC1937_MPEG2_L2_3 0x2006
|
||||
|
||||
|
||||
/* Predefined Audio Channel Configuration Bits */
|
||||
#define AUDIO_CHANNEL_M 0x0000 /* Mono */
|
||||
#define AUDIO_CHANNEL_L 0x0001 /* Left Front */
|
||||
#define AUDIO_CHANNEL_R 0x0002 /* Right Front */
|
||||
#define AUDIO_CHANNEL_C 0x0004 /* Center Front */
|
||||
#define AUDIO_CHANNEL_LFE 0x0008 /* Low Freq. Enhance. */
|
||||
#define AUDIO_CHANNEL_LS 0x0010 /* Left Surround */
|
||||
#define AUDIO_CHANNEL_RS 0x0020 /* Right Surround */
|
||||
#define AUDIO_CHANNEL_LC 0x0040 /* Left of Center */
|
||||
#define AUDIO_CHANNEL_RC 0x0080 /* Right of Center */
|
||||
#define AUDIO_CHANNEL_S 0x0100 /* Surround */
|
||||
#define AUDIO_CHANNEL_SL 0x0200 /* Side Left */
|
||||
#define AUDIO_CHANNEL_SR 0x0400 /* Side Right */
|
||||
#define AUDIO_CHANNEL_T 0x0800 /* Top */
|
||||
|
||||
|
||||
/* Feature Unit Control Bits */
|
||||
#define AUDIO_CONTROL_MUTE 0x0001
|
||||
#define AUDIO_CONTROL_VOLUME 0x0002
|
||||
#define AUDIO_CONTROL_BASS 0x0004
|
||||
#define AUDIO_CONTROL_MID 0x0008
|
||||
#define AUDIO_CONTROL_TREBLE 0x0010
|
||||
#define AUDIO_CONTROL_GRAPHIC_EQUALIZER 0x0020
|
||||
#define AUDIO_CONTROL_AUTOMATIC_GAIN 0x0040
|
||||
#define AUDIO_CONTROL_DEALY 0x0080
|
||||
#define AUDIO_CONTROL_BASS_BOOST 0x0100
|
||||
#define AUDIO_CONTROL_LOUDNESS 0x0200
|
||||
|
||||
/* Processing Unit Control Bits: */
|
||||
#define AUDIO_CONTROL_ENABLE 0x0001 /* Common Bit */
|
||||
#define AUDIO_CONTROL_MODE_SELECT 0x0002 /* Common Bit */
|
||||
|
||||
/* - Up/Down-mix Control Bits */
|
||||
/* AUDIO_CONTROL_ENABLE 0x0001 Common Bit */
|
||||
/* AUDIO_CONTROL_MODE_SELECT 0x0002 Common Bit */
|
||||
|
||||
/* - Dolby Prologic Control Bits */
|
||||
/* AUDIO_CONTROL_ENABLE 0x0001 Common Bit */
|
||||
/* AUDIO_CONTROL_MODE_SELECT 0x0002 Common Bit */
|
||||
|
||||
/* - 3D Stereo Extender Control Bits */
|
||||
/* AUDIO_CONTROL_ENABLE 0x0001 Common Bit */
|
||||
#define AUDIO_CONTROL_SPACIOUSNESS 0x0002
|
||||
|
||||
/* - Reverberation Control Bits */
|
||||
/* AUDIO_CONTROL_ENABLE 0x0001 Common Bit */
|
||||
#define AUDIO_CONTROL_REVERB_TYPE 0x0002
|
||||
#define AUDIO_CONTROL_REVERB_LEVEL 0x0004
|
||||
#define AUDIO_CONTROL_REVERB_TIME 0x0008
|
||||
#define AUDIO_CONTROL_REVERB_FEEDBACK 0x0010
|
||||
|
||||
/* - Chorus Control Bits */
|
||||
/* AUDIO_CONTROL_ENABLE 0x0001 Common Bit */
|
||||
#define AUDIO_CONTROL_CHORUS_LEVEL 0x0002
|
||||
#define AUDIO_CONTROL_SHORUS_RATE 0x0004
|
||||
#define AUDIO_CONTROL_CHORUS_DEPTH 0x0008
|
||||
|
||||
/* - Dynamic Range Compressor Control Bits */
|
||||
/* AUDIO_CONTROL_ENABLE 0x0001 Common Bit */
|
||||
#define AUDIO_CONTROL_COMPRESSION_RATE 0x0002
|
||||
#define AUDIO_CONTROL_MAX_AMPL 0x0004
|
||||
#define AUDIO_CONTROL_THRESHOLD 0x0008
|
||||
#define AUDIO_CONTROL_ATTACK_TIME 0x0010
|
||||
#define AUDIO_CONTROL_RELEASE_TIME 0x0020
|
||||
|
||||
/* Extension Unit Control Bits */
|
||||
/* AUDIO_CONTROL_ENABLE 0x0001 Common Bit */
|
||||
|
||||
/* Endpoint Control Bits */
|
||||
#define AUDIO_CONTROL_SAMPLING_FREQ 0x01
|
||||
#define AUDIO_CONTROL_PITCH 0x02
|
||||
#define AUDIO_MAX_PACKETS_ONLY 0x80
|
||||
|
||||
|
||||
/* Audio Terminal Types */
|
||||
|
||||
/* USB Terminal Types */
|
||||
#define AUDIO_TERMINAL_USB_UNDEFINED 0x0100
|
||||
#define AUDIO_TERMINAL_USB_STREAMING 0x0101
|
||||
#define AUDIO_TERMINAL_USB_VENDOR_SPECIFIC 0x01FF
|
||||
|
||||
/* Input Terminal Types */
|
||||
#define AUDIO_TERMINAL_INPUT_UNDEFINED 0x0200
|
||||
#define AUDIO_TERMINAL_MICROPHONE 0x0201
|
||||
#define AUDIO_TERMINAL_DESKTOP_MICROPHONE 0x0202
|
||||
#define AUDIO_TERMINAL_PERSONAL_MICROPHONE 0x0203
|
||||
#define AUDIO_TERMINAL_OMNI_DIR_MICROPHONE 0x0204
|
||||
#define AUDIO_TERMINAL_MICROPHONE_ARRAY 0x0205
|
||||
#define AUDIO_TERMINAL_PROCESSING_MIC_ARRAY 0x0206
|
||||
|
||||
/* Output Terminal Types */
|
||||
#define AUDIO_TERMINAL_OUTPUT_UNDEFINED 0x0300
|
||||
#define AUDIO_TERMINAL_SPEAKER 0x0301
|
||||
#define AUDIO_TERMINAL_HEADPHONES 0x0302
|
||||
#define AUDIO_TERMINAL_HEAD_MOUNTED_AUDIO 0x0303
|
||||
#define AUDIO_TERMINAL_DESKTOP_SPEAKER 0x0304
|
||||
#define AUDIO_TERMINAL_ROOM_SPEAKER 0x0305
|
||||
#define AUDIO_TERMINAL_COMMUNICATION_SPEAKER 0x0306
|
||||
#define AUDIO_TERMINAL_LOW_FREQ_SPEAKER 0x0307
|
||||
|
||||
/* Bi-directional Terminal Types */
|
||||
#define AUDIO_TERMINAL_BIDIRECTIONAL_UNDEFINED 0x0400
|
||||
#define AUDIO_TERMINAL_HANDSET 0x0401
|
||||
#define AUDIO_TERMINAL_HEAD_MOUNTED_HANDSET 0x0402
|
||||
#define AUDIO_TERMINAL_SPEAKERPHONE 0x0403
|
||||
#define AUDIO_TERMINAL_SPEAKERPHONE_ECHOSUPRESS 0x0404
|
||||
#define AUDIO_TERMINAL_SPEAKERPHONE_ECHOCANCEL 0x0405
|
||||
|
||||
/* Telephony Terminal Types */
|
||||
#define AUDIO_TERMINAL_TELEPHONY_UNDEFINED 0x0500
|
||||
#define AUDIO_TERMINAL_PHONE_LINE 0x0501
|
||||
#define AUDIO_TERMINAL_TELEPHONE 0x0502
|
||||
#define AUDIO_TERMINAL_DOWN_LINE_PHONE 0x0503
|
||||
|
||||
/* External Terminal Types */
|
||||
#define AUDIO_TERMINAL_EXTERNAL_UNDEFINED 0x0600
|
||||
#define AUDIO_TERMINAL_ANALOG_CONNECTOR 0x0601
|
||||
#define AUDIO_TERMINAL_DIGITAL_AUDIO_INTERFACE 0x0602
|
||||
#define AUDIO_TERMINAL_LINE_CONNECTOR 0x0603
|
||||
#define AUDIO_TERMINAL_LEGACY_AUDIO_CONNECTOR 0x0604
|
||||
#define AUDIO_TERMINAL_SPDIF_INTERFACE 0x0605
|
||||
#define AUDIO_TERMINAL_1394_DA_STREAM 0x0606
|
||||
#define AUDIO_TERMINAL_1394_DA_STREAM_TRACK 0x0607
|
||||
|
||||
/* Embedded Function Terminal Types */
|
||||
#define AUDIO_TERMINAL_EMBEDDED_UNDEFINED 0x0700
|
||||
#define AUDIO_TERMINAL_CALIBRATION_NOISE 0x0701
|
||||
#define AUDIO_TERMINAL_EQUALIZATION_NOISE 0x0702
|
||||
#define AUDIO_TERMINAL_CD_PLAYER 0x0703
|
||||
#define AUDIO_TERMINAL_DAT 0x0704
|
||||
#define AUDIO_TERMINAL_DCC 0x0705
|
||||
#define AUDIO_TERMINAL_MINI_DISK 0x0706
|
||||
#define AUDIO_TERMINAL_ANALOG_TAPE 0x0707
|
||||
#define AUDIO_TERMINAL_PHONOGRAPH 0x0708
|
||||
#define AUDIO_TERMINAL_VCR_AUDIO 0x0709
|
||||
#define AUDIO_TERMINAL_VIDEO_DISC_AUDIO 0x070A
|
||||
#define AUDIO_TERMINAL_DVD_AUDIO 0x070B
|
||||
#define AUDIO_TERMINAL_TV_TUNER_AUDIO 0x070C
|
||||
#define AUDIO_TERMINAL_SATELLITE_RECEIVER_AUDIO 0x070D
|
||||
#define AUDIO_TERMINAL_CABLE_TUNER_AUDIO 0x070E
|
||||
#define AUDIO_TERMINAL_DSS_AUDIO 0x070F
|
||||
#define AUDIO_TERMINAL_RADIO_RECEIVER 0x0710
|
||||
#define AUDIO_TERMINAL_RADIO_TRANSMITTER 0x0711
|
||||
#define AUDIO_TERMINAL_MULTI_TRACK_RECORDER 0x0712
|
||||
#define AUDIO_TERMINAL_SYNTHESIZER 0x0713
|
||||
|
||||
|
||||
#endif /* __AUDIO_H__ */
|
|
@ -0,0 +1,45 @@
|
|||
/*----------------------------------------------------------------------------
|
||||
* Name: DEMO.H
|
||||
* Purpose: USB Audio Demo Definitions
|
||||
* Version: V1.10
|
||||
*----------------------------------------------------------------------------
|
||||
* This software is supplied "AS IS" without any warranties, express,
|
||||
* implied or statutory, including but not limited to the implied
|
||||
* warranties of fitness for purpose, satisfactory quality and
|
||||
* noninfringement. Keil extends you a royalty-free right to reproduce
|
||||
* and distribute executable files created using this software for use
|
||||
* on Philips LPC2xxx microcontroller devices only. Nothing else gives
|
||||
* you the right to use this software.
|
||||
*
|
||||
* Copyright (c) 2005-2006 Keil Software.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
/* Clock Definitions */
|
||||
#define CPU_CLOCK 60000000 /* CPU Clock */
|
||||
#define VPB_CLOCK (CPU_CLOCK/1) /* VPB Clock */
|
||||
|
||||
/* Audio Definitions */
|
||||
#define DATA_FREQ 32000 /* Audio Data Frequency */
|
||||
#define P_S 32 /* Packet Size */
|
||||
#if USB_DMA
|
||||
#define P_C 4 /* Packet Count */
|
||||
#else
|
||||
#define P_C 1 /* Packet Count */
|
||||
#endif
|
||||
#define B_S (8*P_C*P_S) /* Buffer Size */
|
||||
|
||||
/* Push Button Definitions */
|
||||
#define PBINT 0x00004000 /* P0.14 */
|
||||
|
||||
/* LED Definitions */
|
||||
#define LEDMSK 0x00FF0000 /* P1.16..23 */
|
||||
|
||||
/* Audio Demo Variables */
|
||||
extern BYTE Mute; /* Mute State */
|
||||
extern DWORD Volume; /* Volume Level */
|
||||
extern WORD VolCur; /* Volume Current Value */
|
||||
extern DWORD InfoBuf[P_C]; /* Packet Info Buffer */
|
||||
extern short DataBuf[B_S]; /* Data Buffer */
|
||||
extern WORD DataOut; /* Data Out Index */
|
||||
extern WORD DataIn; /* Data In Index */
|
||||
extern BYTE DataRun; /* Data Stream Run State */
|
|
@ -0,0 +1,22 @@
|
|||
|
||||
#ifndef __TYPE_H__
|
||||
#define __TYPE_H__
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE (0)
|
||||
#endif
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE (1)
|
||||
#endif
|
||||
|
||||
typedef unsigned char BYTE;
|
||||
typedef unsigned short WORD;
|
||||
typedef unsigned long DWORD;
|
||||
//typedef unsigned int BOOL;
|
||||
|
||||
#endif /* __TYPE_H__ */
|
|
@ -0,0 +1,431 @@
|
|||
/*
|
||||
* QEMU USB HID devices
|
||||
*
|
||||
* Copyright (c) 2005 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include "../qemu-usb/vl.h"
|
||||
|
||||
/* HID interface requests */
|
||||
#define GET_REPORT 0xa101
|
||||
#define GET_IDLE 0xa102
|
||||
#define GET_PROTOCOL 0xa103
|
||||
#define SET_IDLE 0x210a
|
||||
#define SET_PROTOCOL 0x210b
|
||||
|
||||
#define USB_MOUSE 1
|
||||
#define USB_TABLET 2
|
||||
|
||||
#include "type.h"
|
||||
|
||||
#include "usb.h"
|
||||
#include "audio.h"
|
||||
#include "usbcfg.h"
|
||||
#include "usbdesc.h"
|
||||
|
||||
typedef struct SINGSTARMICState {
|
||||
USBDevice dev;
|
||||
//nothing yet
|
||||
} SINGSTARMICState;
|
||||
|
||||
/* descriptor dumped from a real singstar MIC adapter */
|
||||
static const uint8_t singstar_mic_dev_descriptor[] = {
|
||||
/* bLength */ 0x12, //(18)
|
||||
/* bDescriptorType */ 0x01, //(1)
|
||||
/* bcdUSB */ WBVAL(0x0110), //(272)
|
||||
/* bDeviceClass */ 0x00, //(0)
|
||||
/* bDeviceSubClass */ 0x00, //(0)
|
||||
/* bDeviceProtocol */ 0x00, //(0)
|
||||
/* bMaxPacketSize0 */ 0x08, //(8)
|
||||
/* idVendor */ WBVAL(0x1415), //(5141)
|
||||
/* idProduct */ WBVAL(0x0000), //(0)
|
||||
/* bcdDevice */ WBVAL(0x0001), //(1)
|
||||
/* iManufacturer */ 0x01, //(1)
|
||||
/* iProduct */ 0x02, //(2)
|
||||
/* iSerialNumber */ 0x00, //(0)
|
||||
/* bNumConfigurations */ 0x01, //(1)
|
||||
|
||||
};
|
||||
|
||||
static const uint8_t singstar_mic_config_descriptor[] = {
|
||||
|
||||
/* Configuration 1 */
|
||||
0x09, /* bLength */
|
||||
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
WBVAL(0x00b1), /* wTotalLength */
|
||||
0x02, /* bNumInterfaces */
|
||||
0x01, /* bConfigurationValue */
|
||||
0x00, /* iConfiguration */
|
||||
USB_CONFIG_BUS_POWERED, /* bmAttributes */
|
||||
USB_CONFIG_POWER_MA(90), /* bMaxPower */
|
||||
|
||||
/* Interface 0, Alternate Setting 0, Audio Control */
|
||||
USB_INTERFACE_DESC_SIZE, /* bLength */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
0x00, /* bInterfaceNumber */
|
||||
0x00, /* bAlternateSetting */
|
||||
0x00, /* bNumEndpoints */
|
||||
USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */
|
||||
AUDIO_SUBCLASS_AUDIOCONTROL, /* bInterfaceSubClass */
|
||||
AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */
|
||||
0x00, /* iInterface */
|
||||
|
||||
/* Audio Control Interface */
|
||||
AUDIO_CONTROL_INTERFACE_DESC_SZ(1), /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_CONTROL_HEADER, /* bDescriptorSubtype */
|
||||
WBVAL(0x0100), /* 1.00 */ /* bcdADC */
|
||||
WBVAL(0x0028), /* wTotalLength */
|
||||
0x01, /* bInCollection */
|
||||
0x01, /* baInterfaceNr */
|
||||
|
||||
/* Audio Input Terminal */
|
||||
AUDIO_INPUT_TERMINAL_DESC_SIZE, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_CONTROL_INPUT_TERMINAL, /* bDescriptorSubtype */
|
||||
0x01, /* bTerminalID */
|
||||
WBVAL(AUDIO_TERMINAL_MICROPHONE), /* wTerminalType */
|
||||
0x02, /* bAssocTerminal */
|
||||
0x02, /* bNrChannels */
|
||||
WBVAL(AUDIO_CHANNEL_L
|
||||
|AUDIO_CHANNEL_R), /* wChannelConfig */
|
||||
0x00, /* iChannelNames */
|
||||
0x00, /* iTerminal */
|
||||
|
||||
/* Audio Output Terminal */
|
||||
AUDIO_OUTPUT_TERMINAL_DESC_SIZE, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_CONTROL_OUTPUT_TERMINAL, /* bDescriptorSubtype */
|
||||
0x02, /* bTerminalID */
|
||||
WBVAL(AUDIO_TERMINAL_USB_STREAMING), /* wTerminalType */
|
||||
0x01, /* bAssocTerminal */
|
||||
0x03, /* bSourceID */
|
||||
0x00, /* iTerminal */
|
||||
|
||||
/* Audio Feature Unit */
|
||||
AUDIO_FEATURE_UNIT_DESC_SZ(2,1), /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_CONTROL_FEATURE_UNIT, /* bDescriptorSubtype */
|
||||
0x03, /* bUnitID */
|
||||
0x01, /* bSourceID */
|
||||
0x01, /* bControlSize */
|
||||
0x01, /* bmaControls(0) */
|
||||
0x02, /* bmaControls(1) */
|
||||
0x02, /* bmaControls(2) */
|
||||
0x00, /* iTerminal */
|
||||
|
||||
/* Interface 1, Alternate Setting 0, Audio Streaming - Zero Bandwith */
|
||||
USB_INTERFACE_DESC_SIZE, /* bLength */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
0x01, /* bInterfaceNumber */
|
||||
0x00, /* bAlternateSetting */
|
||||
0x00, /* bNumEndpoints */
|
||||
USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */
|
||||
AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubClass */
|
||||
AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */
|
||||
0x00, /* iInterface */
|
||||
|
||||
/* Interface 1, Alternate Setting 1, Audio Streaming - Operational */
|
||||
USB_INTERFACE_DESC_SIZE, /* bLength */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
0x01, /* bInterfaceNumber */
|
||||
0x01, /* bAlternateSetting */
|
||||
0x01, /* bNumEndpoints */
|
||||
USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */
|
||||
AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubClass */
|
||||
AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */
|
||||
0x00, /* iInterface */
|
||||
|
||||
/* Audio Streaming Interface */
|
||||
AUDIO_STREAMING_INTERFACE_DESC_SIZE, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_STREAMING_GENERAL, /* bDescriptorSubtype */
|
||||
0x02, /* bTerminalLink */
|
||||
0x01, /* bDelay */
|
||||
WBVAL(AUDIO_FORMAT_PCM), /* wFormatTag */
|
||||
|
||||
/* Audio Type I Format */
|
||||
AUDIO_FORMAT_TYPE_I_DESC_SZ(5), /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_STREAMING_FORMAT_TYPE, /* bDescriptorSubtype */
|
||||
AUDIO_FORMAT_TYPE_I, /* bFormatType */
|
||||
0x01, /* bNrChannels */
|
||||
0x02, /* bSubFrameSize */
|
||||
0x10, /* bBitResolution */
|
||||
0x05, /* bSamFreqType */
|
||||
B3VAL(8000), /* tSamFreq 1 */
|
||||
B3VAL(11025), /* tSamFreq 2 */
|
||||
B3VAL(22050), /* tSamFreq 3 */
|
||||
B3VAL(44100), /* tSamFreq 4 */
|
||||
B3VAL(48000), /* tSamFreq 5 */
|
||||
|
||||
/* Endpoint - Standard Descriptor */
|
||||
AUDIO_STANDARD_ENDPOINT_DESC_SIZE, /* bLength */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
USB_ENDPOINT_OUT(0x81), /* bEndpointAddress */
|
||||
USB_ENDPOINT_TYPE_ISOCHRONOUS
|
||||
| USB_ENDPOINT_SYNC_ASYNCHRONOUS, /* bmAttributes */
|
||||
WBVAL(0x0064), /* wMaxPacketSize */
|
||||
0x01, /* bInterval */
|
||||
0x00, /* bRefresh */
|
||||
0x00, /* bSynchAddress */
|
||||
|
||||
/* Endpoint - Audio Streaming */
|
||||
AUDIO_STREAMING_ENDPOINT_DESC_SIZE, /* bLength */
|
||||
AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_ENDPOINT_GENERAL, /* bDescriptor */
|
||||
0x01, /* bmAttributes */
|
||||
0x00, /* bLockDelayUnits */
|
||||
WBVAL(0x0000), /* wLockDelay */
|
||||
|
||||
/* Interface 1, Alternate Setting 2, Audio Streaming - ? */
|
||||
USB_INTERFACE_DESC_SIZE, /* bLength */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
0x01, /* bInterfaceNumber */
|
||||
0x02, /* bAlternateSetting */
|
||||
0x01, /* bNumEndpoints */
|
||||
USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */
|
||||
AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubClass */
|
||||
AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */
|
||||
0x00, /* iInterface */
|
||||
|
||||
/* Audio Streaming Interface */
|
||||
AUDIO_STREAMING_INTERFACE_DESC_SIZE, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_STREAMING_GENERAL, /* bDescriptorSubtype */
|
||||
0x02, /* bTerminalLink */
|
||||
0x01, /* bDelay */
|
||||
WBVAL(AUDIO_FORMAT_PCM), /* wFormatTag */
|
||||
|
||||
/* Audio Type I Format */
|
||||
AUDIO_FORMAT_TYPE_I_DESC_SZ(5), /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_STREAMING_FORMAT_TYPE, /* bDescriptorSubtype */
|
||||
AUDIO_FORMAT_TYPE_I, /* bFormatType */
|
||||
0x02, /* bNrChannels */
|
||||
0x02, /* bSubFrameSize */
|
||||
0x10, /* bBitResolution */
|
||||
0x05, /* bSamFreqType */
|
||||
B3VAL(8000), /* tSamFreq 1 */
|
||||
B3VAL(11025), /* tSamFreq 2 */
|
||||
B3VAL(22050), /* tSamFreq 3 */
|
||||
B3VAL(44100), /* tSamFreq 4 */
|
||||
B3VAL(48000), /* tSamFreq 5 */
|
||||
|
||||
/* Endpoint - Standard Descriptor */
|
||||
AUDIO_STANDARD_ENDPOINT_DESC_SIZE, /* bLength */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
USB_ENDPOINT_OUT(0x81), /* bEndpointAddress */
|
||||
USB_ENDPOINT_TYPE_ISOCHRONOUS
|
||||
| USB_ENDPOINT_SYNC_ASYNCHRONOUS, /* bmAttributes */
|
||||
WBVAL(0x00c8), /* wMaxPacketSize */
|
||||
0x01, /* bInterval */
|
||||
0x00, /* bRefresh */
|
||||
0x00, /* bSynchAddress */
|
||||
|
||||
/* Endpoint - Audio Streaming */
|
||||
AUDIO_STREAMING_ENDPOINT_DESC_SIZE, /* bLength */
|
||||
AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_ENDPOINT_GENERAL, /* bDescriptor */
|
||||
0x01, /* bmAttributes */
|
||||
0x00, /* bLockDelayUnits */
|
||||
WBVAL(0x0000), /* wLockDelay */
|
||||
|
||||
/* Terminator */
|
||||
0 /* bLength */
|
||||
};
|
||||
|
||||
|
||||
static void singstar_mic_handle_reset(USBDevice *dev)
|
||||
{
|
||||
/* XXX: do it */
|
||||
return;
|
||||
}
|
||||
|
||||
static int singstar_mic_handle_control(USBDevice *dev, int request, int value,
|
||||
int index, int length, uint8_t *data)
|
||||
{
|
||||
SINGSTARMICState *s = (SINGSTARMICState *)dev;
|
||||
int ret = 0;
|
||||
|
||||
switch(request) {
|
||||
case DeviceRequest | USB_REQ_GET_STATUS:
|
||||
data[0] = (dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
|
||||
data[1] = 0x00;
|
||||
ret = 2;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
|
||||
if (value == USB_DEVICE_REMOTE_WAKEUP) {
|
||||
dev->remote_wakeup = 0;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_FEATURE:
|
||||
if (value == USB_DEVICE_REMOTE_WAKEUP) {
|
||||
dev->remote_wakeup = 1;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_ADDRESS:
|
||||
dev->addr = value;
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
|
||||
switch(value >> 8) {
|
||||
case USB_DT_DEVICE:
|
||||
memcpy(data, singstar_mic_dev_descriptor,
|
||||
sizeof(singstar_mic_dev_descriptor));
|
||||
ret = sizeof(singstar_mic_dev_descriptor);
|
||||
break;
|
||||
case USB_DT_CONFIG:
|
||||
memcpy(data, singstar_mic_config_descriptor,
|
||||
sizeof(singstar_mic_config_descriptor));
|
||||
ret = sizeof(singstar_mic_config_descriptor);
|
||||
break;
|
||||
case USB_DT_STRING:
|
||||
switch(value & 0xff) {
|
||||
case 0:
|
||||
/* language ids */
|
||||
data[0] = 4;
|
||||
data[1] = 3;
|
||||
data[2] = 0x09;
|
||||
data[3] = 0x04;
|
||||
ret = 4;
|
||||
break;
|
||||
case 1:
|
||||
/* serial number */
|
||||
ret = set_usb_string(data, "3X0420811");
|
||||
break;
|
||||
case 2:
|
||||
/* product description */
|
||||
ret = set_usb_string(data, "EyeToy USB camera Namtai");
|
||||
break;
|
||||
case 3:
|
||||
/* vendor description */
|
||||
ret = set_usb_string(data, "PCSX2/QEMU");
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
|
||||
data[0] = 1;
|
||||
ret = 1;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_INTERFACE:
|
||||
data[0] = 0;
|
||||
ret = 1;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_INTERFACE:
|
||||
ret = 0;
|
||||
break;
|
||||
/* hid specific requests */
|
||||
case InterfaceRequest | USB_REQ_GET_DESCRIPTOR:
|
||||
//switch(value >> 8) {
|
||||
//((case 0x22:
|
||||
// memcpy(data, qemu_mouse_hid_report_descriptor,
|
||||
// sizeof(qemu_mouse_hid_report_descriptor));
|
||||
// ret = sizeof(qemu_mouse_hid_report_descriptor);
|
||||
// break;
|
||||
//default:
|
||||
goto fail;
|
||||
//}
|
||||
break;
|
||||
case GET_REPORT:
|
||||
ret = 0;
|
||||
break;
|
||||
case SET_IDLE:
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
fail:
|
||||
ret = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int singstar_mic_handle_data(USBDevice *dev, int pid,
|
||||
uint8_t devep, uint8_t *data, int len)
|
||||
{
|
||||
SINGSTARMICState *s = (SINGSTARMICState *)dev;
|
||||
int ret = 0;
|
||||
|
||||
switch(pid) {
|
||||
case USB_TOKEN_IN:
|
||||
if (devep == 1) {
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case USB_TOKEN_OUT:
|
||||
default:
|
||||
fail:
|
||||
ret = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static void singstar_mic_handle_destroy(USBDevice *dev)
|
||||
{
|
||||
SINGSTARMICState *s = (SINGSTARMICState *)dev;
|
||||
|
||||
free(s);
|
||||
}
|
||||
|
||||
int singstar_mic_handle_packet(USBDevice *s, int pid,
|
||||
uint8_t devaddr, uint8_t devep,
|
||||
uint8_t *data, int len)
|
||||
{
|
||||
fprintf(stderr,"usb-singstar_mic: packet received with pid=%x, devaddr=%x, devep=%x and len=%x\n",pid,devaddr,devep,len);
|
||||
return usb_generic_handle_packet(s,pid,devaddr,devep,data,len);
|
||||
}
|
||||
|
||||
USBDevice *singstar_mic_init()
|
||||
{
|
||||
SINGSTARMICState *s;
|
||||
|
||||
s = (SINGSTARMICState *)qemu_mallocz(sizeof(SINGSTARMICState));
|
||||
if (!s)
|
||||
return NULL;
|
||||
s->dev.speed = USB_SPEED_FULL;
|
||||
s->dev.handle_packet = singstar_mic_handle_packet;
|
||||
s->dev.handle_reset = singstar_mic_handle_reset;
|
||||
s->dev.handle_control = singstar_mic_handle_control;
|
||||
s->dev.handle_data = singstar_mic_handle_data;
|
||||
s->dev.handle_destroy = singstar_mic_handle_destroy;
|
||||
|
||||
strncpy(s->dev.devname, "EyeToy USB camera Namtai", sizeof(s->dev.devname));
|
||||
|
||||
return (USBDevice *)s;
|
||||
|
||||
}
|
|
@ -0,0 +1,626 @@
|
|||
/*
|
||||
* QEMU USB HID devices
|
||||
*
|
||||
* Copyright (c) 2005 Fabrice Bellard
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#include "vl.h"
|
||||
|
||||
/* HID interface requests */
|
||||
#define GET_REPORT 0xa101
|
||||
#define GET_IDLE 0xa102
|
||||
#define GET_PROTOCOL 0xa103
|
||||
#define SET_IDLE 0x210a
|
||||
#define SET_PROTOCOL 0x210b
|
||||
|
||||
#define USB_MOUSE 1
|
||||
#define USB_TABLET 2
|
||||
|
||||
#include "type.h"
|
||||
|
||||
#include "usb.h"
|
||||
#include "audio.h"
|
||||
#include "usbcfg.h"
|
||||
#include "usbdesc.h"
|
||||
|
||||
/* mostly the same values as the Bochs USB Mouse device */
|
||||
static const uint8_t qemu_mic_dev_descriptor[] = {
|
||||
sizeof(qemu_mic_dev_descriptor), /* bLength */
|
||||
1, /* bDescriptorType */
|
||||
WBVAL(0x0110), /* 1.10 */ /* bcdUSB */
|
||||
0x00, /* bDeviceClass */
|
||||
0x00, /* bDeviceSubClass */
|
||||
0x00, /* bDeviceProtocol */
|
||||
USB_MAX_PACKET0, /* bMaxPacketSize0 */
|
||||
WBVAL(0xC251), /* idVendor */
|
||||
WBVAL(0x1304), /* idProduct */
|
||||
WBVAL(0x0100), /* 1.00 */ /* bcdDevice */
|
||||
0x04, /* iManufacturer */
|
||||
0x20, /* iProduct */
|
||||
0x4A, /* iSerialNumber */
|
||||
0x01 /* bNumConfigurations */
|
||||
};
|
||||
|
||||
static const uint8_t qemu_mic_config_descriptor[] = {
|
||||
/* Configuration 1 */
|
||||
sizeof(qemu_mic_config_descriptor), /* bLength */
|
||||
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
WBVAL( /* wTotalLength */
|
||||
USB_CONFIGUARTION_DESC_SIZE +
|
||||
USB_INTERFACE_DESC_SIZE +
|
||||
AUDIO_CONTROL_INTERFACE_DESC_SZ(1) +
|
||||
AUDIO_INPUT_TERMINAL_DESC_SIZE +
|
||||
AUDIO_FEATURE_UNIT_DESC_SZ(1,1) +
|
||||
AUDIO_OUTPUT_TERMINAL_DESC_SIZE +
|
||||
USB_INTERFACE_DESC_SIZE +
|
||||
USB_INTERFACE_DESC_SIZE +
|
||||
AUDIO_STREAMING_INTERFACE_DESC_SIZE +
|
||||
AUDIO_FORMAT_TYPE_I_DESC_SZ(1) +
|
||||
AUDIO_STANDARD_ENDPOINT_DESC_SIZE +
|
||||
AUDIO_STREAMING_ENDPOINT_DESC_SIZE
|
||||
),
|
||||
0x02, /* bNumInterfaces */
|
||||
0x01, /* bConfigurationValue */
|
||||
0x00, /* iConfiguration */
|
||||
USB_CONFIG_BUS_POWERED, /* bmAttributes */
|
||||
USB_CONFIG_POWER_MA(100), /* bMaxPower */
|
||||
/* Interface 0, Alternate Setting 0, Audio Control */
|
||||
USB_INTERFACE_DESC_SIZE, /* bLength */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
0x00, /* bInterfaceNumber */
|
||||
0x00, /* bAlternateSetting */
|
||||
0x00, /* bNumEndpoints */
|
||||
USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */
|
||||
AUDIO_SUBCLASS_AUDIOCONTROL, /* bInterfaceSubClass */
|
||||
AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */
|
||||
0x00, /* iInterface */
|
||||
/* Audio Control Interface */
|
||||
AUDIO_CONTROL_INTERFACE_DESC_SZ(1), /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_CONTROL_HEADER, /* bDescriptorSubtype */
|
||||
WBVAL(0x0100), /* 1.00 */ /* bcdADC */
|
||||
WBVAL( /* wTotalLength */
|
||||
AUDIO_CONTROL_INTERFACE_DESC_SZ(1) +
|
||||
AUDIO_INPUT_TERMINAL_DESC_SIZE +
|
||||
AUDIO_FEATURE_UNIT_DESC_SZ(1,1) +
|
||||
AUDIO_OUTPUT_TERMINAL_DESC_SIZE
|
||||
),
|
||||
0x01, /* bInCollection */
|
||||
0x01, /* baInterfaceNr */
|
||||
/* Audio Input Terminal */
|
||||
AUDIO_INPUT_TERMINAL_DESC_SIZE, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_CONTROL_INPUT_TERMINAL, /* bDescriptorSubtype */
|
||||
0x01, /* bTerminalID */
|
||||
WBVAL(AUDIO_TERMINAL_USB_STREAMING), /* wTerminalType */
|
||||
0x00, /* bAssocTerminal */
|
||||
0x01, /* bNrChannels */
|
||||
WBVAL(AUDIO_CHANNEL_M), /* wChannelConfig */
|
||||
0x00, /* iChannelNames */
|
||||
0x00, /* iTerminal */
|
||||
/* Audio Feature Unit */
|
||||
AUDIO_FEATURE_UNIT_DESC_SZ(1,1), /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_CONTROL_FEATURE_UNIT, /* bDescriptorSubtype */
|
||||
0x02, /* bUnitID */
|
||||
0x01, /* bSourceID */
|
||||
0x01, /* bControlSize */
|
||||
AUDIO_CONTROL_MUTE |
|
||||
AUDIO_CONTROL_VOLUME, /* bmaControls(0) */
|
||||
0x00, /* bmaControls(1) */
|
||||
0x00, /* iTerminal */
|
||||
/* Audio Output Terminal */
|
||||
AUDIO_OUTPUT_TERMINAL_DESC_SIZE, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_CONTROL_OUTPUT_TERMINAL, /* bDescriptorSubtype */
|
||||
0x03, /* bTerminalID */
|
||||
WBVAL(AUDIO_TERMINAL_SPEAKER), /* wTerminalType */
|
||||
0x00, /* bAssocTerminal */
|
||||
0x02, /* bSourceID */
|
||||
0x00, /* iTerminal */
|
||||
/* Interface 1, Alternate Setting 0, Audio Streaming - Zero Bandwith */
|
||||
USB_INTERFACE_DESC_SIZE, /* bLength */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
0x01, /* bInterfaceNumber */
|
||||
0x00, /* bAlternateSetting */
|
||||
0x00, /* bNumEndpoints */
|
||||
USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */
|
||||
AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubClass */
|
||||
AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */
|
||||
0x00, /* iInterface */
|
||||
/* Interface 1, Alternate Setting 1, Audio Streaming - Operational */
|
||||
USB_INTERFACE_DESC_SIZE, /* bLength */
|
||||
USB_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
0x01, /* bInterfaceNumber */
|
||||
0x01, /* bAlternateSetting */
|
||||
0x01, /* bNumEndpoints */
|
||||
USB_DEVICE_CLASS_AUDIO, /* bInterfaceClass */
|
||||
AUDIO_SUBCLASS_AUDIOSTREAMING, /* bInterfaceSubClass */
|
||||
AUDIO_PROTOCOL_UNDEFINED, /* bInterfaceProtocol */
|
||||
0x00, /* iInterface */
|
||||
/* Audio Streaming Interface */
|
||||
AUDIO_STREAMING_INTERFACE_DESC_SIZE, /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_STREAMING_GENERAL, /* bDescriptorSubtype */
|
||||
0x01, /* bTerminalLink */
|
||||
0x01, /* bDelay */
|
||||
WBVAL(AUDIO_FORMAT_PCM), /* wFormatTag */
|
||||
/* Audio Type I Format */
|
||||
AUDIO_FORMAT_TYPE_I_DESC_SZ(1), /* bLength */
|
||||
AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_STREAMING_FORMAT_TYPE, /* bDescriptorSubtype */
|
||||
AUDIO_FORMAT_TYPE_I, /* bFormatType */
|
||||
0x01, /* bNrChannels */
|
||||
0x02, /* bSubFrameSize */
|
||||
16, /* bBitResolution */
|
||||
0x01, /* bSamFreqType */
|
||||
B3VAL(32000), /* tSamFreq */
|
||||
/* Endpoint - Standard Descriptor */
|
||||
AUDIO_STANDARD_ENDPOINT_DESC_SIZE, /* bLength */
|
||||
USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
USB_ENDPOINT_OUT(3), /* bEndpointAddress */
|
||||
USB_ENDPOINT_TYPE_ISOCHRONOUS, /* bmAttributes */
|
||||
WBVAL(64), /* wMaxPacketSize */
|
||||
0x01, /* bInterval */
|
||||
0x00, /* bRefresh */
|
||||
0x00, /* bSynchAddress */
|
||||
/* Endpoint - Audio Streaming */
|
||||
AUDIO_STREAMING_ENDPOINT_DESC_SIZE, /* bLength */
|
||||
AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */
|
||||
AUDIO_ENDPOINT_GENERAL, /* bDescriptor */
|
||||
0x00, /* bmAttributes */
|
||||
0x00, /* bLockDelayUnits */
|
||||
WBVAL(0x0000), /* wLockDelay */
|
||||
/* Terminator */
|
||||
0 /* bLength */
|
||||
};
|
||||
|
||||
static const uint8_t qemu_tablet_config_descriptor[] = {
|
||||
/* one configuration */
|
||||
0x09, /* u8 bLength; */
|
||||
0x02, /* u8 bDescriptorType; Configuration */
|
||||
0x22, 0x00, /* u16 wTotalLength; */
|
||||
0x01, /* u8 bNumInterfaces; (1) */
|
||||
0x01, /* u8 bConfigurationValue; */
|
||||
0x04, /* u8 iConfiguration; */
|
||||
0xa0, /* u8 bmAttributes;
|
||||
Bit 7: must be set,
|
||||
6: Self-powered,
|
||||
5: Remote wakeup,
|
||||
4..0: resvd */
|
||||
50, /* u8 MaxPower; */
|
||||
|
||||
/* USB 1.1:
|
||||
* USB 2.0, single TT organization (mandatory):
|
||||
* one interface, protocol 0
|
||||
*
|
||||
* USB 2.0, multiple TT organization (optional):
|
||||
* two interfaces, protocols 1 (like single TT)
|
||||
* and 2 (multiple TT mode) ... config is
|
||||
* sometimes settable
|
||||
* NOT IMPLEMENTED
|
||||
*/
|
||||
|
||||
/* one interface */
|
||||
0x09, /* u8 if_bLength; */
|
||||
0x04, /* u8 if_bDescriptorType; Interface */
|
||||
0x00, /* u8 if_bInterfaceNumber; */
|
||||
0x00, /* u8 if_bAlternateSetting; */
|
||||
0x01, /* u8 if_bNumEndpoints; */
|
||||
0x03, /* u8 if_bInterfaceClass; */
|
||||
0x01, /* u8 if_bInterfaceSubClass; */
|
||||
0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */
|
||||
0x05, /* u8 if_iInterface; */
|
||||
|
||||
/* HID descriptor */
|
||||
0x09, /* u8 bLength; */
|
||||
0x21, /* u8 bDescriptorType; */
|
||||
0x01, 0x00, /* u16 HID_class */
|
||||
0x00, /* u8 country_code */
|
||||
0x01, /* u8 num_descriptors */
|
||||
0x22, /* u8 type; Report */
|
||||
74, 0, /* u16 len */
|
||||
|
||||
/* one endpoint (status change endpoint) */
|
||||
0x07, /* u8 ep_bLength; */
|
||||
0x05, /* u8 ep_bDescriptorType; Endpoint */
|
||||
0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */
|
||||
0x03, /* u8 ep_bmAttributes; Interrupt */
|
||||
0x08, 0x00, /* u16 ep_wMaxPacketSize; */
|
||||
0x03, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */
|
||||
};
|
||||
|
||||
static const uint8_t qemu_mouse_hid_report_descriptor[] = {
|
||||
0x05, 0x01, 0x09, 0x02, 0xA1, 0x01, 0x09, 0x01,
|
||||
0xA1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03,
|
||||
0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01,
|
||||
0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01,
|
||||
0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81,
|
||||
0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06,
|
||||
0xC0, 0xC0,
|
||||
};
|
||||
|
||||
static const uint8_t qemu_tablet_hid_report_descriptor[] = {
|
||||
0x05, 0x01, /* Usage Page Generic Desktop */
|
||||
0x09, 0x01, /* Usage Mouse */
|
||||
0xA1, 0x01, /* Collection Application */
|
||||
0x09, 0x01, /* Usage Pointer */
|
||||
0xA1, 0x00, /* Collection Physical */
|
||||
0x05, 0x09, /* Usage Page Button */
|
||||
0x19, 0x01, /* Usage Minimum Button 1 */
|
||||
0x29, 0x03, /* Usage Maximum Button 3 */
|
||||
0x15, 0x00, /* Logical Minimum 0 */
|
||||
0x25, 0x01, /* Logical Maximum 1 */
|
||||
0x95, 0x03, /* Report Count 3 */
|
||||
0x75, 0x01, /* Report Size 1 */
|
||||
0x81, 0x02, /* Input (Data, Var, Abs) */
|
||||
0x95, 0x01, /* Report Count 1 */
|
||||
0x75, 0x05, /* Report Size 5 */
|
||||
0x81, 0x01, /* Input (Cnst, Var, Abs) */
|
||||
0x05, 0x01, /* Usage Page Generic Desktop */
|
||||
0x09, 0x30, /* Usage X */
|
||||
0x09, 0x31, /* Usage Y */
|
||||
0x15, 0x00, /* Logical Minimum 0 */
|
||||
0x26, 0xFF, 0x7F, /* Logical Maximum 0x7fff */
|
||||
0x35, 0x00, /* Physical Minimum 0 */
|
||||
0x46, 0xFE, 0x7F, /* Physical Maximum 0x7fff */
|
||||
0x75, 0x10, /* Report Size 16 */
|
||||
0x95, 0x02, /* Report Count 2 */
|
||||
0x81, 0x02, /* Input (Data, Var, Abs) */
|
||||
0x05, 0x01, /* Usage Page Generic Desktop */
|
||||
0x09, 0x38, /* Usage Wheel */
|
||||
0x15, 0x81, /* Logical Minimum -127 */
|
||||
0x25, 0x7F, /* Logical Maximum 127 */
|
||||
0x35, 0x00, /* Physical Minimum 0 (same as logical) */
|
||||
0x45, 0x00, /* Physical Maximum 0 (same as logical) */
|
||||
0x75, 0x08, /* Report Size 8 */
|
||||
0x95, 0x01, /* Report Count 1 */
|
||||
0x81, 0x02, /* Input (Data, Var, Rel) */
|
||||
0xC0, /* End Collection */
|
||||
0xC0, /* End Collection */
|
||||
};
|
||||
|
||||
static void usb_mouse_event(void *opaque,
|
||||
int dx1, int dy1, int dz1, int buttons_state)
|
||||
{
|
||||
USBMouseState *s = opaque;
|
||||
|
||||
s->dx += dx1;
|
||||
s->dy += dy1;
|
||||
s->dz += dz1;
|
||||
s->buttons_state = buttons_state;
|
||||
}
|
||||
|
||||
static void usb_tablet_event(void *opaque,
|
||||
int x, int y, int dz, int buttons_state)
|
||||
{
|
||||
USBMouseState *s = opaque;
|
||||
|
||||
s->x = x;
|
||||
s->y = y;
|
||||
s->dz += dz;
|
||||
s->buttons_state = buttons_state;
|
||||
}
|
||||
|
||||
static inline int int_clamp(int val, int vmin, int vmax)
|
||||
{
|
||||
if (val < vmin)
|
||||
return vmin;
|
||||
else if (val > vmax)
|
||||
return vmax;
|
||||
else
|
||||
return val;
|
||||
}
|
||||
|
||||
static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len)
|
||||
{
|
||||
int dx, dy, dz, b, l;
|
||||
|
||||
if (!s->mouse_grabbed) {
|
||||
qemu_add_mouse_event_handler(usb_mouse_event, s, 0);
|
||||
s->mouse_grabbed = 1;
|
||||
}
|
||||
|
||||
dx = int_clamp(s->dx, -128, 127);
|
||||
dy = int_clamp(s->dy, -128, 127);
|
||||
dz = int_clamp(s->dz, -128, 127);
|
||||
|
||||
s->dx -= dx;
|
||||
s->dy -= dy;
|
||||
s->dz -= dz;
|
||||
|
||||
b = 0;
|
||||
if (s->buttons_state & MOUSE_EVENT_LBUTTON)
|
||||
b |= 0x01;
|
||||
if (s->buttons_state & MOUSE_EVENT_RBUTTON)
|
||||
b |= 0x02;
|
||||
if (s->buttons_state & MOUSE_EVENT_MBUTTON)
|
||||
b |= 0x04;
|
||||
|
||||
buf[0] = b;
|
||||
buf[1] = dx;
|
||||
buf[2] = dy;
|
||||
l = 3;
|
||||
if (len >= 4) {
|
||||
buf[3] = dz;
|
||||
l = 4;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
static int usb_tablet_poll(USBMouseState *s, uint8_t *buf, int len)
|
||||
{
|
||||
int dz, b, l;
|
||||
|
||||
if (!s->mouse_grabbed) {
|
||||
qemu_add_mouse_event_handler(usb_tablet_event, s, 1);
|
||||
s->mouse_grabbed = 1;
|
||||
}
|
||||
|
||||
dz = int_clamp(s->dz, -128, 127);
|
||||
s->dz -= dz;
|
||||
|
||||
/* Appears we have to invert the wheel direction */
|
||||
dz = 0 - dz;
|
||||
b = 0;
|
||||
if (s->buttons_state & MOUSE_EVENT_LBUTTON)
|
||||
b |= 0x01;
|
||||
if (s->buttons_state & MOUSE_EVENT_RBUTTON)
|
||||
b |= 0x02;
|
||||
if (s->buttons_state & MOUSE_EVENT_MBUTTON)
|
||||
b |= 0x04;
|
||||
|
||||
buf[0] = b;
|
||||
buf[1] = s->x & 0xff;
|
||||
buf[2] = s->x >> 8;
|
||||
buf[3] = s->y & 0xff;
|
||||
buf[4] = s->y >> 8;
|
||||
buf[5] = dz;
|
||||
l = 6;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
static void usb_mouse_handle_reset(USBDevice *dev)
|
||||
{
|
||||
USBMouseState *s = (USBMouseState *)dev;
|
||||
|
||||
s->dx = 0;
|
||||
s->dy = 0;
|
||||
s->dz = 0;
|
||||
s->x = 0;
|
||||
s->y = 0;
|
||||
s->buttons_state = 0;
|
||||
}
|
||||
|
||||
static int usb_mouse_handle_control(USBDevice *dev, int request, int value,
|
||||
int index, int length, uint8_t *data)
|
||||
{
|
||||
USBMouseState *s = (USBMouseState *)dev;
|
||||
int ret = 0;
|
||||
|
||||
switch(request) {
|
||||
case DeviceRequest | USB_REQ_GET_STATUS:
|
||||
data[0] = (1 << USB_DEVICE_SELF_POWERED) |
|
||||
(dev->remote_wakeup << USB_DEVICE_REMOTE_WAKEUP);
|
||||
data[1] = 0x00;
|
||||
ret = 2;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_CLEAR_FEATURE:
|
||||
if (value == USB_DEVICE_REMOTE_WAKEUP) {
|
||||
dev->remote_wakeup = 0;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_FEATURE:
|
||||
if (value == USB_DEVICE_REMOTE_WAKEUP) {
|
||||
dev->remote_wakeup = 1;
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_ADDRESS:
|
||||
dev->addr = value;
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
|
||||
switch(value >> 8) {
|
||||
case USB_DT_DEVICE:
|
||||
memcpy(data, qemu_mouse_dev_descriptor,
|
||||
sizeof(qemu_mouse_dev_descriptor));
|
||||
ret = sizeof(qemu_mouse_dev_descriptor);
|
||||
break;
|
||||
case USB_DT_CONFIG:
|
||||
if (s->kind == USB_MOUSE) {
|
||||
memcpy(data, qemu_mouse_config_descriptor,
|
||||
sizeof(qemu_mouse_config_descriptor));
|
||||
ret = sizeof(qemu_mouse_config_descriptor);
|
||||
} else if (s->kind == USB_TABLET) {
|
||||
memcpy(data, qemu_tablet_config_descriptor,
|
||||
sizeof(qemu_tablet_config_descriptor));
|
||||
ret = sizeof(qemu_tablet_config_descriptor);
|
||||
}
|
||||
break;
|
||||
case USB_DT_STRING:
|
||||
switch(value & 0xff) {
|
||||
case 0:
|
||||
/* language ids */
|
||||
data[0] = 4;
|
||||
data[1] = 3;
|
||||
data[2] = 0x09;
|
||||
data[3] = 0x04;
|
||||
ret = 4;
|
||||
break;
|
||||
case 1:
|
||||
/* serial number */
|
||||
ret = set_usb_string(data, "1");
|
||||
break;
|
||||
case 2:
|
||||
/* product description */
|
||||
if (s->kind == USB_MOUSE)
|
||||
ret = set_usb_string(data, "QEMU USB Mouse");
|
||||
else if (s->kind == USB_TABLET)
|
||||
ret = set_usb_string(data, "QEMU USB Tablet");
|
||||
break;
|
||||
case 3:
|
||||
/* vendor description */
|
||||
ret = set_usb_string(data, "PCSX2/QEMU");
|
||||
break;
|
||||
case 4:
|
||||
ret = set_usb_string(data, "HID Mouse");
|
||||
break;
|
||||
case 5:
|
||||
ret = set_usb_string(data, "Endpoint1 Interrupt Pipe");
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_CONFIGURATION:
|
||||
data[0] = 1;
|
||||
ret = 1;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_CONFIGURATION:
|
||||
ret = 0;
|
||||
break;
|
||||
case DeviceRequest | USB_REQ_GET_INTERFACE:
|
||||
data[0] = 0;
|
||||
ret = 1;
|
||||
break;
|
||||
case DeviceOutRequest | USB_REQ_SET_INTERFACE:
|
||||
ret = 0;
|
||||
break;
|
||||
/* hid specific requests */
|
||||
case InterfaceRequest | USB_REQ_GET_DESCRIPTOR:
|
||||
switch(value >> 8) {
|
||||
case 0x22:
|
||||
if (s->kind == USB_MOUSE) {
|
||||
memcpy(data, qemu_mouse_hid_report_descriptor,
|
||||
sizeof(qemu_mouse_hid_report_descriptor));
|
||||
ret = sizeof(qemu_mouse_hid_report_descriptor);
|
||||
} else if (s->kind == USB_TABLET) {
|
||||
memcpy(data, qemu_tablet_hid_report_descriptor,
|
||||
sizeof(qemu_tablet_hid_report_descriptor));
|
||||
ret = sizeof(qemu_tablet_hid_report_descriptor);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case GET_REPORT:
|
||||
if (s->kind == USB_MOUSE)
|
||||
ret = usb_mouse_poll(s, data, length);
|
||||
else if (s->kind == USB_TABLET)
|
||||
ret = usb_tablet_poll(s, data, length);
|
||||
break;
|
||||
case SET_IDLE:
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
fail:
|
||||
ret = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int usb_mouse_handle_data(USBDevice *dev, int pid,
|
||||
uint8_t devep, uint8_t *data, int len)
|
||||
{
|
||||
USBMouseState *s = (USBMouseState *)dev;
|
||||
int ret = 0;
|
||||
|
||||
switch(pid) {
|
||||
case USB_TOKEN_IN:
|
||||
if (devep == 1) {
|
||||
if (s->kind == USB_MOUSE)
|
||||
ret = usb_mouse_poll(s, data, len);
|
||||
else if (s->kind == USB_TABLET)
|
||||
ret = usb_tablet_poll(s, data, len);
|
||||
} else {
|
||||
goto fail;
|
||||
}
|
||||
break;
|
||||
case USB_TOKEN_OUT:
|
||||
default:
|
||||
fail:
|
||||
ret = USB_RET_STALL;
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void usb_mouse_handle_destroy(USBDevice *dev)
|
||||
{
|
||||
USBMouseState *s = (USBMouseState *)dev;
|
||||
|
||||
qemu_add_mouse_event_handler(NULL, NULL, 0);
|
||||
free(s);
|
||||
}
|
||||
|
||||
USBDevice *usb_tablet_init(void)
|
||||
{
|
||||
USBMouseState *s;
|
||||
|
||||
s = qemu_mallocz(sizeof(USBMouseState));
|
||||
if (!s)
|
||||
return NULL;
|
||||
s->dev.speed = USB_SPEED_FULL;
|
||||
s->dev.handle_packet = usb_generic_handle_packet;
|
||||
|
||||
s->dev.handle_reset = usb_mouse_handle_reset;
|
||||
s->dev.handle_control = usb_mouse_handle_control;
|
||||
s->dev.handle_data = usb_mouse_handle_data;
|
||||
s->dev.handle_destroy = usb_mouse_handle_destroy;
|
||||
s->kind = USB_TABLET;
|
||||
|
||||
pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Tablet");
|
||||
|
||||
return (USBDevice *)s;
|
||||
}
|
||||
|
||||
USBDevice *usb_mouse_init(void)
|
||||
{
|
||||
USBMouseState *s;
|
||||
|
||||
s = qemu_mallocz(sizeof(USBMouseState));
|
||||
if (!s)
|
||||
return NULL;
|
||||
s->dev.speed = USB_SPEED_FULL;
|
||||
s->dev.handle_packet = usb_generic_handle_packet;
|
||||
|
||||
s->dev.handle_reset = usb_mouse_handle_reset;
|
||||
s->dev.handle_control = usb_mouse_handle_control;
|
||||
s->dev.handle_data = usb_mouse_handle_data;
|
||||
s->dev.handle_destroy = usb_mouse_handle_destroy;
|
||||
s->kind = USB_MOUSE;
|
||||
|
||||
pstrcpy(s->dev.devname, sizeof(s->dev.devname), "QEMU USB Mouse");
|
||||
|
||||
return (USBDevice *)s;
|
||||
}
|
|
@ -0,0 +1,230 @@
|
|||
/*----------------------------------------------------------------------------
|
||||
* U S B - K e r n e l
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: USB.H
|
||||
* Purpose: USB Definitions
|
||||
* Version: V1.10
|
||||
*----------------------------------------------------------------------------
|
||||
* This software is supplied "AS IS" without any warranties, express,
|
||||
* implied or statutory, including but not limited to the implied
|
||||
* warranties of fitness for purpose, satisfactory quality and
|
||||
* noninfringement. Keil extends you a royalty-free right to reproduce
|
||||
* and distribute executable files created using this software for use
|
||||
* on Philips LPC2xxx microcontroller devices only. Nothing else gives
|
||||
* you the right to use this software.
|
||||
*
|
||||
* Copyright (c) 2005-2006 Keil Software.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __USB_H__
|
||||
#define __USB_H__
|
||||
|
||||
|
||||
#pragma pack(1)
|
||||
|
||||
|
||||
typedef union {
|
||||
WORD W;
|
||||
struct {
|
||||
BYTE L;
|
||||
BYTE H;
|
||||
} WB;
|
||||
} WORD_BYTE;
|
||||
|
||||
|
||||
/* bmRequestType.Dir */
|
||||
#define REQUEST_HOST_TO_DEVICE 0
|
||||
#define REQUEST_DEVICE_TO_HOST 1
|
||||
|
||||
/* bmRequestType.Type */
|
||||
#define REQUEST_STANDARD 0
|
||||
#define REQUEST_CLASS 1
|
||||
#define REQUEST_VENDOR 2
|
||||
#define REQUEST_RESERVED 3
|
||||
|
||||
/* bmRequestType.Recipient */
|
||||
#define REQUEST_TO_DEVICE 0
|
||||
#define REQUEST_TO_INTERFACE 1
|
||||
#define REQUEST_TO_ENDPOINT 2
|
||||
#define REQUEST_TO_OTHER 3
|
||||
|
||||
/* bmRequestType Definition */
|
||||
typedef union _REQUEST_TYPE {
|
||||
struct _BM {
|
||||
BYTE Recipient : 5;
|
||||
BYTE Type : 2;
|
||||
BYTE Dir : 1;
|
||||
} BM;
|
||||
BYTE B;
|
||||
} REQUEST_TYPE;
|
||||
|
||||
/* USB Standard Request Codes */
|
||||
#define USB_REQUEST_GET_STATUS 0
|
||||
#define USB_REQUEST_CLEAR_FEATURE 1
|
||||
#define USB_REQUEST_SET_FEATURE 3
|
||||
#define USB_REQUEST_SET_ADDRESS 5
|
||||
#define USB_REQUEST_GET_DESCRIPTOR 6
|
||||
#define USB_REQUEST_SET_DESCRIPTOR 7
|
||||
#define USB_REQUEST_GET_CONFIGURATION 8
|
||||
#define USB_REQUEST_SET_CONFIGURATION 9
|
||||
#define USB_REQUEST_GET_INTERFACE 10
|
||||
#define USB_REQUEST_SET_INTERFACE 11
|
||||
#define USB_REQUEST_SYNC_FRAME 12
|
||||
|
||||
/* USB GET_STATUS Bit Values */
|
||||
#define USB_GETSTATUS_SELF_POWERED 0x01
|
||||
#define USB_GETSTATUS_REMOTE_WAKEUP 0x02
|
||||
#define USB_GETSTATUS_ENDPOINT_STALL 0x01
|
||||
|
||||
/* USB Standard Feature selectors */
|
||||
#define USB_FEATURE_ENDPOINT_STALL 0
|
||||
#define USB_FEATURE_REMOTE_WAKEUP 1
|
||||
|
||||
/* USB Default Control Pipe Setup Packet */
|
||||
typedef struct _USB_SETUP_PACKET {
|
||||
REQUEST_TYPE bmRequestType;
|
||||
BYTE bRequest;
|
||||
WORD_BYTE wValue;
|
||||
WORD_BYTE wIndex;
|
||||
WORD wLength;
|
||||
} USB_SETUP_PACKET;
|
||||
|
||||
|
||||
/* USB Descriptor Types */
|
||||
#define USB_DEVICE_DESCRIPTOR_TYPE 1
|
||||
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 2
|
||||
#define USB_STRING_DESCRIPTOR_TYPE 3
|
||||
#define USB_INTERFACE_DESCRIPTOR_TYPE 4
|
||||
#define USB_ENDPOINT_DESCRIPTOR_TYPE 5
|
||||
#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE 6
|
||||
#define USB_OTHER_SPEED_CONFIG_DESCRIPTOR_TYPE 7
|
||||
#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 8
|
||||
|
||||
/* USB Device Classes */
|
||||
#define USB_DEVICE_CLASS_RESERVED 0x00
|
||||
#define USB_DEVICE_CLASS_AUDIO 0x01
|
||||
#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
|
||||
#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
|
||||
#define USB_DEVICE_CLASS_MONITOR 0x04
|
||||
#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
|
||||
#define USB_DEVICE_CLASS_POWER 0x06
|
||||
#define USB_DEVICE_CLASS_PRINTER 0x07
|
||||
#define USB_DEVICE_CLASS_STORAGE 0x08
|
||||
#define USB_DEVICE_CLASS_HUB 0x09
|
||||
#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
|
||||
|
||||
/* bmAttributes in Configuration Descriptor */
|
||||
#define USB_CONFIG_POWERED_MASK 0xC0
|
||||
#define USB_CONFIG_BUS_POWERED 0x80
|
||||
#define USB_CONFIG_SELF_POWERED 0x40
|
||||
#define USB_CONFIG_REMOTE_WAKEUP 0x20
|
||||
|
||||
/* bMaxPower in Configuration Descriptor */
|
||||
#define USB_CONFIG_POWER_MA(mA) ((mA)/2)
|
||||
|
||||
/* bEndpointAddress in Endpoint Descriptor */
|
||||
#define USB_ENDPOINT_DIRECTION_MASK 0x80
|
||||
#define USB_ENDPOINT_OUT(addr) ((addr) | 0x00)
|
||||
#define USB_ENDPOINT_IN(addr) ((addr) | 0x80)
|
||||
|
||||
/* bmAttributes in Endpoint Descriptor */
|
||||
#define USB_ENDPOINT_TYPE_MASK 0x03
|
||||
#define USB_ENDPOINT_TYPE_CONTROL 0x00
|
||||
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
|
||||
#define USB_ENDPOINT_TYPE_BULK 0x02
|
||||
#define USB_ENDPOINT_TYPE_INTERRUPT 0x03
|
||||
#define USB_ENDPOINT_SYNC_MASK 0x0C
|
||||
#define USB_ENDPOINT_SYNC_NO_SYNCHRONIZATION 0x00
|
||||
#define USB_ENDPOINT_SYNC_ASYNCHRONOUS 0x04
|
||||
#define USB_ENDPOINT_SYNC_ADAPTIVE 0x08
|
||||
#define USB_ENDPOINT_SYNC_SYNCHRONOUS 0x0C
|
||||
#define USB_ENDPOINT_USAGE_MASK 0x30
|
||||
#define USB_ENDPOINT_USAGE_DATA 0x00
|
||||
#define USB_ENDPOINT_USAGE_FEEDBACK 0x10
|
||||
#define USB_ENDPOINT_USAGE_IMPLICIT_FEEDBACK 0x20
|
||||
#define USB_ENDPOINT_USAGE_RESERVED 0x30
|
||||
|
||||
/* USB Standard Device Descriptor */
|
||||
typedef struct _USB_DEVICE_DESCRIPTOR {
|
||||
BYTE bLength;
|
||||
BYTE bDescriptorType;
|
||||
WORD bcdUSB;
|
||||
BYTE bDeviceClass;
|
||||
BYTE bDeviceSubClass;
|
||||
BYTE bDeviceProtocol;
|
||||
BYTE bMaxPacketSize0;
|
||||
WORD idVendor;
|
||||
WORD idProduct;
|
||||
WORD bcdDevice;
|
||||
BYTE iManufacturer;
|
||||
BYTE iProduct;
|
||||
BYTE iSerialNumber;
|
||||
BYTE bNumConfigurations;
|
||||
} USB_DEVICE_DESCRIPTOR;
|
||||
|
||||
/* USB 2.0 Device Qualifier Descriptor */
|
||||
typedef struct _USB_DEVICE_QUALIFIER_DESCRIPTOR {
|
||||
BYTE bLength;
|
||||
BYTE bDescriptorType;
|
||||
WORD bcdUSB;
|
||||
BYTE bDeviceClass;
|
||||
BYTE bDeviceSubClass;
|
||||
BYTE bDeviceProtocol;
|
||||
BYTE bMaxPacketSize0;
|
||||
BYTE bNumConfigurations;
|
||||
BYTE bReserved;
|
||||
} USB_DEVICE_QUALIFIER_DESCRIPTOR;
|
||||
|
||||
/* USB Standard Configuration Descriptor */
|
||||
typedef struct _USB_CONFIGURATION_DESCRIPTOR {
|
||||
BYTE bLength;
|
||||
BYTE bDescriptorType;
|
||||
WORD wTotalLength;
|
||||
BYTE bNumInterfaces;
|
||||
BYTE bConfigurationValue;
|
||||
BYTE iConfiguration;
|
||||
BYTE bmAttributes;
|
||||
BYTE MaxPower;
|
||||
} USB_CONFIGURATION_DESCRIPTOR;
|
||||
|
||||
/* USB Standard Interface Descriptor */
|
||||
typedef struct _USB_INTERFACE_DESCRIPTOR {
|
||||
BYTE bLength;
|
||||
BYTE bDescriptorType;
|
||||
BYTE bInterfaceNumber;
|
||||
BYTE bAlternateSetting;
|
||||
BYTE bNumEndpoints;
|
||||
BYTE bInterfaceClass;
|
||||
BYTE bInterfaceSubClass;
|
||||
BYTE bInterfaceProtocol;
|
||||
BYTE iInterface;
|
||||
} USB_INTERFACE_DESCRIPTOR;
|
||||
|
||||
/* USB Standard Endpoint Descriptor */
|
||||
typedef struct _USB_ENDPOINT_DESCRIPTOR {
|
||||
BYTE bLength;
|
||||
BYTE bDescriptorType;
|
||||
BYTE bEndpointAddress;
|
||||
BYTE bmAttributes;
|
||||
WORD wMaxPacketSize;
|
||||
BYTE bInterval;
|
||||
} USB_ENDPOINT_DESCRIPTOR;
|
||||
|
||||
/* USB String Descriptor */
|
||||
typedef struct _USB_STRING_DESCRIPTOR {
|
||||
BYTE bLength;
|
||||
BYTE bDescriptorType;
|
||||
WORD bString/*[]*/;
|
||||
} USB_STRING_DESCRIPTOR;
|
||||
|
||||
/* USB Common Descriptor */
|
||||
typedef struct _USB_COMMON_DESCRIPTOR {
|
||||
BYTE bLength;
|
||||
BYTE bDescriptorType;
|
||||
} USB_COMMON_DESCRIPTOR;
|
||||
|
||||
|
||||
#pragma pack()
|
||||
|
||||
|
||||
#endif /* __USB_H__ */
|
|
@ -0,0 +1,161 @@
|
|||
/*----------------------------------------------------------------------------
|
||||
* U S B - K e r n e l
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: USBCFG.H
|
||||
* Purpose: USB Custom Configuration
|
||||
* Version: V1.10
|
||||
*----------------------------------------------------------------------------
|
||||
* This software is supplied "AS IS" without any warranties, express,
|
||||
* implied or statutory, including but not limited to the implied
|
||||
* warranties of fitness for purpose, satisfactory quality and
|
||||
* noninfringement. Keil extends you a royalty-free right to reproduce
|
||||
* and distribute executable files created using this software for use
|
||||
* on Philips LPC2xxx microcontroller devices only. Nothing else gives
|
||||
* you the right to use this software.
|
||||
*
|
||||
* Copyright (c) 2005-2006 Keil Software.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __USBCFG_H__
|
||||
#define __USBCFG_H__
|
||||
|
||||
|
||||
/*
|
||||
//*** <<< Use Configuration Wizard in Context Menu >>> ***
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
// <h> USB Configuration
|
||||
// <o0> USB Power
|
||||
// <i> Default Power Setting
|
||||
// <0=> Bus-powered
|
||||
// <1=> Self-powered
|
||||
// <o1> Max Number of Interfaces <1-256>
|
||||
// <o2> Max Number of Endpoints <1-32>
|
||||
// <o3> Max Endpoint 0 Packet Size
|
||||
// <8=> 8 Bytes <16=> 16 Bytes <32=> 32 Bytes <64=> 64 Bytes
|
||||
// <e4> DMA Transfer
|
||||
// <i> Use DMA for selected Endpoints
|
||||
// <o5.0> Endpoint 0 Out
|
||||
// <o5.1> Endpoint 0 In
|
||||
// <o5.2> Endpoint 1 Out
|
||||
// <o5.3> Endpoint 1 In
|
||||
// <o5.4> Endpoint 2 Out
|
||||
// <o5.5> Endpoint 2 In
|
||||
// <o5.6> Endpoint 3 Out
|
||||
// <o5.7> Endpoint 3 In
|
||||
// <o5.8> Endpoint 4 Out
|
||||
// <o5.9> Endpoint 4 In
|
||||
// <o5.10> Endpoint 5 Out
|
||||
// <o5.11> Endpoint 5 In
|
||||
// <o5.12> Endpoint 6 Out
|
||||
// <o5.13> Endpoint 6 In
|
||||
// <o5.14> Endpoint 7 Out
|
||||
// <o5.15> Endpoint 7 In
|
||||
// <o5.16> Endpoint 8 Out
|
||||
// <o5.17> Endpoint 8 In
|
||||
// <o5.18> Endpoint 9 Out
|
||||
// <o5.19> Endpoint 9 In
|
||||
// <o5.20> Endpoint 10 Out
|
||||
// <o5.21> Endpoint 10 In
|
||||
// <o5.22> Endpoint 11 Out
|
||||
// <o5.23> Endpoint 11 In
|
||||
// <o5.24> Endpoint 12 Out
|
||||
// <o5.25> Endpoint 12 In
|
||||
// <o5.26> Endpoint 13 Out
|
||||
// <o5.27> Endpoint 13 In
|
||||
// <o5.28> Endpoint 14 Out
|
||||
// <o5.29> Endpoint 14 In
|
||||
// <o5.30> Endpoint 15 Out
|
||||
// <o5.31> Endpoint 15 In
|
||||
// </e>
|
||||
// </h>
|
||||
*/
|
||||
|
||||
#define USB_POWER 0
|
||||
#define USB_IF_NUM 4
|
||||
#define USB_EP_NUM 32
|
||||
#define USB_MAX_PACKET0 64
|
||||
#define USB_DMA 0
|
||||
#define USB_DMA_EP 0x00000040
|
||||
|
||||
|
||||
/*
|
||||
// <h> USB Event Handlers
|
||||
// <h> Device Events
|
||||
// <o0.0> Power Event
|
||||
// <o1.0> Reset Event
|
||||
// <o2.0> Suspend Event
|
||||
// <o3.0> Resume Event
|
||||
// <o4.0> Remote Wakeup Event
|
||||
// <o5.0> Start of Frame Event
|
||||
// <o6.0> Error Event
|
||||
// </h>
|
||||
// <h> Endpoint Events
|
||||
// <o7.0> Endpoint 0 Event
|
||||
// <o7.1> Endpoint 1 Event
|
||||
// <o7.2> Endpoint 2 Event
|
||||
// <o7.3> Endpoint 3 Event
|
||||
// <o7.4> Endpoint 4 Event
|
||||
// <o7.5> Endpoint 5 Event
|
||||
// <o7.6> Endpoint 6 Event
|
||||
// <o7.7> Endpoint 7 Event
|
||||
// <o7.8> Endpoint 8 Event
|
||||
// <o7.9> Endpoint 9 Event
|
||||
// <o7.10> Endpoint 10 Event
|
||||
// <o7.11> Endpoint 11 Event
|
||||
// <o7.12> Endpoint 12 Event
|
||||
// <o7.13> Endpoint 13 Event
|
||||
// <o7.14> Endpoint 14 Event
|
||||
// <o7.15> Endpoint 15 Event
|
||||
// </h>
|
||||
// <h> USB Core Events
|
||||
// <o8.0> Set Configuration Event
|
||||
// <o9.0> Set Interface Event
|
||||
// <o10.0> Set/Clear Feature Event
|
||||
// </h>
|
||||
// </h>
|
||||
*/
|
||||
|
||||
#define USB_POWER_EVENT 0
|
||||
#define USB_RESET_EVENT 1
|
||||
#define USB_SUSPEND_EVENT 0
|
||||
#define USB_RESUME_EVENT 0
|
||||
#define USB_WAKEUP_EVENT 0
|
||||
#define USB_SOF_EVENT 1
|
||||
#define USB_ERROR_EVENT 0
|
||||
#define USB_EP_EVENT 0x0009
|
||||
#define USB_CONFIGURE_EVENT 0
|
||||
#define USB_INTERFACE_EVENT 0
|
||||
#define USB_FEATURE_EVENT 0
|
||||
|
||||
|
||||
/*
|
||||
// <e0> USB Class Support
|
||||
// <e1> Human Interface Device (HID)
|
||||
// <o2> Interface Number <0-255>
|
||||
// </e>
|
||||
// <e3> Mass Storage
|
||||
// <o4> Interface Number <0-255>
|
||||
// </e>
|
||||
// <e5> Audio Device
|
||||
// <o6> Control Interface Number <0-255>
|
||||
// <o7> Streaming Interface 1 Number <0-255>
|
||||
// <o8> Streaming Interface 2 Number <0-255>
|
||||
// </e>
|
||||
// </e>
|
||||
*/
|
||||
|
||||
#define USB_CLASS 1
|
||||
#define USB_HID 0
|
||||
#define USB_HID_IF_NUM 0
|
||||
#define USB_MSC 0
|
||||
#define USB_MSC_IF_NUM 0
|
||||
#define USB_AUDIO 1
|
||||
#define USB_ADC_CIF_NUM 0
|
||||
#define USB_ADC_SIF1_NUM 1
|
||||
#define USB_ADC_SIF2_NUM 2
|
||||
|
||||
|
||||
#endif /* __USBCFG_H__ */
|
|
@ -0,0 +1,50 @@
|
|||
/*----------------------------------------------------------------------------
|
||||
* U S B - K e r n e l
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: USBCORE.H
|
||||
* Purpose: USB Core Definitions
|
||||
* Version: V1.10
|
||||
*----------------------------------------------------------------------------
|
||||
* This software is supplied "AS IS" without any warranties, express,
|
||||
* implied or statutory, including but not limited to the implied
|
||||
* warranties of fitness for purpose, satisfactory quality and
|
||||
* noninfringement. Keil extends you a royalty-free right to reproduce
|
||||
* and distribute executable files created using this software for use
|
||||
* on Philips LPC2xxx microcontroller devices only. Nothing else gives
|
||||
* you the right to use this software.
|
||||
*
|
||||
* Copyright (c) 2005-2006 Keil Software.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __USBCORE_H__
|
||||
#define __USBCORE_H__
|
||||
|
||||
|
||||
/* USB Endpoint Data Structure */
|
||||
typedef struct _USB_EP_DATA {
|
||||
BYTE *pData;
|
||||
WORD Count;
|
||||
} USB_EP_DATA;
|
||||
|
||||
/* USB Core Global Variables */
|
||||
extern WORD USB_DeviceStatus;
|
||||
extern BYTE USB_DeviceAddress;
|
||||
extern BYTE USB_Configuration;
|
||||
extern DWORD USB_EndPointMask;
|
||||
extern DWORD USB_EndPointHalt;
|
||||
extern BYTE USB_AltSetting[USB_IF_NUM];
|
||||
|
||||
/* USB Endpoint 0 Buffer */
|
||||
extern BYTE EP0Buf[USB_MAX_PACKET0];
|
||||
|
||||
/* USB Endpoint 0 Data Info */
|
||||
extern USB_EP_DATA EP0Data;
|
||||
|
||||
/* USB Setup Packet */
|
||||
extern USB_SETUP_PACKET SetupPacket;
|
||||
|
||||
/* USB Core Functions */
|
||||
extern void USB_ResetCore (void);
|
||||
|
||||
|
||||
#endif /* __USBCORE_H__ */
|
|
@ -0,0 +1,36 @@
|
|||
/*----------------------------------------------------------------------------
|
||||
* U S B - K e r n e l
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: USBDESC.C
|
||||
* Purpose: USB Descriptors Definitions
|
||||
* Version: V1.10
|
||||
*----------------------------------------------------------------------------
|
||||
* This software is supplied "AS IS" without any warranties, express,
|
||||
* implied or statutory, including but not limited to the implied
|
||||
* warranties of fitness for purpose, satisfactory quality and
|
||||
* noninfringement. Keil extends you a royalty-free right to reproduce
|
||||
* and distribute executable files created using this software for use
|
||||
* on Philips LPC2xxx microcontroller devices only. Nothing else gives
|
||||
* you the right to use this software.
|
||||
*
|
||||
* Copyright (c) 2005-2006 Keil Software.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __USBDESC_H__
|
||||
#define __USBDESC_H__
|
||||
|
||||
|
||||
#define WBVAL(x) (x & 0xFF),((x >> 8) & 0xFF)
|
||||
#define B3VAL(x) (x & 0xFF),((x >> 8) & 0xFF),((x >> 16) & 0xFF)
|
||||
|
||||
#define USB_DEVICE_DESC_SIZE (sizeof(USB_DEVICE_DESCRIPTOR))
|
||||
#define USB_CONFIGUARTION_DESC_SIZE (sizeof(USB_CONFIGURATION_DESCRIPTOR))
|
||||
#define USB_INTERFACE_DESC_SIZE (sizeof(USB_INTERFACE_DESCRIPTOR))
|
||||
#define USB_ENDPOINT_DESC_SIZE (sizeof(USB_ENDPOINT_DESCRIPTOR))
|
||||
|
||||
extern const BYTE USB_DeviceDescriptor[];
|
||||
extern const BYTE USB_ConfigDescriptor[];
|
||||
extern const BYTE USB_StringDescriptor[];
|
||||
|
||||
|
||||
#endif /* __USBDESC_H__ */
|
|
@ -0,0 +1,107 @@
|
|||
/*----------------------------------------------------------------------------
|
||||
* U S B - K e r n e l
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: USBHW.H
|
||||
* Purpose: USB Hardware Layer Definitions
|
||||
* Version: V1.10
|
||||
*----------------------------------------------------------------------------
|
||||
* This software is supplied "AS IS" without any warranties, express,
|
||||
* implied or statutory, including but not limited to the implied
|
||||
* warranties of fitness for purpose, satisfactory quality and
|
||||
* noninfringement. Keil extends you a royalty-free right to reproduce
|
||||
* and distribute executable files created using this software for use
|
||||
* on Philips LPC2xxx microcontroller devices only. Nothing else gives
|
||||
* you the right to use this software.
|
||||
*
|
||||
* Copyright (c) 2005-2006 Keil Software.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __USBHW_H__
|
||||
#define __USBHW_H__
|
||||
|
||||
|
||||
/* USB RAM Definitions */
|
||||
#define USB_RAM_ADR 0x7FD00000 /* USB RAM Start Address */
|
||||
#define USB_RAM_SZ 0x00002000 /* USB RAM Size (8kB) */
|
||||
|
||||
/* DMA Endpoint Descriptors */
|
||||
#define DD_NISO_CNT 16 /* Non-Iso EP DMA Descr. Count (max. 32) */
|
||||
#define DD_ISO_CNT 8 /* Iso EP DMA Descriptor Count (max. 32) */
|
||||
#define DD_NISO_SZ (DD_NISO_CNT * 16) /* Non-Iso DMA Descr. Size */
|
||||
#define DD_ISO_SZ (DD_ISO_CNT * 20) /* Iso DMA Descriptor Size */
|
||||
#define DD_NISO_ADR (USB_RAM_ADR + 128) /* Non-Iso DMA Descr. Address */
|
||||
#define DD_ISO_ADR (DD_NISO_ADR + DD_NISO_SZ) /* Iso DMA Descr. Address */
|
||||
#define DD_SZ (128 + DD_NISO_SZ + DD_ISO_SZ) /* Descr. Size */
|
||||
|
||||
/* DMA Buffer Memory Definitions */
|
||||
#define DMA_BUF_ADR (USB_RAM_ADR + DD_SZ) /* DMA Buffer Start Address */
|
||||
#define DMA_BUF_SZ (USB_RAM_SZ - DD_SZ) /* DMA Buffer Size */
|
||||
|
||||
/* USB Error Codes */
|
||||
#define USB_ERR_PID 0x0001 /* PID Error */
|
||||
#define USB_ERR_UEPKT 0x0002 /* Unexpected Packet */
|
||||
#define USB_ERR_DCRC 0x0004 /* Data CRC Error */
|
||||
#define USB_ERR_TIMOUT 0x0008 /* Bus Time-out Error */
|
||||
#define USB_ERR_EOP 0x0010 /* End of Packet Error */
|
||||
#define USB_ERR_B_OVRN 0x0020 /* Buffer Overrun */
|
||||
#define USB_ERR_BTSTF 0x0040 /* Bit Stuff Error */
|
||||
#define USB_ERR_TGL 0x0080 /* Toggle Bit Error */
|
||||
|
||||
/* USB DMA Status Codes */
|
||||
#define USB_DMA_INVALID 0x0000 /* DMA Invalid - Not Configured */
|
||||
#define USB_DMA_IDLE 0x0001 /* DMA Idle - Waiting for Trigger */
|
||||
#define USB_DMA_BUSY 0x0002 /* DMA Busy - Transfer in progress */
|
||||
#define USB_DMA_DONE 0x0003 /* DMA Transfer Done (no Errors)*/
|
||||
#define USB_DMA_OVER_RUN 0x0004 /* Data Over Run */
|
||||
#define USB_DMA_UNDER_RUN 0x0005 /* Data Under Run (Short Packet) */
|
||||
#define USB_DMA_ERROR 0x0006 /* Error */
|
||||
#define USB_DMA_UNKNOWN 0xFFFF /* Unknown State */
|
||||
|
||||
/* USB DMA Descriptor */
|
||||
typedef struct _USB_DMA_DESCRIPTOR {
|
||||
DWORD BufAdr; /* DMA Buffer Address */
|
||||
WORD BufLen; /* DMA Buffer Length */
|
||||
WORD MaxSize; /* Maximum Packet Size */
|
||||
DWORD InfoAdr; /* Packet Info Memory Address */
|
||||
union { /* DMA Configuration */
|
||||
struct {
|
||||
DWORD Link : 1; /* Link to existing Descriptors */
|
||||
DWORD IsoEP : 1; /* Isonchronous Endpoint */
|
||||
DWORD ATLE : 1; /* ATLE (Auto Transfer Length Extract) */
|
||||
DWORD Rsrvd : 5; /* Reserved */
|
||||
DWORD LenPos : 8; /* Length Position (ATLE) */
|
||||
} Type;
|
||||
DWORD Val;
|
||||
} Cfg;
|
||||
} USB_DMA_DESCRIPTOR;
|
||||
|
||||
/* USB Hardware Functions */
|
||||
extern void USB_Init (void);
|
||||
extern void USB_Connect (BOOL con);
|
||||
extern void USB_Reset (void);
|
||||
extern void USB_Suspend (void);
|
||||
extern void USB_Resume (void);
|
||||
extern void USB_WakeUp (void);
|
||||
extern void USB_WakeUpCfg (BOOL cfg);
|
||||
extern void USB_SetAddress (DWORD adr);
|
||||
extern void USB_Configure (BOOL cfg);
|
||||
extern void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD);
|
||||
extern void USB_DirCtrlEP (DWORD dir);
|
||||
extern void USB_EnableEP (DWORD EPNum);
|
||||
extern void USB_DisableEP (DWORD EPNum);
|
||||
extern void USB_ResetEP (DWORD EPNum);
|
||||
extern void USB_SetStallEP (DWORD EPNum);
|
||||
extern void USB_ClrStallEP (DWORD EPNum);
|
||||
extern DWORD USB_ReadEP (DWORD EPNum, BYTE *pData);
|
||||
extern DWORD USB_WriteEP (DWORD EPNum, BYTE *pData, DWORD cnt);
|
||||
extern BOOL USB_DMA_Setup (DWORD EPNum, USB_DMA_DESCRIPTOR *pDD);
|
||||
extern void USB_DMA_Enable (DWORD EPNum);
|
||||
extern void USB_DMA_Disable(DWORD EPNum);
|
||||
extern DWORD USB_DMA_Status (DWORD EPNum);
|
||||
extern DWORD USB_DMA_BufAdr (DWORD EPNum);
|
||||
extern DWORD USB_DMA_BufCnt (DWORD EPNum);
|
||||
extern DWORD USB_GetFrame (void);
|
||||
extern void USB_ISR (void) __irq;
|
||||
|
||||
|
||||
#endif /* __USBHW_H__ */
|
|
@ -0,0 +1,195 @@
|
|||
/***********************************************************************/
|
||||
/* This file is part of the uVision/ARM development tools */
|
||||
/* Copyright KEIL ELEKTRONIK GmbH 2002-2006 */
|
||||
/***********************************************************************/
|
||||
/* */
|
||||
/* USBREG.H: Header file for Philips LPC214X USB */
|
||||
/* */
|
||||
/***********************************************************************/
|
||||
|
||||
#ifndef __USBREG_H
|
||||
#define __USBREG_H
|
||||
|
||||
|
||||
#define SCB_BASE_ADDR 0xE01FC000 /* System Control Block */
|
||||
|
||||
/* PLL48 Registers */
|
||||
#define PLL48CON (*(volatile unsigned int*)(SCB_BASE_ADDR + 0xA0))
|
||||
#define PLL48CFG (*(volatile unsigned int*)(SCB_BASE_ADDR + 0xA4))
|
||||
#define PLL48STAT (*(volatile unsigned int*)(SCB_BASE_ADDR + 0xA8))
|
||||
#define PLL48FEED (*(volatile unsigned int*)(SCB_BASE_ADDR + 0xAC))
|
||||
|
||||
/* PLL48 Bit Definitions */
|
||||
#define PLLCON_PLLE (1<<0) /* PLL Enable */
|
||||
#define PLLCON_PLLC (1<<1) /* PLL Connect */
|
||||
#define PLLCFG_MSEL (0x1F<<0) /* PLL Multiplier */
|
||||
#define PLLCFG_PSEL (0x03<<5) /* PLL Divider */
|
||||
#define PLLSTAT_PLOCK (1<<10) /* PLL Lock Status */
|
||||
|
||||
|
||||
#define USB_BASE_ADDR 0xE0090000 /* USB Base Address */
|
||||
|
||||
/* Device Interrupt Registers */
|
||||
#define DEV_INT_STAT (*(volatile unsigned int*)(USB_BASE_ADDR + 0x00))
|
||||
#define DEV_INT_EN (*(volatile unsigned int*)(USB_BASE_ADDR + 0x04))
|
||||
#define DEV_INT_CLR (*(volatile unsigned int*)(USB_BASE_ADDR + 0x08))
|
||||
#define DEV_INT_SET (*(volatile unsigned int*)(USB_BASE_ADDR + 0x0C))
|
||||
#define DEV_INT_PRIO (*(volatile unsigned int*)(USB_BASE_ADDR + 0x2C))
|
||||
|
||||
/* Endpoint Interrupt Registers */
|
||||
#define EP_INT_STAT (*(volatile unsigned int*)(USB_BASE_ADDR + 0x30))
|
||||
#define EP_INT_EN (*(volatile unsigned int*)(USB_BASE_ADDR + 0x34))
|
||||
#define EP_INT_CLR (*(volatile unsigned int*)(USB_BASE_ADDR + 0x38))
|
||||
#define EP_INT_SET (*(volatile unsigned int*)(USB_BASE_ADDR + 0x3C))
|
||||
#define EP_INT_PRIO (*(volatile unsigned int*)(USB_BASE_ADDR + 0x40))
|
||||
|
||||
/* Endpoint Realization Registers */
|
||||
#define REALIZE_EP (*(volatile unsigned int*)(USB_BASE_ADDR + 0x44))
|
||||
#define EP_INDEX (*(volatile unsigned int*)(USB_BASE_ADDR + 0x48))
|
||||
#define MAXPACKET_SIZE (*(volatile unsigned int*)(USB_BASE_ADDR + 0x4C))
|
||||
|
||||
/* Command Reagisters */
|
||||
#define CMD_CODE (*(volatile unsigned int*)(USB_BASE_ADDR + 0x10))
|
||||
#define CMD_DATA (*(volatile unsigned int*)(USB_BASE_ADDR + 0x14))
|
||||
|
||||
/* Data Transfer Registers */
|
||||
#define RX_DATA (*(volatile unsigned int*)(USB_BASE_ADDR + 0x18))
|
||||
#define TX_DATA (*(volatile unsigned int*)(USB_BASE_ADDR + 0x1C))
|
||||
#define RX_PLENGTH (*(volatile unsigned int*)(USB_BASE_ADDR + 0x20))
|
||||
#define TX_PLENGTH (*(volatile unsigned int*)(USB_BASE_ADDR + 0x24))
|
||||
#define USB_CTRL (*(volatile unsigned int*)(USB_BASE_ADDR + 0x28))
|
||||
|
||||
/* System Register */
|
||||
#define DC_REVISION (*(volatile unsigned int*)(USB_BASE_ADDR + 0x7C))
|
||||
|
||||
/* DMA Registers */
|
||||
#define DMA_REQ_STAT (*(volatile unsigned int*)(USB_BASE_ADDR + 0x50))
|
||||
#define DMA_REQ_CLR (*(volatile unsigned int*)(USB_BASE_ADDR + 0x54))
|
||||
#define DMA_REQ_SET (*(volatile unsigned int*)(USB_BASE_ADDR + 0x58))
|
||||
#define UDCA_HEAD (*(volatile unsigned int*)(USB_BASE_ADDR + 0x80))
|
||||
#define EP_DMA_STAT (*(volatile unsigned int*)(USB_BASE_ADDR + 0x84))
|
||||
#define EP_DMA_EN (*(volatile unsigned int*)(USB_BASE_ADDR + 0x88))
|
||||
#define EP_DMA_DIS (*(volatile unsigned int*)(USB_BASE_ADDR + 0x8C))
|
||||
#define DMA_INT_STAT (*(volatile unsigned int*)(USB_BASE_ADDR + 0x90))
|
||||
#define DMA_INT_EN (*(volatile unsigned int*)(USB_BASE_ADDR + 0x94))
|
||||
#define EOT_INT_STAT (*(volatile unsigned int*)(USB_BASE_ADDR + 0xA0))
|
||||
#define EOT_INT_CLR (*(volatile unsigned int*)(USB_BASE_ADDR + 0xA4))
|
||||
#define EOT_INT_SET (*(volatile unsigned int*)(USB_BASE_ADDR + 0xA8))
|
||||
#define NDD_REQ_INT_STAT (*(volatile unsigned int*)(USB_BASE_ADDR + 0xAC))
|
||||
#define NDD_REQ_INT_CLR (*(volatile unsigned int*)(USB_BASE_ADDR + 0xB0))
|
||||
#define NDD_REQ_INT_SET (*(volatile unsigned int*)(USB_BASE_ADDR + 0xB4))
|
||||
#define SYS_ERR_INT_STAT (*(volatile unsigned int*)(USB_BASE_ADDR + 0xB8))
|
||||
#define SYS_ERR_INT_CLR (*(volatile unsigned int*)(USB_BASE_ADDR + 0xBC))
|
||||
#define SYS_ERR_INT_SET (*(volatile unsigned int*)(USB_BASE_ADDR + 0xC0))
|
||||
#define MODULE_ID (*(volatile unsigned int*)(USB_BASE_ADDR + 0xFC))
|
||||
|
||||
|
||||
/* Device Interrupt Bit Definitions */
|
||||
#define FRAME_INT 0x00000001
|
||||
#define EP_FAST_INT 0x00000002
|
||||
#define EP_SLOW_INT 0x00000004
|
||||
#define DEV_STAT_INT 0x00000008
|
||||
#define CCEMTY_INT 0x00000010
|
||||
#define CDFULL_INT 0x00000020
|
||||
#define RxENDPKT_INT 0x00000040
|
||||
#define TxENDPKT_INT 0x00000080
|
||||
#define EP_RLZED_INT 0x00000100
|
||||
#define ERR_INT 0x00000200
|
||||
|
||||
/* Rx & Tx Packet Length Definitions */
|
||||
#define PKT_LNGTH_MASK 0x000003FF
|
||||
#define PKT_DV 0x00000400
|
||||
#define PKT_RDY 0x00000800
|
||||
|
||||
/* USB Control Definitions */
|
||||
#define CTRL_RD_EN 0x00000001
|
||||
#define CTRL_WR_EN 0x00000002
|
||||
|
||||
/* Command Codes */
|
||||
#define CMD_SET_ADDR 0x00D00500
|
||||
#define CMD_CFG_DEV 0x00D80500
|
||||
#define CMD_SET_MODE 0x00F30500
|
||||
#define CMD_RD_FRAME 0x00F50500
|
||||
#define DAT_RD_FRAME 0x00F50200
|
||||
#define CMD_RD_TEST 0x00FD0500
|
||||
#define DAT_RD_TEST 0x00FD0200
|
||||
#define CMD_SET_DEV_STAT 0x00FE0500
|
||||
#define CMD_GET_DEV_STAT 0x00FE0500
|
||||
#define DAT_GET_DEV_STAT 0x00FE0200
|
||||
#define CMD_GET_ERR_CODE 0x00FF0500
|
||||
#define DAT_GET_ERR_CODE 0x00FF0200
|
||||
#define CMD_RD_ERR_STAT 0x00FB0500
|
||||
#define DAT_RD_ERR_STAT 0x00FB0200
|
||||
#define DAT_WR_BYTE(x) (0x00000100 | ((x) << 16))
|
||||
#define CMD_SEL_EP(x) (0x00000500 | ((x) << 16))
|
||||
#define DAT_SEL_EP(x) (0x00000200 | ((x) << 16))
|
||||
#define CMD_SEL_EP_CLRI(x) (0x00400500 | ((x) << 16))
|
||||
#define DAT_SEL_EP_CLRI(x) (0x00400200 | ((x) << 16))
|
||||
#define CMD_SET_EP_STAT(x) (0x00400500 | ((x) << 16))
|
||||
#define CMD_CLR_BUF 0x00F20500
|
||||
#define DAT_CLR_BUF 0x00F20200
|
||||
#define CMD_VALID_BUF 0x00FA0500
|
||||
|
||||
/* Device Address Register Definitions */
|
||||
#define DEV_ADDR_MASK 0x7F
|
||||
#define DEV_EN 0x80
|
||||
|
||||
/* Device Configure Register Definitions */
|
||||
#define CONF_DVICE 0x01
|
||||
|
||||
/* Device Mode Register Definitions */
|
||||
#define AP_CLK 0x01
|
||||
#define INAK_CI 0x02
|
||||
#define INAK_CO 0x04
|
||||
#define INAK_II 0x08
|
||||
#define INAK_IO 0x10
|
||||
#define INAK_BI 0x20
|
||||
#define INAK_BO 0x40
|
||||
|
||||
/* Device Status Register Definitions */
|
||||
#define DEV_CON 0x01
|
||||
#define DEV_CON_CH 0x02
|
||||
#define DEV_SUS 0x04
|
||||
#define DEV_SUS_CH 0x08
|
||||
#define DEV_RST 0x10
|
||||
|
||||
/* Error Code Register Definitions */
|
||||
#define ERR_EC_MASK 0x0F
|
||||
#define ERR_EA 0x10
|
||||
|
||||
/* Error Status Register Definitions */
|
||||
#define ERR_PID 0x01
|
||||
#define ERR_UEPKT 0x02
|
||||
#define ERR_DCRC 0x04
|
||||
#define ERR_TIMOUT 0x08
|
||||
#define ERR_EOP 0x10
|
||||
#define ERR_B_OVRN 0x20
|
||||
#define ERR_BTSTF 0x40
|
||||
#define ERR_TGL 0x80
|
||||
|
||||
/* Endpoint Select Register Definitions */
|
||||
#define EP_SEL_F 0x01
|
||||
#define EP_SEL_ST 0x02
|
||||
#define EP_SEL_STP 0x04
|
||||
#define EP_SEL_PO 0x08
|
||||
#define EP_SEL_EPN 0x10
|
||||
#define EP_SEL_B_1_FULL 0x20
|
||||
#define EP_SEL_B_2_FULL 0x40
|
||||
|
||||
/* Endpoint Status Register Definitions */
|
||||
#define EP_STAT_ST 0x01
|
||||
#define EP_STAT_DA 0x20
|
||||
#define EP_STAT_RF_MO 0x40
|
||||
#define EP_STAT_CND_ST 0x80
|
||||
|
||||
/* Clear Buffer Register Definitions */
|
||||
#define CLR_BUF_PO 0x01
|
||||
|
||||
|
||||
/* DMA Interrupt Bit Definitions */
|
||||
#define EOT_INT 0x01
|
||||
#define NDD_REQ_INT 0x02
|
||||
#define SYS_ERR_INT 0x04
|
||||
|
||||
|
||||
#endif /* __USBREG_H */
|
|
@ -0,0 +1,74 @@
|
|||
/*----------------------------------------------------------------------------
|
||||
* U S B - K e r n e l
|
||||
*----------------------------------------------------------------------------
|
||||
* Name: USBUSER.H
|
||||
* Purpose: USB Custom User Definitions
|
||||
* Version: V1.10
|
||||
*----------------------------------------------------------------------------
|
||||
* This software is supplied "AS IS" without any warranties, express,
|
||||
* implied or statutory, including but not limited to the implied
|
||||
* warranties of fitness for purpose, satisfactory quality and
|
||||
* noninfringement. Keil extends you a royalty-free right to reproduce
|
||||
* and distribute executable files created using this software for use
|
||||
* on Philips LPC2xxx microcontroller devices only. Nothing else gives
|
||||
* you the right to use this software.
|
||||
*
|
||||
* Copyright (c) 2005-2006 Keil Software.
|
||||
*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef __USBUSER_H__
|
||||
#define __USBUSER_H__
|
||||
|
||||
|
||||
/* USB Device Events Callback Functions */
|
||||
extern void USB_Power_Event (BOOL power);
|
||||
extern void USB_Reset_Event (void);
|
||||
extern void USB_Suspend_Event (void);
|
||||
extern void USB_Resume_Event (void);
|
||||
extern void USB_WakeUp_Event (void);
|
||||
extern void USB_SOF_Event (void);
|
||||
extern void USB_Error_Event (DWORD error);
|
||||
|
||||
/* USB Endpoint Callback Events */
|
||||
#define USB_EVT_SETUP 1 /* Setup Packet */
|
||||
#define USB_EVT_OUT 2 /* OUT Packet */
|
||||
#define USB_EVT_IN 3 /* IN Packet */
|
||||
#define USB_EVT_OUT_NAK 4 /* OUT Packet - Not Acknowledged */
|
||||
#define USB_EVT_IN_NAK 5 /* IN Packet - Not Acknowledged */
|
||||
#define USB_EVT_OUT_STALL 6 /* OUT Packet - Stalled */
|
||||
#define USB_EVT_IN_STALL 7 /* IN Packet - Stalled */
|
||||
#define USB_EVT_OUT_DMA_EOT 8 /* DMA OUT EP - End of Transfer */
|
||||
#define USB_EVT_IN_DMA_EOT 9 /* DMA IN EP - End of Transfer */
|
||||
#define USB_EVT_OUT_DMA_NDR 10 /* DMA OUT EP - New Descriptor Request */
|
||||
#define USB_EVT_IN_DMA_NDR 11 /* DMA IN EP - New Descriptor Request */
|
||||
#define USB_EVT_OUT_DMA_ERR 12 /* DMA OUT EP - Error */
|
||||
#define USB_EVT_IN_DMA_ERR 13 /* DMA IN EP - Error */
|
||||
|
||||
/* USB Endpoint Events Callback Pointers */
|
||||
extern void (* const USB_P_EP[16])(DWORD event);
|
||||
|
||||
/* USB Endpoint Events Callback Functions */
|
||||
extern void USB_EndPoint0 (DWORD event);
|
||||
extern void USB_EndPoint1 (DWORD event);
|
||||
extern void USB_EndPoint2 (DWORD event);
|
||||
extern void USB_EndPoint3 (DWORD event);
|
||||
extern void USB_EndPoint4 (DWORD event);
|
||||
extern void USB_EndPoint5 (DWORD event);
|
||||
extern void USB_EndPoint6 (DWORD event);
|
||||
extern void USB_EndPoint7 (DWORD event);
|
||||
extern void USB_EndPoint8 (DWORD event);
|
||||
extern void USB_EndPoint9 (DWORD event);
|
||||
extern void USB_EndPoint10 (DWORD event);
|
||||
extern void USB_EndPoint11 (DWORD event);
|
||||
extern void USB_EndPoint12 (DWORD event);
|
||||
extern void USB_EndPoint13 (DWORD event);
|
||||
extern void USB_EndPoint14 (DWORD event);
|
||||
extern void USB_EndPoint15 (DWORD event);
|
||||
|
||||
/* USB Core Events Callback Functions */
|
||||
extern void USB_Configure_Event (void);
|
||||
extern void USB_Interface_Event (void);
|
||||
extern void USB_Feature_Event (void);
|
||||
|
||||
|
||||
#endif /* __USBUSER_H__ */
|
Loading…
Reference in New Issue