[comp.unix.aux] SCSI device driver PROBLEM

urlichs@smurf.sub.org (Matthias Urlichs) (10/13/90)

The following occurs on A/UX 2.0 sf (Seeding Final), on my IIfx.

The SCSI device driver I'm currently writing tries to do the following:

ds_ioctl(...) {
[ struct scsireq *r; initialize r; general handwaving ]

   int ds_ret();
   r->faddr = ds_wakeup();
   r->cmdlen		= ...;
   r->datalen		= ...;
   r->senselen		= ...;
   r->driver		= (long) r;
   ret = scsimgrs[MGR(dev)].s_req(ID(dev), r, (struct vio *)0);
   if (ret) {  [...] }
   sleep(r, PZERO);		/* wait for the request to finish */

   [ check errors, return data ]
   return(0);
}

int
ds_ret(req) struct scsireq *req;
{	wakeup(req);
	return(0);
}

The big problem is that whenever r->datalen is >= 512, nothing happens:
Everything seems to work, r->datasent ends up being equal to r->datalen, the
command is performed on the disk, but the buffer I'm trying to read the data
from ends up unchanged.
This may or may not have something to do with the fact that with 512 bytes,
the A/UX 2.0 SCSI system decides to start using DMA.

Any insights are appreciated -- I'm basically stumped by this, and I _need_
this. (It's going to be a free implementation of (a subset of) the MacOS
SCSI Manager under A/UX, and everything else already works. I even found out
how to patch out that pesky SST_MORE error.)

Trace (trying to read the first 512 bytes off hard disk ID 5):
(Note that the dump of the first 8 Bytes is wrong -- the HD has a valid
partition map at the beginning. Buffer length & address are correct.)

7 12906300.5     STA 00 cs=      bs=    M   dcl=0082 md=     0000 IDLE>NEWTASK>CHOOSE
7 12906301.5     STA 00 cs=      bs=    M   dcl=0080 md=     0000 CHOOSE>NEWTASK>RUN
0 12906301.5     STA 00 cs=      bs=    M   dcl=0080 md=     0000 scsitask top
7 12906301.5 SEL STA A0 cs= B S. bs=    M   dcl=0080 md=     0000 selected
7 12906301.5 DOU SEL 00 cs= B    bs=    M   dcl=0080 md=     0000 scsitask top
0 12906301.5 CMD SEL 00 cs= BR   bs=        dcl=0080 md=     0000 task req wait
0 12906301.5 CMD CMD A0 cs= BR . bs=    M   dcl=0080 md=     0000 SPH_CMD Read
0 12906301.5 DOU CMD 00 cs= B    bs= D      dcl=0080 md=  d  0000 08000000 0100
0 12906302.5 DIN CMD 00 cs= B    bs= D      dcl=0080 md=  d  0000 scsitask top
0 12906302.5 DIN CMD 45 cs= BR   bs=        dcl=0080 md=     0000 task req wait
0 12906302.5 DIN DAT 45 cs= BR   bs=    M   dcl=0080 md=     0000 SPH_DIN 512 spd 5
0 12906302.5 DIN DAT 45 cs= BR   bs=    M   dcl=0005 md=e d  0512 dmaR 512 @12017084
7 12906303.5 DIN DAT 45 cs= BR   bs=    M   dcl=0005 md=e d  0512 RUN>DMA>DMA
2 12906303.5 DIN DAT 00 cs= B    bs=E  IM   dcl=0047 md=e d  0000 irq:R512 L0 C 47
2 12906303.5 STA DAT 00 cs= BR . bs=E  I    dcl=0047 md=e d  0000 scsiirq-EOP
7 12906304.5     DAT 00 cs=      bs=........dcl=.... md=     .... DMA>EOP>EOP
2 12906304.5 STA DAT 00 cs= BR . bs=E       dcl=0080 md=  d  0000 00000000 00000000
7 12906305.5 STA DAT 00 cs= BR . bs=E       dcl=0080 md=  d  0000 EOP>WAITP>WPHASE
7 12906305.5 STA DAT 00 cs= BR . bs=E       dcl=0082 md= bd  0000 spinwait req
7 12906305.5 STA DAT 00 cs= BR . bs=        dcl=0082 md= b   0000 pretend phase int
7 12906305.5 STA DAT 00 cs= BR . bs=        dcl=0082 md= b   0000 WPHASE>PHASE>RUN
0 12906305.5 STA DAT 00 cs= BR . bs=        dcl=0080 md= b   0000 scsitask top
0 12906305.5 STA DAT 00 cs= BR . bs=        dcl=0080 md= b   0000 task req wait
0 12906305.5 STA STA 00 cs= BR . bs=    M   dcl=0080 md= b   0000 SPH_STAT
0 12906305.5 MIN STA 00 cs= B    bs=        dcl=0080 md= bd  0000 00 Good
0 12906306.5 MIN STA 00 cs= BR . bs=   I    dcl=00C0 md= bd  0000 scsitask top
0 12906306.5 MIN STA 00 cs= BR . bs=        dcl=0080 md= b   0000 task req wait
0 12906306.5 MIN STA 00 cs= BR . bs=    M   dcl=0080 md= b   0000 SPH_MIN
2 12906306.5 MIN STA 00 cs= BR . bs=    M   dcl=0080 md= b   0000 00 Command Complete
7 12906307.5     STA 00 cs=      bs=    M   dcl=0080 md=     0000 RUN>DONE>NOTIFY
7 12906308.5     STA 00 cs=      bs=    M   dcl=0080 md=     0000 NOTIFY>DONE>CHOOSE
7 12906309.5     STA 00 cs=      bs=    M   dcl=0080 md=     0000 CHOOSE>DONE>IDLE
, OK 0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0, Trans 512
7 12906310.5     STA 00 cs=      bs=    M   dcl=0082 md=     0000 IDLE>NEWTASK>CHOOSE

