- Upgraded some components of qemu-usb with a somewhat newer version from late 2010 (it was a recent version when I did the upgrades).
 - Fixed the plugin to work with recent versions of pcsx2. 

I will try to integrate the plugin into the build system tomorrow, and fix some more issues.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4899 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gigaherz 2011-09-04 01:53:30 +00:00
parent 446bf31eb4
commit ceab7de544
24 changed files with 3154 additions and 4607 deletions

View File

@ -1,809 +0,0 @@
#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__ */

View File

@ -1,75 +0,0 @@
#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__ */

View File

@ -44,10 +44,26 @@ u8 *ram;
usbStruct usb; usbStruct usb;
USBcallback _USBirq; USBcallback _USBirq;
FILE *usbLog; FILE *usbLog;
int64_t usb_frame_time; int64_t usb_frame_time=0;
int64_t usb_bit_time; int64_t usb_bit_time=0;
s64 clocks; s64 clocks=0;
s64 remaining=0;
int64_t get_ticks_per_sec()
{
return PSXCLK;
}
void __Log(char *fmt, ...) {
va_list list;
if (!conf.Log) return;
va_start(list, fmt);
vfprintf(usbLog, fmt, list);
va_end(list);
}
u32 CALLBACK PS2EgetLibType() { u32 CALLBACK PS2EgetLibType() {
return PS2E_LT_USB; return PS2E_LT_USB;
@ -61,16 +77,6 @@ u32 CALLBACK PS2EgetLibVersion2(u32 type) {
return (version<<16) | (revision<<8) | build; 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) void USBirq(int cycles)
{ {
USB_LOG("USBirq.\n"); USB_LOG("USBirq.\n");
@ -84,7 +90,7 @@ s32 CALLBACK USBinit() {
{ {
usbLog = fopen("logs/usbLog.txt", "w"); usbLog = fopen("logs/usbLog.txt", "w");
setvbuf(usbLog, NULL, _IONBF, 0); setvbuf(usbLog, NULL, _IONBF, 0);
USB_LOG("usblinuz plugin version %d,%d\n",revision,build); USB_LOG("USBqemu plugin version %d,%d\n",revision,build);
USB_LOG("USBinit\n"); USB_LOG("USBinit\n");
} }
@ -96,12 +102,13 @@ s32 CALLBACK USBinit() {
void CALLBACK USBshutdown() { void CALLBACK USBshutdown() {
qemu_ohci->rhport[0].port.dev->handle_destroy(qemu_ohci->rhport[0].port.dev); qemu_ohci->rhport[0].port.dev->info->handle_destroy(qemu_ohci->rhport[0].port.dev);
free(qemu_ohci); free(qemu_ohci);
#ifdef _DEBUG #ifdef _DEBUG
fclose(usbLog); if(usbLog)
fclose(usbLog);
#endif #endif
} }
@ -140,7 +147,7 @@ u16 CALLBACK USBread16(u32 addr) {
u32 CALLBACK USBread32(u32 addr) { u32 CALLBACK USBread32(u32 addr) {
u32 hard; u32 hard;
hard=ohci_mem_read(qemu_ohci,addr); hard=ohci_mem_read(qemu_ohci,addr - qemu_ohci->mem);
USB_LOG("* Known 32bit read at address %lx: %lx\n", addr, hard); USB_LOG("* Known 32bit read at address %lx: %lx\n", addr, hard);
@ -157,7 +164,7 @@ void CALLBACK USBwrite16(u32 addr, u16 value) {
void CALLBACK USBwrite32(u32 addr, u32 value) { void CALLBACK USBwrite32(u32 addr, u32 value) {
USB_LOG("* Known 32bit write at address %lx value %lx\n", addr, value); USB_LOG("* Known 32bit write at address %lx value %lx\n", addr, value);
ohci_mem_write(qemu_ohci,addr,value); ohci_mem_write(qemu_ohci,addr - qemu_ohci->mem, value);
} }
void CALLBACK USBirqCallback(USBcallback callback) { void CALLBACK USBirqCallback(USBcallback callback) {
@ -209,20 +216,31 @@ s32 CALLBACK USBfreeze(int mode, freezeData *data) {
return 0; return 0;
} }
void CALLBACK USBasync(u32 cycles) void CALLBACK USBasync(u32 _cycles)
{ {
clocks+=cycles; remaining += _cycles;
clocks += remaining;
if(qemu_ohci->eof_timer>0) if(qemu_ohci->eof_timer>0)
{ {
while(cycles>=qemu_ohci->eof_timer) while(remaining>=qemu_ohci->eof_timer)
{ {
cycles-=qemu_ohci->eof_timer; remaining-=qemu_ohci->eof_timer;
qemu_ohci->eof_timer=0; qemu_ohci->eof_timer=0;
ohci_frame_boundary(qemu_ohci); ohci_frame_boundary(qemu_ohci);
} }
if((cycles>0)&&(qemu_ohci->eof_timer>0)) if((remaining>0)&&(qemu_ohci->eof_timer>0))
qemu_ohci->eof_timer-=cycles; {
s64 m = qemu_ohci->eof_timer;
if(remaining < m)
m = remaining;
qemu_ohci->eof_timer -= m;
remaining -= m;
}
} }
//if(qemu_ohci->eof_timer <= 0)
//{
// ohci_frame_boundary(qemu_ohci);
//}
} }
s32 CALLBACK USBtest() { s32 CALLBACK USBtest() {

View File

@ -100,11 +100,15 @@ typedef struct OHCIPort {
typedef uint32_t target_phys_addr_t; typedef uint32_t target_phys_addr_t;
typedef struct { typedef struct {
target_phys_addr_t mem_base; //USBBus bus;
//qemu_irq irq;
enum ohci_type type;
int mem; int mem;
int num_ports; int num_ports;
const char *name;
uint64_t eof_timer; //QEMUTimer *eof_timer;
int64_t eof_timer;
int64_t sof_time; int64_t sof_time;
/* OHCI state */ /* OHCI state */
@ -135,6 +139,23 @@ typedef struct {
uint32_t rhdesc_a, rhdesc_b; uint32_t rhdesc_a, rhdesc_b;
uint32_t rhstatus; uint32_t rhstatus;
OHCIPort rhport[OHCI_MAX_PORTS]; OHCIPort rhport[OHCI_MAX_PORTS];
/* PXA27x Non-OHCI events */
uint32_t hstatus;
uint32_t hmask;
uint32_t hreset;
uint32_t htest;
/* SM501 local memory offset */
target_phys_addr_t localmem_base;
/* Active packets. */
uint32_t old_ctl;
USBPacket usb_packet;
uint8_t usb_buf[8192];
uint32_t async_td;
int async_complete;
} OHCIState; } OHCIState;
/* Host Controller Communications Area */ /* Host Controller Communications Area */
@ -144,6 +165,20 @@ struct ohci_hcca {
uint32_t done; uint32_t done;
}; };
extern int64_t usb_frame_time;
extern int64_t usb_bit_time;
enum ohci_type {
OHCI_TYPE_PCI,
OHCI_TYPE_PXA,
OHCI_TYPE_SM501,
};
int64_t get_ticks_per_sec();
static void ohci_bus_stop(OHCIState *ohci);
/* Bitfields for the first word of an Endpoint Desciptor. */ /* Bitfields for the first word of an Endpoint Desciptor. */
#define OHCI_ED_FA_SHIFT 0 #define OHCI_ED_FA_SHIFT 0
#define OHCI_ED_FA_MASK (0x7f<<OHCI_ED_FA_SHIFT) #define OHCI_ED_FA_MASK (0x7f<<OHCI_ED_FA_SHIFT)
@ -154,8 +189,8 @@ struct ohci_hcca {
#define OHCI_ED_S (1<<13) #define OHCI_ED_S (1<<13)
#define OHCI_ED_K (1<<14) #define OHCI_ED_K (1<<14)
#define OHCI_ED_F (1<<15) #define OHCI_ED_F (1<<15)
#define OHCI_ED_MPS_SHIFT 7 #define OHCI_ED_MPS_SHIFT 16
#define OHCI_ED_MPS_MASK (0xf<<OHCI_ED_FA_SHIFT) #define OHCI_ED_MPS_MASK (0x7ff<<OHCI_ED_MPS_SHIFT)
/* Flags in the head field of an Endpoint Desciptor. */ /* Flags in the head field of an Endpoint Desciptor. */
#define OHCI_ED_H 1 #define OHCI_ED_H 1
@ -174,6 +209,22 @@ struct ohci_hcca {
#define OHCI_TD_CC_SHIFT 28 #define OHCI_TD_CC_SHIFT 28
#define OHCI_TD_CC_MASK (0xf<<OHCI_TD_CC_SHIFT) #define OHCI_TD_CC_MASK (0xf<<OHCI_TD_CC_SHIFT)
/* Bitfields for the first word of an Isochronous Transfer Desciptor. */
/* CC & DI - same as in the General Transfer Desciptor */
#define OHCI_TD_SF_SHIFT 0
#define OHCI_TD_SF_MASK (0xffff<<OHCI_TD_SF_SHIFT)
#define OHCI_TD_FC_SHIFT 24
#define OHCI_TD_FC_MASK (7<<OHCI_TD_FC_SHIFT)
/* Isochronous Transfer Desciptor - Offset / PacketStatusWord */
#define OHCI_TD_PSW_CC_SHIFT 12
#define OHCI_TD_PSW_CC_MASK (0xf<<OHCI_TD_PSW_CC_SHIFT)
#define OHCI_TD_PSW_SIZE_SHIFT 0
#define OHCI_TD_PSW_SIZE_MASK (0xfff<<OHCI_TD_PSW_SIZE_SHIFT)
#define OHCI_PAGE_MASK 0xfffff000
#define OHCI_OFFSET_MASK 0xfff
#define OHCI_DPTR_MASK 0xfffffff0 #define OHCI_DPTR_MASK 0xfffffff0
#define OHCI_BM(val, field) \ #define OHCI_BM(val, field) \
@ -200,6 +251,15 @@ struct ohci_td {
uint32_t be; uint32_t be;
}; };
/* Isochronous transfer descriptor */
struct ohci_iso_td {
uint32_t flags;
uint32_t bp;
uint32_t next;
uint32_t be;
uint16_t offset[8];
};
#define USB_HZ 12000000 #define USB_HZ 12000000
/* OHCI Local stuff */ /* OHCI Local stuff */
@ -294,12 +354,15 @@ struct ohci_td {
#define OHCI_CC_BUFFEROVERRUN 0xc #define OHCI_CC_BUFFEROVERRUN 0xc
#define OHCI_CC_BUFFERUNDERRUN 0xd #define OHCI_CC_BUFFERUNDERRUN 0xd
#define OHCI_HRESET_FSBIR (1 << 0)
int64_t get_clock(); int64_t get_clock();
OHCIState *ohci_create(uint32_t base, int ports); OHCIState *ohci_create(uint32_t base, int ports);
uint32_t ohci_mem_read(OHCIState *ohci, uint32_t addr ); uint32_t ohci_mem_read(void *ptr, target_phys_addr_t addr);
void ohci_mem_write(OHCIState *ohci, uint32_t addr, uint32_t value ); void ohci_mem_write(void *ptr, target_phys_addr_t addr, uint32_t val);
void ohci_frame_boundary(void *opaque); void ohci_frame_boundary(void *opaque);
int ohci_bus_start(OHCIState *ohci); int ohci_bus_start(OHCIState *ohci);

View File

@ -1,669 +0,0 @@
<?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>

View File

@ -1,26 +0,0 @@

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

View File

@ -1,669 +0,0 @@
<?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>

View File

@ -1,25 +0,0 @@
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

View File

@ -1,669 +0,0 @@
<?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>

View File

@ -1,7 +1,3 @@
; USBlinuz.def : Declares the module parameters for the DLL.
LIBRARY "USBqemu"
DESCRIPTION 'USBqemu Driver'
EXPORTS EXPORTS
; Explicit exports can go here ; Explicit exports can go here

View File

@ -1,23 +1,17 @@
Microsoft Visual Studio Solution File, Format Version 9.00 Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2005 # Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "USBlinuz", "USBlinuz_vc2005.vcproj", "{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "USBqemu", "USBqemu.vcxproj", "{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32 Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Debug|Win32.ActiveCfg = Debug|Win32 {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|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.ActiveCfg = Release|Win32
{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}.Release|Win32.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -0,0 +1,147 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{BF7B81A5-E348-4F7C-A69F-F74C8EEEAD70}</ProjectGuid>
<RootNamespace>USBlinuz</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet>
<WholeProgramOptimization>false</WholeProgramOptimization>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">H:\pcsx2-trunk\bin\plugins\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)bin\</OutDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</LinkIncremental>
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectName)-dbg</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>..\;h:\pcsx2-trunk\common\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>__WIN32__;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
</ClCompile>
<Link>
<ModuleDefinitionFile>USBqemu.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
<IntrinsicFunctions>true</IntrinsicFunctions>
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
<WholeProgramOptimization>false</WholeProgramOptimization>
<AdditionalIncludeDirectories>..\;h:\pcsx2-trunk\common\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>__WIN32__;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>
</DebugInformationFormat>
</ClCompile>
<Link>
<ModuleDefinitionFile>USBqemu.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<ImportLibrary>$(OutDir)USBlinuz.lib</ImportLibrary>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Config.cpp" />
<ClCompile Include="..\USB.cpp" />
<ClCompile Include="Win32.cpp" />
<ClCompile Include="..\qemu-usb\usb-base.cpp" />
<ClCompile Include="..\usb-eyetoy\usb-eyetoy.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\qemu-usb\usb-hid.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\qemu-usb\usb-hub.cpp" />
<ClCompile Include="..\qemu-usb\usb-kbd.cpp" />
<ClCompile Include="..\usb-mic\usb-mic-dummy.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\qemu-usb\usb-ohci.cpp" />
<ClCompile Include="..\qemu-usb\vl.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="USBqemu.def" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h" />
<ClInclude Include="..\USB.h" />
<ClInclude Include="..\qemu-usb\usb-ohci.h" />
<ClInclude Include="..\qemu-usb\usb.h" />
<ClInclude Include="..\qemu-usb\vl.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="USBlinuz.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{dfc571b5-5df6-405b-9920-d273ad48d332}</UniqueIdentifier>
<Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm</Extensions>
</Filter>
<Filter Include="Source Files\qemu-usb">
<UniqueIdentifier>{fe40e0a3-a73a-44b8-a8ee-3d9591f91f0b}</UniqueIdentifier>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{2f1d0e2b-ba2b-4bd2-8bbd-63b3e4909ff3}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc</Extensions>
</Filter>
<Filter Include="Header Files\qemu-usb">
<UniqueIdentifier>{d1b11b29-e230-4fb1-84e1-795a3aafe8dd}</UniqueIdentifier>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{5468eb4e-6580-45d9-9432-a8ac8083abf9}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Config.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\USB.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Win32.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\qemu-usb\usb-base.cpp">
<Filter>Source Files\qemu-usb</Filter>
</ClCompile>
<ClCompile Include="..\usb-eyetoy\usb-eyetoy.cpp">
<Filter>Source Files\qemu-usb</Filter>
</ClCompile>
<ClCompile Include="..\qemu-usb\usb-hid.cpp">
<Filter>Source Files\qemu-usb</Filter>
</ClCompile>
<ClCompile Include="..\qemu-usb\usb-hub.cpp">
<Filter>Source Files\qemu-usb</Filter>
</ClCompile>
<ClCompile Include="..\qemu-usb\usb-kbd.cpp">
<Filter>Source Files\qemu-usb</Filter>
</ClCompile>
<ClCompile Include="..\usb-mic\usb-mic-dummy.cpp">
<Filter>Source Files\qemu-usb</Filter>
</ClCompile>
<ClCompile Include="..\qemu-usb\usb-ohci.cpp">
<Filter>Source Files\qemu-usb</Filter>
</ClCompile>
<ClCompile Include="..\qemu-usb\vl.cpp">
<Filter>Source Files\qemu-usb</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="USBqemu.def">
<Filter>Source Files</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\USB.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\qemu-usb\usb-ohci.h">
<Filter>Header Files\qemu-usb</Filter>
</ClInclude>
<ClInclude Include="..\qemu-usb\usb.h">
<Filter>Header Files\qemu-usb</Filter>
</ClInclude>
<ClInclude Include="..\qemu-usb\vl.h">
<Filter>Header Files\qemu-usb</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="USBlinuz.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@ -2,7 +2,9 @@
* QEMU USB emulation * QEMU USB emulation
* *
* Copyright (c) 2005 Fabrice Bellard * Copyright (c) 2005 Fabrice Bellard
* *
* 2008 Generic packet handler rewrite by Max Krasnyansky
*
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
@ -22,6 +24,7 @@
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "vl.h" #include "vl.h"
//#include "usb.h"
void usb_attach(USBPort *port, USBDevice *dev) void usb_attach(USBPort *port, USBDevice *dev)
{ {
@ -29,150 +32,174 @@ void usb_attach(USBPort *port, USBDevice *dev)
} }
/**********************/ /**********************/
/* generic USB device helpers (you are not forced to use them when /* generic USB device helpers (you are not forced to use them when
writing your USB device driver, but they help handling the writing your USB device driver, but they help handling the
protocol) protocol)
*/ */
#define SETUP_STATE_IDLE 0 #define SETUP_STATE_IDLE 0
#define SETUP_STATE_DATA 1 #define SETUP_STATE_DATA 1
#define SETUP_STATE_ACK 2 #define SETUP_STATE_ACK 2
int usb_generic_handle_packet(USBDevice *s, int pid, static int do_token_setup(USBDevice *s, USBPacket *p)
uint8_t devaddr, uint8_t devep,
uint8_t *data, int len)
{ {
int l, ret = 0; int request, value, index;
int ret = 0;
switch(pid) { if (p->len != 8)
return USB_RET_STALL;
memcpy(s->setup_buf, p->data, 8);
s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6];
s->setup_index = 0;
request = (s->setup_buf[0] << 8) | s->setup_buf[1];
value = (s->setup_buf[3] << 8) | s->setup_buf[2];
index = (s->setup_buf[5] << 8) | s->setup_buf[4];
if (s->setup_buf[0] & USB_DIR_IN) {
ret = s->info->handle_control(s, request, value, index,
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;
}
return ret;
}
static int do_token_in(USBDevice *s, USBPacket *p)
{
int request, value, index;
int ret = 0;
if (p->devep != 0)
return s->info->handle_data(s, p);
request = (s->setup_buf[0] << 8) | s->setup_buf[1];
value = (s->setup_buf[3] << 8) | s->setup_buf[2];
index = (s->setup_buf[5] << 8) | s->setup_buf[4];
switch(s->setup_state) {
case SETUP_STATE_ACK:
if (!(s->setup_buf[0] & USB_DIR_IN)) {
s->setup_state = SETUP_STATE_IDLE;
ret = s->info->handle_control(s, request, value, index,
s->setup_len, s->data_buf);
if (ret > 0)
return 0;
return ret;
}
/* return 0 byte */
return 0;
case SETUP_STATE_DATA:
if (s->setup_buf[0] & USB_DIR_IN) {
int len = s->setup_len - s->setup_index;
if (len > p->len)
len = p->len;
memcpy(p->data, s->data_buf + s->setup_index, len);
s->setup_index += len;
if (s->setup_index >= s->setup_len)
s->setup_state = SETUP_STATE_ACK;
return len;
}
s->setup_state = SETUP_STATE_IDLE;
return USB_RET_STALL;
default:
return USB_RET_STALL;
}
}
static int do_token_out(USBDevice *s, USBPacket *p)
{
if (p->devep != 0)
return s->info->handle_data(s, p);
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 additional output */
}
return 0;
case SETUP_STATE_DATA:
if (!(s->setup_buf[0] & USB_DIR_IN)) {
int len = s->setup_len - s->setup_index;
if (len > p->len)
len = p->len;
memcpy(s->data_buf + s->setup_index, p->data, len);
s->setup_index += len;
if (s->setup_index >= s->setup_len)
s->setup_state = SETUP_STATE_ACK;
return len;
}
s->setup_state = SETUP_STATE_IDLE;
return USB_RET_STALL;
default:
return USB_RET_STALL;
}
}
/*
* Generic packet handler.
* Called by the HC (host controller).
*
* Returns length of the transaction or one of the USB_RET_XXX codes.
*/
int usb_generic_handle_packet(USBDevice *s, USBPacket *p)
{
switch(p->pid) {
case USB_MSG_ATTACH: case USB_MSG_ATTACH:
s->state = USB_STATE_ATTACHED; s->state = USB_STATE_ATTACHED;
break; return 0;
case USB_MSG_DETACH: case USB_MSG_DETACH:
s->state = USB_STATE_NOTATTACHED; s->state = USB_STATE_NOTATTACHED;
break; return 0;
case USB_MSG_RESET: case USB_MSG_RESET:
s->remote_wakeup = 0; s->remote_wakeup = 0;
s->addr = 0; s->addr = 0;
s->state = USB_STATE_DEFAULT; s->state = USB_STATE_DEFAULT;
s->handle_reset(s); s->info->handle_reset(s);
break; return 0;
case USB_TOKEN_SETUP: }
if (s->state < USB_STATE_DEFAULT || devaddr != s->addr)
return USB_RET_NODEV; /* Rest of the PIDs must match our address */
if (len != 8) if (s->state < USB_STATE_DEFAULT || p->devaddr != s->addr)
goto fail; return USB_RET_NODEV;
memcpy(s->setup_buf, data, 8);
s->setup_len = (s->setup_buf[7] << 8) | s->setup_buf[6]; switch (p->pid) {
s->setup_index = 0; case USB_TOKEN_SETUP:
if (s->setup_buf[0] & USB_DIR_IN) { return do_token_setup(s, p);
ret = s->handle_control(s,
(s->setup_buf[0] << 8) | s->setup_buf[1], case USB_TOKEN_IN:
(s->setup_buf[3] << 8) | s->setup_buf[2], return do_token_in(s, p);
(s->setup_buf[5] << 8) | s->setup_buf[4],
s->setup_len, case USB_TOKEN_OUT:
s->data_buf); return do_token_out(s, p);
if (ret < 0)
return ret; default:
if (ret < s->setup_len) return USB_RET_STALL;
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 */ /* XXX: fix overflow */
@ -191,3 +218,14 @@ int set_usb_string(uint8_t *buf, const char *str)
} }
return q - buf; return q - buf;
} }
/* Send an internal message to a USB device. */
void usb_send_msg(USBDevice *dev, int msg)
{
USBPacket p;
memset(&p, 0, sizeof(p));
p.pid = msg;
dev->info->handle_packet(dev, &p);
/* This _must_ be synchronous */
}

View File

@ -1,8 +1,9 @@
/* /*
* QEMU USB HID devices * QEMU USB HID devices
* *
* Copyright (c) 2005 Fabrice Bellard * Copyright (c) 2005 Fabrice Bellard
* * Copyright (c) 2007 OpenMoko, Inc. (andrew@openedhand.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
@ -21,31 +22,60 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#include "vl.h" #include "hw.h"
#include "console.h"
#include "usb.h"
/* HID interface requests */ /* HID interface requests */
#define GET_REPORT 0xa101 #define GET_REPORT 0xa101
#define GET_IDLE 0xa102 #define GET_IDLE 0xa102
#define GET_PROTOCOL 0xa103 #define GET_PROTOCOL 0xa103
#define SET_REPORT 0x2109
#define SET_IDLE 0x210a #define SET_IDLE 0x210a
#define SET_PROTOCOL 0x210b #define SET_PROTOCOL 0x210b
#define USB_MOUSE 1 /* HID descriptor types */
#define USB_TABLET 2 #define USB_DT_HID 0x21
#define USB_DT_REPORT 0x22
#define USB_DT_PHY 0x23
#define USB_MOUSE 1
#define USB_TABLET 2
#define USB_KEYBOARD 3
typedef struct USBMouseState { typedef struct USBMouseState {
USBDevice dev;
int dx, dy, dz, buttons_state; int dx, dy, dz, buttons_state;
int x, y; int x, y;
int kind;
int mouse_grabbed; int mouse_grabbed;
QEMUPutMouseEntry *eh_entry;
} USBMouseState; } USBMouseState;
typedef struct USBKeyboardState {
uint16_t modifiers;
uint8_t leds;
uint8_t key[16];
int keys;
} USBKeyboardState;
typedef struct USBHIDState {
USBDevice dev;
union {
USBMouseState ptr;
USBKeyboardState kbd;
};
int kind;
int protocol;
uint8_t idle;
int changed;
void *datain_opaque;
void (*datain)(void *);
} USBHIDState;
/* mostly the same values as the Bochs USB Mouse device */ /* mostly the same values as the Bochs USB Mouse device */
static const uint8_t qemu_mouse_dev_descriptor[] = { static const uint8_t qemu_mouse_dev_descriptor[] = {
0x12, /* u8 bLength; */ 0x12, /* u8 bLength; */
0x01, /* u8 bDescriptorType; Device */ 0x01, /* u8 bDescriptorType; Device */
0x10, 0x00, /* u16 bcdUSB; v1.0 */ 0x00, 0x01, /* u16 bcdUSB; v1.0 */
0x00, /* u8 bDeviceClass; */ 0x00, /* u8 bDeviceClass; */
0x00, /* u8 bDeviceSubClass; */ 0x00, /* u8 bDeviceSubClass; */
@ -70,13 +100,13 @@ static const uint8_t qemu_mouse_config_descriptor[] = {
0x01, /* u8 bNumInterfaces; (1) */ 0x01, /* u8 bNumInterfaces; (1) */
0x01, /* u8 bConfigurationValue; */ 0x01, /* u8 bConfigurationValue; */
0x04, /* u8 iConfiguration; */ 0x04, /* u8 iConfiguration; */
0xa0, /* u8 bmAttributes; 0xa0, /* u8 bmAttributes;
Bit 7: must be set, Bit 7: must be set,
6: Self-powered, 6: Self-powered,
5: Remote wakeup, 5: Remote wakeup,
4..0: resvd */ 4..0: resvd */
50, /* u8 MaxPower; */ 50, /* u8 MaxPower; */
/* USB 1.1: /* USB 1.1:
* USB 2.0, single TT organization (mandatory): * USB 2.0, single TT organization (mandatory):
* one interface, protocol 0 * one interface, protocol 0
@ -97,8 +127,8 @@ static const uint8_t qemu_mouse_config_descriptor[] = {
0x03, /* u8 if_bInterfaceClass; */ 0x03, /* u8 if_bInterfaceClass; */
0x01, /* u8 if_bInterfaceSubClass; */ 0x01, /* u8 if_bInterfaceSubClass; */
0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ 0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */
0x05, /* u8 if_iInterface; */ 0x07, /* u8 if_iInterface; */
/* HID descriptor */ /* HID descriptor */
0x09, /* u8 bLength; */ 0x09, /* u8 bLength; */
0x21, /* u8 bDescriptorType; */ 0x21, /* u8 bDescriptorType; */
@ -106,14 +136,14 @@ static const uint8_t qemu_mouse_config_descriptor[] = {
0x00, /* u8 country_code */ 0x00, /* u8 country_code */
0x01, /* u8 num_descriptors */ 0x01, /* u8 num_descriptors */
0x22, /* u8 type; Report */ 0x22, /* u8 type; Report */
50, 0, /* u16 len */ 52, 0, /* u16 len */
/* one endpoint (status change endpoint) */ /* one endpoint (status change endpoint) */
0x07, /* u8 ep_bLength; */ 0x07, /* u8 ep_bLength; */
0x05, /* u8 ep_bDescriptorType; Endpoint */ 0x05, /* u8 ep_bDescriptorType; Endpoint */
0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */
0x03, /* u8 ep_bmAttributes; Interrupt */ 0x03, /* u8 ep_bmAttributes; Interrupt */
0x03, 0x00, /* u16 ep_wMaxPacketSize; */ 0x04, 0x00, /* u16 ep_wMaxPacketSize; */
0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */
}; };
@ -124,14 +154,14 @@ static const uint8_t qemu_tablet_config_descriptor[] = {
0x22, 0x00, /* u16 wTotalLength; */ 0x22, 0x00, /* u16 wTotalLength; */
0x01, /* u8 bNumInterfaces; (1) */ 0x01, /* u8 bNumInterfaces; (1) */
0x01, /* u8 bConfigurationValue; */ 0x01, /* u8 bConfigurationValue; */
0x04, /* u8 iConfiguration; */ 0x05, /* u8 iConfiguration; */
0xa0, /* u8 bmAttributes; 0xa0, /* u8 bmAttributes;
Bit 7: must be set, Bit 7: must be set,
6: Self-powered, 6: Self-powered,
5: Remote wakeup, 5: Remote wakeup,
4..0: resvd */ 4..0: resvd */
50, /* u8 MaxPower; */ 50, /* u8 MaxPower; */
/* USB 1.1: /* USB 1.1:
* USB 2.0, single TT organization (mandatory): * USB 2.0, single TT organization (mandatory):
* one interface, protocol 0 * one interface, protocol 0
@ -152,7 +182,7 @@ static const uint8_t qemu_tablet_config_descriptor[] = {
0x03, /* u8 if_bInterfaceClass; */ 0x03, /* u8 if_bInterfaceClass; */
0x01, /* u8 if_bInterfaceSubClass; */ 0x01, /* u8 if_bInterfaceSubClass; */
0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ 0x02, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */
0x05, /* u8 if_iInterface; */ 0x07, /* u8 if_iInterface; */
/* HID descriptor */ /* HID descriptor */
0x09, /* u8 bLength; */ 0x09, /* u8 bLength; */
@ -169,79 +199,299 @@ static const uint8_t qemu_tablet_config_descriptor[] = {
0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */ 0x81, /* u8 ep_bEndpointAddress; IN Endpoint 1 */
0x03, /* u8 ep_bmAttributes; Interrupt */ 0x03, /* u8 ep_bmAttributes; Interrupt */
0x08, 0x00, /* u16 ep_wMaxPacketSize; */ 0x08, 0x00, /* u16 ep_wMaxPacketSize; */
0x03, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */ 0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */
};
static const uint8_t qemu_keyboard_config_descriptor[] = {
/* one configuration */
0x09, /* u8 bLength; */
USB_DT_CONFIG, /* u8 bDescriptorType; Configuration */
0x22, 0x00, /* u16 wTotalLength; */
0x01, /* u8 bNumInterfaces; (1) */
0x01, /* u8 bConfigurationValue; */
0x06, /* u8 iConfiguration; */
0xa0, /* u8 bmAttributes;
Bit 7: must be set,
6: Self-powered,
5: Remote wakeup,
4..0: resvd */
0x32, /* 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; */
USB_DT_INTERFACE, /* u8 if_bDescriptorType; Interface */
0x00, /* u8 if_bInterfaceNumber; */
0x00, /* u8 if_bAlternateSetting; */
0x01, /* u8 if_bNumEndpoints; */
0x03, /* u8 if_bInterfaceClass; HID */
0x01, /* u8 if_bInterfaceSubClass; Boot */
0x01, /* u8 if_bInterfaceProtocol; Keyboard */
0x07, /* u8 if_iInterface; */
/* HID descriptor */
0x09, /* u8 bLength; */
USB_DT_HID, /* u8 bDescriptorType; */
0x11, 0x01, /* u16 HID_class */
0x00, /* u8 country_code */
0x01, /* u8 num_descriptors */
USB_DT_REPORT, /* u8 type; Report */
0x3f, 0x00, /* u16 len */
/* one endpoint (status change endpoint) */
0x07, /* u8 ep_bLength; */
USB_DT_ENDPOINT, /* u8 ep_bDescriptorType; Endpoint */
USB_DIR_IN | 0x01, /* u8 ep_bEndpointAddress; IN Endpoint 1 */
0x03, /* u8 ep_bmAttributes; Interrupt */
0x08, 0x00, /* u16 ep_wMaxPacketSize; */
0x0a, /* u8 ep_bInterval; (255ms -- usb 2.0 spec) */
}; };
static const uint8_t qemu_mouse_hid_report_descriptor[] = { static const uint8_t qemu_mouse_hid_report_descriptor[] = {
0x05, 0x01, 0x09, 0x02, 0xA1, 0x01, 0x09, 0x01, 0x05, 0x01, /* Usage Page (Generic Desktop) */
0xA1, 0x00, 0x05, 0x09, 0x19, 0x01, 0x29, 0x03, 0x09, 0x02, /* Usage (Mouse) */
0x15, 0x00, 0x25, 0x01, 0x95, 0x03, 0x75, 0x01, 0xa1, 0x01, /* Collection (Application) */
0x81, 0x02, 0x95, 0x01, 0x75, 0x05, 0x81, 0x01, 0x09, 0x01, /* Usage (Pointer) */
0x05, 0x01, 0x09, 0x30, 0x09, 0x31, 0x15, 0x81, 0xa1, 0x00, /* Collection (Physical) */
0x25, 0x7F, 0x75, 0x08, 0x95, 0x02, 0x81, 0x06, 0x05, 0x09, /* Usage Page (Button) */
0xC0, 0xC0, 0x19, 0x01, /* Usage Minimum (1) */
0x29, 0x03, /* Usage Maximum (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, Variable, Absolute) */
0x95, 0x01, /* Report Count (1) */
0x75, 0x05, /* Report Size (5) */
0x81, 0x01, /* Input (Constant) */
0x05, 0x01, /* Usage Page (Generic Desktop) */
0x09, 0x30, /* Usage (X) */
0x09, 0x31, /* Usage (Y) */
0x09, 0x38, /* Usage (Wheel) */
0x15, 0x81, /* Logical Minimum (-0x7f) */
0x25, 0x7f, /* Logical Maximum (0x7f) */
0x75, 0x08, /* Report Size (8) */
0x95, 0x03, /* Report Count (3) */
0x81, 0x06, /* Input (Data, Variable, Relative) */
0xc0, /* End Collection */
0xc0, /* End Collection */
}; };
static const uint8_t qemu_tablet_hid_report_descriptor[] = { static const uint8_t qemu_tablet_hid_report_descriptor[] = {
0x05, 0x01, /* Usage Page Generic Desktop */ 0x05, 0x01, /* Usage Page (Generic Desktop) */
0x09, 0x01, /* Usage Mouse */ 0x09, 0x01, /* Usage (Pointer) */
0xA1, 0x01, /* Collection Application */ 0xa1, 0x01, /* Collection (Application) */
0x09, 0x01, /* Usage Pointer */ 0x09, 0x01, /* Usage (Pointer) */
0xA1, 0x00, /* Collection Physical */ 0xa1, 0x00, /* Collection (Physical) */
0x05, 0x09, /* Usage Page Button */ 0x05, 0x09, /* Usage Page (Button) */
0x19, 0x01, /* Usage Minimum Button 1 */ 0x19, 0x01, /* Usage Minimum (1) */
0x29, 0x03, /* Usage Maximum Button 3 */ 0x29, 0x03, /* Usage Maximum (3) */
0x15, 0x00, /* Logical Minimum 0 */ 0x15, 0x00, /* Logical Minimum (0) */
0x25, 0x01, /* Logical Maximum 1 */ 0x25, 0x01, /* Logical Maximum (1) */
0x95, 0x03, /* Report Count 3 */ 0x95, 0x03, /* Report Count (3) */
0x75, 0x01, /* Report Size 1 */ 0x75, 0x01, /* Report Size (1) */
0x81, 0x02, /* Input (Data, Var, Abs) */ 0x81, 0x02, /* Input (Data, Variable, Absolute) */
0x95, 0x01, /* Report Count 1 */ 0x95, 0x01, /* Report Count (1) */
0x75, 0x05, /* Report Size 5 */ 0x75, 0x05, /* Report Size (5) */
0x81, 0x01, /* Input (Cnst, Var, Abs) */ 0x81, 0x01, /* Input (Constant) */
0x05, 0x01, /* Usage Page Generic Desktop */ 0x05, 0x01, /* Usage Page (Generic Desktop) */
0x09, 0x30, /* Usage X */ 0x09, 0x30, /* Usage (X) */
0x09, 0x31, /* Usage Y */ 0x09, 0x31, /* Usage (Y) */
0x15, 0x00, /* Logical Minimum 0 */ 0x15, 0x00, /* Logical Minimum (0) */
0x26, 0xFF, 0x7F, /* Logical Maximum 0x7fff */ 0x26, 0xff, 0x7f, /* Logical Maximum (0x7fff) */
0x35, 0x00, /* Physical Minimum 0 */ 0x35, 0x00, /* Physical Minimum (0) */
0x46, 0xFE, 0x7F, /* Physical Maximum 0x7fff */ 0x46, 0xff, 0x7f, /* Physical Maximum (0x7fff) */
0x75, 0x10, /* Report Size 16 */ 0x75, 0x10, /* Report Size (16) */
0x95, 0x02, /* Report Count 2 */ 0x95, 0x02, /* Report Count (2) */
0x81, 0x02, /* Input (Data, Var, Abs) */ 0x81, 0x02, /* Input (Data, Variable, Absolute) */
0x05, 0x01, /* Usage Page Generic Desktop */ 0x05, 0x01, /* Usage Page (Generic Desktop) */
0x09, 0x38, /* Usage Wheel */ 0x09, 0x38, /* Usage (Wheel) */
0x15, 0x81, /* Logical Minimum -127 */ 0x15, 0x81, /* Logical Minimum (-0x7f) */
0x25, 0x7F, /* Logical Maximum 127 */ 0x25, 0x7f, /* Logical Maximum (0x7f) */
0x35, 0x00, /* Physical Minimum 0 (same as logical) */ 0x35, 0x00, /* Physical Minimum (same as logical) */
0x45, 0x00, /* Physical Maximum 0 (same as logical) */ 0x45, 0x00, /* Physical Maximum (same as logical) */
0x75, 0x08, /* Report Size 8 */ 0x75, 0x08, /* Report Size (8) */
0x95, 0x01, /* Report Count 1 */ 0x95, 0x01, /* Report Count (1) */
0x81, 0x02, /* Input (Data, Var, Rel) */ 0x81, 0x06, /* Input (Data, Variable, Relative) */
0xC0, /* End Collection */ 0xc0, /* End Collection */
0xC0, /* End Collection */ 0xc0, /* End Collection */
}; };
static const uint8_t qemu_keyboard_hid_report_descriptor[] = {
0x05, 0x01, /* Usage Page (Generic Desktop) */
0x09, 0x06, /* Usage (Keyboard) */
0xa1, 0x01, /* Collection (Application) */
0x75, 0x01, /* Report Size (1) */
0x95, 0x08, /* Report Count (8) */
0x05, 0x07, /* Usage Page (Key Codes) */
0x19, 0xe0, /* Usage Minimum (224) */
0x29, 0xe7, /* Usage Maximum (231) */
0x15, 0x00, /* Logical Minimum (0) */
0x25, 0x01, /* Logical Maximum (1) */
0x81, 0x02, /* Input (Data, Variable, Absolute) */
0x95, 0x01, /* Report Count (1) */
0x75, 0x08, /* Report Size (8) */
0x81, 0x01, /* Input (Constant) */
0x95, 0x05, /* Report Count (5) */
0x75, 0x01, /* Report Size (1) */
0x05, 0x08, /* Usage Page (LEDs) */
0x19, 0x01, /* Usage Minimum (1) */
0x29, 0x05, /* Usage Maximum (5) */
0x91, 0x02, /* Output (Data, Variable, Absolute) */
0x95, 0x01, /* Report Count (1) */
0x75, 0x03, /* Report Size (3) */
0x91, 0x01, /* Output (Constant) */
0x95, 0x06, /* Report Count (6) */
0x75, 0x08, /* Report Size (8) */
0x15, 0x00, /* Logical Minimum (0) */
0x25, 0xff, /* Logical Maximum (255) */
0x05, 0x07, /* Usage Page (Key Codes) */
0x19, 0x00, /* Usage Minimum (0) */
0x29, 0xff, /* Usage Maximum (255) */
0x81, 0x00, /* Input (Data, Array) */
0xc0, /* End Collection */
};
#define USB_HID_USAGE_ERROR_ROLLOVER 0x01
#define USB_HID_USAGE_POSTFAIL 0x02
#define USB_HID_USAGE_ERROR_UNDEFINED 0x03
/* Indices are QEMU keycodes, values are from HID Usage Table. Indices
* above 0x80 are for keys that come after 0xe0 or 0xe1+0x1d or 0xe1+0x9d. */
static const uint8_t usb_hid_usage_keys[0x100] = {
0x00, 0x29, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
0x24, 0x25, 0x26, 0x27, 0x2d, 0x2e, 0x2a, 0x2b,
0x14, 0x1a, 0x08, 0x15, 0x17, 0x1c, 0x18, 0x0c,
0x12, 0x13, 0x2f, 0x30, 0x28, 0xe0, 0x04, 0x16,
0x07, 0x09, 0x0a, 0x0b, 0x0d, 0x0e, 0x0f, 0x33,
0x34, 0x35, 0xe1, 0x31, 0x1d, 0x1b, 0x06, 0x19,
0x05, 0x11, 0x10, 0x36, 0x37, 0x38, 0xe5, 0x55,
0xe2, 0x2c, 0x32, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e,
0x3f, 0x40, 0x41, 0x42, 0x43, 0x53, 0x47, 0x5f,
0x60, 0x61, 0x56, 0x5c, 0x5d, 0x5e, 0x57, 0x59,
0x5a, 0x5b, 0x62, 0x63, 0x00, 0x00, 0x00, 0x44,
0x45, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e,
0xe8, 0xe9, 0x71, 0x72, 0x73, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0xe3, 0xe7, 0x65,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x58, 0xe4, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x00, 0x46,
0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x4a,
0x52, 0x4b, 0x00, 0x50, 0x00, 0x4f, 0x00, 0x4d,
0x51, 0x4e, 0x49, 0x4c, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static void usb_hid_changed(USBHIDState *hs)
{
hs->changed = 1;
if (hs->datain)
hs->datain(hs->datain_opaque);
}
static void usb_mouse_event(void *opaque, static void usb_mouse_event(void *opaque,
int dx1, int dy1, int dz1, int buttons_state) int dx1, int dy1, int dz1, int buttons_state)
{ {
USBMouseState *s = opaque; USBHIDState *hs = opaque;
USBMouseState *s = &hs->ptr;
s->dx += dx1; s->dx += dx1;
s->dy += dy1; s->dy += dy1;
s->dz += dz1; s->dz += dz1;
s->buttons_state = buttons_state; s->buttons_state = buttons_state;
usb_hid_changed(hs);
} }
static void usb_tablet_event(void *opaque, static void usb_tablet_event(void *opaque,
int x, int y, int dz, int buttons_state) int x, int y, int dz, int buttons_state)
{ {
USBMouseState *s = opaque; USBHIDState *hs = opaque;
USBMouseState *s = &hs->ptr;
s->x = x; s->x = x;
s->y = y; s->y = y;
s->dz += dz; s->dz += dz;
s->buttons_state = buttons_state; s->buttons_state = buttons_state;
usb_hid_changed(hs);
}
static void usb_keyboard_event(void *opaque, int keycode)
{
USBHIDState *hs = opaque;
USBKeyboardState *s = &hs->kbd;
uint8_t hid_code, key;
int i;
key = keycode & 0x7f;
hid_code = usb_hid_usage_keys[key | ((s->modifiers >> 1) & (1 << 7))];
s->modifiers &= ~(1 << 8);
switch (hid_code) {
case 0x00:
return;
case 0xe0:
if (s->modifiers & (1 << 9)) {
s->modifiers ^= 3 << 8;
return;
}
case 0xe1 ... 0xe7:
if (keycode & (1 << 7)) {
s->modifiers &= ~(1 << (hid_code & 0x0f));
return;
}
case 0xe8 ... 0xef:
s->modifiers |= 1 << (hid_code & 0x0f);
return;
}
if (keycode & (1 << 7)) {
for (i = s->keys - 1; i >= 0; i --)
if (s->key[i] == hid_code) {
s->key[i] = s->key[-- s->keys];
s->key[s->keys] = 0x00;
usb_hid_changed(hs);
break;
}
if (i < 0)
return;
} else {
for (i = s->keys - 1; i >= 0; i --)
if (s->key[i] == hid_code)
break;
if (i < 0) {
if (s->keys < sizeof(s->key))
s->key[s->keys ++] = hid_code;
} else
return;
}
usb_hid_changed(hs);
} }
static inline int int_clamp(int val, int vmin, int vmax) static inline int int_clamp(int val, int vmin, int vmax)
@ -254,23 +504,28 @@ static inline int int_clamp(int val, int vmin, int vmax)
return val; return val;
} }
static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len) static int usb_mouse_poll(USBHIDState *hs, uint8_t *buf, int len)
{ {
int dx, dy, dz, b, l; int dx, dy, dz, b, l;
USBMouseState *s = &hs->ptr;
if (!s->mouse_grabbed) { if (!s->mouse_grabbed) {
qemu_add_mouse_event_handler(usb_mouse_event, s, 0); s->eh_entry = qemu_add_mouse_event_handler(usb_mouse_event, hs,
0, "QEMU USB Mouse");
s->mouse_grabbed = 1; s->mouse_grabbed = 1;
} }
dx = int_clamp(s->dx, -128, 127); dx = int_clamp(s->dx, -127, 127);
dy = int_clamp(s->dy, -128, 127); dy = int_clamp(s->dy, -127, 127);
dz = int_clamp(s->dz, -128, 127); dz = int_clamp(s->dz, -127, 127);
s->dx -= dx; s->dx -= dx;
s->dy -= dy; s->dy -= dy;
s->dz -= dz; s->dz -= dz;
/* Appears we have to invert the wheel direction */
dz = 0 - dz;
b = 0; b = 0;
if (s->buttons_state & MOUSE_EVENT_LBUTTON) if (s->buttons_state & MOUSE_EVENT_LBUTTON)
b |= 0x01; b |= 0x01;
@ -278,28 +533,31 @@ static int usb_mouse_poll(USBMouseState *s, uint8_t *buf, int len)
b |= 0x02; b |= 0x02;
if (s->buttons_state & MOUSE_EVENT_MBUTTON) if (s->buttons_state & MOUSE_EVENT_MBUTTON)
b |= 0x04; b |= 0x04;
buf[0] = b; l = 0;
buf[1] = dx; if (len > l)
buf[2] = dy; buf[l ++] = b;
l = 3; if (len > l)
if (len >= 4) { buf[l ++] = dx;
buf[3] = dz; if (len > l)
l = 4; buf[l ++] = dy;
} if (len > l)
buf[l ++] = dz;
return l; return l;
} }
static int usb_tablet_poll(USBMouseState *s, uint8_t *buf, int len) static int usb_tablet_poll(USBHIDState *hs, uint8_t *buf, int len)
{ {
int dz, b, l; int dz, b, l;
USBMouseState *s = &hs->ptr;
if (!s->mouse_grabbed) { if (!s->mouse_grabbed) {
qemu_add_mouse_event_handler(usb_tablet_event, s, 1); s->eh_entry = qemu_add_mouse_event_handler(usb_tablet_event, hs,
1, "QEMU USB Tablet");
s->mouse_grabbed = 1; s->mouse_grabbed = 1;
} }
dz = int_clamp(s->dz, -128, 127); dz = int_clamp(s->dz, -127, 127);
s->dz -= dz; s->dz -= dz;
/* Appears we have to invert the wheel direction */ /* Appears we have to invert the wheel direction */
@ -323,22 +581,59 @@ static int usb_tablet_poll(USBMouseState *s, uint8_t *buf, int len)
return l; return l;
} }
static void usb_mouse_handle_reset(USBDevice *dev) static int usb_keyboard_poll(USBKeyboardState *s, uint8_t *buf, int len)
{ {
USBMouseState *s = (USBMouseState *)dev; if (len < 2)
return 0;
s->dx = 0; buf[0] = s->modifiers & 0xff;
s->dy = 0; buf[1] = 0;
s->dz = 0; if (s->keys > 6)
s->x = 0; memset(buf + 2, USB_HID_USAGE_ERROR_ROLLOVER, MIN(8, len) - 2);
s->y = 0; else
s->buttons_state = 0; memcpy(buf + 2, s->key, MIN(8, len) - 2);
return MIN(8, len);
} }
static int usb_mouse_handle_control(USBDevice *dev, int request, int value, static int usb_keyboard_write(USBKeyboardState *s, uint8_t *buf, int len)
{
if (len > 0) {
/* 0x01: Num Lock LED
* 0x02: Caps Lock LED
* 0x04: Scroll Lock LED
* 0x08: Compose LED
* 0x10: Kana LED */
s->leds = buf[0];
}
return 0;
}
static void usb_mouse_handle_reset(USBDevice *dev)
{
USBHIDState *s = (USBHIDState *)dev;
s->ptr.dx = 0;
s->ptr.dy = 0;
s->ptr.dz = 0;
s->ptr.x = 0;
s->ptr.y = 0;
s->ptr.buttons_state = 0;
s->protocol = 1;
}
static void usb_keyboard_handle_reset(USBDevice *dev)
{
USBHIDState *s = (USBHIDState *)dev;
qemu_add_kbd_event_handler(usb_keyboard_event, s);
s->protocol = 1;
}
static int usb_hid_handle_control(USBDevice *dev, int request, int value,
int index, int length, uint8_t *data) int index, int length, uint8_t *data)
{ {
USBMouseState *s = (USBMouseState *)dev; USBHIDState *s = (USBHIDState *)dev;
int ret = 0; int ret = 0;
switch(request) { switch(request) {
@ -371,20 +666,24 @@ static int usb_mouse_handle_control(USBDevice *dev, int request, int value,
case DeviceRequest | USB_REQ_GET_DESCRIPTOR: case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
switch(value >> 8) { switch(value >> 8) {
case USB_DT_DEVICE: case USB_DT_DEVICE:
memcpy(data, qemu_mouse_dev_descriptor, memcpy(data, qemu_mouse_dev_descriptor,
sizeof(qemu_mouse_dev_descriptor)); sizeof(qemu_mouse_dev_descriptor));
ret = sizeof(qemu_mouse_dev_descriptor); ret = sizeof(qemu_mouse_dev_descriptor);
break; break;
case USB_DT_CONFIG: case USB_DT_CONFIG:
if (s->kind == USB_MOUSE) { if (s->kind == USB_MOUSE) {
memcpy(data, qemu_mouse_config_descriptor, memcpy(data, qemu_mouse_config_descriptor,
sizeof(qemu_mouse_config_descriptor)); sizeof(qemu_mouse_config_descriptor));
ret = sizeof(qemu_mouse_config_descriptor); ret = sizeof(qemu_mouse_config_descriptor);
} else if (s->kind == USB_TABLET) { } else if (s->kind == USB_TABLET) {
memcpy(data, qemu_tablet_config_descriptor, memcpy(data, qemu_tablet_config_descriptor,
sizeof(qemu_tablet_config_descriptor)); sizeof(qemu_tablet_config_descriptor));
ret = sizeof(qemu_tablet_config_descriptor); ret = sizeof(qemu_tablet_config_descriptor);
} } else if (s->kind == USB_KEYBOARD) {
memcpy(data, qemu_keyboard_config_descriptor,
sizeof(qemu_keyboard_config_descriptor));
ret = sizeof(qemu_keyboard_config_descriptor);
}
break; break;
case USB_DT_STRING: case USB_DT_STRING:
switch(value & 0xff) { switch(value & 0xff) {
@ -402,19 +701,22 @@ static int usb_mouse_handle_control(USBDevice *dev, int request, int value,
break; break;
case 2: case 2:
/* product description */ /* product description */
if (s->kind == USB_MOUSE) ret = set_usb_string(data, s->dev.product_desc);
ret = set_usb_string(data, "QEMU USB Mouse");
else if (s->kind == USB_TABLET)
ret = set_usb_string(data, "QEMU USB Tablet");
break; break;
case 3: case 3:
/* vendor description */ /* vendor description */
ret = set_usb_string(data, "PCSX2/QEMU"); ret = set_usb_string(data, "QEMU " QEMU_VERSION);
break; break;
case 4: case 4:
ret = set_usb_string(data, "HID Mouse"); ret = set_usb_string(data, "HID Mouse");
break; break;
case 5: case 5:
ret = set_usb_string(data, "HID Tablet");
break;
case 6:
ret = set_usb_string(data, "HID Keyboard");
break;
case 7:
ret = set_usb_string(data, "Endpoint1 Interrupt Pipe"); ret = set_usb_string(data, "Endpoint1 Interrupt Pipe");
break; break;
default: default:
@ -444,26 +746,55 @@ static int usb_mouse_handle_control(USBDevice *dev, int request, int value,
switch(value >> 8) { switch(value >> 8) {
case 0x22: case 0x22:
if (s->kind == USB_MOUSE) { if (s->kind == USB_MOUSE) {
memcpy(data, qemu_mouse_hid_report_descriptor, memcpy(data, qemu_mouse_hid_report_descriptor,
sizeof(qemu_mouse_hid_report_descriptor)); sizeof(qemu_mouse_hid_report_descriptor));
ret = sizeof(qemu_mouse_hid_report_descriptor); ret = sizeof(qemu_mouse_hid_report_descriptor);
} else if (s->kind == USB_TABLET) { } else if (s->kind == USB_TABLET) {
memcpy(data, qemu_tablet_hid_report_descriptor, memcpy(data, qemu_tablet_hid_report_descriptor,
sizeof(qemu_tablet_hid_report_descriptor)); sizeof(qemu_tablet_hid_report_descriptor));
ret = sizeof(qemu_tablet_hid_report_descriptor); ret = sizeof(qemu_tablet_hid_report_descriptor);
} } else if (s->kind == USB_KEYBOARD) {
break; memcpy(data, qemu_keyboard_hid_report_descriptor,
sizeof(qemu_keyboard_hid_report_descriptor));
ret = sizeof(qemu_keyboard_hid_report_descriptor);
}
break;
default: default:
goto fail; goto fail;
} }
break; break;
case GET_REPORT: case GET_REPORT:
if (s->kind == USB_MOUSE) if (s->kind == USB_MOUSE)
ret = usb_mouse_poll(s, data, length); ret = usb_mouse_poll(s, data, length);
else if (s->kind == USB_TABLET) else if (s->kind == USB_TABLET)
ret = usb_tablet_poll(s, data, length); ret = usb_tablet_poll(s, data, length);
else if (s->kind == USB_KEYBOARD)
ret = usb_keyboard_poll(&s->kbd, data, length);
break;
case SET_REPORT:
if (s->kind == USB_KEYBOARD)
ret = usb_keyboard_write(&s->kbd, data, length);
else
goto fail;
break;
case GET_PROTOCOL:
if (s->kind != USB_KEYBOARD)
goto fail;
ret = 1;
data[0] = s->protocol;
break;
case SET_PROTOCOL:
if (s->kind != USB_KEYBOARD)
goto fail;
ret = 0;
s->protocol = value;
break;
case GET_IDLE:
ret = 1;
data[0] = s->idle;
break; break;
case SET_IDLE: case SET_IDLE:
s->idle = (uint8_t) (value >> 8);
ret = 0; ret = 0;
break; break;
default: default:
@ -474,19 +805,24 @@ static int usb_mouse_handle_control(USBDevice *dev, int request, int value,
return ret; return ret;
} }
static int usb_mouse_handle_data(USBDevice *dev, int pid, static int usb_hid_handle_data(USBDevice *dev, USBPacket *p)
uint8_t devep, uint8_t *data, int len)
{ {
USBMouseState *s = (USBMouseState *)dev; USBHIDState *s = (USBHIDState *)dev;
int ret = 0; int ret = 0;
switch(pid) { switch(p->pid) {
case USB_TOKEN_IN: case USB_TOKEN_IN:
if (devep == 1) { if (p->devep == 1) {
if (s->kind == USB_MOUSE) /* TODO: Implement finite idle delays. */
ret = usb_mouse_poll(s, data, len); if (!(s->changed || s->idle))
else if (s->kind == USB_TABLET) return USB_RET_NAK;
ret = usb_tablet_poll(s, data, len); s->changed = 0;
if (s->kind == USB_MOUSE)
ret = usb_mouse_poll(s, p->data, p->len);
else if (s->kind == USB_TABLET)
ret = usb_tablet_poll(s, p->data, p->len);
else if (s->kind == USB_KEYBOARD)
ret = usb_keyboard_poll(&s->kbd, p->data, p->len);
} else { } else {
goto fail; goto fail;
} }
@ -500,52 +836,89 @@ static int usb_mouse_handle_data(USBDevice *dev, int pid,
return ret; return ret;
} }
static void usb_mouse_handle_destroy(USBDevice *dev) static void usb_hid_handle_destroy(USBDevice *dev)
{ {
USBMouseState *s = (USBMouseState *)dev; USBHIDState *s = (USBHIDState *)dev;
qemu_add_mouse_event_handler(NULL, NULL, 0); if (s->kind != USB_KEYBOARD)
free(s); qemu_remove_mouse_event_handler(s->ptr.eh_entry);
/* TODO: else */
} }
USBDevice *usb_tablet_init(void) static int usb_hid_initfn(USBDevice *dev, int kind)
{ {
USBMouseState *s; USBHIDState *s = DO_UPCAST(USBHIDState, dev, dev);
s = qemu_mallocz(sizeof(USBMouseState));
if (!s)
return NULL;
s->dev.speed = USB_SPEED_FULL; s->dev.speed = USB_SPEED_FULL;
s->dev.handle_packet = usb_generic_handle_packet; s->kind = kind;
/* Force poll routine to be run and grab input the first time. */
s->dev.handle_reset = usb_mouse_handle_reset; s->changed = 1;
s->dev.handle_control = usb_mouse_handle_control; return 0;
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) static int usb_tablet_initfn(USBDevice *dev)
{ {
USBMouseState *s; return usb_hid_initfn(dev, USB_TABLET);
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;
} }
static int usb_mouse_initfn(USBDevice *dev)
{
return usb_hid_initfn(dev, USB_MOUSE);
}
static int usb_keyboard_initfn(USBDevice *dev)
{
return usb_hid_initfn(dev, USB_KEYBOARD);
}
void usb_hid_datain_cb(USBDevice *dev, void *opaque, void (*datain)(void *))
{
USBHIDState *s = (USBHIDState *)dev;
s->datain_opaque = opaque;
s->datain = datain;
}
static struct USBDeviceInfo hid_info[] = {
{
.product_desc = "QEMU USB Tablet",
.qdev.name = "usb-tablet",
.usbdevice_name = "tablet",
.qdev.size = sizeof(USBHIDState),
.init = usb_tablet_initfn,
.handle_packet = usb_generic_handle_packet,
.handle_reset = usb_mouse_handle_reset,
.handle_control = usb_hid_handle_control,
.handle_data = usb_hid_handle_data,
.handle_destroy = usb_hid_handle_destroy,
},{
.product_desc = "QEMU USB Mouse",
.qdev.name = "usb-mouse",
.usbdevice_name = "mouse",
.qdev.size = sizeof(USBHIDState),
.init = usb_mouse_initfn,
.handle_packet = usb_generic_handle_packet,
.handle_reset = usb_mouse_handle_reset,
.handle_control = usb_hid_handle_control,
.handle_data = usb_hid_handle_data,
.handle_destroy = usb_hid_handle_destroy,
},{
.product_desc = "QEMU USB Keyboard",
.qdev.name = "usb-kbd",
.usbdevice_name = "keyboard",
.qdev.size = sizeof(USBHIDState),
.init = usb_keyboard_initfn,
.handle_packet = usb_generic_handle_packet,
.handle_reset = usb_keyboard_handle_reset,
.handle_control = usb_hid_handle_control,
.handle_data = usb_hid_handle_data,
.handle_destroy = usb_hid_handle_destroy,
},{
/* end of list */
}
};
static void usb_hid_register_devices(void)
{
usb_qdev_register_many(hid_info);
}
device_init(usb_hid_register_devices)

View File

@ -2,7 +2,7 @@
* QEMU USB HUB emulation * QEMU USB HUB emulation
* *
* Copyright (c) 2005 Fabrice Bellard * Copyright (c) 2005 Fabrice Bellard
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
@ -112,13 +112,13 @@ static const uint8_t qemu_hub_config_descriptor[] = {
0x01, /* u8 bNumInterfaces; (1) */ 0x01, /* u8 bNumInterfaces; (1) */
0x01, /* u8 bConfigurationValue; */ 0x01, /* u8 bConfigurationValue; */
0x00, /* u8 iConfiguration; */ 0x00, /* u8 iConfiguration; */
0xc0, /* u8 bmAttributes; 0xc0, /* u8 bmAttributes;
Bit 7: must be set, Bit 7: must be set,
6: Self-powered, 6: Self-powered,
5: Remote wakeup, 5: Remote wakeup,
4..0: resvd */ 4..0: resvd */
0x00, /* u8 MaxPower; */ 0x00, /* u8 MaxPower; */
/* USB 1.1: /* USB 1.1:
* USB 2.0, single TT organization (mandatory): * USB 2.0, single TT organization (mandatory):
* one interface, protocol 0 * one interface, protocol 0
@ -140,7 +140,7 @@ static const uint8_t qemu_hub_config_descriptor[] = {
0x00, /* u8 if_bInterfaceSubClass; */ 0x00, /* u8 if_bInterfaceSubClass; */
0x00, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */ 0x00, /* u8 if_bInterfaceProtocol; [usb1.1 or single tt] */
0x00, /* u8 if_iInterface; */ 0x00, /* u8 if_iInterface; */
/* one endpoint (status change endpoint) */ /* one endpoint (status change endpoint) */
0x07, /* u8 ep_bLength; */ 0x07, /* u8 ep_bLength; */
0x05, /* u8 ep_bDescriptorType; Endpoint */ 0x05, /* u8 ep_bDescriptorType; Endpoint */
@ -165,13 +165,13 @@ static const uint8_t qemu_hub_hub_descriptor[] =
static void usb_hub_attach(USBPort *port1, USBDevice *dev) static void usb_hub_attach(USBPort *port1, USBDevice *dev)
{ {
USBHubState *s =(USBHubState *) port1->opaque; USBHubState *s = (USBHubState *)port1->opaque;
USBHubPort *port = (USBHubPort *)&s->ports[port1->index]; USBHubPort *port = &s->ports[port1->index];
if (dev) { if (dev) {
if (port->port.dev) if (port->port.dev)
usb_attach(port1, NULL); usb_attach(port1, NULL);
port->wPortStatus |= PORT_STAT_CONNECTION; port->wPortStatus |= PORT_STAT_CONNECTION;
port->wPortChange |= PORT_STAT_C_CONNECTION; port->wPortChange |= PORT_STAT_C_CONNECTION;
if (dev->speed == USB_SPEED_LOW) if (dev->speed == USB_SPEED_LOW)
@ -180,8 +180,7 @@ static void usb_hub_attach(USBPort *port1, USBDevice *dev)
port->wPortStatus &= ~PORT_STAT_LOW_SPEED; port->wPortStatus &= ~PORT_STAT_LOW_SPEED;
port->port.dev = dev; port->port.dev = dev;
/* send the attach message */ /* send the attach message */
dev->handle_packet(dev, usb_send_msg(dev, USB_MSG_ATTACH);
USB_MSG_ATTACH, 0, 0, NULL, 0);
} else { } else {
dev = port->port.dev; dev = port->port.dev;
if (dev) { if (dev) {
@ -192,8 +191,7 @@ static void usb_hub_attach(USBPort *port1, USBDevice *dev)
port->wPortChange |= PORT_STAT_C_ENABLE; port->wPortChange |= PORT_STAT_C_ENABLE;
} }
/* send the detach message */ /* send the detach message */
dev->handle_packet(dev, usb_send_msg(dev, USB_MSG_DETACH);
USB_MSG_DETACH, 0, 0, NULL, 0);
port->port.dev = NULL; port->port.dev = NULL;
} }
} }
@ -246,12 +244,12 @@ static int usb_hub_handle_control(USBDevice *dev, int request, int value,
case DeviceRequest | USB_REQ_GET_DESCRIPTOR: case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
switch(value >> 8) { switch(value >> 8) {
case USB_DT_DEVICE: case USB_DT_DEVICE:
memcpy(data, qemu_hub_dev_descriptor, memcpy(data, qemu_hub_dev_descriptor,
sizeof(qemu_hub_dev_descriptor)); sizeof(qemu_hub_dev_descriptor));
ret = sizeof(qemu_hub_dev_descriptor); ret = sizeof(qemu_hub_dev_descriptor);
break; break;
case USB_DT_CONFIG: case USB_DT_CONFIG:
memcpy(data, qemu_hub_config_descriptor, memcpy(data, qemu_hub_config_descriptor,
sizeof(qemu_hub_config_descriptor)); sizeof(qemu_hub_config_descriptor));
/* status change endpoint size based on number /* status change endpoint size based on number
@ -280,7 +278,7 @@ static int usb_hub_handle_control(USBDevice *dev, int request, int value,
break; break;
case 3: case 3:
/* vendor description */ /* vendor description */
ret = set_usb_string(data, "PCSX2/QEMU"); ret = set_usb_string(data, "QEMU v0.12.5");
break; break;
default: default:
goto fail; goto fail;
@ -349,8 +347,7 @@ static int usb_hub_handle_control(USBDevice *dev, int request, int value,
break; break;
case PORT_RESET: case PORT_RESET:
if (dev) { if (dev) {
dev->handle_packet(dev, usb_send_msg(dev, USB_MSG_RESET);
USB_MSG_RESET, 0, 0, NULL, 0);
port->wPortChange |= PORT_STAT_C_RESET; port->wPortChange |= PORT_STAT_C_RESET;
/* set enable bit */ /* set enable bit */
port->wPortStatus |= PORT_STAT_ENABLE; port->wPortStatus |= PORT_STAT_ENABLE;
@ -404,7 +401,7 @@ static int usb_hub_handle_control(USBDevice *dev, int request, int value,
case GetHubDescriptor: case GetHubDescriptor:
{ {
unsigned int n, limit, var_hub_size = 0; unsigned int n, limit, var_hub_size = 0;
memcpy(data, qemu_hub_hub_descriptor, memcpy(data, qemu_hub_hub_descriptor,
sizeof(qemu_hub_hub_descriptor)); sizeof(qemu_hub_hub_descriptor));
data[2] = s->nb_ports; data[2] = s->nb_ports;
@ -434,22 +431,21 @@ static int usb_hub_handle_control(USBDevice *dev, int request, int value,
return ret; return ret;
} }
static int usb_hub_handle_data(USBDevice *dev, int pid, static int usb_hub_handle_data(USBDevice *dev, USBPacket *p)
uint8_t devep, uint8_t *data, int len)
{ {
USBHubState *s = (USBHubState *)dev; USBHubState *s = (USBHubState *)dev;
int ret; int ret;
switch(pid) { switch(p->pid) {
case USB_TOKEN_IN: case USB_TOKEN_IN:
if (devep == 1) { if (p->devep == 1) {
USBHubPort *port; USBHubPort *port;
unsigned int status; unsigned int status;
int i, n; int i, n;
n = (s->nb_ports + 1 + 7) / 8; n = (s->nb_ports + 1 + 7) / 8;
if (len == 1) { /* FreeBSD workaround */ if (p->len == 1) { /* FreeBSD workaround */
n = 1; n = 1;
} else if (n > len) { } else if (n > p->len) {
return USB_RET_BABBLE; return USB_RET_BABBLE;
} }
status = 0; status = 0;
@ -460,7 +456,7 @@ static int usb_hub_handle_data(USBDevice *dev, int pid,
} }
if (status != 0) { if (status != 0) {
for(i = 0; i < n; i++) { for(i = 0; i < n; i++) {
data[i] = status >> (8 * i); p->data[i] = status >> (8 * i);
} }
ret = n; ret = n;
} else { } else {
@ -479,9 +475,7 @@ static int usb_hub_handle_data(USBDevice *dev, int pid,
return ret; return ret;
} }
static int usb_hub_broadcast_packet(USBHubState *s, int pid, static int usb_hub_broadcast_packet(USBHubState *s, USBPacket *p)
uint8_t devaddr, uint8_t devep,
uint8_t *data, int len)
{ {
USBHubPort *port; USBHubPort *port;
USBDevice *dev; USBDevice *dev;
@ -491,9 +485,7 @@ static int usb_hub_broadcast_packet(USBHubState *s, int pid,
port = &s->ports[i]; port = &s->ports[i];
dev = port->port.dev; dev = port->port.dev;
if (dev && (port->wPortStatus & PORT_STAT_ENABLE)) { if (dev && (port->wPortStatus & PORT_STAT_ENABLE)) {
ret = dev->handle_packet(dev, pid, ret = dev->info->handle_packet(dev, p);
devaddr, devep,
data, len);
if (ret != USB_RET_NODEV) { if (ret != USB_RET_NODEV) {
return ret; return ret;
} }
@ -502,9 +494,7 @@ static int usb_hub_broadcast_packet(USBHubState *s, int pid,
return USB_RET_NODEV; return USB_RET_NODEV;
} }
static int usb_hub_handle_packet(USBDevice *dev, int pid, static int usb_hub_handle_packet(USBDevice *dev, USBPacket *p)
uint8_t devaddr, uint8_t devep,
uint8_t *data, int len)
{ {
USBHubState *s = (USBHubState *)dev; USBHubState *s = (USBHubState *)dev;
@ -513,53 +503,59 @@ static int usb_hub_handle_packet(USBDevice *dev, int pid,
#endif #endif
if (dev->state == USB_STATE_DEFAULT && if (dev->state == USB_STATE_DEFAULT &&
dev->addr != 0 && dev->addr != 0 &&
devaddr != dev->addr && p->devaddr != dev->addr &&
(pid == USB_TOKEN_SETUP || (p->pid == USB_TOKEN_SETUP ||
pid == USB_TOKEN_OUT || p->pid == USB_TOKEN_OUT ||
pid == USB_TOKEN_IN)) { p->pid == USB_TOKEN_IN)) {
/* broadcast the packet to the devices */ /* broadcast the packet to the devices */
return usb_hub_broadcast_packet(s, pid, devaddr, devep, data, len); return usb_hub_broadcast_packet(s, p);
} }
return usb_generic_handle_packet(dev, pid, devaddr, devep, data, len); return usb_generic_handle_packet(dev, p);
} }
static void usb_hub_handle_destroy(USBDevice *dev) static void usb_hub_handle_destroy(USBDevice *dev)
{ {
USBHubState *s = (USBHubState *)dev; USBHubState *s = (USBHubState *)dev;
int i;
free(s); //for (i = 0; i < s->nb_ports; i++) {
// usb_unregister_port(usb_bus_from_device(dev),
// &s->ports[i].port);
//}
} }
USBDevice *usb_hub_init(int nb_ports) static int usb_hub_initfn(USBDevice *dev)
{ {
USBHubState *s; USBHubState *s = (USBHubState*)dev;
USBHubPort *port; USBHubPort *port;
int i; int i;
if (nb_ports > MAX_PORTS) s->dev.speed = USB_SPEED_FULL,
return NULL; s->nb_ports = MAX_PORTS; /* FIXME: make configurable */
s = (USBHubState *)qemu_mallocz(sizeof(USBHubState)); for (i = 0; i < s->nb_ports; i++) {
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 = &s->ports[i];
port->port.opaque = s; //usb_register_port(usb_bus_from_device(dev),
port->port.index = i; // &port->port, s, i, usb_hub_attach);
port->port.attach = usb_hub_attach;
port->wPortStatus = PORT_STAT_POWER; port->wPortStatus = PORT_STAT_POWER;
port->wPortChange = 0; port->wPortChange = 0;
} }
return (USBDevice *)s; return 0;
} }
static struct USBDeviceInfo hub_info = {
usb_hub_initfn,
usb_hub_handle_packet,
usb_hub_handle_destroy,
usb_hub_handle_reset,
usb_hub_handle_control,
usb_hub_handle_data,
"QEMU USB Hub",
};
static void usb_hub_register_devices(void)
{
//usb_qdev_register(&hub_info);
}
//device_init(usb_hub_register_devices)

View File

@ -38,6 +38,8 @@ typedef struct USBKeyboardState {
int keyboard_grabbed; int keyboard_grabbed;
} USBKeyboardState; } USBKeyboardState;
USBDeviceInfo devinfo;
extern HWND gsWnd; extern HWND gsWnd;
#define VK_BASED #define VK_BASED
@ -817,16 +819,15 @@ static int usb_keyboard_handle_control(USBDevice *dev, int request, int value,
return ret; return ret;
} }
static int usb_keyboard_handle_data(USBDevice *dev, int pid, static int usb_keyboard_handle_data(USBDevice *dev, USBPacket* packet)
uint8_t devep, uint8_t *data, int len)
{ {
USBKeyboardState *s = (USBKeyboardState *)dev; USBKeyboardState *s = (USBKeyboardState *)dev;
int ret = 0; int ret = 0;
switch(pid) { switch(packet->pid) {
case USB_TOKEN_IN: case USB_TOKEN_IN:
if (devep == 1) { if (packet->devep == 1) {
ret = usb_keyboard_poll(s, data, len); ret = usb_keyboard_poll(s, packet->data, packet->len);
} else { } else {
goto fail; goto fail;
} }
@ -857,14 +858,13 @@ USBDevice *usb_keyboard_init(void)
return NULL; return NULL;
memset(s,0,sizeof(USBKeyboardState)); memset(s,0,sizeof(USBKeyboardState));
s->dev.speed = USB_SPEED_FULL; s->dev.speed = USB_SPEED_FULL;
s->dev.handle_packet = usb_generic_handle_packet; s->dev.info = &devinfo;
s->dev.info->handle_packet = usb_generic_handle_packet;
s->dev.handle_reset = usb_keyboard_handle_reset; s->dev.info->handle_reset = usb_keyboard_handle_reset;
s->dev.handle_control = usb_keyboard_handle_control; s->dev.info->handle_control = usb_keyboard_handle_control;
s->dev.handle_data = usb_keyboard_handle_data; s->dev.info->handle_data = usb_keyboard_handle_data;
s->dev.handle_destroy = usb_keyboard_handle_destroy; s->dev.info->handle_destroy = usb_keyboard_handle_destroy;
s->dev.info->product_desc = "Generic USB Keyboard";
strncpy(s->dev.devname, "Generic USB Keyboard", sizeof(s->dev.devname));
return (USBDevice *)s; return (USBDevice *)s;
} }

View File

@ -1,4 +1,4 @@
/* /*
* USB Mass Storage Device emulation * USB Mass Storage Device emulation
* *
* Copyright (c) 2006 CodeSourcery. * Copyright (c) 2006 CodeSourcery.
@ -7,15 +7,22 @@
* This code is licenced under the LGPL. * This code is licenced under the LGPL.
*/ */
#include "vl.h" #include "qemu-common.h"
#include "qemu-option.h"
#include "qemu-config.h"
#include "usb.h"
#include "block.h"
#include "scsi.h"
#include "console.h"
#include "monitor.h"
//#define DEBUG_MSD //#define DEBUG_MSD
#ifdef DEBUG_MSD #ifdef DEBUG_MSD
#define DPRINTF(fmt, args...) \ #define DPRINTF(fmt, ...) \
do { printf("usb-msd: " fmt , ##args); } while (0) do { printf("usb-msd: " fmt , ## __VA_ARGS__); } while (0)
#else #else
#define DPRINTF(fmt, args...) do {} while(0) #define DPRINTF(fmt, ...) do {} while(0)
#endif #endif
/* USB requests. */ /* USB requests. */
@ -32,16 +39,42 @@ enum USBMSDMode {
typedef struct { typedef struct {
USBDevice dev; USBDevice dev;
enum USBMSDMode mode; enum USBMSDMode mode;
uint32_t scsi_len;
uint8_t *scsi_buf;
uint32_t usb_len;
uint8_t *usb_buf;
uint32_t data_len; uint32_t data_len;
uint32_t residue;
uint32_t tag; uint32_t tag;
SCSIBus bus;
DriveInfo *dinfo;
SCSIDevice *scsi_dev; SCSIDevice *scsi_dev;
int result; int result;
/* For async completion. */
USBPacket *packet;
} MSDState; } MSDState;
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 const uint8_t qemu_msd_dev_descriptor[] = { static const uint8_t qemu_msd_dev_descriptor[] = {
0x12, /* u8 bLength; */ 0x12, /* u8 bLength; */
0x01, /* u8 bDescriptorType; Device */ 0x01, /* u8 bDescriptorType; Device */
0x10, 0x00, /* u16 bcdUSB; v1.0 */ 0x00, 0x01, /* u16 bcdUSB; v1.0 */
0x00, /* u8 bDeviceClass; */ 0x00, /* u8 bDeviceClass; */
0x00, /* u8 bDeviceSubClass; */ 0x00, /* u8 bDeviceSubClass; */
@ -68,13 +101,13 @@ static const uint8_t qemu_msd_config_descriptor[] = {
0x01, /* u8 bNumInterfaces; (1) */ 0x01, /* u8 bNumInterfaces; (1) */
0x01, /* u8 bConfigurationValue; */ 0x01, /* u8 bConfigurationValue; */
0x00, /* u8 iConfiguration; */ 0x00, /* u8 iConfiguration; */
0xc0, /* u8 bmAttributes; 0xc0, /* u8 bmAttributes;
Bit 7: must be set, Bit 7: must be set,
6: Self-powered, 6: Self-powered,
5: Remote wakeup, 5: Remote wakeup,
4..0: resvd */ 4..0: resvd */
0x00, /* u8 MaxPower; */ 0x00, /* u8 MaxPower; */
/* one interface */ /* one interface */
0x09, /* u8 if_bLength; */ 0x09, /* u8 if_bLength; */
0x04, /* u8 if_bDescriptorType; Interface */ 0x04, /* u8 if_bDescriptorType; Interface */
@ -85,7 +118,7 @@ static const uint8_t qemu_msd_config_descriptor[] = {
0x06, /* u8 if_bInterfaceSubClass; SCSI */ 0x06, /* u8 if_bInterfaceSubClass; SCSI */
0x50, /* u8 if_bInterfaceProtocol; Bulk Only */ 0x50, /* u8 if_bInterfaceProtocol; Bulk Only */
0x00, /* u8 if_iInterface; */ 0x00, /* u8 if_iInterface; */
/* Bulk-In endpoint */ /* Bulk-In endpoint */
0x07, /* u8 ep_bLength; */ 0x07, /* u8 ep_bLength; */
0x05, /* u8 ep_bDescriptorType; Endpoint */ 0x05, /* u8 ep_bDescriptorType; Endpoint */
@ -103,13 +136,91 @@ static const uint8_t qemu_msd_config_descriptor[] = {
0x00 /* u8 ep_bInterval; */ 0x00 /* u8 ep_bInterval; */
}; };
static void usb_msd_command_complete(void *opaque, uint32_t tag, int fail) static void usb_msd_copy_data(MSDState *s)
{ {
MSDState *s = (MSDState *)opaque; uint32_t len;
len = s->usb_len;
if (len > s->scsi_len)
len = s->scsi_len;
if (s->mode == USB_MSDM_DATAIN) {
memcpy(s->usb_buf, s->scsi_buf, len);
} else {
memcpy(s->scsi_buf, s->usb_buf, len);
}
s->usb_len -= len;
s->scsi_len -= len;
s->usb_buf += len;
s->scsi_buf += len;
s->data_len -= len;
if (s->scsi_len == 0) {
if (s->mode == USB_MSDM_DATAIN) {
s->scsi_dev->info->read_data(s->scsi_dev, s->tag);
} else if (s->mode == USB_MSDM_DATAOUT) {
s->scsi_dev->info->write_data(s->scsi_dev, s->tag);
}
}
}
DPRINTF("Command complete\n"); static void usb_msd_send_status(MSDState *s)
s->result = fail; {
s->mode = USB_MSDM_CSW; struct usb_msd_csw csw;
csw.sig = cpu_to_le32(0x53425355);
csw.tag = cpu_to_le32(s->tag);
csw.residue = s->residue;
csw.status = s->result;
memcpy(s->usb_buf, &csw, 13);
}
static void usb_msd_command_complete(SCSIBus *bus, int reason, uint32_t tag,
uint32_t arg)
{
MSDState *s = DO_UPCAST(MSDState, dev.qdev, bus->qbus.parent);
USBPacket *p = s->packet;
if (tag != s->tag) {
fprintf(stderr, "usb-msd: Unexpected SCSI Tag 0x%x\n", tag);
}
if (reason == SCSI_REASON_DONE) {
DPRINTF("Command complete %d\n", arg);
s->residue = s->data_len;
s->result = arg != 0;
if (s->packet) {
if (s->data_len == 0 && s->mode == USB_MSDM_DATAOUT) {
/* A deferred packet with no write data remaining must be
the status read packet. */
usb_msd_send_status(s);
s->mode = USB_MSDM_CBW;
} else {
if (s->data_len) {
s->data_len -= s->usb_len;
if (s->mode == USB_MSDM_DATAIN)
memset(s->usb_buf, 0, s->usb_len);
s->usb_len = 0;
}
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
}
s->packet = NULL;
usb_packet_complete(p);
} else if (s->data_len == 0) {
s->mode = USB_MSDM_CSW;
}
return;
}
s->scsi_len = arg;
s->scsi_buf = s->scsi_dev->info->get_buf(s->scsi_dev, tag);
if (p) {
usb_msd_copy_data(s);
if (s->usb_len == 0) {
/* Set s->packet to NULL before calling usb_packet_complete
because annother request may be issued before
usb_packet_complete returns. */
DPRINTF("Packet complete %p\n", p);
s->packet = NULL;
usb_packet_complete(p);
}
}
} }
static void usb_msd_handle_reset(USBDevice *dev) static void usb_msd_handle_reset(USBDevice *dev)
@ -156,12 +267,12 @@ static int usb_msd_handle_control(USBDevice *dev, int request, int value,
case DeviceRequest | USB_REQ_GET_DESCRIPTOR: case DeviceRequest | USB_REQ_GET_DESCRIPTOR:
switch(value >> 8) { switch(value >> 8) {
case USB_DT_DEVICE: case USB_DT_DEVICE:
memcpy(data, qemu_msd_dev_descriptor, memcpy(data, qemu_msd_dev_descriptor,
sizeof(qemu_msd_dev_descriptor)); sizeof(qemu_msd_dev_descriptor));
ret = sizeof(qemu_msd_dev_descriptor); ret = sizeof(qemu_msd_dev_descriptor);
break; break;
case USB_DT_CONFIG: case USB_DT_CONFIG:
memcpy(data, qemu_msd_config_descriptor, memcpy(data, qemu_msd_config_descriptor,
sizeof(qemu_msd_config_descriptor)); sizeof(qemu_msd_config_descriptor));
ret = sizeof(qemu_msd_config_descriptor); ret = sizeof(qemu_msd_config_descriptor);
break; break;
@ -233,32 +344,24 @@ static int usb_msd_handle_control(USBDevice *dev, int request, int value,
return ret; return ret;
} }
struct usb_msd_cbw { static void usb_msd_cancel_io(USBPacket *p, void *opaque)
uint32_t sig; {
uint32_t tag; MSDState *s = opaque;
uint32_t data_len; s->scsi_dev->info->cancel_io(s->scsi_dev, s->tag);
uint8_t flags; s->packet = NULL;
uint8_t lun; s->scsi_len = 0;
uint8_t cmd_len; }
uint8_t cmd[16];
};
struct usb_msd_csw { static int usb_msd_handle_data(USBDevice *dev, USBPacket *p)
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; MSDState *s = (MSDState *)dev;
int ret = 0; int ret = 0;
struct usb_msd_cbw cbw; struct usb_msd_cbw cbw;
struct usb_msd_csw csw; uint8_t devep = p->devep;
uint8_t *data = p->data;
int len = p->len;
switch (pid) { switch (p->pid) {
case USB_TOKEN_OUT: case USB_TOKEN_OUT:
if (devep != 2) if (devep != 2)
goto fail; goto fail;
@ -291,7 +394,17 @@ static int usb_msd_handle_data(USBDevice *dev, int pid, uint8_t devep,
} }
DPRINTF("Command tag 0x%x flags %08x len %d data %d\n", DPRINTF("Command tag 0x%x flags %08x len %d data %d\n",
s->tag, cbw.flags, cbw.cmd_len, s->data_len); s->tag, cbw.flags, cbw.cmd_len, s->data_len);
scsi_send_command(s->scsi_dev, s->tag, cbw.cmd, 0); s->residue = 0;
s->scsi_dev->info->send_command(s->scsi_dev, s->tag, cbw.cmd, 0);
/* ??? Should check that USB and SCSI data transfer
directions match. */
if (s->residue == 0) {
if (s->mode == USB_MSDM_DATAIN) {
s->scsi_dev->info->read_data(s->scsi_dev, s->tag);
} else if (s->mode == USB_MSDM_DATAOUT) {
s->scsi_dev->info->write_data(s->scsi_dev, s->tag);
}
}
ret = len; ret = len;
break; break;
@ -300,13 +413,25 @@ static int usb_msd_handle_data(USBDevice *dev, int pid, uint8_t devep,
if (len > s->data_len) if (len > s->data_len)
goto fail; goto fail;
if (scsi_write_data(s->scsi_dev, data, len)) s->usb_buf = data;
goto fail; s->usb_len = len;
if (s->scsi_len) {
s->data_len -= len; usb_msd_copy_data(s);
if (s->data_len == 0) }
s->mode = USB_MSDM_CSW; if (s->residue && s->usb_len) {
ret = len; s->data_len -= s->usb_len;
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
s->usb_len = 0;
}
if (s->usb_len) {
DPRINTF("Deferring packet %p\n", p);
usb_defer_packet(p, usb_msd_cancel_io, s);
s->packet = p;
ret = USB_RET_ASYNC;
} else {
ret = len;
}
break; break;
default: default:
@ -320,33 +445,52 @@ static int usb_msd_handle_data(USBDevice *dev, int pid, uint8_t devep,
goto fail; goto fail;
switch (s->mode) { switch (s->mode) {
case USB_MSDM_DATAOUT:
if (s->data_len != 0 || len < 13)
goto fail;
/* Waiting for SCSI write to complete. */
usb_defer_packet(p, usb_msd_cancel_io, s);
s->packet = p;
ret = USB_RET_ASYNC;
break;
case USB_MSDM_CSW: case USB_MSDM_CSW:
DPRINTF("Command status %d tag 0x%x, len %d\n", DPRINTF("Command status %d tag 0x%x, len %d\n",
s->result, s->tag, len); s->result, s->tag, len);
if (len < 13) if (len < 13)
goto fail; goto fail;
csw.sig = cpu_to_le32(0x53425355); s->usb_len = len;
csw.tag = cpu_to_le32(s->tag); s->usb_buf = data;
csw.residue = 0; usb_msd_send_status(s);
csw.status = s->result;
memcpy(data, &csw, 13);
ret = 13;
s->mode = USB_MSDM_CBW; s->mode = USB_MSDM_CBW;
ret = 13;
break; break;
case USB_MSDM_DATAIN: case USB_MSDM_DATAIN:
DPRINTF("Data in %d/%d\n", len, s->data_len); DPRINTF("Data in %d/%d\n", len, s->data_len);
if (len > s->data_len) if (len > s->data_len)
len = s->data_len; len = s->data_len;
s->usb_buf = data;
if (scsi_read_data(s->scsi_dev, data, len)) s->usb_len = len;
goto fail; if (s->scsi_len) {
usb_msd_copy_data(s);
s->data_len -= len; }
if (s->data_len == 0) if (s->residue && s->usb_len) {
s->mode = USB_MSDM_CSW; s->data_len -= s->usb_len;
ret = len; memset(s->usb_buf, 0, s->usb_len);
if (s->data_len == 0)
s->mode = USB_MSDM_CSW;
s->usb_len = 0;
}
if (s->usb_len) {
DPRINTF("Deferring packet %p\n", p);
usb_defer_packet(p, usb_msd_cancel_io, s);
s->packet = p;
ret = USB_RET_ASYNC;
} else {
ret = len;
}
break; break;
default: default:
@ -365,38 +509,118 @@ static int usb_msd_handle_data(USBDevice *dev, int pid, uint8_t devep,
return ret; return ret;
} }
static void usb_msd_handle_destroy(USBDevice *dev) static void usb_msd_password_cb(void *opaque, int err)
{ {
MSDState *s = (MSDState *)dev; MSDState *s = opaque;
scsi_disk_destroy(s->scsi_dev); if (!err)
qemu_free(s); usb_device_attach(&s->dev);
else
qdev_unplug(&s->dev.qdev);
} }
USBDevice *usb_msd_init(const char *filename) static int usb_msd_initfn(USBDevice *dev)
{ {
MSDState *s; MSDState *s = DO_UPCAST(MSDState, dev, dev);
BlockDriverState *bdrv;
s = qemu_mallocz(sizeof(MSDState)); if (!s->dinfo || !s->dinfo->bdrv) {
if (!s) qemu_error("usb-msd: drive property not set\n");
return NULL; return -1;
}
bdrv = bdrv_new("usb");
bdrv_open(bdrv, filename, 0);
s->dev.speed = USB_SPEED_FULL; s->dev.speed = USB_SPEED_FULL;
s->dev.handle_packet = usb_generic_handle_packet; scsi_bus_new(&s->bus, &s->dev.qdev, 0, 1, usb_msd_command_complete);
s->scsi_dev = scsi_bus_legacy_add_drive(&s->bus, s->dinfo, 0);
s->bus.qbus.allow_hotplug = 0;
usb_msd_handle_reset(dev);
s->dev.handle_reset = usb_msd_handle_reset; if (bdrv_key_required(s->dinfo->bdrv)) {
s->dev.handle_control = usb_msd_handle_control; if (s->dev.qdev.hotplugged) {
s->dev.handle_data = usb_msd_handle_data; monitor_read_bdrv_key_start(cur_mon, s->dinfo->bdrv,
s->dev.handle_destroy = usb_msd_handle_destroy; usb_msd_password_cb, s);
s->dev.auto_attach = 0;
} else {
autostart = 0;
}
}
snprintf(s->dev.devname, sizeof(s->dev.devname), "QEMU USB MSD(%.16s)", return 0;
filename);
s->scsi_dev = scsi_disk_init(bdrv, usb_msd_command_complete, s);
usb_msd_handle_reset((USBDevice *)s);
return (USBDevice *)s;
} }
static USBDevice *usb_msd_init(const char *filename)
{
static int nr=0;
char id[8];
QemuOpts *opts;
DriveInfo *dinfo;
USBDevice *dev;
int fatal_error;
const char *p1;
char fmt[32];
/* parse -usbdevice disk: syntax into drive opts */
snprintf(id, sizeof(id), "usb%d", nr++);
opts = qemu_opts_create(&qemu_drive_opts, id, 0);
p1 = strchr(filename, ':');
if (p1++) {
const char *p2;
if (strstart(filename, "format=", &p2)) {
int len = MIN(p1 - p2, sizeof(fmt));
pstrcpy(fmt, len, p2);
qemu_opt_set(opts, "format", fmt);
} else if (*filename != ':') {
printf("unrecognized USB mass-storage option %s\n", filename);
return NULL;
}
filename = p1;
}
if (!*filename) {
printf("block device specification needed\n");
return NULL;
}
qemu_opt_set(opts, "file", filename);
qemu_opt_set(opts, "if", "none");
/* create host drive */
dinfo = drive_init(opts, NULL, &fatal_error);
if (!dinfo) {
qemu_opts_del(opts);
return NULL;
}
/* create guest device */
dev = usb_create(NULL /* FIXME */, "usb-storage");
if (!dev) {
return NULL;
}
qdev_prop_set_drive(&dev->qdev, "drive", dinfo);
if (qdev_init(&dev->qdev) < 0)
return NULL;
return dev;
}
static struct USBDeviceInfo msd_info = {
.product_desc = "QEMU USB MSD",
.qdev.name = "usb-storage",
.qdev.size = sizeof(MSDState),
.init = usb_msd_initfn,
.handle_packet = usb_generic_handle_packet,
.handle_reset = usb_msd_handle_reset,
.handle_control = usb_msd_handle_control,
.handle_data = usb_msd_handle_data,
.usbdevice_name = "disk",
.usbdevice_init = usb_msd_init,
.qdev.props = (Property[]) {
DEFINE_PROP_DRIVE("drive", MSDState, dinfo),
DEFINE_PROP_END_OF_LIST(),
},
};
static void usb_msd_register_devices(void)
{
usb_qdev_register(&msd_info);
}
device_init(usb_msd_register_devices)

File diff suppressed because it is too large Load Diff

View File

@ -1,175 +1,259 @@
/* /*
* QEMU USB API * QEMU USB API
* *
* Copyright (c) 2005 Fabrice Bellard * Copyright (c) 2005 Fabrice Bellard
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights * in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is * copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions: * furnished to do so, subject to the following conditions:
* *
* The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * 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, * 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 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*/ */
#define USB_TOKEN_SETUP 0x2d #include "qemu-queue.h"
#define USB_TOKEN_IN 0x69 /* device -> host */
#define USB_TOKEN_OUT 0xe1 /* host -> device */ #define USB_TOKEN_SETUP 0x2d
#define USB_TOKEN_IN 0x69 /* device -> host */
/* specific usb messages, also sent in the 'pid' parameter */ #define USB_TOKEN_OUT 0xe1 /* host -> device */
#define USB_MSG_ATTACH 0x100
#define USB_MSG_DETACH 0x101 /* specific usb messages, also sent in the 'pid' parameter */
#define USB_MSG_RESET 0x102 #define USB_MSG_ATTACH 0x100
#define USB_MSG_DETACH 0x101
#define USB_RET_NODEV (-1) #define USB_MSG_RESET 0x102
#define USB_RET_NAK (-2)
#define USB_RET_STALL (-3) #define USB_RET_NODEV (-1)
#define USB_RET_BABBLE (-4) #define USB_RET_NAK (-2)
#define USB_RET_STALL (-3)
#define USB_SPEED_LOW 0 #define USB_RET_BABBLE (-4)
#define USB_SPEED_FULL 1 #define USB_RET_ASYNC (-5)
#define USB_SPEED_HIGH 2
#define USB_SPEED_LOW 0
#define USB_STATE_NOTATTACHED 0 #define USB_SPEED_FULL 1
#define USB_STATE_ATTACHED 1 #define USB_SPEED_HIGH 2
//#define USB_STATE_POWERED 2
#define USB_STATE_DEFAULT 3 #define USB_STATE_NOTATTACHED 0
//#define USB_STATE_ADDRESS 4 #define USB_STATE_ATTACHED 1
//#define USB_STATE_CONFIGURED 5 //#define USB_STATE_POWERED 2
#define USB_STATE_SUSPENDED 6 #define USB_STATE_DEFAULT 3
//#define USB_STATE_ADDRESS 4
#define USB_CLASS_AUDIO 1 //#define USB_STATE_CONFIGURED 5
#define USB_CLASS_COMM 2 #define USB_STATE_SUSPENDED 6
#define USB_CLASS_HID 3
#define USB_CLASS_PHYSICAL 5 #define USB_CLASS_AUDIO 1
#define USB_CLASS_STILL_IMAGE 6 #define USB_CLASS_COMM 2
#define USB_CLASS_PRINTER 7 #define USB_CLASS_HID 3
#define USB_CLASS_MASS_STORAGE 8 #define USB_CLASS_PHYSICAL 5
#define USB_CLASS_HUB 9 #define USB_CLASS_STILL_IMAGE 6
#define USB_CLASS_CDC_DATA 0x0a #define USB_CLASS_PRINTER 7
#define USB_CLASS_CSCID 0x0b #define USB_CLASS_MASS_STORAGE 8
#define USB_CLASS_CONTENT_SEC 0x0d #define USB_CLASS_HUB 9
#define USB_CLASS_APP_SPEC 0xfe #define USB_CLASS_CDC_DATA 0x0a
#define USB_CLASS_VENDOR_SPEC 0xff #define USB_CLASS_CSCID 0x0b
#define USB_CLASS_CONTENT_SEC 0x0d
#define USB_DIR_OUT 0 #define USB_CLASS_APP_SPEC 0xfe
#define USB_DIR_IN 0x80 #define USB_CLASS_VENDOR_SPEC 0xff
#define USB_TYPE_MASK (0x03 << 5) #define USB_DIR_OUT 0
#define USB_TYPE_STANDARD (0x00 << 5) #define USB_DIR_IN 0x80
#define USB_TYPE_CLASS (0x01 << 5)
#define USB_TYPE_VENDOR (0x02 << 5) #define USB_TYPE_MASK (0x03 << 5)
#define USB_TYPE_RESERVED (0x03 << 5) #define USB_TYPE_STANDARD (0x00 << 5)
#define USB_TYPE_CLASS (0x01 << 5)
#define USB_RECIP_MASK 0x1f #define USB_TYPE_VENDOR (0x02 << 5)
#define USB_RECIP_DEVICE 0x00 #define USB_TYPE_RESERVED (0x03 << 5)
#define USB_RECIP_INTERFACE 0x01
#define USB_RECIP_ENDPOINT 0x02 #define USB_RECIP_MASK 0x1f
#define USB_RECIP_OTHER 0x03 #define USB_RECIP_DEVICE 0x00
#define USB_RECIP_INTERFACE 0x01
#define DeviceRequest ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8) #define USB_RECIP_ENDPOINT 0x02
#define DeviceOutRequest ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8) #define USB_RECIP_OTHER 0x03
#define InterfaceRequest \
((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8) #define DeviceRequest ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)
#define InterfaceOutRequest \ #define DeviceOutRequest ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_DEVICE)<<8)
((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8) #define InterfaceRequest \
#define EndpointRequest ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_ENDPOINT)<<8) ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
#define EndpointOutRequest \ #define InterfaceOutRequest \
((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_ENDPOINT)<<8) ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_INTERFACE)<<8)
#define EndpointRequest ((USB_DIR_IN|USB_TYPE_STANDARD|USB_RECIP_ENDPOINT)<<8)
#define USB_REQ_GET_STATUS 0x00 #define EndpointOutRequest \
#define USB_REQ_CLEAR_FEATURE 0x01 ((USB_DIR_OUT|USB_TYPE_STANDARD|USB_RECIP_ENDPOINT)<<8)
#define USB_REQ_SET_FEATURE 0x03
#define USB_REQ_SET_ADDRESS 0x05 #define USB_REQ_GET_STATUS 0x00
#define USB_REQ_GET_DESCRIPTOR 0x06 #define USB_REQ_CLEAR_FEATURE 0x01
#define USB_REQ_SET_DESCRIPTOR 0x07 #define USB_REQ_SET_FEATURE 0x03
#define USB_REQ_GET_CONFIGURATION 0x08 #define USB_REQ_SET_ADDRESS 0x05
#define USB_REQ_SET_CONFIGURATION 0x09 #define USB_REQ_GET_DESCRIPTOR 0x06
#define USB_REQ_GET_INTERFACE 0x0A #define USB_REQ_SET_DESCRIPTOR 0x07
#define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_GET_CONFIGURATION 0x08
#define USB_REQ_SYNCH_FRAME 0x0C #define USB_REQ_SET_CONFIGURATION 0x09
#define USB_REQ_GET_INTERFACE 0x0A
#define USB_DEVICE_SELF_POWERED 0 #define USB_REQ_SET_INTERFACE 0x0B
#define USB_DEVICE_REMOTE_WAKEUP 1 #define USB_REQ_SYNCH_FRAME 0x0C
#define USB_DT_DEVICE 0x01 #define USB_DEVICE_SELF_POWERED 0
#define USB_DT_CONFIG 0x02 #define USB_DEVICE_REMOTE_WAKEUP 1
#define USB_DT_STRING 0x03
#define USB_DT_INTERFACE 0x04 #define USB_DT_DEVICE 0x01
#define USB_DT_ENDPOINT 0x05 #define USB_DT_CONFIG 0x02
#define USB_DT_CLASS 0x24 #define USB_DT_STRING 0x03
#define USB_DT_INTERFACE 0x04
typedef struct USBPort USBPort; #define USB_DT_ENDPOINT 0x05
typedef struct USBDevice USBDevice;
#define USB_ENDPOINT_XFER_CONTROL 0
/* definition of a USB device */ #define USB_ENDPOINT_XFER_ISOC 1
struct USBDevice { #define USB_ENDPOINT_XFER_BULK 2
void *opaque; #define USB_ENDPOINT_XFER_INT 3
int (*handle_packet)(USBDevice *dev, int pid,
uint8_t devaddr, uint8_t devep, typedef struct USBBus USBBus;
uint8_t *data, int len); typedef struct USBPort USBPort;
void (*handle_destroy)(USBDevice *dev); typedef struct USBDevice USBDevice;
typedef struct USBDeviceInfo USBDeviceInfo;
int speed; typedef struct USBPacket USBPacket;
/* The following fields are used by the generic USB device /* definition of a USB device */
layer. They are here just to avoid creating a new structure for struct USBDevice {
them. */ //DeviceState qdev;
void (*handle_reset)(USBDevice *dev); USBDeviceInfo *info;
int (*handle_control)(USBDevice *dev, int request, int value, void *opaque;
int index, int length, uint8_t *data);
int (*handle_data)(USBDevice *dev, int pid, uint8_t devep, int speed;
uint8_t *data, int len); uint8_t addr;
uint8_t addr; char product_desc[32];
char devname[32]; int auto_attach;
int attached;
int state;
uint8_t setup_buf[8]; int state;
uint8_t data_buf[1024]; uint8_t setup_buf[8];
int remote_wakeup; uint8_t data_buf[1024];
int setup_state; int remote_wakeup;
int setup_len; int setup_state;
int setup_index; int setup_len;
}; int setup_index;
};
typedef void (*usb_attachfn)(USBPort *port, USBDevice *dev);
struct USBDeviceInfo {
/* USB port on which a device can be connected */ //DeviceInfo qdev;
struct USBPort { int (*init)(USBDevice *dev);
USBDevice *dev;
usb_attachfn attach; /*
void *opaque; * Process USB packet.
int index; /* internal port index, may be used with the opaque */ * Called by the HC (Host Controller).
struct USBPort *next; /* Used internally by qemu. */ *
}; * Returns length of the transaction
* or one of the USB_RET_XXX codes.
void usb_attach(USBPort *port, USBDevice *dev); */
int usb_generic_handle_packet(USBDevice *s, int pid, int (*handle_packet)(USBDevice *dev, USBPacket *p);
uint8_t devaddr, uint8_t devep,
uint8_t *data, int len); /*
int set_usb_string(uint8_t *buf, const char *str); * Called when device is destroyed.
*/
/* usb hub */ void (*handle_destroy)(USBDevice *dev);
USBDevice *usb_hub_init(int nb_ports);
/*
/* usb-ohci.c */ * Reset the device
void usb_ohci_init(void *bus, int num_ports, int devfn); */
void (*handle_reset)(USBDevice *dev);
/* usb-hid.c */
USBDevice *usb_mouse_init(void); /*
* Process control request.
/* usb-kbd.c */ * Called from handle_packet().
USBDevice *usb_keyboard_init(void); *
* Returns length or one of the USB_RET_ codes.
/* usb-msd.c */ */
USBDevice *usb_msd_init(const char *filename); int (*handle_control)(USBDevice *dev, int request, int value,
int index, int length, uint8_t *data);
/*
* Process data transfers (both BULK and ISOC).
* Called from handle_packet().
*
* Returns length or one of the USB_RET_ codes.
*/
int (*handle_data)(USBDevice *dev, USBPacket *p);
const char *product_desc;
/* handle legacy -usbdevice command line options */
const char *usbdevice_name;
USBDevice *(*usbdevice_init)(const char *params);
};
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 */
QTAILQ_ENTRY(USBPort) next;
};
typedef void USBCallback(USBPacket * packet, void *opaque);
/* Structure used to hold information about an active USB packet. */
struct USBPacket {
/* Data fields for use by the driver. */
int pid;
uint8_t devaddr;
uint8_t devep;
uint8_t *data;
int len;
/* Internal use by the USB layer. */
USBCallback *complete_cb;
void *complete_opaque;
USBCallback *cancel_cb;
void *cancel_opaque;
};
/* Defer completion of a USB packet. The hadle_packet routine should then
return USB_RET_ASYNC. Packets that complete immediately (before
handle_packet returns) should not call this method. */
static inline void usb_defer_packet(USBPacket *p, USBCallback *cancel,
void * opaque)
{
p->cancel_cb = cancel;
p->cancel_opaque = opaque;
}
/* Notify the controller that an async packet is complete. This should only
be called for packets previously deferred with usb_defer_packet, and
should never be called from within handle_packet. */
static inline void usb_packet_complete(USBPacket *p)
{
p->complete_cb(p, p->complete_opaque);
}
/* Cancel an active packet. The packed must have been deferred with
usb_defer_packet, and not yet completed. */
static inline void usb_cancel_packet(USBPacket * p)
{
p->cancel_cb(p, p->cancel_opaque);
}
void usb_attach(USBPort *port, USBDevice *dev);
int usb_generic_handle_packet(USBDevice *s, USBPacket *p);
int set_usb_string(uint8_t *buf, const char *str);
void usb_send_msg(USBDevice *dev, int msg);
/* usb-hid.c */
void usb_hid_datain_cb(USBDevice *dev, void *opaque, void (*datain)(void *));
/* usb ports of the VM */
#define VM_USB_HUB_SIZE 2
/* usb-kbd.cpp */
USBDevice *usb_keyboard_init(void);

View File

@ -1,21 +1,21 @@
#include <stdio.h> #include <stdio.h>
#include <memory.h> #include <memory.h>
#include <malloc.h> #include <malloc.h>
#include "vl.h" #include "vl.h"
void cpu_physical_memory_rw(uint32_t addr, uint8_t *buf, void cpu_physical_memory_rw(uint32_t addr, uint8_t *buf,
int len, int is_write); int len, int is_write);
static inline void cpu_physical_memory_read(uint32_t addr, static inline void cpu_physical_memory_read(uint32_t addr,
uint8_t *buf, int len) uint8_t *buf, int len)
{ {
cpu_physical_memory_rw(addr, buf, len, 0); cpu_physical_memory_rw(addr, buf, len, 0);
} }
static inline void cpu_physical_memory_write(uint32_t addr, static inline void cpu_physical_memory_write(uint32_t addr,
const uint8_t *buf, int len) const uint8_t *buf, int len)
{ {
cpu_physical_memory_rw(addr, (uint8_t *)buf, len, 1); cpu_physical_memory_rw(addr, (uint8_t *)buf, len, 1);
} }
/* compute with 96 bit intermediate result: (a*b)/c */ /* compute with 96 bit intermediate result: (a*b)/c */
uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c) uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)

View File

@ -59,7 +59,7 @@ typedef unsigned __int64 uint64_t;
#include <windows.h> #include <windows.h>
#define fsync _commit #define fsync _commit
#define lseek _lseeki64 #define lseek _lseeki64
#define ENOTSUP 4096 //#define ENOTSUP 4096
extern int qemu_ftruncate64(int, int64_t); extern int qemu_ftruncate64(int, int64_t);
#define ftruncate qemu_ftruncate64 #define ftruncate qemu_ftruncate64