1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

Obtained from: Simon Shapiro

Userland utilities to control, and monitor a DPT RAID system.
This commit is contained in:
Julian Elischer 1998-01-26 06:20:48 +00:00
parent b37c91fdc7
commit c5bc0dccc4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=32802
20 changed files with 1737 additions and 0 deletions

5
usr.sbin/dpt/Makefile Normal file
View File

@ -0,0 +1,5 @@
# $Id: Makefile,v 1.2 1998/01/21 07:46:46 ShimonR Exp ShimonR $
SUBDIR= dpt_ctlinfo dpt_ctls dpt_dm dpt_led dpt_sig dpt_softc dpt_sysinfo
.include <bsd.subdir.mk>

View File

@ -0,0 +1,6 @@
# $Id: Makefile.inc,v 1.2 1998/01/21 07:46:46 ShimonR Exp ShimonR $
.include "${.CURDIR}/../../Makefile.inc"
# $Id: Makefile.inc,v 1.2 1998/01/21 07:46:46 ShimonR Exp ShimonR $
.include "${.CURDIR}/../../Makefile.inc"

View File

@ -0,0 +1,12 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $Id: Makefile,v 1.1 1998/01/22 23:32:27 ShimonR Exp ShimonR $
PROG= dpt_ctlinfo
SRCS= dpt_ctlinfo.c
CFLAGS+=-Wall -I../../../sys -I/usr/src/sys
BINMODE=500
BINOWN= root
MAN8= dpt_ctlinfo.8
.include <bsd.prog.mk>

View File

@ -0,0 +1,3 @@
.\" Copyright (c) 1997 Simon Shapiro. All rights reserved.
.\"
.\" There is nothing here yet, but an empty file will not patch

View File

@ -0,0 +1,121 @@
/*
* Copyright (c) 1997 by Simon Shapiro
* All Rights Reserved
*
* 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,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
*/
/* dpt_ctlinfo.c: Dunp a DPT HBA Information Block */
#ident "$Id: dpt_ctlinfo.c,v 1.1 1998/01/22 23:32:27 ShimonR Exp ShimonR $"
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/queue.h>
#include <sys/ioctl.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_message.h>
#include <scsi/scsiconf.h>
#define DPT_MEASURE_PERFORMANCE
#include <sys/dpt.h>
int
main(int argc, char **argv, char **argp)
{
eata_pt_t pass_thru;
dpt_compat_ha_t compat_softc;
int result;
int fd;
int ndx;
if ( (fd = open(argv[1], O_RDWR, S_IRUSR | S_IWUSR)) == -1 ) {
(void)fprintf(stderr, "%s ERROR: Failed to open \"%s\" - %s\n",
argv[0], argv[1], strerror(errno));
exit(1);
}
pass_thru.eataID[0] = 'E';
pass_thru.eataID[1] = 'A';
pass_thru.eataID[2] = 'T';
pass_thru.eataID[3] = 'A';
pass_thru.command = DPT_CTRLINFO;
pass_thru.command_buffer = (u_int8_t *)&compat_softc;
if ( (result = ioctl(fd, DPT_IOCTL_SEND, &pass_thru)) != 0 ) {
(void)fprintf(stderr, "%s ERROR: Failed to send IOCTL %x - %s\n",
argv[0], DPT_IOCTL_SEND,
strerror(errno));
exit(1);
}
(void)fprintf(stdout, "%x:", compat_softc.ha_state);
for (ndx = 0; ndx < MAX_CHANNELS; ndx++)
(void)fprintf(stdout, (ndx == (MAX_CHANNELS - 1)) ? "%d:" : "%d,",
compat_softc.ha_id[ndx]);
(void)fprintf(stdout, "%d:", compat_softc.ha_vect);
(void)fprintf(stdout, "%x:", compat_softc.ha_base);
(void)fprintf(stdout, "%d:", compat_softc.ha_max_jobs);
switch (compat_softc.ha_cache) {
case DPT_NO_CACHE:
(void)fprintf(stdout, "No Cache:");
break;
case DPT_CACHE_WRITETHROUGH:
(void)fprintf(stdout, "WriteThrough:");
break;
case DPT_CACHE_WRITEBACK:
(void)fprintf(stdout, "WriteBack:");
break;
default:
(void)fprintf(stdout, "UnKnown (%d):", compat_softc.ha_cache);
}
(void)fprintf(stdout, "%d:", compat_softc.ha_cachesize);
(void)fprintf(stdout, "%d:", compat_softc.ha_nbus);
(void)fprintf(stdout, "%d:", compat_softc.ha_ntargets);
(void)fprintf(stdout, "%d:", compat_softc.ha_nluns);
(void)fprintf(stdout, "%d:", compat_softc.ha_tshift);
(void)fprintf(stdout, "%d:", compat_softc.ha_bshift);
(void)fprintf(stdout, "%d:", compat_softc.ha_npend);
(void)fprintf(stdout, "%d:", compat_softc.ha_active_jobs);
(void)fprintf(stdout, "%s\n", compat_softc.ha_fw_version);
return(0);
}

View File

@ -0,0 +1,12 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $Id: Makefile,v 1.1 1998/01/22 22:07:22 ShimonR Exp ShimonR $
PROG= dpt_ctls
SRCS= dpt_ctls.c
CFLAGS+=-Wall -I../../../sys -I/usr/src/sys
BINMODE=500
BINOWN= root
MAN8= dpt_ctls.8
.include <bsd.prog.mk>

View File

@ -0,0 +1,3 @@
.\" Copyright (c) 1997 Simon Shapiro. All rights reserved.
.\"
.\" There is nothing here yet, but an empty file will not patch

View File