-- 
Matthias Urlichs -- urlichs@smurf.sub.org -- urlichs@smurf.ira.uka.de     /(o\
Humboldtstrasse 7 - 7500 Karlsruhe 1 - FRG -- +49+721+621127(0700-2330)   \o)/

rick@apple.com (Rick Auricchio) (10/16/90)

In article <voo-f2.#g3@smurf.sub.org> urlichs@smurf.sub.org (Matthias Urlichs) writes:
>The following occurs on A/UX 2.0 sf (Seeding Final), on my IIfx.
>
>The SCSI device driver I'm currently writing tries to do the following:
>
>ds_ioctl(...) {
>[ struct scsireq *r; initialize r; general handwaving ]
>
>   int ds_ret();
>   r->faddr = ds_wakeup();
>   r->cmdlen		= ...;
>
>The big problem is that whenever r->datalen is >= 512, nothing happens:
>Everything seems to work, r->datasent ends up being equal to r->datalen, the
>command is performed on the disk, but the buffer I'm trying to read the data
>from ends up unchanged.

    If you've written this exactly like your posting, I see the problem.

>   r->faddr = ds_wakeup();

    Specifying ds_wakeup() with the parens causes an immediate call to
    the function.  You want ds_wakeup without parens to just stuff its
    address.  I got bit by this one a long time ago and it took forever
    to figure it out.
--
Rick Auricchio, Apple Computer Inc, 10300 Bubb Rd, MS 50-UX Cupertino CA 95014
rick@apple.COM  	  	 Mooney N894AR     		(408) 974-4227
		Work is for people who don't know how to fly.
My opinion is my own. My employer? They use a windsock and a fire extinguisher.

urlichs@smurf.sub.org (Matthias Urlichs) (10/16/90)

In comp.unix.aux, article <10716@goofy.Apple.COM>,
  rick@apple.com (Rick Auricchio) writes:

< > [ problems with my SCSI driver ]
<     If you've written this exactly like your posting, I see the problem.
< 
< >   r->faddr = ds_wakeup();
< 
<     Specifying ds_wakeup() with the parens causes an immediate call to
<     the function.  You want ds_wakeup without parens to just stuff its
<     address.  I got bit by this one a long time ago and it took forever
<     to figure it out.

I hate C. ;-)

But that's not the problem -- I copied the other code over and added that
line to show what's going on.

The problem only shows up when I transfer more than 511 bytes. Tracing shows
that this is when the DMA stuff kicks in, which may or may not have anything
to do with the problem.

-- 
Matthias Urlichs -- urlichs@smurf.sub.org -- urlichs@smurf.ira.uka.de     /(o\
Humboldtstrasse 7 - 7500 Karlsruhe 1 - FRG -- +49+721+621127(0700-2330)   \o)/