From c6e0494463248edada3b702380d518b37e71bead Mon Sep 17 00:00:00 2001 From: "Sergey Semyonov (Serge)" Date: Wed, 24 Aug 2011 11:00:06 +0000 Subject: [PATCH] usbhid: update git-svn-id: svn://kolibrios.org@2111 a494cfbc-eb01-0410-851d-a64ba20cac60 --- drivers/usb/uhci/hcd.inc | 69 ++++++++++++++++++++------------------- drivers/usb/uhci/hid.inc | 1 + drivers/usb/uhci/makefile | 8 ++--- drivers/usb/uhci/pci.inc | 18 ++++++++++ drivers/usb/uhci/usb.c | 1 + 5 files changed, 59 insertions(+), 38 deletions(-) diff --git a/drivers/usb/uhci/hcd.inc b/drivers/usb/uhci/hcd.inc index 602f2205c5..2810391a7a 100644 --- a/drivers/usb/uhci/hcd.inc +++ b/drivers/usb/uhci/hcd.inc @@ -54,6 +54,10 @@ void uhci_reset_hc(hc_t *hc) /* 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. */ + + out16(hc->iobase + UHCI_USBCMD, 0); + out16(hc->iobase + UHCI_USBINTR, 0); + pciWriteWord(hc->PciTag, UHCI_USBLEGSUP, UHCI_USBLEGSUP_RWC); /* Reset the HC - this will force us to get a @@ -120,49 +124,42 @@ reset_needed: 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 *rq; - u16_t status; + request_t *rtmp; + td_t *td; - 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 (!(status & ~USBSTS_HCH)) /* shared interrupt, not mine */ + if( td->status & TD_CTRL_ACTIVE) 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) - { - request_t *rtmp; - td_t *td; + RaiseEvent(rtmp->evh, 0, &rtmp->event); + }; - rtmp = rq; - 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); - }; - } + return 1; }; @@ -263,7 +260,13 @@ bool init_hc(hc_t *hc) 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); @@ -588,7 +591,7 @@ bool ctrl_request(udev_t *dev, void *req, u32_t pid, safe_sti(efl); - WaitEvent(rq->evh.handle, rq->evh.euid); + WaitEvent(rq->evh); dbgprintf("td0 status 0x%0x\n", td0->status); dbgprintf("td status 0x%0x\n", td->status); diff --git a/drivers/usb/uhci/hid.inc b/drivers/usb/uhci/hid.inc index dfacc66247..dc35074f69 100644 --- a/drivers/usb/uhci/hid.inc +++ b/drivers/usb/uhci/hid.inc @@ -121,6 +121,7 @@ bool mouse_handler(udev_t *dev, struct tag_request *rq) struct boot_packet *pkt; pkt = (struct boot_packet *)rq->data; 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->token ^= DATA1; diff --git a/drivers/usb/uhci/makefile b/drivers/usb/uhci/makefile index d5d67de6aa..634ba01c9d 100644 --- a/drivers/usb/uhci/makefile +++ b/drivers/usb/uhci/makefile @@ -1,13 +1,11 @@ CC = gcc - DRV_DIR = $(CURDIR)/../.. DRV_INCLUDES = $(DRV_DIR)/include - -INCLUDES = -I$(DRV_INCLUDES) -I$(DRV_DIR)/include/linux +INCLUDES = -I$(DRV_INCLUDES) -I$(DRV_INCLUDES)/linux 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) kpack $(NAME).dll $(NAME).drv -%.o : %.c $(HFILES) $(SRC_DEP) Makefile +%.o: %.c $(HFILES) $(SRC_DEP) Makefile $(CC) $(CFLAGS) $(DEFINES) $(INCLUDES) -o $@ $< -%.o : %.S $(HFILES) Makefile +%.o: %.S $(HFILES) Makefile as -o $@ $< diff --git a/drivers/usb/uhci/pci.inc b/drivers/usb/uhci/pci.inc index e6bb11b05a..3fd6239f57 100644 --- a/drivers/usb/uhci/pci.inc +++ b/drivers/usb/uhci/pci.inc @@ -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, bool destructive, bool *min) diff --git a/drivers/usb/uhci/usb.c b/drivers/usb/uhci/usb.c index d9d51be11f..257b6e0c1c 100644 --- a/drivers/usb/uhci/usb.c +++ b/drivers/usb/uhci/usb.c @@ -2,6 +2,7 @@ #include #include +#include #include #include #include