/*
* Copyright (c) 1992 OMRON Corporation.
*
* This code is derived from software contributed to Berkeley by
* OMRON Corporation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)scsi.c 8.1 (Berkeley) 6/10/93
*/
/*
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* OMRON Corporation.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)scsi.c 8.1 (Berkeley) 6/10/93
*/
/*
* scsi.c -- front end of SCSI test commands
* by A.Fujita, FEB-09-1992
*/
int
scsi(int argc, char *argv[])
{
char *p;
int i, status;
if (argc < 2) {
printf("This command is required subcommand !!\n");
return ST_ERROR;
}
if (!strcmp(argv[1], "device")) {
if (argc > 2) {
i = 0;
for (p = argv[2]; *p != '\0' ; p++) {
i = i * 10 + *p - '0';
}
if (i < 8 && i >= 0) {
scsi_device = i;
}
}
printf("Current Device ID: %d\n", scsi_device);
} else if (!strcmp(argv[1], "test_unit_rdy")) {
/* CTLR SLAVE LUN */
scsi_test_unit_rdy( 0, scsi_device, 0);
} else if (!strcmp(argv[1], "request_sense")) {
/* CTLR SLAVE LUN */
scsi_request_sense( 0, scsi_device, 0, sensbuff, SENSBUFF);
} else if (!strcmp(argv[1], "inquiry")) {
if (scsi_immed_command( 0, scsi_device, 0, &inquiry,
(uint8_t *)&inquirybuf, sizeof(inquirybuf)) == 0) {
printf("Type:\t0x%x\n", inquirybuf.type);
printf("Qualifier:\t0x%x\n", inquirybuf.qual);
printf("Version:\t0x%x\n", inquirybuf.version);
printf("RDF:\t0x%x\n", inquirybuf.rsvd);
printf("Vendor ID:\t");
for (i = 0; i < 8; i++)
printf("%c", inquirybuf.vendor_id[i]);
printf("\n");
printf("Product ID:\t");
for (i = 0; i < 16; i++)
printf("%c", inquirybuf.product_id[i]);
printf("\n");
printf("Revision:\t");
for (i = 0; i < 4; i++)
printf("%c", inquirybuf.rev[i]);
printf("\n");
}
} else if (!strcmp(argv[1], "read_capacity")) {
if (scsi_immed_command( 0, scsi_device, 0, &capacity,
(uint8_t *)&capacitybuf, sizeof(capacitybuf)) == 0) {
printf("Logical Block Address:\t%ld (0x%lx)\n",
capacitybuf[0], capacitybuf[0]);
printf("Block Length:\t\t%ld (0x%lx)\n",
capacitybuf[1], capacitybuf[1]);
}
} else if (!strcmp(argv[1], "trace")) {
for (i = 0; i < 7; i++) {
printf("SCSI ID %d .... ", i);
status = scsi_test_unit_rdy(0, i, 0);
if (status >= 0)
printf("found.\n");
else
printf("no.\n");
}
} else if (!strcmp(argv[1], "format_unit")) {
i = 0;
while (i == 0) {
printf("Do you really want to format SCSI %d device ?"
" [y/n]: ", scsi_device);
i = getchar();
printf("\n");
if ((i != 'y') && (i != 'Y') &&
(i != 'n') && (i != 'N'))
i = 0;
}
if ((i == 'y') || (i == 'Y'))
status = scsi_format_unit(0, scsi_device, 0);
}