From 903a706729b360b0a406a2f3e5d4428ae5580042 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Wed, 17 Apr 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-04-17 --- alphapc/trap.c | 69 +++++++++++++++++++++++++++----------------------- mtx/trap.c | 11 ++++---- pc/kbd.c | 18 +++++++++++-- pc/trap.c | 3 ++- pc/usbuhci.c | 26 +++++++++++-------- 5 files changed, 75 insertions(+), 52 deletions(-) diff --git a/alphapc/trap.c b/alphapc/trap.c index c9d3e9b87e856bf1875b39b0d9feab1384a0e173..716d68aae1cc2ce140d21f261458239958edbd46 100644 --- a/alphapc/trap.c +++ b/alphapc/trap.c @@ -682,10 +682,12 @@ print("unknown noted arg 0x%lux\n", arg0); long syscall(Ureg *aur) { + int i; char *e; long ret; ulong sp; Ureg *ur; + ulong scallnr; m->syscall++; up = m->proc; @@ -695,9 +697,10 @@ syscall(Ureg *aur) up->dbgreg = aur; ur->type = 5; /* for debugging */ + scallnr = ur->r0; up->scallnr = ur->r0; - if(up->scallnr == RFORK && up->fpstate == FPactive){ + if(scallnr == RFORK && up->fpstate == FPactive){ savefpregs(&up->fpsave); up->fpstate = FPinactive; //print("SR=%lux+", up->fpsave.fpstatus); @@ -707,46 +710,48 @@ syscall(Ureg *aur) sp = ur->sp; up->nerrlab = 0; ret = -1; - if(waserror()) - goto error; - - if(up->scallnr >= nsyscall){ - pprint("bad sys call %d pc %lux\n", - up->scallnr, (ulong)ur->pc); -print("bad sys call %d pc %lux\n", up->scallnr, (ulong)ur->pc); - postnote(up, 1, "sys: bad sys call", NDebug); - error(Ebadarg); - } - - if(sp & (BY2WD-1)){ /* XXX too weak? */ - pprint("odd sp in sys call pc %lux sp %lux\n", - (ulong)ur->pc, (ulong)ur->sp); - postnote(up, 1, "sys: odd stack", NDebug); - error(Ebadarg); - } - - if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-sizeof(Sargs))) - validaddr(sp, sizeof(Sargs), 0); + if(!waserror()) { + if(scallnr >= nsyscall || systab[scallnr] == nil){ + pprint("bad sys call %d pc %lux\n", up->scallnr, (ulong)ur->pc); + postnote(up, 1, "sys: bad sys call", NDebug); + error(Ebadarg); + } - up->s = *((Sargs*)(sp+2*BY2WD)); - up->psstate = sysctab[up->scallnr]; + if(sp & (BY2WD-1)){ /* XXX too weak? */ + pprint("odd sp in sys call pc %lux sp %lux\n", + (ulong)ur->pc, (ulong)ur->sp); + postnote(up, 1, "sys: odd stack", NDebug); + error(Ebadarg); + } - ret = (*systab[up->scallnr])(up->s.args); - poperror(); + if(sp<(USTKTOP-BY2PG) || sp>(USTKTOP-sizeof(Sargs))) + validaddr(sp, sizeof(Sargs), 0); -error: - /* failure: save the error buffer for errstr */ - e = up->syserrstr; - up->syserrstr = up->errstr; - up->errstr = e; + up->s = *((Sargs*)(sp+2*BY2WD)); + up->psstate = sysctab[scallnr]; + ret = systab[scallnr](up->s.args); + poperror(); + }else{ + /* failure: save the error buffer for errstr */ + e = up->syserrstr; + up->syserrstr = up->errstr; + up->errstr = e; + } + if(up->nerrlab){ + print("bad errstack [%uld]: %d extra\n", scallnr, up->nerrlab); + for(i = 0; i < NERR; i++) + print("sp=%lux pc=%lux\n", + up->errlab[i].sp, up->errlab[i].pc); + panic("error stack"); + } up->nerrlab = 0; up->psstate = 0; up->insyscall = 0; - if(up->scallnr == NOTED) /* ugly hack */ + if(scallnr == NOTED) /* ugly hack */ noted(ur, &aur, *(ulong*)(sp+2*BY2WD)); /* doesn't return */ - if(up->scallnr!=RFORK && (up->procctl || up->nnote)){ + if(scallnr!=RFORK && (up->procctl || up->nnote)){ ur->r0 = ret; /* load up for noted() */ if(notify(ur)) return ur->r0; diff --git a/mtx/trap.c b/mtx/trap.c index 867401e5c30c663beaef0210e3b0d232d83d2f10..11ee9eeb91a582034620c66e9dee69132635d25c 100644 --- a/mtx/trap.c +++ b/mtx/trap.c @@ -627,10 +627,10 @@ dbgpc(Proc *p) void syscall(Ureg* ureg) { + int i; char *e; - ulong sp; long ret; - int i, scallnr; + ulong sp, scallnr; m->syscall++; up->insyscall = 1; @@ -638,15 +638,14 @@ syscall(Ureg* ureg) up->dbgreg = ureg; scallnr = ureg->r3; -//print("scall %s lr =%lux\n", sysctab[scallnr], ureg->lr); - up->scallnr = scallnr; + up->scallnr = ureg->r3; spllo(); sp = ureg->usp; up->nerrlab = 0; ret = -1; if(!waserror()){ - if(scallnr >= nsyscall){ + if(scallnr >= nsyscall || systab[scallnr] == nil){ pprint("bad sys call number %d pc %lux\n", scallnr, ureg->pc); postnote(up, 1, "sys: bad sys call", NDebug); error(Ebadarg); @@ -667,7 +666,7 @@ syscall(Ureg* ureg) up->errstr = e; } if(up->nerrlab){ - print("bad errstack [%d]: %d extra\n", scallnr, up->nerrlab); + print("bad errstack [%uld]: %d extra\n", scallnr, up->nerrlab); print("scall %s lr =%lux\n", sysctab[scallnr], ureg->lr); for(i = 0; i < NERR; i++) print("sp=%lux pc=%lux\n", up->errlab[i].sp, up->errlab[i].pc); diff --git a/pc/kbd.c b/pc/kbd.c index e82f90128bd25c08384ca63e2ef1320a1a02ed13..a306ea1d22501da507686bc83cd608f4494d95d6 100644 --- a/pc/kbd.c +++ b/pc/kbd.c @@ -354,10 +354,24 @@ i8042intr(Ureg*, void*) return; case Latin: alt = 1; - collecting = 1; - nk = 0; + /* + * VMware uses Ctl-Alt as the key combination + * to make the VM give up keyboard and mouse focus. + * This has the unfortunate side effect that when you + * come back into focus, Plan 9 thinks you want to type + * a compose sequence (you just typed alt). + * + * As a clusmy hack around this, we look for ctl-alt + * and don't treat it as the start of a compose sequence. + */ + if(!ctl){ + collecting = 1; + nk = 0; + } return; case Ctrl: + collecting = 0; + nk = 0; ctl = 1; return; } diff --git a/pc/trap.c b/pc/trap.c index b6c8157fada15db19aac5eca5e11424b2f77b8a6..d17a62220d2d2830935a15eeb6b6dccafaea22b0 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -531,7 +531,8 @@ syscall(Ureg* ureg) char *e; ulong sp; long ret; - int i, scallnr; + int i; + ulong scallnr; if((ureg->cs & 0xFFFF) != UESEL) panic("syscall: cs 0x%4.4luX\n", ureg->cs); diff --git a/pc/usbuhci.c b/pc/usbuhci.c index b287ff093d1cc951fcbf46534be192a3dd72a1e6..972beefe347c9daf4651cddaa31f9bf20aecbad5 100644 --- a/pc/usbuhci.c +++ b/pc/usbuhci.c @@ -1425,23 +1425,33 @@ reset(Usbhost *uh) if(ctlr == nil) return -1; + io = ctlr->io; p = ctlr->pcidev; - pcicfgw16(p, 0xc0, 0x2000); /* legacy support register: turn off lunacy mode */ uh->ctlr = ctlr; - uh->port = ctlr->io; + uh->port = io; uh->irq = p->intl; uh->tbdf = p->tbdf; - io = ctlr->io; - i = inb(io+SOFMod); + XPRINT("usbcmd\t0x%.4x\nusbsts\t0x%.4x\nusbintr\t0x%.4x\nfrnum\t0x%.2x\n", + IN(Cmd), IN(Status), IN(Usbintr), inb(io+Frnum)); + XPRINT("frbaseadd\t0x%.4x\nsofmod\t0x%x\nportsc1\t0x%.4x\nportsc2\t0x%.4x\n", + IN(Flbaseadd), inb(io+SOFMod), IN(Portsc0), IN(Portsc1)); + + OUT(Cmd, 0); /* stop */ + while((IN(Status) & (1<<5)) == 0) /* wait for halt */ + ; + OUT(Status, 0xFF); /* clear pending interrupts */ + pcicfgw16(p, 0xc0, 0x2000); /* legacy support register: turn off lunacy mode */ + if(0){ + i = inb(io+SOFMod); OUT(Cmd, 4); /* global reset */ delay(15); OUT(Cmd, 0); /* end reset */ delay(4); + outb(io+SOFMod, i); } - outb(io+SOFMod, i); ctlr->tdpool = xspanalloc(128*sizeof(TD), 16, 0); for(i=128; --i>=0;){ @@ -1475,12 +1485,6 @@ reset(Usbhost *uh) ctlr->bulkq->head = PCIWADDR(ctlr->recvq) | IsQH; ctlr->recvq->head = PCIWADDR(ctlr->bwsop) | IsQH; /* loop back */ - XPRINT("usbcmd\t0x%.4x\nusbsts\t0x%.4x\nusbintr\t0x%.4x\nfrnum\t0x%.2x\n", - IN(Cmd), IN(Status), IN(Usbintr), inb(io+Frnum)); - XPRINT("frbaseadd\t0x%.4x\nsofmod\t0x%x\nportsc1\t0x%.4x\nportsc2\t0x%.4x\n", - IN(Flbaseadd), inb(io+SOFMod), IN(Portsc0), IN(Portsc1)); - OUT(Cmd, 0); /* stop */ - ctlr->frames = xspanalloc(FRAMESIZE, FRAMESIZE, 0); ctlr->frameld = xallocz(FRAMESIZE, 1); for (i = 0; i < NFRAME; i++)