From 4ae8949ed6f54d96edae374cecd9f832e930b95c Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 10 May 1998 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1998-05-10 --- pc/devata.c | 54 ++++++++++++++++++++++++++++++++++++++++++++--------- port/proc.c | 1 + 2 files changed, 46 insertions(+), 9 deletions(-) diff --git a/pc/devata.c b/pc/devata.c index 27a2277bdd76714daa8279f59a76e1d810ce2f30..20bd622761e91e6e1f58e22567c77f10367c4898 100644 --- a/pc/devata.c +++ b/pc/devata.c @@ -1,6 +1,7 @@ /* * This has gotten a bit messy with the addition of multiple controller * and ATAPI support; needs a rewrite before adding any 'ctl' functions. + * The register locking needs looked at. */ #include "u.h" #include "../port/lib.h" @@ -10,11 +11,11 @@ #include "io.h" #include "../port/error.h" -#define DEBUG 0 -#define DPRINT if(DEBUG)print -#define XPRINT if(DEBUG)print -#define ILOCK(x) -#define IUNLOCK(x) +#define DEBUG 0 +#define DPRINT if(DEBUG)print +#define XPRINT if(DEBUG)print +#define ILOCK(x) ilock(x) +#define IUNLOCK(x) iunlock(x) typedef struct Drive Drive; typedef struct Ident Ident; @@ -1150,9 +1151,6 @@ retryatapi: dp->cyl = ip->cyls; dp->heads = ip->heads; dp->sectors = ip->s2t; - XPRINT("%s: %s %d/%d/%d CHS %lld bytes\n", - dp->vol, id, dp->cyl, dp->heads, dp->sectors, - dp->cap); if(ip->cvalid&(1<<0)){ /* use current settings */ @@ -1176,6 +1174,9 @@ retryatapi: dp->lbasecs = 0; dp->cap = (vlong)dp->bytes * dp->cyl * dp->heads * dp->sectors; } + XPRINT("%s: %s %d/%d/%d CHS %lld bytes\n", + dp->vol, id, dp->cyl, dp->heads, dp->sectors, + dp->cap); if(cp->cmd){ cp->lastcmd = cp->cmd; @@ -1716,6 +1717,39 @@ atapiexec(Drive *dp) } } +static void +atapireqsense(Drive* dp) +{ + Controller *cp; + uchar *buf; + + cp = dp->cp; + + buf = smalloc(Maxxfer); + cp->buf = buf; + cp->dp = dp; + + if(waserror()){ + free(buf); + return; + } + + cp->len = 18; + cp->count = 0; + memset(cp->cmdblk, 0, sizeof(cp->cmdblk)); + cp->cmdblk[0] = Creqsense; + cp->cmdblk[4] = 18; + atapiexec(dp); + if(cp->count != 18){ + print("cmd=%2.2uX, lastcmd=%2.2uX ", cp->cmd, cp->lastcmd); + print("cdsize count %d, status 0x%2.2uX, error 0x%2.2uX\n", + cp->count, cp->status, cp->error); + } + + poperror(); + free(buf); +} + static long atapiio(Drive *dp, uchar *a, ulong len, vlong off, int cmd) { @@ -1735,8 +1769,10 @@ atapiio(Drive *dp, uchar *a, ulong len, vlong off, int cmd) retry: if(waserror()){ + DPRINT("atapiio: cmd %uX error %uX\n", cp->cmdblk[0], cp->error); dp->partok = 0; if((cp->status & Serr) && (cp->error & 0xF0) == 0x60){ + atapireqsense(dp); dp->vers++; if(retrycount){ retrycount--; @@ -1842,7 +1878,7 @@ atapipart(Drive *dp) retrycount = 2; retry: if(waserror()){ - DPRINT("atapipart: cmd %uX error %uX\n", cp->cmd, cp->error); + DPRINT("atapipart: cmd %uX error %uX\n", cp->cmdblk[0], cp->error); if((cp->status & Serr) && (cp->error & 0xF0) == 0x60){ dp->vers++; if(retrycount){ diff --git a/port/proc.c b/port/proc.c index 524ce4a7e66019e0f25d8a725db4e1215e605bb9..07b0038c161cc8b4bdc8ef843b4fe5de978612ce 100644 --- a/port/proc.c +++ b/port/proc.c @@ -413,6 +413,7 @@ sleep1(Rendez *r, int (*f)(void*), void *arg) up->state = Wakeme; up->r = r; unlock(&up->rlock); + splx(s); } void