@ -0,0 +1,80 @@
/*
* Copyright (c) 1997 by Simon Shapiro
* All Rights Reserved
*
* 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,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
*/
/* dpt_ctls.c: Dunp a the number of configured DPT HBAs */
#ident "$Id: dpt_ctls.c,v 1.1 1998/01/22 22:07:22 ShimonR Exp ShimonR $"
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/queue.h>
#include <sys/ioctl.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_message.h>
#include <scsi/scsiconf.h>
#include <sys/dpt.h>
int
main(int argc, char **argv, char **argp)
{
eata_pt_t pass_thru;
int controllers_present;
int result;
int fd;
if ( (fd = open(argv[1], O_RDWR, S_IRUSR | S_IWUSR)) == -1 ) {
(void)fprintf(stderr, "%s ERROR: Failed to open \"%s\" - %s\n",
argv[0], argv[1], strerror(errno));
exit(1);
}
pass_thru.eataID[0] = 'E';
pass_thru.eataID[1] = 'A';
pass_thru.eataID[2] = 'T';
pass_thru.eataID[3] = 'A';
pass_thru.command = DPT_NUMCTRLS;
pass_thru.command_buffer = (u_int8_t *)&controllers_present;
if ( (result = ioctl(fd, DPT_IOCTL_SEND, &pass_thru)) != 0 ) {
(void)fprintf(stderr, "%s ERROR: Failed to send IOCTL %x - %s\n",
argv[0], DPT_IOCTL_SEND,
strerror(errno));
exit(1);
}
(void)fprintf(stdout, "%d\n", controllers_present);
return(0);
}

View File

@ -0,0 +1,12 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $Id: Makefile,v 1.4 1998/01/21 17:38:32 ShimonR Exp ShimonR $
PROG= dpt_dm
SRCS= dpt_dm.c
CFLAGS+=-Wall -I../../../sys -I/usr/src/sys
BINMODE=500
BINOWN= root
MAN8= dpt_dm.8
.include <bsd.prog.mk>

View File

@ -0,0 +1,6 @@
.\" Copyright (c) 1997 Simon Shapiro. All rights reserved.
.\"
.\" There is nothing here yet, but an empty file will not patch
.\" Copyright (c) 1997 Simon Shapiro. All rights reserved.
.\"
.\" There is nothing here yet, but an empty file will not patch

View File

