Fix select and poll use in LWPs.
[dragonfly.git] / usr.sbin / dpt / dpt_ctlinfo / dpt_ctlinfo.c
blob2fe4f9b50426754490346afbfa34039f62a15380
1 /*
2 * Copyright (c) 1997 by Simon Shapiro
3 * All Rights Reserved
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
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
27 * SUCH DAMAGE.
29 * $FreeBSD: src/usr.sbin/dpt/dpt_ctlinfo/dpt_ctlinfo.c,v 1.3 1999/08/28 01:16:06 peter Exp $
30 * $DragonFly: src/usr.sbin/dpt/dpt_ctlinfo/dpt_ctlinfo.c,v 1.3 2004/12/18 22:48:03 swildner Exp $
33 /* dpt_ctlinfo.c: Dunp a DPT HBA Information Block */
35 #include <fcntl.h>
36 #include <stdio.h>
37 #include <string.h>
38 #include <errno.h>
39 #include <sys/time.h>
40 #include <sys/stat.h>
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
49 #include <sys/dpt.h>
52 int
53 main(int argc, char **argv, char **argp)
55 eata_pt_t pass_thru;
56 dpt_compat_ha_t compat_softc;
58 int result;
59 int fd;
60 int ndx;
62 if ( (fd = open(argv[1], O_RDWR, S_IRUSR | S_IWUSR)) == -1 ) {
63 fprintf(stderr, "%s ERROR: Failed to open \"%s\" - %s\n",
64 argv[0], argv[1], strerror(errno));
65 exit(1);
68 pass_thru.eataID[0] = 'E';
69 pass_thru.eataID[1] = 'A';
70 pass_thru.eataID[2] = 'T';
71 pass_thru.eataID[3] = 'A';
72 pass_thru.command = DPT_CTRLINFO;
73 pass_thru.command_buffer = (u_int8_t *)&compat_softc;
75 if ( (result = ioctl(fd, DPT_IOCTL_SEND, &pass_thru)) != 0 ) {
76 fprintf(stderr, "%s ERROR: Failed to send IOCTL "
77 "%lx - %s\n",
78 argv[0], DPT_IOCTL_SEND,
79 strerror(errno));
80 exit(1);
83 fprintf(stdout, "%x:", compat_softc.ha_state);
85 for (ndx = 0; ndx < MAX_CHANNELS; ndx++)
86 fprintf(stdout, (ndx == (MAX_CHANNELS - 1)) ? "%d:" :
87 "%d,",
88 compat_softc.ha_id[ndx]);
90 fprintf(stdout, "%d:", compat_softc.ha_vect);
91 fprintf(stdout, "%x:", compat_softc.ha_base);
92 fprintf(stdout, "%d:", compat_softc.ha_max_jobs);
94 switch (compat_softc.ha_cache) {
95 case DPT_NO_CACHE:
96 fprintf(stdout, "No Cache:");
97 break;
98 case DPT_CACHE_WRITETHROUGH:
99 fprintf(stdout, "WriteThrough:");
100 break;
101 case DPT_CACHE_WRITEBACK:
102 fprintf(stdout, "WriteBack:");
103 break;
104 default:
105 fprintf(stdout, "UnKnown (%d):", compat_softc.ha_cache);
108 fprintf(stdout, "%d:", compat_softc.ha_cachesize);
109 fprintf(stdout, "%d:", compat_softc.ha_nbus);
110 fprintf(stdout, "%d:", compat_softc.ha_ntargets);
111 fprintf(stdout, "%d:", compat_softc.ha_nluns);
112 fprintf(stdout, "%d:", compat_softc.ha_tshift);
113 fprintf(stdout, "%d:", compat_softc.ha_bshift);
115 fprintf(stdout, "%d:", compat_softc.ha_npend);
116 fprintf(stdout, "%d:", compat_softc.ha_active_jobs);
118 fprintf(stdout, "%s\n", compat_softc.ha_fw_version);
122 return(0);