skip book previous and next navigation links
go up to top of book: HP OpenVMS I/O User's Reference Manual HP OpenVMS I/O User's Reference Manual
go to beginning of chapter: Using the OpenVMS Generic SCSI Class Driver Using the OpenVMS Generic SCSI Class Driver
go to previous page: Generic SCSI Class Driver Device Information Generic SCSI Class Driver Device Information
go to next page: Local Area Network (LAN) Device DriversLocal Area Network (LAN) Device Drivers
end of book navigation links

Call a Generic SCSI Class Driver  



Generic SCSI Class Driver Call Example is an application that uses the generic SCSI class driver to send a SCSI INQUIRY command to a device.
Example 1  Generic SCSI Class Driver Call Example  
/*
GKTEST.C
 
This program uses the SCSI generic class driver to send an inquiry command
to a device on the SCSI bus.
 
*/
 
#include ctype
 
/* Define the descriptor used to pass the SCSI information to GKDRIVER */
 
#define OPCODE 0
#define FLAGS 1
#define COMMAND_ADDRESS 2
#define COMMAND_LENGTH 3
#define DATA_ADDRESS 4
#define DATA_LENGTH 5
#define PAD_LENGTH 6
#define PHASE_TIMEOUT 7
#define DISCONNECT_TIMEOUT 8
 
#define FLAGS_READ 1
#define FLAGS_DISCONNECT 2
 
#define GK_EFN 1
 
#define SCSI_STATUS_MASK 0X3E
 
#define INQUIRY_OPCODE 0x12
#define INQUIRY_DATA_LENGTH 0x30
 
globalvalue
        IO$_DIAGNOSE;
 
short
        gk_chan,
        transfer_length;
 
int
        i,
        status,
        gk_device_desc[2],
        gk_iosb[2],
        gk_desc[15];
 
char
        scsi_status,
        inquiry_command[6] = {INQUIRY_OPCODE, 0, 0, 0, INQUIRY_DATA_LENGTH, 0},
        inquiry_data[INQUIRY_DATA_LENGTH],
        gk_device[] = {"GKA0"};
 
main ()
{
 
/* Assign a channel to GKA0 */
 
        gk_device_desc[0] = 4;
        gk_device_desc[1] = _device[0];
        status = sys$assign (_device_desc[0], _chan, 0, 0);
        if (!(status & 1) ) sys$exit (status);
 
/* Set up the descriptor with the SCSI information to be sent to the target */
 
        gk_desc[OPCODE] = 1;
        gk_desc[FLAGS] = FLAGS_READ + FLAGS_DISCONNECT;
        gk_desc[COMMAND_ADDRESS] = _command[0];
        gk_desc[COMMAND_LENGTH] = 6;
        gk_desc[DATA_ADDRESS] = _data[0];
        gk_desc[DATA_LENGTH] = INQUIRY_DATA_LENGTH;
        gk_desc[PAD_LENGTH] = 0;
        gk_desc[PHASE_TIMEOUT] = 0;
        gk_desc[DISCONNECT_TIMEOUT] = 0;
        for (i=9; i<15; i++) gk_desc[i] = 0;    /* Clear reserved fields */
 
/* Issue the QIO to send the inquiry command and receive the inquiry data */
 
        status = sys$qiow (GK_EFN, gk_chan, IO$_DIAGNOSE, gk_iosb, 0, 0, 
                           _desc[0], 15*4, 0, 0, 0, 0);
 
/* Check the various returned status values */
 
        if (!(status & 1) ) sys$exit (status);
        if (!(gk_iosb[0] & 1) ) sys$exit (gk_iosb[0] & 0xffff);
        scsi_status = (gk_iosb[1] >> 24) & SCSI_STATUS_MASK;
        if (scsi_status) {
                printf ("Bad SCSI status returned: %02.2x\n", scsi_status);
                sys$exit (1);
        }
 
/* The command succeeded. Display the SCSI data returned from the target */
 
        transfer_length = gk_iosb[0] >> 16;
        printf ("SCSI inquiry data returned: ");
        for (i=0; i<transfer_length; i++) {
                if (isprint (inquiry_data[i]) )
                        printf ("%c", inquiry_data[i]);
                else
                        printf (".");
        }
        printf ("\n");
}



go to previous page: Generic SCSI Class Driver Device Information Generic SCSI Class Driver Device Information
go to next page: Local Area Network (LAN) Device DriversLocal Area Network (LAN) Device Drivers