@ -0,0 +1,391 @@
/*
* Copyright (c) 1997 by Simon Shapiro
* All Rights Reserved
*
* 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,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
*/
/* dpt_dm.c: Dump a DPT metrics structure */
#ident "$Id: dpt_dm.c,v 1.8 1998/01/21 17:38:32 ShimonR Exp ShimonR $"
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/queue.h>
#include <sys/ioctl.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_message.h>
#include <scsi/scsiconf.h>
#define DPT_MEASURE_PERFORMANCE
#include <sys/dpt.h>
char *
scsi_cmd_name(u_int8_t cmd)
{
switch (cmd) {
case 0x40:
return ("Change Definition [7.1]");
break;
case 0x39:
return ("Compare [7,2]");
break;
case 0x18:
return ("Copy [7.3]");
break;
case 0x3a:
return ("Copy and Verify [7.4]");
break;
case 0x04:
return ("Format Unit [6.1.1]");
break;
case 0x12:
return ("Inquiry [7.5]");
break;
case 0x36:
return ("lock/Unlock Cache [6.1.2]");
break;
case 0x4c:
return ("Log Select [7.6]");
break;
case 0x4d:
return ("Log Sense [7.7]");
break;
case 0x15:
return ("Mode select (6) [7.8]");
break;
case 0x55:
return ("Mode Select (10) [7.9]");
break;
case 0x1a:
return ("Mode Sense (6) [7.10]");
break;
case 0x5a:
return ("Mode Sense (10) [7.11]");
break;
case 0xa7:
return ("Move Medium Attached [SMC]");
break;
case 0x5e:
return ("Persistent Reserve In [7.12]");
break;
case 0x5f:
return ("Persistent Reserve Out [7.13]");
break;
case 0x1e:
return ("Prevent/Allow Medium Removal [7.14]");
break;
case 0x08:
return ("Read, Receive (6) [6.1.5]");
break;
case 0x28:
return ("Read (10) [6.1.5]");
break;
case 0xa8:
return ("Read (12) [6.1.5]");
break;
case 0x3c:
return ("Read Buffer [7.15]");
break;
case 0x25:
return ("Read Capacity [6.1.6]");
break;
case 0x37:
return ("Read Defect Data (10) [6.1.7]");
break;
case 0xb7:
return ("Read Defect Data (12) [6.2.5]");
break;
case 0xb4:
return ("Read Element Status Attached [SMC]");
break;
case 0x3e:
return ("Read Long [6.1.8]");
break;
case 0x07:
return ("Reassign Blocks [6.1.9]");
break;
case 0x81:
return ("Rebuild [6.1.10]");
break;
case 0x1c:
return ("Receive Diagnostics Result [7.16]");
break;
case 0x82:
return ("Regenerate [6.1.11]");
break;
case 0x17:
return ("Release(6) [7.17]");
break;
case 0x57:
return ("Release(10) [7.18]");
break;
case 0xa0:
return ("Report LUNs [7.19]");
break;
case 0x03:
return ("Request Sense [7.20]");
break;
case 0x16:
return ("Resereve (6) [7.21]");
break;
case 0x56:
return ("Reserve(10) [7.22]");
break;
case 0x2b:
return ("Reserve(10) [6.1.12]");
break;
case 0x1d:
return ("Send Disagnostics [7.23]");
break;
case 0x33:
return ("Set Limit (10) [6.1.13]");
break;
case 0xb3:
return ("Set Limit (12) [6.2.8]");
break;
case 0x1b:
return ("Start/Stop Unit [6.1.14]");
break;
case 0x35:
return ("Synchronize Cache [6.1.15]");
break;
case 0x00:
return ("Test Unit Ready [7.24]");
break;
case 0x3d:
return ("Update Block (6.2.9");
break;
case 0x2f:
return ("Verify (10) [6.1.16, 6.2.10]");
break;
case 0xaf:
return ("Verify (12) [6.2.11]");
break;
case 0x0a:
return ("Write, Send (6) [6.1.17, 9.2]");
break;
case 0x2a:
return ("Write (10) [6.1.18]");
break;
case 0xaa:
return ("Write (12) [6.2.13]");
break;
case 0x2e:
return ("Write and Verify (10) [6.1.19, 6.2.14]");
break;
case 0xae:
return ("Write and Verify (12) [6.1.19, 6.2.15]");
break;
case 0x03b:
return ("Write Buffer [7.25]");
break;
case 0x03f:
return ("Write Long [6.1.20]");
break;
case 0x041:
return ("Write Same [6.1.21]");
break;
case 0x052:
return ("XD Read [6.1.22]");
break;
case 0x050:
return ("XD Write [6.1.22]");
break;
case 0x080:
return ("XD Write Extended [6.1.22]");
break;
case 0x051:
return ("XO Write [6.1.22]");
break;
default:
return ("Unknown SCSI Command");
}
}
int
main(int argc, char **argv, char **argp)
{
dpt_perf_t metrics;
int result;
int fd;
int ndx;
if ( (fd = open(argv[1], O_RDWR, S_IRUSR | S_IWUSR)) == -1 ) {
(void)fprintf(stderr, "%s ERROR: Failed to open \"%s\" - %s\n",
argv[0], argv[1], strerror(errno));
exit(1);
}
if ( (result = ioctl(fd, DPT_IOCTL_INTERNAL_METRICS, &metrics)) != 0 ) {
(void)fprintf(stderr, "%s ERROR: Failed to send IOCTL %x - %s\n",
argv[0], DPT_IOCTL_INTERNAL_METRICS,
strerror(errno));
exit(2);
}
/* Interrupt related measurements */
(void)fprintf(stdout, "Interrupts:%d:%d:%d:%d\n\nCommands:\n",
metrics.aborted_interrupts,
metrics.spurious_interrupts,
metrics.min_intr_time,
metrics.max_intr_time);
/* SCSI Commands, can be no more than 256 of them */
for (ndx = 0; ndx < 256; ndx++) {
if (metrics.command_count[ndx] != 0) {
(void)fprintf(stdout, "%d:%s:%d:%d:%d\n",
ndx,
scsi_cmd_name((u_int8_t)ndx),
metrics.command_count[ndx],
metrics.min_command_time[ndx],
metrics.max_command_time[ndx]);
}
}
(void)fprintf(stdout, "\nREAD by size:\n");
/* READ/WRITE statistics, per block size */
for ( ndx = 0; ndx < 10; ndx++) {
if (metrics.read_by_size_count[ndx] != 0) {
char* block_size;
switch ( ndx ) {
case SIZE_512:
block_size = "512";
break;
case SIZE_1K:
block_size = "1K";
break;
case SIZE_2K:
block_size = "2K";
break;
case SIZE_4K:
block_size = "4K";
break;
case SIZE_8K:
block_size = "8K";
break;
case SIZE_16K:
block_size = "16K";
break;
case SIZE_32K:
block_size = "32K";
break;
case SIZE_64K:
block_size = "64K";
break;
case SIZE_BIGGER:
block_size = "BIGGER";
break;
case SIZE_OTHER:
block_size = "OTHER";
break;
default:
block_size = "Gcc, shut up!";
}
(void)fprintf(stdout, "%s:%u:%u:%u\n", block_size,
metrics.read_by_size_count[ndx],
metrics.read_by_size_min_time[ndx],
metrics.read_by_size_max_time[ndx]);
}
}
(void)fprintf(stdout, "\nWRITE by size:\n");
for ( ndx = 0; ndx < 10; ndx++) {
if (metrics.write_by_size_count[ndx] != 0) {
char* block_size;
switch ( ndx ) {
case SIZE_512:
block_size = "512";
break;
case SIZE_1K:
block_size = "1K";
break;
case SIZE_2K:
block_size = "2K";
break;
case SIZE_4K:
block_size = "4K";
break;
case SIZE_8K:
block_size = "8K";
break;
case SIZE_16K:
block_size = "16K";
break;
case SIZE_32K:
block_size = "32K";
break;
case SIZE_64K:
block_size = "64K";
break;
case SIZE_BIGGER:
block_size = "BIGGER";
break;
case SIZE_OTHER:
block_size = "OTHER";
break;
default:
block_size = "Gcc, shut up!";
}
(void)fprintf(stdout, "%s:%u:%u:%u\n", block_size,
metrics.write_by_size_count[ndx],
metrics.write_by_size_min_time[ndx],
metrics.write_by_size_max_time[ndx]);
}
}
(void)fprintf(stdout, "\nQueues:%u:%u:%u:%u:%u:%u:%u:%u:%u\n",
metrics.max_waiting_count,
metrics.min_waiting_time,
metrics.max_waiting_time,
metrics.max_submit_count,
metrics.min_submit_time,
metrics.max_submit_time,
metrics.max_complete_count,
metrics.min_complete_time,
metrics.max_complete_time);
(void)fprintf(stdout, "Hardware Ports:%u:%u:%u:%u\n",
metrics.command_collisions,
metrics.command_too_busy,
metrics.max_eata_tries,
metrics.min_eata_tries);
return(0);
}

View File

@ -0,0 +1,12 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $Id: Makefile,v 1.4 1998/01/21 17:41:39 ShimonR Exp $
PROG= dpt_sig
SRCS= dpt_sig.c
CFLAGS+=-Wall -I../../../sys -I/usr/src/sys
BINMODE=500
BINOWN= root
MAN8= dpt_sig.8
.include <bsd.prog.mk>

View File

@ -0,0 +1,3 @@
.\" Copyright (c) 1997 Simon Shapiro. All rights reserved.
.\"
.\" There is nothing here yet, but an empty file will not patch

View File

