Re: SCSI question

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Morgan Schweers <mrs@...>, <linux-activists@...>
Date: Wednesday, January 15, 1992 - 4:18 am

Greetings,
        Being a novice at fun stuff like kernel development and device
    driver design, I'd like to know under what circumstances I'd need
    a SCSI driver.

        I have a 20Meg floptical disk drive that MS/DOS thinks is just
    another drive.  No device drivers are needed, etc...  It is,
    however, a SCSI device.  Does this mean that I'll need a driver
    for it under Linux?

Yes.  Most definately.   The current SCSI situation is that I'm working on 
a multi-tiered driver (interference from fried SCSI hosts, family visits,
long ski weekends, sysadmin chores and Usenix) with abstract high level 
disk and tape drivers that interface with low level SCSI drivers in a 
device independant manner.  The low level driver needed for each SCSI host
merely has to send SCSI commands and return the results / data to the 
high level driver- bad block remapping, etc are all handled by the 
high level driver.  


The initial low level driver will be for the seagate ST-01 / ST-02 
controllers.  Other hosts should be fairly easy to adapt to - see 
the interface spec following this.


        Does anyone have any good kernel and driver design books that
    they can refer me to?

                                             --  Morgan Schweers

--------

Current interface spec for SCSI driver - should have everything 
(keeping my fingers crossed here) ready within two weeks after 
Usenix.  I've added a command queing function, where the driver is 
notified on command completion, so that multiple read/writes etc. can
be accomplished - much better than the kernel blocking until the 
read/write was done....

-- hosts.h --

#ifndef __HOST_H__
	#define __HOSTS_H__

/*
	File hosts.h
	SCSI host adapter include file.
*/

#define MAX_SCSI_HOSTS 1

/*
	The Scsi_Host type has all that is needed to interface with a SCSI
	host in a device independant matter.  
*/

typedef struct     
	{
	/*
		The name pointer is a pointer to the name of the SCSI
		device detected.
	*/

	char *name;

	/*
		The detect function shall return non zero on detection,
		and initialize all data necessary for this particular
		SCSI driver.
	*/

	int (* detect)(void); 

	/*
		The info function will return whatever useful
		information the developer sees fit.
	*/

        char *(* info)(void);

	/*
		The command function shall return the SCSI return
		code in the low 8 bits, a driver error in the high 8
		bits.  Target is the target ID, IN normal numbers - not a
		bit.  The cmnd is the variable length command to
                be sent,
		buff a pointer to the buffer which will be read from / 
		written to, and bufflen the length of that buffer
	*/

	int (* command)(unsigned char target, const void *cmnd, 
			     void *buff, int bufflen);

        /*
                The QueueCommand function works in a similar manner
                to the command function.  It takes an additional parameter,
                void (* done)(int code) which is passed the exit result
                when the command is complete.
        */

        int (* queuecommand)(unsigned char target, const void *cmnd,
                             void *buff, int bufflen, void (*done)(int));



	/*
		present contains a flag as to weather we are present -
		so we don't have to call detect multiple times.
	*/

	unsigned char present;	
	} Scsi_Host;

/*
	The scsi_hosts array is	the array containing the data for all 
	possible <supported> scsi hosts.   
*/

extern Scsi_Host scsi_hosts[MAX_SCSI_HOSTS];

/*
	scsi_init initializes the scsi hosts.
*/

void scsi_init(void);
#endif



--- scsi.h ---


#ifndef __SCSI_H__
	#define __SCSI_H__
/*
	For documentation on the OPCODES, MESSAGES, and SENSE values,
	please consult the SCSI standard.
*/

/*
	SCSI opcodes
*/

