[comp.protocols.misc] SCSI handshaking questions

unhd (Roger Gonzalez ) (10/26/89)

I'm in the process of implementing a file system for a WORM drive, and
have been getting my hands dirty in the registers of the NCR5380 SCSI
chip on an Ironics IV3273 system controller board.  But before my pleas
for advice, some background... 

My development environment is Unix, but I'm *not* writing a Unix device
driver.  The eventual target of this optical WORM drive is a robot
submersible running the real time operating system pSOS.  The testbed
for the pSOS stuff is just a few boards down the VMEbus from the Unix
cards.  Since the WORM is our only storage media, we can't store any
info about free blocks and things on a separate rewritable disk. 
(That's how most people deal with a WORM, I'm told.  I don't have that
luxury.) So..  the object of my quest is a stand-alone WORM file system,
with a set of utilities running on Unix (but built out of pSOS/Unix
portable libraries) to poke around inside the disk.  I've designed the
file system, and in general, I know what I'm doing.  BUT.... 

I'm a SCSI virgin.

But I've gotten my feet wet.  I'm to the point where I'm writing/reading
stuff to/from the controller's registers, I understand *most* of the
handshaking that goes on, and I've written what looks to be a usable
set of routines, built in layers, from bus commands, to SCSI commands,
and eventually the file system stuff will sit on top of that.

an example of a bus level routine is:

put_scsi(phase_command, buffer, count)     <- currently in 'C', eventually
    byte phase_command;                       in assembler for speed.
    byte *buffer;
    u_int count;
{
    tell target to assert phase_command (C/D, I/O, and/or MSG)
    wait for PHASE_MATCH=1 or timeout
    while data to output {
        wait for REQ=1 or timeout
        put a byte in the output register
        assert ACK
        if phase_command is DATA_OUT (C/D, I/O, MSG all 0) also assert DATABUS
        wait for REQ=0 or timeout
        deassert ACK
    }
}

in the next layer there is:

scsi_command(command, size)
    byte *command;
    u_int size;
{
    return(put_scsi(COMMAND_PHASE, command, size));
}

and so forth.

*****
Now that I've swamped you with details... on to the questions (since you
must know what you're talking about if you haven't hit 'n' yet :-)

AM I EVEN CLOSE?
I need ANY advice at all!  Do I need to check for interrupts?  How can I
make it so that bus arbitration is supported? (not necessary now, but who
knows)  I guess I just would like to have a dialog with someone who knows
SCSI inside and out.  I'm doing all this with only the chip and board
reference manuals.

As a related question..  I wrote a little utility that just watches all
the read-only registers on the chip, and if anything changes, prints a
line with the high bits in reverse video.  I can watch this slave boards
SCSI chip fine, but when I read the Unix SCSI chip, it worked fine for a
'ls' and then froze up on the next command, a 'pwd' (crashing the box
and taking out chunks of disk space).  Why should reading the registers
have any effect at all?

Thanks for your patience,

-Roger
 wizard in training :-)

(please reply by email.. I don't read this group often. tnx.)
-- 
UUCP:   unhd!rg@cs.utexas.edu | USPS: Marine Systems Engineering Laboratory
BITNET: r_gonzalez at unhh    |       University of New Hampshire
PHONE:  (603) 862-4600        |       242 SERB
FAX:    (603) 862-4399        |       Durham, NH  03824-3525