usbhid: update

git-svn-id: svn://kolibrios.org@2111 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Sergey Semyonov (Serge) 2011-08-24 11:00:06 +00:00
parent fa03894a53
commit c6e0494463
5 changed files with 59 additions and 38 deletions

View File

@ -54,6 +54,10 @@ void uhci_reset_hc(hc_t *hc)
/* Turn off PIRQ enable and SMI enable. (This also turns off the /* Turn off PIRQ enable and SMI enable. (This also turns off the
* BIOS's USB Legacy Support.) Turn off all the R/WC bits too. * BIOS's USB Legacy Support.) Turn off all the R/WC bits too.
*/ */
out16(hc->iobase + UHCI_USBCMD, 0);
out16(hc->iobase + UHCI_USBINTR, 0);
pciWriteWord(hc->PciTag, UHCI_USBLEGSUP, UHCI_USBLEGSUP_RWC); pciWriteWord(hc->PciTag, UHCI_USBLEGSUP, UHCI_USBLEGSUP_RWC);
/* Reset the HC - this will force us to get a /* Reset the HC - this will force us to get a
@ -120,49 +124,42 @@ reset_needed:
return 1; return 1;
} }
void hc_interrupt() int hc_interrupt(void *data)
{ {
hc_t *hc; hc_t *hc = (hc_t*)data;
// printf("USB interrupt\n"); // printf("USB interrupt\n");
hc = (hc_t*)hc_list.next; request_t *rq;
u16_t status;
while( &hc->list != &hc_list) status = in16(hc->iobase + USBSTS);
if (!(status & ~USBSTS_HCH)) /* shared interrupt, not mine */
return 0;
out16(hc->iobase + USBSTS, status); /* Clear it */
rq = (request_t*)hc->rq_list.next;
while( &rq->list != &hc->rq_list)
{ {
hc_t *htmp; request_t *rtmp;
request_t *rq; td_t *td;
u16_t status;
htmp = hc; rtmp = rq;
rq = (request_t*)rq->list.next;
hc = (hc_t*)hc->list.next; td = rtmp->td_tail;
status = in16(htmp->iobase + USBSTS); if( td->status & TD_CTRL_ACTIVE)
if (!(status & ~USBSTS_HCH)) /* shared interrupt, not mine */
continue; continue;
out16(htmp->iobase + USBSTS, status); /* Clear it */
rq = (request_t*)htmp->rq_list.next; list_del(&rtmp->list);
while( &rq->list != &htmp->rq_list) RaiseEvent(rtmp->evh, 0, &rtmp->event);
{ };
request_t *rtmp;
td_t *td;
rtmp = rq; return 1;
rq = (request_t*)rq->list.next;
td = rtmp->td_tail;
if( td->status & TD_CTRL_ACTIVE)
continue;
list_del(&rtmp->list);
RaiseEvent(rtmp->evh, 0, &rtmp->event);
};
}
}; };
@ -263,7 +260,13 @@ bool init_hc(hc_t *hc)
out16(hc->iobase + UHCI_USBINTR, 4); out16(hc->iobase + UHCI_USBINTR, 4);
AttachIntHandler(hc->irq_line, hc_interrupt, 0); printf("set handler %d ", hc->irq_line);
delay(100/10);
AttachIntHandler(hc->irq_line, hc_interrupt, hc);
printf("done\n");
delay(100/10);
pciWriteWord(hc->PciTag, UHCI_USBLEGSUP, UHCI_USBLEGSUP_DEFAULT); pciWriteWord(hc->PciTag, UHCI_USBLEGSUP, UHCI_USBLEGSUP_DEFAULT);
@ -588,7 +591,7 @@ bool ctrl_request(udev_t *dev, void *req, u32_t pid,
safe_sti(efl); safe_sti(efl);
WaitEvent(rq->evh.handle, rq->evh.euid); WaitEvent(rq->evh);
dbgprintf("td0 status 0x%0x\n", td0->status); dbgprintf("td0 status 0x%0x\n", td0->status);
dbgprintf("td status 0x%0x\n", td->status); dbgprintf("td status 0x%0x\n", td->status);

View File

@ -121,6 +121,7 @@ bool mouse_handler(udev_t *dev, struct tag_request *rq)
struct boot_packet *pkt; struct boot_packet *pkt;
pkt = (struct boot_packet *)rq->data; pkt = (struct boot_packet *)rq->data;
SetMouseData(pkt->buttons, pkt->x, -pkt->y, -pkt->z, 0); SetMouseData(pkt->buttons, pkt->x, -pkt->y, -pkt->z, 0);
memset(pkt,0, sizeof(*pkt));
}; };
td->status = TD_CTRL_ACTIVE | TD_CTRL_IOC | dev->speed; td->status = TD_CTRL_ACTIVE | TD_CTRL_IOC | dev->speed;
td->token ^= DATA1; td->token ^= DATA1;

View File

@ -1,13 +1,11 @@
CC = gcc CC = gcc
DRV_DIR = $(CURDIR)/../.. DRV_DIR = $(CURDIR)/../..
DRV_INCLUDES = $(DRV_DIR)/include DRV_INCLUDES = $(DRV_DIR)/include
INCLUDES = -I$(DRV_INCLUDES) -I$(DRV_INCLUDES)/linux
INCLUDES = -I$(DRV_INCLUDES) -I$(DRV_DIR)/include/linux
DEFINES = -D__KERNEL__ -DCONFIG_X86_32 DEFINES = -D__KERNEL__ -DCONFIG_X86_32
@ -42,10 +40,10 @@ $(NAME).dll: $(NAME_OBJS) usb.lds Makefile
ld $(LIBPATH) $(LDFLAGS) -T usb.lds -o $@ $(NAME_OBJS) $(LIBS) ld $(LIBPATH) $(LDFLAGS) -T usb.lds -o $@ $(NAME_OBJS) $(LIBS)
kpack $(NAME).dll $(NAME).drv kpack $(NAME).dll $(NAME).drv
%.o : %.c $(HFILES) $(SRC_DEP) Makefile %.o: %.c $(HFILES) $(SRC_DEP) Makefile
$(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $<
%.o : %.S $(HFILES) Makefile %.o: %.S $(HFILES) Makefile
as -o $@ $< as -o $@ $<

View File

@ -1,4 +1,22 @@
#define PCI_MAP_REG_START 0x10
#define PCI_MAP_ROM_REG 0x30
#define PCI_MAP_MEMORY 0x00000000
#define PCI_MAP_IO 0x00000001
#define PCI_MAP_MEMORY_TYPE 0x00000007
#define PCI_MAP_IO_TYPE 0x00000003
#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000
#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002
#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004
#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006
#define PCI_MAP_MEMORY_CACHABLE 0x00000008
#define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e
#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0
#define PCI_MAP_IO_ATTR_MASK 0x00000003
u32_t pciGetBaseSize(int bus, int devfn, int index, u32_t pciGetBaseSize(int bus, int devfn, int index,
bool destructive, bool *min) bool destructive, bool *min)

View File

@ -2,6 +2,7 @@
#include <ddk.h> #include <ddk.h>
#include <mutex.h> #include <mutex.h>
#include <linux/errno.h>
#include <pci.h> #include <pci.h>
#include <linux/dmapool.h> #include <linux/dmapool.h>
#include <linux/string.h> #include <linux/string.h>