DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SCO OpenServer

scsi(D3osdi)


scsi: scsi_deverr, scsi_get_gen_cmd, scsi_getdev, scsi_mkadr3, scsi_s2tos, scsi_s3tol, scsi_stok, scsi_stol, scsi_swap4 -- SCSI conversion routines

Syntax

   #include <sys/scsi.h>
   

int scsi_deverr(request_ptr, name, msg, type, flags, dev, a0, a1) REQ_IO request_ptr; char *name; char *msg; char *type; unsigned flags; dev_t dev; int a0; int a1;

int scsi_get_gen_cmd(request_ptr, command, arrayp, nelements) REQ_IO request_ptr; int command, nelements; paddr_t *arrayp;

DEVCFG *scsi_getdev(unit, config-tbl, dev_open, name) int unit; DEVCFG *config-tbl; int (*dev_open)(); char *name;

int scsi_mkadr3(str, adr) char str[]; char adr[];

short scsi_s2tos(adr) char *adr;

   long
   scsi_s3tol(adr)
   char adr[];
   

caddr_t scsi_stok(adr) char adr[];

long scsi_stol(adr) char adr[ ];

int scsi_swap4(adr) char *adr;

Description

These routines are used when converting between different SCSI addressing schemes, and for miscellaneous tasks.

Arguments


scsi_deverr

request_ptr
pointer to an instance of the scsi_io_req(D4osdi) structure (SCSI I/O request block).

dev
the peripheral driver name (for example, ``Stp'').

msg
an error message which may be NULL.

type
type of peripheral (for example, ``tape'').

flags
peripheral physical unit number.

dev
UNIX device number, which may be NODEV.

a0 and a1
arguments to be printed using optional format specifiers within msg in the manner of sprintf(S). Set a0 and a1 to NULL if not used.

scsi_get_gen_cmd

request_ptr
pointer to an instance of the scsi_io_req(D4osdi) structure (SCSI I/O request block).

command
TEST_CMD, SENSE_CMD, or INQUIRY_CMD which are defined in scsi.h.

arrayp
pointer to an array containing the arguments to command.

nelements
indicates the number of elements in the array pointed to by arrayp.

scsi_getdev

unit
the zero-based index of the device in the configuration table pointed to by config-tbl. The configuration table is an array that stores device information used to build a block or character device switch table entry. The configuration table is an instance of the scsi_dev_cfg(D4osdi) structure defined in scsi.h and must be NULL terminated. The index member of this structure is filled in by the operating system and contains the major number of the device.

dev_open
address of the driver's open(D2osdi) routine.

name
address of an array containing the name of the disk. For example, for the SCSI disk driver supplied with your system, ``Sdsk'' is used.

scsi_mkadr3

str
pointer to a three-byte array.

adr
points to a three-byte array for the address to be created. The most significant byte of adr is not used.

scsi_s2tos

adr
pointer to a two-byte array.

scsi_s3tol

adr
pointer to a three-byte array.

scsi_stok

adr
pointer to a three-byte array.

scsi_stol

adr
pointer to a four-byte array.

scsi_swap4

adr
pointer to a four-byte array.

Return values

scsi_get_gen_cmd( ) has no return value under normal conditions, but -1 can be returned if command is not one of the three permissible values.

scsi_getdev( ) returns a pointer to the configuration table entry for the device or NULL if the device cannot be found in the configuration table. In addition to returning NULL, the following message is displayed on the console and stored in the putbuf array in memory:

   WARNING: No configuration information for device name
Where device is the major device number and name is the argument to the routine.

scsi_s2tos( ) returns a short integer.

scsi_s3tol( ) and scsi_stol( ) returns long integers.

scsi_stok( ) returns a kernel address.

Usage

scsi_deverr( ) prints a SCSI sense error message, identifying the SCSI device by the hardware configuration (<ha, id, lun>), and by the software configuration (UNIX device number and SCSI physical unit number).

scsi_get_gen_cmd( ) is used to fill a command block.

scsi_getdev( ) gets a SCSI device number.

The conversion routines are as follows.

Conversion routines

Routine Source Destination
scsi_mkadr3(str, adr) adr str
Makes 3-byte address   2 1 0   2 1 0
    a b c   c b a
short = scsi_s2tos(adr) adr short
Converts 2 bytes to a short     1 0     1 0
      a b     b a
long = scsi_s3tol(adr) adr long
Converts 3 bytes to a long   2 1 0 3 2 1 0
    a b c 0 c b a
kernel = scsi_stok(adr) adr kernel
Converts 3 bytes to a   2 1 0 3 2 1 0
kernel address   a b c 0 c b a
long = scsi_stol(adr) adr long
Converts 4 bytes to a long 3 2 1 0 3 2 1 0
  a b c d d c b a
scsi_swap4(adr) adr adr
Swaps 4 bytes 3 2 1 0 3 2 1 0
  a b c d d c b a

 +----------------------------+---------------------+----------------+
 |Routine                     |       Source        |  Destination   |
 +----------------------------+---------------------+----------------+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |scsi_mkadr3(str, adr)       | adr | str   |   |   |    |   |   |   |
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |Makes 3-byte address        |                     |       2        |
 +----------------------------+---------------------+----------------+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |                            |     |   a   | b | c |    | c | b | a |
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |short = scsi_s2tos(adr)     | adr | short |   |   |    |   |   |   |
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |Converts 2 bytes to a short |     |       | 1 | 0 |    |   | 1 | 0 |
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |                            |     |       | a | b |    |   | b | a |
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |long = scsi_s3tol(adr)      |         adr         |      long      |
 +----------------------------+---------------------+----------------+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |Converts 3 bytes to a long  |     |   2   | 1 | 0 |  3 | 2 | 1 | 0 |
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |                            |     |   a   | b | c | 0  | c | b | a |
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |kernel = scsi_stok(adr)     |         adr         |     kernel     |
 +----------------------------+---------------------+----------------+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |Converts 3 bytes to a       |     |   2   | 1 | 0 | 3  | 2 | 1 | 0 |
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |kernel address              |     |   a   | b | c | 0  | c | b | a |
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |long = scsi_stol(adr)       |         adr         |      long      |
 +----------------------------+---------------------+----------------+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |Converts 4 bytes to a long  |  3  |   2   | 1 | 0 | 3  | 2 | 1 | 0 |
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |                            |  a  |   b   | c | d | d  | c | b | a |
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |scsi_swap4(adr)             |         adr         |      adr       |
 +----------------------------+---------------------+----------------+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |Swaps 4 bytes               |  3  |   2   | 1 | 0 | 3  | 2 | 1 | 0 |
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |                            +-----+-------+---+---+----+---+---+---+
 +----------------------------+-----+-------+---+---+----+---+---+---+
 |                            |  a  |   b   | c | d | d  | c | b | a |
 +----------------------------+-----+-------+---+---+----+---+---+---+

Hardware applicability

All

Version applicability

osdi: 2, 3, 4, 5

References

Sharegister(D3osdi), Sdevregister(D3osdi), mscsi(F) , scsi_distributed(D3osdi)

``OSDI SCSI driver interface version for SCO OpenServer 5'' in HDK Technical Reference


19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 5 HDK - June 2005