/* SKTEST.C This program is provide to be used as an example of how an application program issues QIO's to Sample SCSI class driver (SKDRIVER). */ #include ctype #include stdio /* Define the descriptor used to pass the SCSI information to SKDRIVER */ #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 SK_EFN 1 #define SCSI_STATUS_MASK 0X3E #define INQUIRY_OPCODE 0x12 #define INQUIRY_DATA_LENGTH 0x24 globalvalue IO$_DIAGNOSE, IO$_AVAILABLE, IO$_READVBLK; short sk_chan, transfer_length; int i, status, sk_device_desc[2], sk_iosb[2], sk_desc[15], bcnt, data[512]; char scsi_status, inquiry_command[6] = {INQUIRY_OPCODE, 0, 0, 0, INQUIRY_DATA_LENGTH, 0}, inquiry_data[INQUIRY_DATA_LENGTH], Configure_command[6] = {12, 13, 0, 0, 12, 0}, CONFIGURE_data[12], DATAIN_command[6] = {12, 7, 0, 0, 255, 0}, DATAIN_data[255], sk_device[] = {"SCSI_TARGET"}; main () { /* Assign a channel to SCSI_TARGET */ sk_device_desc[0] = 11; /* Length of device name */ sk_device_desc[1] = &sk_device[0]; status = sys$assign (&sk_device_desc[0], &sk_chan, 0, 0); if (!(status & 1)) sys$exit (status); /* Set up the descriptor with the SCSI information to be sent to the target */ sk_desc[OPCODE] = 1; sk_desc[FLAGS] = FLAGS_READ + FLAGS_DISCONNECT; sk_desc[COMMAND_ADDRESS] = &inquiry_command[0]; sk_desc[COMMAND_LENGTH] = 6; sk_desc[DATA_ADDRESS] = &inquiry_data[0]; sk_desc[DATA_LENGTH] = INQUIRY_DATA_LENGTH; sk_desc[PAD_LENGTH] = 0; sk_desc[PHASE_TIMEOUT] = 60; sk_desc[DISCONNECT_TIMEOUT] = 60; for (i=9; i<15; i++) sk_desc[i] = 0; /* Clear reserved fields */ /* / This is an example in a higher level language demonstrating how to invoked / the READVBLK function of a SCSI class driver. This I/O operation / causes the SCSI class driver to executed an INQUIRY command and returns / the INQUIRY data to a users supplied output buffer. /*/ printf ("\n"); printf ("QIO to SKDRIVER performing a READVBLK function"); printf ("\n"); status = sys$qiow (SK_EFN, sk_chan, IO$_READVBLK, sk_iosb, 0, 0, &inquiry_data[0], INQUIRY_DATA_LENGTH, 0, 0, 0, 0, 0); if (!(status & 1)) sys$exit (status); if (!(sk_iosb[0] & 1)) sys$exit (sk_iosb[0] & 0xffff); transfer_length = sk_iosb[1]; printf ("SCSI inquiry data returned: "); for (i=0; i> 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 = sk_iosb[0] >> 16; printf ("SCSI inquiry data returned: "); for (i=0; i