@@ -26,7 +26,7 @@ olivetti_m24.c opti.c pc.c pci.c pic.c piix.c pit.c ppi.c ps1.c rom.c scat.c ser
|
||||
sound_ad1848.c sound_adlib.c sound_adlibgold.c sound_cms.c sound_emu8k.c sound_gus.c \
|
||||
sound_mpu401_uart.c sound_opl.c sound_pas16.c sound_ps1.c sound_pssj.c sound_sb.c sound_sb_dsp.c sound_sn76489.c \
|
||||
sound_speaker.c sound_ssi2001.c sound_wss.c sound_ym7128.c soundopenal.c tandy_eeprom.c tandy_rom.c thread-pthread.c \
|
||||
timer.c um8669f.c um8881f.c vid_ati_eeprom.c vid_ati_mach64.c vid_ati18800.c vid_ati28800.c \
|
||||
timer.c um8669f.c um8881f.c usb.c vid_ati_eeprom.c vid_ati_mach64.c vid_ati18800.c vid_ati28800.c \
|
||||
vid_ati68860_ramdac.c vid_cga.c vid_cl_gd.c vid_cl_gd_blit.c vid_cl_ramdac.c vid_ega.c vid_et4000.c vid_et4000w32.c vid_hercules.c vid_herculesplus.c\
|
||||
vid_icd2061.c vid_ics2595.c vid_incolor.c vid_mda.c vid_nv_riva128.c vid_olivetti_m24.c vid_oti067.c vid_paradise.c vid_pc200.c \
|
||||
vid_pc1512.c vid_pc1640.c vid_pcjr.c vid_ps1_svga.c vid_s3.c vid_s3_virge.c vid_sdac_ramdac.c \
|
||||
|
@@ -13,7 +13,7 @@ OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acer386sx.o acerm3a.o ali1429
|
||||
scat.o scsi.o serial.o sis496.o sis85c471.o sio.o sound.o sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o \
|
||||
sound_dbopl.o sound_emu8k.o sound_gus.o sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_resid.o \
|
||||
sound_sb.o sound_sb_dsp.o sound_sn76489.o sound_speaker.o sound_ssi2001.o sound_wss.o sound_ym7128.o \
|
||||
soundopenal.o tandy_eeprom.o tandy_rom.o timer.o um8669f.o vid_ati_eeprom.o vid_ati_mach64.o vid_ati18800.o \
|
||||
soundopenal.o tandy_eeprom.o tandy_rom.o timer.o um8669f.o usb.o vid_ati_eeprom.o vid_ati_mach64.o vid_ati18800.o \
|
||||
vid_ati28800.o vid_ati68860_ramdac.o vid_bt485_ramdac.o vid_cga.o vid_cl_gd.o vid_cl_gd_blit.o vid_cl_ramdac.o vid_colorplus.o vid_ega.o vid_et4000.o \
|
||||
vid_et4000w32.o vid_hercules.o vid_herculesplus.o vid_icd2061.o vid_ics2595.o vid_incolor.o vid_mda.o vid_nv_riva128.o \
|
||||
vid_olivetti_m24.o vid_oti067.o vid_paradise.o vid_pc1512.o vid_pc1640.o vid_pc200.o \
|
||||
|
@@ -13,7 +13,7 @@ OBJ = 386.o 386_dynarec.o 386_dynarec_ops.o 808x.o acer386sx.o acerm3a.o ali1429
|
||||
scat.o scsi.o serial.o sis496.o sis85c471.o sio.o sound.o sound_ad1848.o sound_adlib.o sound_adlibgold.o sound_cms.o \
|
||||
sound_dbopl.o sound_emu8k.o sound_gus.o sound_mpu401_uart.o sound_opl.o sound_pas16.o sound_ps1.o sound_pssj.o sound_resid.o \
|
||||
sound_sb.o sound_sb_dsp.o sound_sn76489.o sound_speaker.o sound_ssi2001.o sound_wss.o sound_ym7128.o \
|
||||
soundopenal.o tandy_eeprom.o tandy_rom.o timer.o um8669f.o vid_ati_eeprom.o vid_ati_mach64.o vid_ati18800.o \
|
||||
soundopenal.o tandy_eeprom.o tandy_rom.o timer.o um8669f.o usb.o vid_ati_eeprom.o vid_ati_mach64.o vid_ati18800.o \
|
||||
vid_ati28800.o vid_ati68860_ramdac.o vid_bt485_ramdac.o vid_cga.o vid_cl_gd.o vid_cl_gd_blit.o vid_cl_ramdac.o vid_colorplus.o vid_ega.o vid_et4000.o \
|
||||
vid_et4000w32.o vid_hercules.o vid_herculesplus.ovid_icd2061.o vid_ics2595.o vid_incolor.o vid_mda.o vid_nv_riva128.o \
|
||||
vid_olivetti_m24.o vid_oti067.o vid_paradise.o vid_pc1512.o vid_pc1640.o vid_pc200.o \
|
||||
|
48
src/usb.c
Normal file
48
src/usb.c
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Copyright holders: Melissa Goad
|
||||
see COPYING for more details
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "ibm.h"
|
||||
#include "io.h"
|
||||
#include "mem.h"
|
||||
|
||||
#include "usb.h"
|
||||
|
||||
uint8_t (*usb_packet_handle[32])(usb_packet_t* packet, void *priv);
|
||||
void *usb_priv[32];
|
||||
static int usb_min_card, usb_max_card;
|
||||
|
||||
void usb_init(int min_card, int max_card)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = 0; c < 32; c++)
|
||||
usb_packet_handle[c] = usb_priv[c] = NULL;
|
||||
|
||||
usb_min_card = min_card;
|
||||
usb_max_card = max_card;
|
||||
}
|
||||
|
||||
void usb_add_specific(int card, void (*packet_handle)(usb_packet_t *packet, void *priv), void *priv)
|
||||
{
|
||||
usb_packet_handle[card] = packet_handle;
|
||||
usb_priv[card] = priv;
|
||||
}
|
||||
|
||||
void usb_add(void (*packet_handle)(usb_packet_t *packet, void *priv), void *priv)
|
||||
{
|
||||
int c;
|
||||
|
||||
for (c = usb_min_card; c <= usb_max_card; c++)
|
||||
{
|
||||
if (!usb_packet_handle[c])
|
||||
{
|
||||
usb_packet_handle[c] = packet_handle;
|
||||
usb_priv[c] = priv;
|
||||
// pclog("USB device added to card: %i\n", c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
41
src/usb.h
Normal file
41
src/usb.h
Normal file
@@ -0,0 +1,41 @@
|
||||
/* Copyright holders: Melissa Goad
|
||||
see COPYING for more details
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t pid; //low 4 bits are the real pid, top 4 bits are just ~pid
|
||||
uint8_t dev_addr;
|
||||
uint8_t dev_endpoint;
|
||||
int crc5;
|
||||
uint16_t crc16;
|
||||
uint8_t data[1024];
|
||||
int len;
|
||||
void* device;
|
||||
} usb_packet_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
USB_DEV_TYPE_NONE = 0,
|
||||
USB_DEV_TYPE_MOUSE,
|
||||
USB_DEV_TYPE_TABLET,
|
||||
USB_DEV_TYPE_KEYPAD,
|
||||
USB_DEV_TYPE_DISK,
|
||||
USB_DEV_TYPE_CDROM,
|
||||
USB_DEV_TYPE_HUB,
|
||||
USB_DEV_TYPE_PRINTER
|
||||
} usb_device_type_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
USB_PID_TOKEN_STALL = 0x1e,
|
||||
USB_PID_TOKEN_SETUP = 0x2d,
|
||||
USB_PID_TOKEN_PRE = 0x3c,
|
||||
USB_PID_TOKEN_DATA1 = 0x4b,
|
||||
USB_PID_TOKEN_NAK = 0x5a,
|
||||
USB_PID_TOKEN_IN = 0x69,
|
||||
USB_PID_TOKEN_SOF = 0xa5,
|
||||
USB_PID_TOKEN_DATA0 = 0xc3,
|
||||
USB_PID_TOKEN_ACK = 0xd2,
|
||||
USB_PID_TOKEN_OUT = 0xe1
|
||||
} usb_pid_type_t;
|
Reference in New Issue
Block a user