Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / usr.sbin / pcvt / ispcvt / ispcvt.c
1 /*
2  * Copyright (c) 1992, 1995 Hellmuth Michaelis
3  *
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
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. All advertising materials mentioning features or use of this software
15  *    must display the following acknowledgement:
16  *      This product includes software developed by Hellmuth Michaelis
17  * 4. The name authors may not be used to endorse or promote products
18  *    derived from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
21  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
22  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
29  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30  *
31  * $FreeBSD: src/usr.sbin/pcvt/ispcvt/ispcvt.c,v 1.7.6.1 2001/05/12 10:11:41 kris Exp $
32  * $DragonFly: src/usr.sbin/pcvt/ispcvt/Attic/ispcvt.c,v 1.2 2003/06/17 04:29:59 dillon Exp $
33  */
34
35 static char *id =
36         "@(#)ispcvt.c, 3.20, Last Edit-Date: [Wed Apr  5 17:53:28 1995]";
37
38 /*---------------------------------------------------------------------------*
39  *
40  *      history:
41  *
42  *      -hm     upgraded to report pcvt compile time configuration
43  *      -hm     PCVT_INHIBIT_NUMLOCK patch from Joerg
44  *      -hm     PCVT_META_ESC patch from Joerg
45  *      -hm     PCVT_PCBURST
46  *      -hm     new ioctl VGAPCVTINFO
47  *      -hm     new CONF_ values for 3.10
48  *      -hm     new CONF_ values for 3.20
49  *      -hm     removed PCVT_FAKE_SYSCONS10
50  *      -hm     added PCVT_PORTIO_DELAY
51  *      -hm     removed PCVT_386BSD
52  *      -hm     add -d option to specify a device
53  *      -hm     PCVT_XSERVER -> XSERVER
54  *
55  *---------------------------------------------------------------------------*/
56
57 #include <stdio.h>
58 #include <err.h>
59 #include <fcntl.h>
60 #include <machine/pcvt_ioctl.h>
61
62 #define DEFAULTFD 0
63
64 main(argc,argv)
65 int argc;
66 char *argv[];
67 {
68         extern int optind;
69         extern int opterr;
70         extern char *optarg;
71
72         struct pcvtid pcvtid;
73         struct pcvtinfo pcvtinfo;
74         int c;
75         char *p;
76         int verbose = 0;
77         int config = 0;
78         int dflag = 0;
79         int fd;
80         char *device;
81
82         while( (c = getopt(argc, argv, "vcd:")) != -1)
83         {
84                 switch(c)
85                 {
86                         case 'v':
87                                 verbose = 1;
88                                 break;
89
90                         case 'c':
91                                 config = 1;
92                                 break;
93
94                         case 'd':
95                                 device = optarg;
96                                 dflag = 1;
97                                 break;
98
99                         case '?':
100                         default:
101                                 usage();
102                                 break;
103                 }
104         }
105
106         if(dflag)
107         {
108                 if((fd = open(device, O_RDWR)) == -1)
109                 {
110                         if(verbose)
111                                 warn("ERROR opening %s", device);
112                         exit(1);
113                 }
114         }
115         else
116         {
117                 fd = DEFAULTFD;
118         }
119
120         if(ioctl(fd, VGAPCVTID, &pcvtid) == -1)
121         {
122                 if(verbose)
123                         warn("ioctl VGAPCVTID failed, error");
124                 exit(1);
125         }
126
127         if(!strcmp(pcvtid.name, PCVTIDNAME))
128         {
129                 if(pcvtid.rmajor == PCVTIDMAJOR)
130                 {
131                         if(pcvtid.rminor != PCVTIDMINOR)
132                         {
133                                 if(verbose)
134                                         warnx("minor revision: expected %d, got %d", PCVTIDMINOR, pcvtid.rminor);
135                                 exit(4);        /* minor revision mismatch */
136                         }
137                 }
138                 else
139                 {
140                         if(verbose)
141                                 warnx("major revision: expected %d, got %d", PCVTIDMAJOR, pcvtid.rmajor);
142                         exit(3);        /* major revision mismatch */
143                 }
144         }
145         else
146         {
147                 if(verbose)
148                         warnx("name check: expected %s, got %s", PCVTIDNAME, pcvtid.name);
149                 exit(2);        /* name mismatch */
150         }
151
152         if(verbose)
153         {
154                 warnx("\nkernel and utils match, driver name [%s], release [%1.1d.%02.2d]\n",
155                           pcvtid.name, pcvtid.rmajor, pcvtid.rminor);
156         }
157
158         if(config == 0)
159                 exit(0);
160
161         if(ioctl(fd, VGAPCVTINFO, &pcvtinfo) == -1)
162         {
163                 if(verbose)
164                         warn("ioctl VGAPCVTINFO failed, error");
165                 exit(1);
166         }
167
168         if(verbose)
169         {
170                 switch(pcvtinfo.opsys)
171                 {
172                         case CONF_NETBSD:
173                                 p = "PCVT_NETBSD";
174                                 break;
175
176                         case CONF_FREEBSD:
177                                 p = "PCVT_FREEBSD";
178                                 break;
179
180                         default:
181                         case CONF_UNKNOWNOPSYS:
182                                 p = "UNKNOWN";
183                                 break;
184
185                 }
186                 fprintf(stderr,"Operating System     = %s\t", p);
187                 fprintf(stderr,"OS Release Id        = %u\n", pcvtinfo.opsysrel);
188                 fprintf(stderr,"PCVT_NSCREENS        = %u\t\t", pcvtinfo.nscreens);
189                 fprintf(stderr,"PCVT_UPDATEFAST      = %u\n", pcvtinfo.updatefast);
190                 fprintf(stderr,"PCVT_UPDATESLOW      = %u\t\t", pcvtinfo.updateslow);
191                 fprintf(stderr,"PCVT_SYSBEEPF        = %u\n", pcvtinfo.sysbeepf);
192                 fprintf(stderr,"PCVT_PCBURST         = %u\t\t", pcvtinfo.pcburst);
193                 fprintf(stderr,"PCVT_KBD_FIFO_SZ     = %u\n\n", pcvtinfo.kbd_fifo_sz);
194
195         /* config booleans */
196
197                 fprintf(stderr,"PCVT_132GENERIC      = %s",
198                         (pcvtinfo.compile_opts & CONF_132GENERIC) ? "ON" : "OFF");
199                 next();
200                 fprintf(stderr,"PCVT_24LINESDEF      = %s",
201                         (pcvtinfo.compile_opts & CONF_24LINESDEF) ? "ON" : "OFF");
202                 next();
203                 fprintf(stderr,"PCVT_BACKUP_FONTS    = %s",
204                         (pcvtinfo.compile_opts & CONF_BACKUP_FONTS) ? "ON" : "OFF");
205                 next();
206                 fprintf(stderr,"PCVT_CTRL_ALT_DEL    = %s",
207                         (pcvtinfo.compile_opts & CONF_CTRL_ALT_DEL) ? "ON" : "OFF");
208                 next();
209                 fprintf(stderr,"PCVT_EMU_MOUSE       = %s",
210                         (pcvtinfo.compile_opts & CONF_EMU_MOUSE) ? "ON" : "OFF");
211                 next();
212                 fprintf(stderr,"PCVT_INHIBIT_NUMLOCK = %s",
213                         (pcvtinfo.compile_opts & CONF_INHIBIT_NUMLOCK) ? "ON" : "OFF");
214                 next();
215                 fprintf(stderr,"PCVT_KEYBDID         = %s",
216                         (pcvtinfo.compile_opts & CONF_KEYBDID) ? "ON" : "OFF");
217                 next();
218                 fprintf(stderr,"PCVT_KBD_FIFO        = %s",
219                         (pcvtinfo.compile_opts & CONF_KBD_FIFO) ? "ON" : "OFF");
220                 next();
221                 fprintf(stderr,"PCVT_META_ESC        = %s",
222                         (pcvtinfo.compile_opts & CONF_META_ESC) ? "ON" : "OFF");
223                 next();
224                 fprintf(stderr,"PCVT_NOFASTSCROLL    = %s",
225                         (pcvtinfo.compile_opts & CONF_NOFASTSCROLL) ? "ON" : "OFF");
226                 next();
227                 fprintf(stderr,"PCVT_NO_LED_UPDATE   = %s",
228                         (pcvtinfo.compile_opts & CONF_NO_LED_UPDATE) ? "ON" : "OFF");
229                 next();
230                 fprintf(stderr,"PCVT_NULLCHARS       = %s",
231                         (pcvtinfo.compile_opts & CONF_NULLCHARS) ? "ON" : "OFF");
232                 next();
233                 fprintf(stderr,"PCVT_PALFLICKER      = %s",
234                         (pcvtinfo.compile_opts & CONF_PALFLICKER) ? "ON" : "OFF");
235                 next();
236                 fprintf(stderr,"PCVT_PORTIO_DELAY    = %s",
237                         (pcvtinfo.compile_opts & CONF_PORTIO_DELAY) ? "ON" : "OFF");
238                 next();
239                 fprintf(stderr,"PCVT_PRETTYSCRNS     = %s",
240                         (pcvtinfo.compile_opts & CONF_PRETTYSCRNS) ? "ON" : "OFF");
241                 next();
242                 fprintf(stderr,"PCVT_SCREENSAVER     = %s",
243                         (pcvtinfo.compile_opts & CONF_SCREENSAVER) ? "ON" : "OFF");
244                 next();
245                 fprintf(stderr,"PCVT_SETCOLOR        = %s",
246                         (pcvtinfo.compile_opts & CONF_SETCOLOR) ? "ON" : "OFF");
247                 next();
248                 fprintf(stderr,"PCVT_SHOWKEYS        = %s",
249                         (pcvtinfo.compile_opts & CONF_SHOWKEYS) ? "ON" : "OFF");
250                 next();
251                 fprintf(stderr,"PCVT_SIGWINCH        = %s",
252                         (pcvtinfo.compile_opts & CONF_SIGWINCH) ? "ON" : "OFF");
253                 next();
254                 fprintf(stderr,"PCVT_SLOW_INTERRUPT  = %s",
255                         (pcvtinfo.compile_opts & CONF_SLOW_INTERRUPT) ? "ON" : "OFF");
256                 next();
257                 fprintf(stderr,"PCVT_SW0CNOUTP       = %s",
258                         (pcvtinfo.compile_opts & CONF_SW0CNOUTP) ? "ON" : "OFF");
259                 next();
260                 fprintf(stderr,"PCVT_USEKBDSEC       = %s",
261                         (pcvtinfo.compile_opts & CONF_USEKBDSEC) ? "ON" : "OFF");
262                 next();
263                 fprintf(stderr,"PCVT_USL_VT_COMPAT   = %s",
264                         (pcvtinfo.compile_opts & CONF_USL_VT_COMPAT) ? "ON" : "OFF");
265                 next();
266                 fprintf(stderr,"PCVT_VT220KEYB       = %s",
267                         ((u_int)pcvtinfo.compile_opts & (u_int)CONF_VT220KEYB) ? "ON" : "OFF");
268                 next();
269                 fprintf(stderr,"PCVT_WAITRETRACE     = %s",
270                         (pcvtinfo.compile_opts & CONF_WAITRETRACE) ? "ON" : "OFF");
271                 next();
272                 fprintf(stderr,"XSERVER              = %s",
273                         (pcvtinfo.compile_opts & CONF_XSERVER) ? "ON" : "OFF");
274
275                 fprintf(stderr,"\n\n");
276         }
277         else /* !verbose */
278         {
279                 fprintf(stderr,"BSD Version      = %u\n", pcvtinfo.opsys);
280                 fprintf(stderr,"PCVT_NSCREENS    = %u\n", pcvtinfo.nscreens);
281                 fprintf(stderr,"PCVT_UPDATEFAST  = %u\n", pcvtinfo.updatefast);
282                 fprintf(stderr,"PCVT_UPDATESLOW  = %u\n", pcvtinfo.updateslow);
283                 fprintf(stderr,"PCVT_SYSBEEPF    = %u\n", pcvtinfo.sysbeepf);
284                 fprintf(stderr,"Compile options  = 0x%08X\n", pcvtinfo.compile_opts);
285         }
286 }
287
288 usage()
289 {
290         fprintf(stderr,"\nispcvt - verify current video driver is the pcvt-driver\n");
291         fprintf(stderr,"  usage: ispcvt [-v] [-c] [-d device]\n");
292         fprintf(stderr,"options: -v         be verbose\n");
293         fprintf(stderr,"         -c         print compile time configuration\n");
294         fprintf(stderr,"         -d <name>  use devicefile <name> for verification\n\n");
295         exit(5);
296 }
297
298 next()
299 {
300         static int i = 0;
301
302         fprintf(stderr, "%s", (i == 0) ? "\t\t" : "\n");
303
304         i = ~i;
305 }
306
307 /* EOF */