#define TEST_UNIT_READY 	0x00
#define REZERO_UNIT		0x01
#define REQUEST_SENSE		0x03
#define FORMAT_UNIT		0x04
#define REASSIGN_BLOCKS		0x07
#define READ_6			0x08
#define WRITE_6			0x0a
#define SEEK			0x0b
#define INQUIRY			0x12
#define MODE_SELECT		0x15
#define RESERVE			0x16
#define RELEASE			0x17
#define COPY			0x18
#define MODE_SENSE		0x1a
#define START_STOP		0x1b
#define RECIEVE_DAIGNOSTIC	0x1c
#define SEND_DIAGNOSTIC		0x1d
#define ALLOW_MEDIUM_REMOVAL	0x1e

#define READ_CAPACITY		0x25
#define READ_10			0x28
#define WRITE_10		0x2a
#define SEEK_10			0x2b
#define WRITE_VERIFY		0x2e
#define VERIFY			0x2f
#define SEARCH_HIGH		0x30
#define SEARCH_EQUAL		0x31
#define SEARCH_LOW		0x32
#define SET_LIMITS		0x33
#define COMPARE			0x39
#define COPY_VERIFY		0x3a

/*
	MESSAGE CODES
*/

#define COMMAND_COMPLETE	0x00
#define EXTENDED_MESSAGE	0x01
#define SAVE_POINTERS		0x02
#define RESTORE_POINTERS 	0x03
#define DISCONNECT		0x04
#define INITIATOR_ERROR		0x05
#define ABORT			0x06
#define MESAGE_REJECT		0x07
#define NOP			0x08
#define MSG_PARITY_ERROR	0x09
#define LINKED_CMD_COMPLETE	0x0a
#define LINKED_FLG_CMD_COMPLETE	0x0b
#define BUS_DEVICE_RESET	0x0c
#define IDENTIFY		0x80

/*
        Our errors returned by OUR driver, NOT SCSI message.  Orr'd with
        SCSI message passed back to driver <IF any>.
*/

/* 	NO error							*/
#define DID_OK 			0x0000
/* 	Couldn't connect before timeout period				*/
#define DID_NO_CONNECT		0x0100
/*	BUS stayed busy through time out period				*/
#define DID_BUS_BUSY		0x0200
/*	TIMED OUT for other reason					*/
#define DID_TIME_OUT		0x0300
/*	ERROR from TARGET						*/
#define DID_TERROR		0x0400
/*	TARGET was busy							*/
#define DID_TBUSY		0x0500
/*	TARGET disconnected prematurely					*/
#define DID_TDISCONNECT		0x0600
/*	TARGET was off line						*/
#define DID_TOFFLINE		0x0700
/*      TARGET wants US to send IT a message				*/
#defibe DID_TREQ_MSG_OUT	0x0800
/*	TARGET parity error						*/
#define DID_TPARITY		0x0900
/*	TARGET requested reselect					*/
#define DID_TRESELECT		0x0A00
/*	TARGET was not in the range 0-6 inlclusive			*/
#define DID_BAD_TARGET		0x0B00

/*
	SENSE KEYS
*/

#define NO_SENSE 		0x00
#define RECOVERED_ERROR		0x01
#define NOT_READY		0x02
#define MEDIUM_ERROR		0x03
#define	HARDWARE_ERROR		0x04
#define ILLEGAL_REQUEST		0x05
#define UNIT_ATTENTION		0x06
#define DATA_PROTECT		0x07
#define BLANK_CHECK		0x08
#define COPY_ABORTED		0x0a
#define ABORTED_COMMAND		0x0b
#define	VOLUME_OVERFLOW		0x0d
#define MISCOMPARE		0x0e


/*
	DEVICE TYPES

*/

#define TYPE_DISK	0x00
#define TYPE_TAPE	0x01
#define TYPE_WORM	0x04	/* Treated as ROM by our system */
#define TYPE_ROM	0x05
#define TYPE_NO_LUN	0x7f
/*
	Every SCSI command starts with a one byte OP-code.
	The next byte's high three bits are the LUN of the
	device.  Any multi-byte quantities are stored high byte
	first, and may have a 5 bit MSB in the same byte
	as the LUN.
*/


#endif
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: SCSI question , , (Wed Jan 15, 4:18 am)