@ -0,0 +1,596 @@
/*
* Copyright (c) 1997 by Simon Shapiro
* All Rights Reserved
*
* 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,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
*/
/* dpt_sig.c: Dunp a DPT Signature */
#ident "$Id: dpt_sig.c,v 1.6 1998/01/22 22:06:30 ShimonR Exp ShimonR $"
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/queue.h>
#include <sys/ioctl.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_message.h>
#include <scsi/scsiconf.h>
#define DPT_MEASURE_PERFORMANCE
#include <sys/dpt.h>
/* A primitive subset of isgraph. Used by hex_dump below */
#define IsGraph(val) ( (((val) >= ' ') && ((val) <= '~')) )
/*
* This function dumps bytes to the screen in hex format.
*/
void
hex_dump(u_int8_t * data, int length, char *name, int no)
{
int line, column, ndx;
(void)fprintf(stdout, "Kernel Hex Dump for %s-%d at %p (%d bytes)\n",
name, no, data, length);
/* Zero out all the counters and repeat for as many bytes as we have */
for (ndx = 0, column = 0, line = 0; ndx < length; ndx++) {
/* Print relative offset at the beginning of every line */
if (column == 0)
(void)fprintf(stdout, "%04x ", ndx);
/* Print the byte as two hex digits, followed by a space */
(void)fprintf(stdout, "%02x ", data[ndx]);
/* Split the row of 16 bytes in half */
if (++column == 8) {
(void)fprintf(stdout, " ");
}
/* St the end of each row of 16 bytes, put a space ... */
if (column == 16) {
(void)fprintf(stdout, " ");
/* ... and then print the ASCII-visible on a line. */
for (column = 0; column < 16; column++) {
int ascii_pos = ndx - 15 + column;
/*
* Non-printable and non-ASCII are just a
* dot. ;-(
*/
if (IsGraph(data[ascii_pos]))
(void)fprintf(stdout, "%c", data[ascii_pos]);
else
(void)fprintf(stdout, ".");
}
/* Each line ends with a new line */
(void)fprintf(stdout, "\n");
column = 0;
/*
* Every 256 bytes (16 lines of 16 bytes each) have
* an empty line, separating them from the next
* ``page''. Yes, I programmed on a Z-80, where a
* page was 256 bytes :-)
*/
if (++line > 15) {
(void)fprintf(stdout, "\n");
line = 0;
}
}
}
/*
* We are basically done. We do want, however, to handle the ASCII
* translation of fractional lines.
*/
if ((ndx == length) && (column != 0)) {
int modulus = 16 - column, spaces = modulus * 3, skip;
/*
* Skip to the right, as many spaces as there are bytes
* ``missing'' ...
*/
for (skip = 0; skip < spaces; skip++)
(void)fprintf(stdout, " ");
/* ... And the gap separating the hex dump from the ASCII */
(void)fprintf(stdout, " ");
/*
* Do not forget the extra space that splits the hex dump
* vertically
*/
if (column < 8)
(void)fprintf(stdout, " ");
for (column = 0; column < (16 - modulus); column++) {
int ascii_pos = ndx - (16 - modulus) + column;
if (IsGraph(data[ascii_pos]))
(void)fprintf(stdout, "%c", data[ascii_pos]);
else
(void)fprintf(stdout, ".");
}
(void)fprintf(stdout, "\n");
}
}
int
main(int argc, char **argv, char **argp)
{
eata_pt_t pass_thru;
dpt_sig_t signature;
char *sp1;
char *sp2;
int result;
int fd;
int ndx;
/* If we do not do that, gcc complains about uninitialized usage (?) */
sp1 = "Unknown";
sp2 = "Unknown";
if ( (fd = open(argv[1], O_RDWR, S_IRUSR | S_IWUSR)) == -1 ) {
(void)fprintf(stderr, "%s ERROR: Failed to open \"%s\" - %s\n",
argv[0], argv[1], strerror(errno));
exit(1);
}
pass_thru.eataID[0] = 'E';
pass_thru.eataID[1] = 'A';
pass_thru.eataID[2] = 'T';
pass_thru.eataID[3] = 'A';
pass_thru.command = DPT_SIGNATURE;
pass_thru.command_buffer = (u_int8_t *)&signature;
if ( (result = ioctl(fd, DPT_IOCTL_SEND, &pass_thru)) != 0 ) {
(void)fprintf(stderr, "%s ERROR: Failed to send IOCTL %x - %s\n",
argv[0], DPT_IOCTL_SEND,
strerror(errno));
exit(1);
}
/* dsSignature is not null terminated! */
for (ndx = 0; ndx < sizeof(signature.dsSignature); ndx++)
(void)fputc(signature.dsSignature[ndx], stdout);
(void)fprintf(stdout, ":%x:", signature.SigVersion);
switch (signature.ProcessorFamily) {
case PROC_INTEL:
sp1 = "Intel";
switch ( signature.Processor ) {
case PROC_8086:
sp2 = "8086";
break;
case PROC_286:
sp2 = "80286";
break;
case PROC_386:
sp2 = "386";
break;
case PROC_486:
sp2 = "486";
break;
case PROC_PENTIUM:
sp2 = "Pentium";
break;
case PROC_P6:
sp2 = "PentiumPro";
break;
default:
sp2 = "Unknown Processor";
break;
}
break;
case PROC_MOTOROLA:
sp1 = "Motorola";
switch ( signature.Processor ) {
case PROC_68000:
sp2 = "68000";
break;
case PROC_68020:
sp2 = "68020";
break;
case PROC_68030:
sp2 = "68030";
break;
case PROC_68040:
sp2 = "68040";
break;
default:
sp2 = "Unknown Processor";
break;
}
break;
case PROC_MIPS4000:
sp1 = "MIPS/SGI";
break;
case PROC_ALPHA:
sp1 = "DEC Alpha";
break;
default:
sp1 = "Unknown Processor Family";
break;
}
(void)fprintf(stdout, "%s:%s:", sp1, sp2);
switch ( signature.Filetype ) {
case FT_EXECUTABLE:
sp1 = "Executable";
break;
case FT_SCRIPT:
sp1 = "Script";
break;
case FT_HBADRVR:
sp1 = "HBA Driver";
break;
case FT_OTHERDRVR:
sp1 = "Other Driver";
break;
case FT_IFS:
sp1 = "Installable FileSystem";
break;
case FT_ENGINE:
sp1 = "DPT Engine";
break;
case FT_COMPDRVR:
sp1 = "Compressed Driver";
break;
case FT_LANGUAGE:
sp1 = "Language File";
break;
case FT_FIRMWARE:
sp1 = "DownLoadable Firmware";
break;
case FT_COMMMODL:
sp1 = "Communications Module";
break;
case FT_INT13:
sp1 = "INT13 Type HBA Driver";
break;
case FT_HELPFILE:
sp1 = "Help File";
break;
case FT_LOGGER:
sp1 = "Event Logger";
break;
case FT_INSTALL:
sp1 = "Installation Procedure";
break;
case FT_LIBRARY:
sp1 = "Storage Manager Real-Mode Call";
break;
case FT_RESOURCE:
sp1 = "Storage Manager Resource File";
break;
case FT_MODEM_DB:
sp1 = "Storage Manager Modem Database";
break;
default:
sp1 = "Unknown File Type";
break;
}
switch ( signature.FiletypeFlags ) {
case FTF_DLL:
sp2 = "Dynamically Linked Library";
break;
case FTF_NLM:
sp2 = "NetWare Loadable Module";
break;
case FTF_OVERLAYS:
sp2 = "Uses Overlays";
break;
case FTF_DEBUG:
sp2 = "Debug Version";
break;
case FTF_TSR:
sp2 = "DOS Terminate-n-Stay Resident Thing";
break;
case FTF_SYS:
sp2 = "DOS Loadable Driver";
break;
case FTF_PROTECTED:
sp2 = "Runs in Protected Mode";
break;
case FTF_APP_SPEC:
sp2 = "Application Specific";
break;
default:
sp2 = "Unknown File Type Flag";
break;
}
(void)fprintf(stdout, "%s:%s:", sp1, sp2);
switch ( signature.OEM ) {
case OEM_DPT:
sp1 = "DPT";
break;
case OEM_ATT:
sp1 = "AT&T";
break;
case OEM_NEC:
sp1 = "NEC";
break;
case OEM_ALPHA:
sp1 = "Alphatronix";
break;
case OEM_AST:
sp1 = "AST";
break;
case OEM_OLIVETTI:
sp1 = "Olivetti";
break;
case OEM_SNI:
sp1 = "Siemens/Nixdorf";
break;
default:
sp1 = "Unknown OEM";
break;
}
switch ( signature.OS ) {
case OS_DOS:
sp2 = "DOS";
break;
case OS_WINDOWS:
sp2 = "Microsoft Windows 3.x";
break;
case OS_WINDOWS_NT:
sp2 = "Microsoft Windows NT";
break;
case OS_OS2M:
sp2 = "OS/2 1.2.x,MS 1.3.0,IBM 1.3.x";
break;
case OS_OS2L:
sp2 = "Microsoft OS/2 1.301 - LADDR";
break;
case OS_OS22x:
sp2 = "IBM OS/2 2.x";
break;
case OS_NW286:
sp2 = "Novell NetWare 286";
break;
case OS_NW386:
sp2 = "Novell NetWare 386";
break;
case OS_GEN_UNIX:
sp2 = "Generic Unix";
break;
case OS_SCO_UNIX:
sp2 = "SCO Unix";
break;
case OS_ATT_UNIX:
sp2 = "AT&T Unix";
break;
case OS_UNIXWARE:
sp2 = "UnixWare Unix";
break;
case OS_INT_UNIX:
sp2 = "Interactive Unix";
break;
case OS_SOLARIS:
sp2 = "SunSoft Solaris";
break;
case OS_QNX:
sp2 = "QNX for Tom Moch";
break;
case OS_NEXTSTEP:
sp2 = "NeXTSTEP";
break;
case OS_BANYAN:
sp2 = "Banyan Vines";
break;
case OS_OLIVETTI_UNIX:
sp2 = "Olivetti Unix";
break;
case OS_FREEBSD:
sp2 = "FreeBSD 2.2 and later";
break;
case OS_OTHER:
sp2 = "Other";
break;
default:
sp2 = "Unknown O/S";
break;
}
(void)fprintf(stdout, "%s:%s:\n", sp1, sp2);
if ( signature.Capabilities & CAP_RAID0 )
(void)fprintf(stdout, "RAID-0:");
if ( signature.Capabilities & CAP_RAID1 )
(void)fprintf(stdout, "RAID-1:");
if ( signature.Capabilities & CAP_RAID3 )
(void)fprintf(stdout, "RAID-3:");
if ( signature.Capabilities & CAP_RAID5 )
(void)fprintf(stdout, "RAID-5:");
if ( signature.Capabilities & CAP_SPAN )
(void)fprintf(stdout, "SPAN:");
if ( signature.Capabilities & CAP_PASS )
(void)fprintf(stdout, "PASS:");
if ( signature.Capabilities & CAP_OVERLAP )
(void)fprintf(stdout, "OVERLAP:");
if ( signature.Capabilities & CAP_ASPI )
(void)fprintf(stdout, "ASPI:");
if ( signature.Capabilities & CAP_ABOVE16MB )
(void)fprintf(stdout, "ISA16MB:");
if ( signature.Capabilities & CAP_EXTEND )
(void)fprintf(stdout, "ISA16MB:");
(void)fprintf(stdout, "\n");
if ( signature.DeviceSupp & DEV_DASD )
(void)fprintf(stdout, "DASD:");
if ( signature.DeviceSupp & DEV_TAPE )
(void)fprintf(stdout, "Tape:");
if ( signature.DeviceSupp & DEV_PRINTER )
(void)fprintf(stdout, "Printer:");
if ( signature.DeviceSupp & DEV_PROC )
(void)fprintf(stdout, "CPU:");
if ( signature.DeviceSupp & DEV_WORM )
(void)fprintf(stdout, "WORM:");
if ( signature.DeviceSupp & DEV_CDROM )
(void)fprintf(stdout, "CDROM:");
if ( signature.DeviceSupp & DEV_SCANNER )
(void)fprintf(stdout, "Scanner:");
if ( signature.DeviceSupp & DEV_OPTICAL )
(void)fprintf(stdout, "Optical:");
if ( signature.DeviceSupp & DEV_JUKEBOX )
(void)fprintf(stdout, "Jukebox:");
if ( signature.DeviceSupp & DEV_COMM )
(void)fprintf(stdout, "Comm:");
if ( signature.DeviceSupp & DEV_OTHER )
(void)fprintf(stdout, "Other:");
if ( signature.DeviceSupp & DEV_ALL )
(void)fprintf(stdout, "All:");
(void)fprintf(stdout, "\n");
if ( signature.AdapterSupp & ADF_2001 )
(void)fprintf(stdout, "PM2001:");
if ( signature.AdapterSupp & ADF_2012A )
(void)fprintf(stdout, "PM2012A:");
if ( signature.AdapterSupp & ADF_PLUS_ISA )
(void)fprintf(stdout, "PM2011+PM2021:");
if ( signature.AdapterSupp & ADF_PLUS_EISA )
(void)fprintf(stdout, "PM2012B+PM2022:");
if ( signature.AdapterSupp & ADF_SC3_ISA )
(void)fprintf(stdout, "PM2021:");
if ( signature.AdapterSupp & ADF_SC3_EISA )
(void)fprintf(stdout, "PM2022+PM2122:");
if ( signature.AdapterSupp & ADF_SC3_PCI )
(void)fprintf(stdout, "SmartCache III PCI:");
if ( signature.AdapterSupp & ADF_SC4_ISA )
(void)fprintf(stdout, "SmartCache IV ISA:");
if ( signature.AdapterSupp & ADF_SC4_EISA )
(void)fprintf(stdout, "SmartCache IV EISA:");
if ( signature.AdapterSupp & ADF_SC4_PCI )
(void)fprintf(stdout, "SmartCache IV PCI:");
if ( signature.AdapterSupp & ADF_ALL_MASTER )
(void)fprintf(stdout, "All Bus Mastering:");
if ( signature.AdapterSupp & ADF_ALL_CACHE )
(void)fprintf(stdout, "All Caching:");
if ( signature.AdapterSupp & ADF_ALL )
(void)fprintf(stdout, "All HBAs:");
(void)fprintf(stdout, "\n");
if ( signature.Application & APP_DPTMGR )
(void)fprintf(stdout, "DPTMGR:");
if ( signature.Application & APP_ENGINE )
(void)fprintf(stdout, "Engine:");
if ( signature.Application & APP_SYTOS )
(void)fprintf(stdout, "Systron Sytos Plus:");
if ( signature.Application & APP_CHEYENNE )
(void)fprintf(stdout, "Cheyenne ARCServe + ARCSolo:");
if ( signature.Application & APP_MSCDEX )
(void)fprintf(stdout, "Microsoft CD-ROM extensions:");
if ( signature.Application & APP_NOVABACK )
(void)fprintf(stdout, "NovaStor Novaback:");
if ( signature.Application & APP_AIM )
(void)fprintf(stdout, "Archive Information Manager:");
(void)fprintf(stdout, "\n");
if ( signature.Requirements & REQ_SMARTROM )
(void)fprintf(stdout, "SmartROM:");
if ( signature.Requirements & REQ_DPTDDL )
(void)fprintf(stdout, "DPTDDL.SYS:");
if ( signature.Requirements & REQ_HBA_DRIVER )
(void)fprintf(stdout, "HBA Driver:");
if ( signature.Requirements & REQ_ASPI_TRAN )
(void)fprintf(stdout, "ASPI Transport Modules:");
if ( signature.Requirements & REQ_ENGINE )
(void)fprintf(stdout, "DPT Engine:");
if ( signature.Requirements & REQ_COMM_ENG )
(void)fprintf(stdout, "DPT Comm Engine:");
(void)fprintf(stdout, "\n");
(void)fprintf(stdout, "%x.%x.%x:%d.%d.%d\n",
signature.Version, signature.Revision,
signature.SubRevision,
signature.Month, signature.Day, signature.Year + 1980);
return(0);
}

