]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/MAI/bios_emulator/scitech/src/v86bios/console.c
2 * Copyright 1999 Egbert Eich
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the authors not be used in
9 * advertising or publicity pertaining to distribution of the software without
10 * specific, written prior permission. The authors makes no representations
11 * about the suitability of this software for any purpose. It is provided
12 * "as is" without express or implied warranty.
14 * THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20 * PERFORMANCE OF THIS SOFTWARE.
22 #include <sys/ioctl.h>
37 console Con
= {-1,-1};
43 if ((fd
= open("/dev/tty0",O_WRONLY
,0)) < 0)
46 if ((ioctl(fd
, VT_OPENQRY
, &VTno
) < 0) || (VTno
== -1)) {
47 fprintf(stderr
,"cannot get a vt\n");
52 sprintf(VTname
,"/dev/tty%i",VTno
);
54 if ((fd
= open(VTname
, O_RDWR
|O_NDELAY
, 0)) < 0) {
55 fprintf(stderr
,"cannot open console\n");
59 if (ioctl(fd
, VT_GETSTATE
, &vts
) == 0)
60 Con
.vt
= vts
.v_active
;
62 if (ioctl(fd
, VT_ACTIVATE
, VTno
) != 0) {
63 fprintf(stderr
,"cannot activate console\n");
67 if (ioctl(fd
, VT_WAITACTIVE
, VTno
) != 0) {
68 fprintf(stderr
,"wait for active console failed\n");
73 if (ioctl(fd
, KDSETMODE
, KD_GRAPHICS
) < 0) {
83 close_console(console Con
)
89 ioctl(Con
.fd
, KDSETMODE
, KD_TEXT
);
92 ioctl(Con
.fd
, VT_ACTIVATE
, Con
.vt
);