From c08e139ce921c071191b458c6388678300e24253 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sat, 16 Feb 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-02-16 --- pc/devusb.c | 25 +++++++++++++------------ pc/usb.h | 16 ++++++++++------ pc/usbuhci.c | 23 +++++++++++------------ 3 files changed, 34 insertions(+), 30 deletions(-) diff --git a/pc/devusb.c b/pc/devusb.c index 411cfcf8cbc76673b0653843ce0ccaf99867c91a..f4e3f388c214b8a5fef7e144373cbc1a7cf54e6b 100644 --- a/pc/devusb.c +++ b/pc/devusb.c @@ -1827,21 +1827,24 @@ isoio(Endpt *e, void *a, long n, ulong offset, int w) if (e->psize > e->maxpkt) panic("packet size > maximum"); } + if((i = n) >= e->psize) + i = e->psize; + if (w) + e->buffered += i; + else{ + e->buffered -= i; + if (e->buffered < 0) + e->buffered = 0; + } + isolock = 0; + iunlock(&activends); td->flags &= ~IsoClean; bp = e->bp0 + (td - e->td0) * e->maxpkt / e->pollms; q = bp + e->off; - if((i = n) >= e->psize) - i = e->psize; if (w){ memmove(q, p, i); - e->buffered += i; }else{ memmove(p, q, i); - e->buffered -= i; - if (e->buffered < 0){ - XPRINT("e->buffered %d?\n", e->buffered); - e->buffered = 0; - } } p += i; n -= i; @@ -1860,11 +1863,9 @@ isoio(Endpt *e, void *a, long n, ulong offset, int w) } while(n > 0); n = p-(uchar*)a; e->foffset += n; - if (isolock){ - isolock = 0; - iunlock(&activends); - } poperror(); + if (isolock) + iunlock(&activends); qunlock(&e->rlock); return n; } diff --git a/pc/usb.h b/pc/usb.h index 800d1326517b3efe7813e075f7e78f0468b16737..bbea530ae9433d0bde51000d50d62e0762bd2c2e 100644 --- a/pc/usb.h +++ b/pc/usb.h @@ -116,7 +116,6 @@ struct Udev int state; int id; uchar port; /* port number on connecting hub */ - uchar root; ulong csp; int ls; int npt; @@ -125,14 +124,19 @@ struct Udev Udev* next; /* next device on this hub */ }; +/* + * One of these per active Host Controller Interface (HCI) + */ struct Usbhost { - ISAConf; /* hardware info */ + ISAConf; /* hardware info */ + int tbdf; /* type+busno+devno+funcno */ - int ctlrno; - int tbdf; /* type+busno+devno+funcno */ + QLock; /* protects namespace state */ + int idgen; /* version number to distinguish new connections */ + Udev* dev[MaxUsbDev]; /* device endpoints managed by this HCI */ - void (*init)(Usbhost*); /* filled in by reset routine */ + void (*init)(Usbhost*); void (*interrupt)(Ureg*, void*); void (*portinfo)(Usbhost*, char*, char*); @@ -151,4 +155,4 @@ struct Usbhost void *ctlr; }; -extern void addusbhost(char*, int(*)(Usbhost*)); +extern void addusbtype(char*, int(*)(Usbhost*)); diff --git a/pc/usbuhci.c b/pc/usbuhci.c index ac61074835bea6905c873fed29c90b3e62172048..8ff63bfa218e768920988655ca458ff59e37821c 100644 --- a/pc/usbuhci.c +++ b/pc/usbuhci.c @@ -80,14 +80,14 @@ static struct } portstatus[] = { - { Suspend, "Suspend", }, - { PortReset, "PortReset", }, - { SlowDevice, "SlowDevice", }, - { ResumeDetect, "ResumeDetect", }, - { PortChange, "PortChange", }, - { PortEnable, "PortEnable", }, - { StatusChange, "StatusChange", }, - { DevicePresent, "DevicePresent", }, + { Suspend, "suspend", }, + { PortReset, "reset", }, + { SlowDevice, "lowspeed", }, + { ResumeDetect, "resume", }, + { PortChange, "portchange", }, + { PortEnable, "enable", }, + { StatusChange, "statuschange", }, + { DevicePresent, "present", }, }; typedef struct Ctlr Ctlr; @@ -396,9 +396,8 @@ cleantd(Ctlr *ctlr, TD *t, int discard) err = t->status & (AnyError&~NAKed); /* TO DO: on t->status&AnyError, q->entries will not have advanced */ if (err) { -// XPRINT("cleanTD: Error %8.8lux %8.8lux %8.8lux %8.8lux\n", t->link, t->status, t->dev, t->buffer); - print("cleanTD: Error %8.8lux %8.8lux %8.8lux %8.8lux\n", t->link, t->status, t->dev, t->buffer); -print("real maxlen %d\n", t->ep->maxpkt); + XPRINT("cleanTD: Error %8.8lux %8.8lux %8.8lux %8.8lux\n", t->link, t->status, t->dev, t->buffer); +// print("cleanTD: Error %8.8lux %8.8lux %8.8lux %8.8lux\n", t->link, t->status, t->dev, t->buffer); } switch(t->dev&0xFF){ case TokIN: @@ -1527,5 +1526,5 @@ reset(Usbhost *uh) void usbuhcilink(void) { - addusbhost("uhci", reset); + addusbtype("uhci", reset); }