View File

@ -0,0 +1,12 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $Id: Makefile,v 1.3 1998/01/21 07:50:38 ShimonR Exp ShimonR $
PROG= dpt_softc
SRCS= dpt_softc.c
CFLAGS+=-Wall -I../../../sys -I/usr/src/sys
BINMODE=500
BINOWN= root
MAN8= dpt_softc.8
.include <bsd.prog.mk>

View File

@ -0,0 +1,4 @@
.\" Copyright (c) 1997 Simon Shapiro. All rights reserved.
.\"
.\" There is nothing here yet, but an empty file will not patch

View File

@ -0,0 +1,188 @@
/*
* Copyright (c) 1997 by Simon Shapiro
* All Rights Reserved
*
* 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,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
*/
/* dpt_softc.c: Dunp a DPT control structure */
#ident "$Id: dpt_softc.c,v 1.7 1998/01/22 21:37:40 ShimonR Exp $"
#include <stdlib.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/queue.h>
#include <sys/ioctl.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_message.h>
#include <scsi/scsiconf.h>
/*
* The following two defines alter the size and composition of dpt_softc_t.
* If useland does not match the kenel, disaster will ensue.
* Since we do not know how to pick up kernel options from here,
* and since we always use these options, we will enable them here.
*
* If you build a kernel without these options, edit here and recompile.
*/
#define DPT_MEASURE_PERFORMANCE
#define DEVFS
#include <sys/dpt.h>
static char i2bin_bitmap[48]; /* Used for binary dump of registers */
char *
i2bin(unsigned int no, int length)
{
int ndx, rind;
for (ndx = 0, rind = 0; ndx < 32; ndx++, rind++) {
i2bin_bitmap[rind] = (((no << ndx) & 0x80000000) ? '1' : '0');
if (((ndx % 4) == 3))
i2bin_bitmap[++rind] = ' ';
}
if ((ndx % 4) == 3)
i2bin_bitmap[rind - 1] = '\0';
else
i2bin_bitmap[rind] = '\0';
switch (length) {
case 8:
return (i2bin_bitmap + 30);
break;
case 16:
return (i2bin_bitmap + 20);
break;
case 24:
return (i2bin_bitmap + 10);
break;
case 32:
return (i2bin_bitmap);
default:
return ("i2bin: Invalid length Specs");
break;
}
}
int
main(int argc, char **argv, char **argp)
{
dpt_user_softc_t udpt;
int result;
int fd;
if ( (fd = open(argv[1], O_RDWR, S_IRUSR | S_IWUSR)) == -1 ) {
(void)fprintf(stderr, "%s ERROR: Failed to open \"%s\" - %s\n",
argv[0], argv[1], strerror(errno));
exit(1);
}
if ( (result = ioctl(fd, DPT_IOCTL_SOFTC, &udpt)) != 0 ) {
(void)fprintf(stderr, "%s ERROR: Failed to send IOCTL %x - %s\n",
argv[0], DPT_IOCTL_SOFTC,
strerror(errno));
exit(2);
}
(void)fprintf(stdout, "Counters:%d:%d:%d:%d:%d:%d:%d\n",
udpt.total_ccbs_count,
udpt.free_ccbs_count,
udpt.waiting_ccbs_count,
udpt.submitted_ccbs_count,
udpt.completed_ccbs_count,
udpt.commands_processed,
udpt.lost_interrupts);
(void)fprintf(stdout, "Queue Status:%s\n",
i2bin(udpt.queue_status, sizeof(udpt.queue_status) * 8));
(void)fprintf(stdout, "Free lock:%s\n",
i2bin(udpt.free_lock, sizeof(udpt.free_lock) * 8));
(void)fprintf(stdout, "Waiting lock:%s\n",
i2bin(udpt.waiting_lock, sizeof(udpt.waiting_lock) * 8));
(void)fprintf(stdout, "Submitted lock:%s\n",
i2bin(udpt.submitted_lock, sizeof(udpt.submitted_lock) * 8));
(void)fprintf(stdout, "Completed lock:%s\n",
i2bin(udpt.completed_lock, sizeof(udpt.completed_lock) * 8));
(void)fprintf(stdout, "Configuration:%s:%d:%d:%d:%x:%d:%d\n",
udpt.handle_interrupts ? "Yes" : "No",
udpt.max_id,
udpt.max_lun,
udpt.channels,
udpt.io_base,
udpt.irq,
udpt.dma_channel);
(void)fprintf(stdout, "ID:%x:%x:%s:%s:%s:%s:%x\n",
udpt.board_data.deviceType,
udpt.board_data.rm_dtq,
udpt.board_data.vendor,
udpt.board_data.modelNum,
udpt.board_data.firmware,
udpt.board_data.protocol,
udpt.EATA_revision);
(void)fprintf(stdout,"Capabilities:%x:%d:%s:%s:%s:%s:%s\n",
udpt.bustype,
udpt.channels,
i2bin((u_int32_t)udpt.state, sizeof(udpt.state) * 8),
udpt.primary ? "Yes" : "No",
udpt.more_support ? "Yes" : "No",
udpt.immediate_support ? "Yes" : "No",
udpt.broken_INQUIRY ? "Yes" : "No");
(void)fprintf(stdout,"More Config:%d:%d:%d:%d:%d:%d:%d:%d:%d:%d\n",
udpt.resetlevel[0],
udpt.resetlevel[1],
udpt.resetlevel[2],
udpt.cplen,
udpt.cppadlen,
udpt.queuesize,
udpt.sgsize,
udpt.hostid[0],
udpt.hostid[1],
udpt.hostid[2]);
(void)fprintf(stdout,"Cache:%s:%d\n",
(udpt.cache_type == DPT_NO_CACHE)
? "None"
: (udpt.cache_type == DPT_CACHE_WRITETHROUGH)
? "Write-Through" : "Write-Back",
udpt.cache_size);
return(0);
}

