2 * Copyright (c) 1997 by Simon Shapiro
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions, and the following disclaimer,
10 * without modification, immediately at the beginning of the file.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * $FreeBSD: src/usr.sbin/dpt/dpt_sig/dpt_sig.c,v 1.3 1999/08/28 01:16:09 peter Exp $
30 * $DragonFly: src/usr.sbin/dpt/dpt_sig/dpt_sig.c,v 1.3 2004/12/18 22:48:03 swildner Exp $
33 /* dpt_sig.c: Dunp a DPT Signature */
41 #include <sys/queue.h>
42 #include <sys/ioctl.h>
43 #include <scsi/scsi_all.h>
44 #include <scsi/scsi_message.h>
45 #include <scsi/scsiconf.h>
47 #define DPT_MEASURE_PERFORMANCE
51 /* A primitive subset of isgraph. Used by hex_dump below */
52 #define IsGraph(val) ( (((val) >= ' ') && ((val) <= '~')) )
55 * This function dumps bytes to the screen in hex format.
58 hex_dump(u_int8_t * data, int length, char *name, int no)
60 int line, column, ndx;
62 fprintf(stdout, "Kernel Hex Dump for %s-%d at %p (%d bytes)\n",
63 name, no, data, length);
65 /* Zero out all the counters and repeat for as many bytes as we have */
66 for (ndx = 0, column = 0, line = 0; ndx < length; ndx++) {
67 /* Print relative offset at the beginning of every line */
69 fprintf(stdout, "%04x ", ndx);
71 /* Print the byte as two hex digits, followed by a space */
72 fprintf(stdout, "%02x ", data[ndx]);
74 /* Split the row of 16 bytes in half */
78 /* St the end of each row of 16 bytes, put a space ... */
82 /* ... and then print the ASCII-visible on a line. */
83 for (column = 0; column < 16; column++) {
84 int ascii_pos = ndx - 15 + column;
87 * Non-printable and non-ASCII are just a
90 if (IsGraph(data[ascii_pos]))
91 fprintf(stdout, "%c", data[ascii_pos]);
96 /* Each line ends with a new line */
97 fprintf(stdout, "\n");
101 * Every 256 bytes (16 lines of 16 bytes each) have
102 * an empty line, separating them from the next
103 * ``page''. Yes, I programmed on a Z-80, where a
104 * page was 256 bytes :-)
107 fprintf(stdout, "\n");
114 * We are basically done. We do want, however, to handle the ASCII
115 * translation of fractional lines.
117 if ((ndx == length) && (column != 0)) {
118 int modulus = 16 - column, spaces = modulus * 3, skip;
121 * Skip to the right, as many spaces as there are bytes
124 for (skip = 0; skip < spaces; skip++)
125 fprintf(stdout, " ");
127 /* ... And the gap separating the hex dump from the ASCII */
128 fprintf(stdout, " ");
131 * Do not forget the extra space that splits the hex dump
135 fprintf(stdout, " ");
137 for (column = 0; column < (16 - modulus); column++) {
138 int ascii_pos = ndx - (16 - modulus) + column;
140 if (IsGraph(data[ascii_pos]))
141 fprintf(stdout, "%c", data[ascii_pos]);
143 fprintf(stdout, ".");
145 fprintf(stdout, "\n");
151 main(int argc, char **argv, char **argp)
162 /* If we do not do that, gcc complains about uninitialized usage (?) */
166 if ( (fd = open(argv[1], O_RDWR, S_IRUSR | S_IWUSR)) == -1 ) {
167 fprintf(stderr, "%s ERROR: Failed to open \"%s\" "
169 argv[0], argv[1], strerror(errno));
173 pass_thru.eataID[0] = 'E';
174 pass_thru.eataID[1] = 'A';
175 pass_thru.eataID[2] = 'T';
176 pass_thru.eataID[3] = 'A';
177 pass_thru.command = DPT_SIGNATURE;
178 pass_thru.command_buffer = (u_int8_t *)&signature;
180 if ( (result = ioctl(fd, DPT_IOCTL_SEND, &pass_thru)) != 0 ) {
181 fprintf(stderr, "%s ERROR: Failed to send IOCTL "
183 argv[0], DPT_IOCTL_SEND,
188 /* dsSignature is not null terminated! */
189 for (ndx = 0; ndx < sizeof(signature.dsSignature); ndx++)
190 fputc(signature.dsSignature[ndx], stdout);
192 fprintf(stdout, ":%x:", signature.SigVersion);
194 switch (signature.ProcessorFamily) {
197 switch ( signature.Processor ) {
217 sp2 = "Unknown Processor";
223 switch ( signature.Processor ) {
237 sp2 = "Unknown Processor";
248 sp1 = "Unknown Processor Family";
252 fprintf(stdout, "%s:%s:", sp1, sp2);
254 switch ( signature.Filetype ) {
265 sp1 = "Other Driver";
268 sp1 = "Installable FileSystem";
274 sp1 = "Compressed Driver";
277 sp1 = "Language File";
280 sp1 = "DownLoadable Firmware";
283 sp1 = "Communications Module";
286 sp1 = "INT13 Type HBA Driver";
292 sp1 = "Event Logger";
295 sp1 = "Installation Procedure";
298 sp1 = "Storage Manager Real-Mode Call";
301 sp1 = "Storage Manager Resource File";
304 sp1 = "Storage Manager Modem Database";
307 sp1 = "Unknown File Type";
311 switch ( signature.FiletypeFlags ) {
313 sp2 = "Dynamically Linked Library";
316 sp2 = "NetWare Loadable Module";
319 sp2 = "Uses Overlays";
322 sp2 = "Debug Version";
325 sp2 = "DOS Terminate-n-Stay Resident Thing";
328 sp2 = "DOS Loadable Driver";
331 sp2 = "Runs in Protected Mode";
334 sp2 = "Application Specific";
337 sp2 = "Unknown File Type Flag";
341 fprintf(stdout, "%s:%s:", sp1, sp2);
343 switch ( signature.OEM ) {
363 sp1 = "Siemens/Nixdorf";
370 switch ( signature.OS ) {
375 sp2 = "Microsoft Windows 3.x";
378 sp2 = "Microsoft Windows NT";
381 sp2 = "OS/2 1.2.x,MS 1.3.0,IBM 1.3.x";
384 sp2 = "Microsoft OS/2 1.301 - LADDR";
387 sp2 = "IBM OS/2 2.x";
390 sp2 = "Novell NetWare 286";
393 sp2 = "Novell NetWare 386";
396 sp2 = "Generic Unix";
405 sp2 = "UnixWare Unix";
408 sp2 = "Interactive Unix";
411 sp2 = "SunSoft Solaris";
414 sp2 = "QNX for Tom Moch";
420 sp2 = "Banyan Vines";
422 case OS_OLIVETTI_UNIX:
423 sp2 = "Olivetti Unix";
426 sp2 = "FreeBSD 2.2 and later";
436 fprintf(stdout, "%s:%s:\n", sp1, sp2);
438 if ( signature.Capabilities & CAP_RAID0 )
439 fprintf(stdout, "RAID-0:");
441 if ( signature.Capabilities & CAP_RAID1 )
442 fprintf(stdout, "RAID-1:");
444 if ( signature.Capabilities & CAP_RAID3 )
445 fprintf(stdout, "RAID-3:");
447 if ( signature.Capabilities & CAP_RAID5 )
448 fprintf(stdout, "RAID-5:");
450 if ( signature.Capabilities & CAP_SPAN )
451 fprintf(stdout, "SPAN:");
453 if ( signature.Capabilities & CAP_PASS )
454 fprintf(stdout, "PASS:");
456 if ( signature.Capabilities & CAP_OVERLAP )
457 fprintf(stdout, "OVERLAP:");
459 if ( signature.Capabilities & CAP_ASPI )
460 fprintf(stdout, "ASPI:");
462 if ( signature.Capabilities & CAP_ABOVE16MB )
463 fprintf(stdout, "ISA16MB:");
465 if ( signature.Capabilities & CAP_EXTEND )
466 fprintf(stdout, "ISA16MB:");
468 fprintf(stdout, "\n");
470 if ( signature.DeviceSupp & DEV_DASD )
471 fprintf(stdout, "DASD:");
473 if ( signature.DeviceSupp & DEV_TAPE )
474 fprintf(stdout, "Tape:");
476 if ( signature.DeviceSupp & DEV_PRINTER )
477 fprintf(stdout, "Printer:");
479 if ( signature.DeviceSupp & DEV_PROC )
480 fprintf(stdout, "CPU:");
482 if ( signature.DeviceSupp & DEV_WORM )
483 fprintf(stdout, "WORM:");
485 if ( signature.DeviceSupp & DEV_CDROM )
486 fprintf(stdout, "CDROM:");
488 if ( signature.DeviceSupp & DEV_SCANNER )
489 fprintf(stdout, "Scanner:");
491 if ( signature.DeviceSupp & DEV_OPTICAL )
492 fprintf(stdout, "Optical:");
494 if ( signature.DeviceSupp & DEV_JUKEBOX )
495 fprintf(stdout, "Jukebox:");
497 if ( signature.DeviceSupp & DEV_COMM )
498 fprintf(stdout, "Comm:");
500 if ( signature.DeviceSupp & DEV_OTHER )
501 fprintf(stdout, "Other:");
503 if ( signature.DeviceSupp & DEV_ALL )
504 fprintf(stdout, "All:");
506 fprintf(stdout, "\n");
508 if ( signature.AdapterSupp & ADF_2001 )
509 fprintf(stdout, "PM2001:");
511 if ( signature.AdapterSupp & ADF_2012A )
512 fprintf(stdout, "PM2012A:");
514 if ( signature.AdapterSupp & ADF_PLUS_ISA )
515 fprintf(stdout, "PM2011+PM2021:");
517 if ( signature.AdapterSupp & ADF_PLUS_EISA )
518 fprintf(stdout, "PM2012B+PM2022:");
520 if ( signature.AdapterSupp & ADF_SC3_ISA )
521 fprintf(stdout, "PM2021:");
523 if ( signature.AdapterSupp & ADF_SC3_EISA )
524 fprintf(stdout, "PM2022+PM2122:");
526 if ( signature.AdapterSupp & ADF_SC3_PCI )
527 fprintf(stdout, "SmartCache III PCI:");
529 if ( signature.AdapterSupp & ADF_SC4_ISA )
530 fprintf(stdout, "SmartCache IV ISA:");
532 if ( signature.AdapterSupp & ADF_SC4_EISA )
533 fprintf(stdout, "SmartCache IV EISA:");
535 if ( signature.AdapterSupp & ADF_SC4_PCI )
536 fprintf(stdout, "SmartCache IV PCI:");
538 if ( signature.AdapterSupp & ADF_ALL_MASTER )
539 fprintf(stdout, "All Bus Mastering:");
541 if ( signature.AdapterSupp & ADF_ALL_CACHE )
542 fprintf(stdout, "All Caching:");
544 if ( signature.AdapterSupp & ADF_ALL )
545 fprintf(stdout, "All HBAs:");
547 fprintf(stdout, "\n");
549 if ( signature.Application & APP_DPTMGR )
550 fprintf(stdout, "DPTMGR:");
552 if ( signature.Application & APP_ENGINE )
553 fprintf(stdout, "Engine:");
555 if ( signature.Application & APP_SYTOS )
556 fprintf(stdout, "Systron Sytos Plus:");
558 if ( signature.Application & APP_CHEYENNE )
559 fprintf(stdout, "Cheyenne ARCServe + ARCSolo:");
561 if ( signature.Application & APP_MSCDEX )
562 fprintf(stdout, "Microsoft CD-ROM extensions:");
564 if ( signature.Application & APP_NOVABACK )
565 fprintf(stdout, "NovaStor Novaback:");
567 if ( signature.Application & APP_AIM )
568 fprintf(stdout, "Archive Information Manager:");
570 fprintf(stdout, "\n");
572 if ( signature.Requirements & REQ_SMARTROM )
573 fprintf(stdout, "SmartROM:");
575 if ( signature.Requirements & REQ_DPTDDL )
576 fprintf(stdout, "DPTDDL.SYS:");
578 if ( signature.Requirements & REQ_HBA_DRIVER )
579 fprintf(stdout, "HBA Driver:");
581 if ( signature.Requirements & REQ_ASPI_TRAN )
582 fprintf(stdout, "ASPI Transport Modules:");
584 if ( signature.Requirements & REQ_ENGINE )
585 fprintf(stdout, "DPT Engine:");
587 if ( signature.Requirements & REQ_COMM_ENG )
588 fprintf(stdout, "DPT Comm Engine:");
590 fprintf(stdout, "\n");
592 fprintf(stdout, "%x.%x.%x:%d.%d.%d\n",
593 signature.Version, signature.Revision,
594 signature.SubRevision,
595 signature.Month, signature.Day, signature.Year + 1980);