Clean (void) casts from usr.sbin
[dragonfly.git] / usr.sbin / dpt / dpt_sysinfo / dpt_sysinfo.c
1 /*
2  *       Copyright (c) 1997 by Simon Shapiro
3  *       All Rights Reserved
4  *
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.
16  *
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.
28  *
29  * $FreeBSD: src/usr.sbin/dpt/dpt_sysinfo/dpt_sysinfo.c,v 1.3 1999/08/28 01:16:10 peter Exp $
30  * $DragonFly: src/usr.sbin/dpt/dpt_sysinfo/dpt_sysinfo.c,v 1.3 2004/12/18 22:48:03 swildner Exp $
31  */
32
33 /* dpt_ctlinfo.c:  Dunp a DPT HBA Information Block */
34
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>
46
47 #define DPT_MEASURE_PERFORMANCE
48
49 #include <sys/dpt.h>
50
51
52 int
53 main(int argc, char **argv, char **argp)
54 {
55     eata_pt_t           pass_thru;
56         dpt_sysinfo_t sysinfo;
57     
58     int result;
59     int fd;
60     int ndx;
61     
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);
66     }
67
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_SYSINFO;
73     pass_thru.command_buffer = (u_int8_t *)&sysinfo;
74
75     if ( (result = ioctl(fd, DPT_IOCTL_SEND, &pass_thru)) != 0 ) {
76                 fprintf(stderr, "%s ERROR:  Failed to send IOCTL %lx - %s\n",
77                         argv[0], DPT_IOCTL_SEND,
78                         strerror(errno));
79                 exit(1);
80     }
81
82         fprintf(stdout, "%x:%x:%d:",
83                 sysinfo.drive0CMOS, sysinfo.drive1CMOS, sysinfo.numDrives);
84
85         switch (sysinfo.processorFamily) {
86         case PROC_INTEL:
87                 fprintf(stdout, "Intel:");
88                 switch (sysinfo.processorType) {
89                 case PROC_8086:
90                         fprintf(stdout, "8086:");
91                         break;
92                 case PROC_286:
93                         fprintf(stdout, "80286:");
94                         break;
95                 case PROC_386:
96                         fprintf(stdout, "i386:");
97                         break;
98                 case PROC_486:
99                         fprintf(stdout, "80486:");
100                         break;
101                 case PROC_PENTIUM:
102                         fprintf(stdout, "Pentium:");
103                         break;
104                 case PROC_P6:
105                         fprintf(stdout, "Pentium-Pro:");
106                         break;
107                 default:
108                         fprintf(stdout, "Unknown (%d):", sysinfo.processorType);
109                 }
110                 break;
111         case PROC_MOTOROLA:
112                 fprintf(stdout, "Motorola:");
113                 switch (sysinfo.processorType) {
114                 case PROC_68000:
115                         fprintf(stdout, "M68000");
116                         break;
117                 case PROC_68020:
118                         fprintf(stdout, "M68020");
119                         break;
120                 case PROC_68030:
121                         fprintf(stdout, "M68030");
122                         break;
123                 case PROC_68040:
124                         fprintf(stdout, "M68040");
125                         break;
126                 default:
127                         fprintf(stdout, "Unknown (%d):", sysinfo.processorType);
128                 }
129                 break;
130         case PROC_MIPS4000:
131                 fprintf(stdout, "MIPS:Any:");
132                 break;
133         case PROC_ALPHA:
134                 fprintf(stdout, "Alpha:Any:");
135                 break;
136         default:
137                 fprintf(stdout, "Unknown (%d):Any:", sysinfo.processorFamily);
138         }
139
140         fprintf(stdout, "%d.%d.%d:",
141                 sysinfo.smartROMMajorVersion,
142                 sysinfo.smartROMMinorVersion,
143                 sysinfo.smartROMRevision);
144
145         fprintf(stdout, "%c%c%c%c%c%c%c%c%c%c%c:",
146                 (sysinfo.flags & SI_CMOS_Valid)         ? '+' : '-',
147                 (sysinfo.flags & SI_NumDrivesValid)     ? '+' : '-',
148                 (sysinfo.flags & SI_ProcessorValid)     ? '+' : '-',
149                 (sysinfo.flags & SI_MemorySizeValid)    ? '+' : '-',
150                 (sysinfo.flags & SI_DriveParamsValid)   ? '+' : '-',
151                 (sysinfo.flags & SI_SmartROMverValid)   ? '+' : '-',
152                 (sysinfo.flags & SI_OSversionValid)     ? '+' : '-',
153                 (sysinfo.flags & SI_OSspecificValid)    ? '+' : '-',
154                 (sysinfo.flags & SI_BusTypeValid)               ? '+' : '-',
155                 (sysinfo.flags & SI_ALL_VALID)                  ? '+' : '-',
156                 (sysinfo.flags & SI_NO_SmartROM)        ? '+' : '-');
157
158         fprintf(stdout, "%d:", sysinfo.conventionalMemSize);
159         fprintf(stdout, "%d:", sysinfo.extendedMemSize);
160
161         switch (sysinfo.osType) {
162         case OS_DOS:
163                 fprintf(stdout, "DOS:");
164                 break;
165         case OS_WINDOWS:
166                 fprintf(stdout, "Win3.1:");
167                 break;
168         case OS_WINDOWS_NT:
169                 fprintf(stdout, "NT:");
170                 break;
171         case OS_OS2M:
172                 fprintf(stdout, "OS/2-std:");
173                 break;
174         case OS_OS2L:
175                 fprintf(stdout, "OS/2-LADDR:");
176                 break;
177         case OS_OS22x:
178                 fprintf(stdout, "OS/2-2.x:");
179                 break;
180         case OS_NW286:
181                 fprintf(stdout, "NetWare-286:");
182                 break;
183         case OS_NW386:
184                 fprintf(stdout, "NetWare-386:");
185                 break;
186         case OS_GEN_UNIX:
187                 fprintf(stdout, "Unix:");
188                 break;
189         case OS_SCO_UNIX:
190                 fprintf(stdout, "SCO Unix:");
191                 break;
192         case OS_ATT_UNIX:
193                 fprintf(stdout, "AT&T Unix:");
194                 break;
195         case OS_UNIXWARE:
196                 fprintf(stdout, "UnixWare:");
197                 break;
198         case OS_INT_UNIX:
199                 fprintf(stdout, "IAC Unix:");
200                 break;
201         case OS_SOLARIS:
202                 fprintf(stdout, "Solaris:");
203                 break;
204         case OS_QNX:
205                 fprintf(stdout, "Qnx:");
206                 break;
207         case OS_NEXTSTEP:
208                 fprintf(stdout, "NextStep:");
209                 break;
210         case OS_BANYAN:
211                 fprintf(stdout, "Banyan:");
212                 break;
213         case OS_OLIVETTI_UNIX:
214                 fprintf(stdout, "Olivetti Unix:");
215                 break;
216         case OS_FREEBSD:
217                 fprintf(stdout, "FreeBSD:");
218                 break;
219         case OS_OTHER:
220                 fprintf(stdout, "Other (%d):", sysinfo.osType);
221                 break;
222         default:
223                 fprintf(stdout, "Unknown (%d):", sysinfo.osType);
224         }
225
226         fprintf(stdout, "%d.%d.%d.%d:", sysinfo.osMajorVersion,
227                 sysinfo.osMinorVersion, sysinfo.osRevision,
228                 sysinfo.osSubRevision);
229
230         switch (sysinfo.busType) {
231         case HBA_BUS_ISA:
232                 fprintf(stdout, "ISA:");
233                 break;
234         case HBA_BUS_EISA:
235                 fprintf(stdout, "EISA:");
236                 break;
237         case HBA_BUS_PCI:
238                 fprintf(stdout, "PCI:");
239                 break;
240         default:
241                 fprintf(stdout, "Unknown (%d):", sysinfo.busType);
242         }
243
244         for (ndx = 0; ndx < 16; ndx++) {
245                 if (sysinfo.drives[ndx].cylinders == 0)
246                         continue;
247                 fprintf(stdout, "d%dc%dh%ds%d:", ndx,
248                         sysinfo.drives[ndx].cylinders,
249                         sysinfo.drives[ndx].heads,
250                         sysinfo.drives[ndx].sectors);
251         }
252
253         fprintf(stdout, "\n");
254
255     return(0);
256 }