View File

@ -0,0 +1,12 @@
# @(#)Makefile 8.1 (Berkeley) 5/31/93
# $Id: Makefile,v 1.1 1998/01/22 23:32:27 ShimonR Exp ShimonR $
PROG= dpt_sysinfo
SRCS= dpt_sysinfo.c
CFLAGS+=-Wall -I../../../sys -I/usr/src/sys
BINMODE=500
BINOWN= root
MAN8= dpt_sysinfo.8
.include <bsd.prog.mk>

View File

@ -0,0 +1,3 @@
.\" Copyright (c) 1997 Simon Shapiro. All rights reserved.
.\"
.\" There is nothing here yet, but an empty file will not patch

View File

@ -0,0 +1,256 @@
/*
* Copyright (c) 1997 by Simon Shapiro
* All Rights Reserved
*
* 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,
* without modification, immediately at the beginning of the file.
* 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. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*
*/
/* dpt_ctlinfo.c: Dunp a DPT HBA Information Block */
#ident "$Id: dpt_ctlinfo.c,v 1.1 1998/01/22 23:32:27 ShimonR Exp ShimonR $"
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/stat.h>
#include <sys/queue.h>
#include <sys/ioctl.h>
#include <scsi/scsi_all.h>
#include <scsi/scsi_message.h>
#include <scsi/scsiconf.h>
#define DPT_MEASURE_PERFORMANCE
#include <sys/dpt.h>
int
main(int argc, char **argv, char **argp)
{
eata_pt_t pass_thru;
dpt_sysinfo_t sysinfo;
int result;
int fd;
int ndx;
if ( (fd = open(argv[1], O_RDWR, S_IRUSR | S_IWUSR)) == -1 ) {
(void)fprintf(stderr, "%s ERROR: Failed to open \"%s\" - %s\n",
argv[0], argv[1], strerror(errno));
exit(1);
}
pass_thru.eataID[0] = 'E';
pass_thru.eataID[1] = 'A';
pass_thru.eataID[2] = 'T';
pass_thru.eataID[3] = 'A';
pass_thru.command = DPT_SYSINFO;
pass_thru.command_buffer = (u_int8_t *)&sysinfo;
if ( (result = ioctl(fd, DPT_IOCTL_SEND, &pass_thru)) != 0 ) {
(void)fprintf(stderr, "%s ERROR: Failed to send IOCTL %x - %s\n",
argv[0], DPT_IOCTL_SEND,
strerror(errno));
exit(1);
}
(void)fprintf(stdout, "%x:%x:%d:",
sysinfo.drive0CMOS, sysinfo.drive1CMOS, sysinfo.numDrives);
switch (sysinfo.processorFamily) {
case PROC_INTEL:
(void)fprintf(stdout, "Intel:");
switch (sysinfo.processorType) {
case PROC_8086:
(void)fprintf(stdout, "8086:");
break;
case PROC_286:
(void)fprintf(stdout, "80286:");
break;
case PROC_386:
(void)fprintf(stdout, "i386:");
break;
case PROC_486:
(void)fprintf(stdout, "80486:");
break;
case PROC_PENTIUM:
(void)fprintf(stdout, "Pentium:");
break;
case PROC_P6:
(void)fprintf(stdout, "Pentium-Pro:");
break;
default:
(void)fprintf(stdout, "Unknown (%d):", sysinfo.processorType);
}
break;
case PROC_MOTOROLA:
(void)fprintf(stdout, "Motorola:");
switch (sysinfo.processorType) {
case PROC_68000:
(void)fprintf(stdout, "M68000");
break;
case PROC_68020:
(void)fprintf(stdout, "M68020");
break;
case PROC_68030:
(void)fprintf(stdout, "M68030");
break;
case PROC_68040:
(void)fprintf(stdout, "M68040");
break;
default:
(void)fprintf(stdout, "Unknown (%d):", sysinfo.processorType);
}
break;
case PROC_MIPS4000:
(void)fprintf(stdout, "MIPS:Any:");
break;
case PROC_ALPHA:
(void)fprintf(stdout, "Alpha:Any:");
break;
default:
(void)fprintf(stdout, "Unknown (%d):Any:", sysinfo.processorFamily);
}
(void)fprintf(stdout, "%d.%d.%d:",
sysinfo.smartROMMajorVersion,
sysinfo.smartROMMinorVersion,
sysinfo.smartROMRevision);
(void)fprintf(stdout, "%c%c%c%c%c%c%c%c%c%c%c:",
(sysinfo.flags & SI_CMOS_Valid) ? '+' : '-',
(sysinfo.flags & SI_NumDrivesValid) ? '+' : '-',
(sysinfo.flags & SI_ProcessorValid) ? '+' : '-',
(sysinfo.flags & SI_MemorySizeValid) ? '+' : '-',
(sysinfo.flags & SI_DriveParamsValid) ? '+' : '-',
(sysinfo.flags & SI_SmartROMverValid) ? '+' : '-',
(sysinfo.flags & SI_OSversionValid) ? '+' : '-',
(sysinfo.flags & SI_OSspecificValid) ? '+' : '-',
(sysinfo.flags & SI_BusTypeValid) ? '+' : '-',
(sysinfo.flags & SI_ALL_VALID) ? '+' : '-',
(sysinfo.flags & SI_NO_SmartROM) ? '+' : '-');
(void)fprintf(stdout, "%d:", sysinfo.conventionalMemSize);
(void)fprintf(stdout, "%d:", sysinfo.extendedMemSize);
switch (sysinfo.osType) {
case OS_DOS:
(void)fprintf(stdout, "DOS:");
break;
case OS_WINDOWS:
(void)fprintf(stdout, "Win3.1:");
break;
case OS_WINDOWS_NT:
(void)fprintf(stdout, "NT:");
break;
case OS_OS2M:
(void)fprintf(stdout, "OS/2-std:");
break;
case OS_OS2L:
(void)fprintf(stdout, "OS/2-LADDR:");
break;
case OS_OS22x:
(void)fprintf(stdout, "OS/2-2.x:");
break;
case OS_NW286:
(void)fprintf(stdout, "NetWare-286:");
break;
case OS_NW386:
(void)fprintf(stdout, "NetWare-386:");
break;
case OS_GEN_UNIX:
(void)fprintf(stdout, "Unix:");
break;
case OS_SCO_UNIX:
(void)fprintf(stdout, "SCO Unix:");
break;
case OS_ATT_UNIX:
(void)fprintf(stdout, "AT&T Unix:");
break;
case OS_UNIXWARE:
(void)fprintf(stdout, "UnixWare:");
break;
case OS_INT_UNIX:
(void)fprintf(stdout, "IAC Unix:");
break;
case OS_SOLARIS:
(void)fprintf(stdout, "Solaris:");
break;
case OS_QNX:
(void)fprintf(stdout, "Qnx:");
break;
case OS_NEXTSTEP:
(void)fprintf(stdout, "NextStep:");
break;
case OS_BANYAN:
(void)fprintf(stdout, "Banyan:");
break;
case OS_OLIVETTI_UNIX:
(void)fprintf(stdout, "Olivetti Unix:");
break;
case OS_FREEBSD:
(void)fprintf(stdout, "FreeBSD:");
break;
case OS_OTHER:
(void)fprintf(stdout, "Other (%d):", sysinfo.osType);
break;
default:
(void)fprintf(stdout, "Unknown (%d):", sysinfo.osType);
}
(void)fprintf(stdout, "%d.%d.%d.%d:", sysinfo.osMajorVersion,
sysinfo.osMinorVersion, sysinfo.osRevision,
sysinfo.osSubRevision);
switch (sysinfo.busType) {
case HBA_BUS_ISA:
(void)fprintf(stdout, "ISA:");
break;
case HBA_BUS_EISA:
(void)fprintf(stdout, "EISA:");
break;
case HBA_BUS_PCI:
(void)fprintf(stdout, "PCI:");
break;
default:
(void)fprintf(stdout, "Unknown (%d):", sysinfo.busType);
}
for (ndx = 0; ndx < 16; ndx++) {
if (sysinfo.drives[ndx].cylinders == 0)
continue;
(void)fprintf(stdout, "d%dc%dh%ds%d:", ndx,
sysinfo.drives[ndx].cylinders,
sysinfo.drives[ndx].heads,
sysinfo.drives[ndx].sectors);
}
(void)fprintf(stdout, "\n");
return(0);
}