/* 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] = &gk_device[0]; status = sys$assign (&gk_device_desc[0], &gk_chan, 0, 0); if (!(status & 1)) { printf ("Unable to assign channel to %s", &gk_device[0]); 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] = &inquiry_command[0]; gk_desc[COMMAND_LENGTH] = 6; gk_desc[DATA_ADDRESS] = &inquiry_data[0]; gk_desc[DATA_LENGTH] = INQUIRY_DATA_LENGTH; gk_desc[PAD_LENGTH] = 0; gk_desc[PHASE_TIMEOUT] = 180; gk_desc[DISCONNECT_TIMEOUT] = 60; 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, &gk_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