Lines 31-37
Link Here
|
31 |
*/ |
31 |
*/ |
32 |
|
32 |
|
33 |
#include <sys/cdefs.h> |
33 |
#include <sys/cdefs.h> |
34 |
__FBSDID("$FreeBSD: projects/doscmd/tty.c,v 1.25 2002/04/12 21:18:05 charnier Exp $"); |
34 |
__FBSDID("$FreeBSD: src/usr.bin/doscmd/tty.c,v 1.8.2.2 2002/04/25 11:04:51 tg Exp $"); |
35 |
|
35 |
|
36 |
#include <sys/ioctl.h> |
36 |
#include <sys/ioctl.h> |
37 |
#include <sys/time.h> |
37 |
#include <sys/time.h> |
Lines 124-145
Link Here
|
124 |
|
124 |
|
125 |
#define row (CursRow0) |
125 |
#define row (CursRow0) |
126 |
#define col (CursCol0) |
126 |
#define col (CursCol0) |
|
|
127 |
#define BIOSrow (BIOS_CursRow0) |
128 |
#define BIOScol (BIOS_CursCol0) |
129 |
|
127 |
|
130 |
|
128 |
/* Local functions */ |
131 |
/* Local functions */ |
129 |
static void _kbd_event(int, int, void *, regcontext_t *); |
132 |
static void _kbd_event(int, int, void *, regcontext_t *); |
130 |
static void Failure(void *); |
133 |
static void Failure(void *); |
131 |
static void SetVREGCur(void); |
134 |
static void SetVREGCur(void); |
132 |
#ifndef NO_X |
|
|
133 |
static void debug_event(int, int, void *, regcontext_t *); |
135 |
static void debug_event(int, int, void *, regcontext_t *); |
134 |
#endif |
|
|
135 |
static unsigned char inb_port60(int); |
136 |
static unsigned char inb_port60(int); |
136 |
static int inrange(int, int, int); |
137 |
static int inrange(int, int, int); |
137 |
#ifndef NO_X |
|
|
138 |
static void kbd_event(int, int, void *, regcontext_t *); |
138 |
static void kbd_event(int, int, void *, regcontext_t *); |
139 |
static u_short read_raw_kbd(int, u_short *); |
139 |
static u_short read_raw_kbd(int, u_short *); |
140 |
static void setgc(u_short); |
140 |
static void setgc(u_short); |
141 |
static void video_async_event(int, int, void *, regcontext_t *); |
141 |
static void video_async_event(int, int, void *, regcontext_t *); |
142 |
#endif |
|
|
143 |
|
142 |
|
144 |
#ifndef NO_X |
143 |
#ifndef NO_X |
145 |
static void dac2rgb(XColor *, int); |
144 |
static void dac2rgb(XColor *, int); |
Lines 197-204
Link Here
|
197 |
#define K4_SLOCK_LED 0x01 |
196 |
#define K4_SLOCK_LED 0x01 |
198 |
#define K4_NLOCK_LED 0x02 |
197 |
#define K4_NLOCK_LED 0x02 |
199 |
#define K4_CLOCK_LED 0x04 |
198 |
#define K4_CLOCK_LED 0x04 |
200 |
#define K4_ACK 0x10 /* ACK received from keyboard */ |
199 |
#define K4_ACK 0x10 /* ACK recieved from keyboard */ |
201 |
#define K4_RESEND 0x20 /* RESEND received from keyboard */ |
200 |
#define K4_RESEND 0x20 /* RESEND recieved from keyboard */ |
202 |
#define K4_LED 0x40 /* LED update in progress */ |
201 |
#define K4_LED 0x40 /* LED update in progress */ |
203 |
#define K4_ERROR 0x80 |
202 |
#define K4_ERROR 0x80 |
204 |
|
203 |
|
Lines 329-335
Link Here
|
329 |
} |
328 |
} |
330 |
|
329 |
|
331 |
void |
330 |
void |
332 |
video_setborder(int color __unused) |
331 |
video_setborder(int color) |
333 |
{ |
332 |
{ |
334 |
#ifndef NO_X |
333 |
#ifndef NO_X |
335 |
XSetWindowBackground(dpy, win, pixels[color & 0xf]); |
334 |
XSetWindowBackground(dpy, win, pixels[color & 0xf]); |
Lines 341-350
Link Here
|
341 |
blink = mode; |
340 |
blink = mode; |
342 |
} |
341 |
} |
343 |
|
342 |
|
344 |
#ifndef NO_X |
|
|
345 |
static void |
343 |
static void |
346 |
setgc(u_short attr) |
344 |
setgc(u_short attr) |
347 |
{ |
345 |
{ |
|
|
346 |
#ifndef NO_X |
348 |
XGCValues v; |
347 |
XGCValues v; |
349 |
if (blink && !show && (attr & 0x8000)) |
348 |
if (blink && !show && (attr & 0x8000)) |
350 |
v.foreground = pixels[(attr >> 12) & 0x07]; |
349 |
v.foreground = pixels[(attr >> 12) & 0x07]; |
Lines 353-360
Link Here
|
353 |
|
352 |
|
354 |
v.background = pixels[(attr >> 12) & (blink ? 0x07 : 0x0f)]; |
353 |
v.background = pixels[(attr >> 12) & (blink ? 0x07 : 0x0f)]; |
355 |
XChangeGC(dpy, gc, GCForeground|GCBackground, &v); |
354 |
XChangeGC(dpy, gc, GCForeground|GCBackground, &v); |
356 |
} |
|
|
357 |
#endif |
355 |
#endif |
|
|
356 |
} |
358 |
|
357 |
|
359 |
void |
358 |
void |
360 |
video_update(regcontext_t *REGS __unused) |
359 |
video_update(regcontext_t *REGS __unused) |
Lines 535-540
Link Here
|
535 |
|
534 |
|
536 |
return; |
535 |
return; |
537 |
} |
536 |
} |
|
|
537 |
#endif |
538 |
|
538 |
|
539 |
static u_short Ascii2Scan[] = { |
539 |
static u_short Ascii2Scan[] = { |
540 |
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, |
540 |
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, |
Lines 554-560
Link Here
|
554 |
0x0019, 0x0010, 0x0013, 0x001f, 0x0014, 0x0016, 0x002f, 0x0011, |
554 |
0x0019, 0x0010, 0x0013, 0x001f, 0x0014, 0x0016, 0x002f, 0x0011, |
555 |
0x002d, 0x0015, 0x002c, 0x011a, 0x012b, 0x011b, 0x0129, 0xffff, |
555 |
0x002d, 0x0015, 0x002c, 0x011a, 0x012b, 0x011b, 0x0129, 0xffff, |
556 |
}; |
556 |
}; |
557 |
#endif |
|
|
558 |
|
557 |
|
559 |
struct { |
558 |
struct { |
560 |
u_short base; |
559 |
u_short base; |
Lines 653-661
Link Here
|
653 |
{ 0x8600, 0x5888, 0x8a00, 0x8c00 }, /* key 88 - F12 */ |
652 |
{ 0x8600, 0x5888, 0x8a00, 0x8c00 }, /* key 88 - F12 */ |
654 |
}; |
653 |
}; |
655 |
|
654 |
|
656 |
#ifndef NO_X |
|
|
657 |
void |
655 |
void |
658 |
debug_event(int fd __unused, int cond, void *arg __unused, regcontext_t *REGS) |
656 |
debug_event(int fd, int cond, void *arg, regcontext_t *REGS) |
659 |
{ |
657 |
{ |
660 |
static char ibuf[1024]; |
658 |
static char ibuf[1024]; |
661 |
static int icnt = 0; |
659 |
static int icnt = 0; |
Lines 667-674
Link Here
|
667 |
|
665 |
|
668 |
if (!(cond & AS_RD)) |
666 |
if (!(cond & AS_RD)) |
669 |
return; |
667 |
return; |
670 |
|
668 |
if(!doormode) |
671 |
r = read(STDIN_FILENO, ibuf + icnt, sizeof(ibuf) - icnt); |
669 |
r = read(STDIN_FILENO, ibuf + icnt, sizeof(ibuf) - icnt); |
672 |
if (r <= 0) |
670 |
if (r <= 0) |
673 |
return; |
671 |
return; |
674 |
|
672 |
|
Lines 773-779
Link Here
|
773 |
ibuf[icnt] = 0; |
771 |
ibuf[icnt] = 0; |
774 |
} |
772 |
} |
775 |
} |
773 |
} |
776 |
#endif |
|
|
777 |
|
774 |
|
778 |
unsigned char |
775 |
unsigned char |
779 |
inb_port60(int port __unused) |
776 |
inb_port60(int port __unused) |
Lines 784-792
Link Here
|
784 |
return(r); |
781 |
return(r); |
785 |
} |
782 |
} |
786 |
|
783 |
|
787 |
#ifndef NO_X |
|
|
788 |
void |
784 |
void |
789 |
kbd_event(int fd, int cond, void *arg __unused, regcontext_t *REGS __unused) |
785 |
kbd_event(int fd, int cond, void *arg, regcontext_t *REGS) |
790 |
{ |
786 |
{ |
791 |
if (!(cond & AS_RD)) |
787 |
if (!(cond & AS_RD)) |
792 |
return; |
788 |
return; |
Lines 797-803
Link Here
|
797 |
if ((break_code = read_raw_kbd(fd, &scan_code)) != 0xffff) |
793 |
if ((break_code = read_raw_kbd(fd, &scan_code)) != 0xffff) |
798 |
hardint(0x01); |
794 |
hardint(0x01); |
799 |
} |
795 |
} |
800 |
#endif |
|
|
801 |
|
796 |
|
802 |
void |
797 |
void |
803 |
int09(REGISTERS __unused) |
798 |
int09(REGISTERS __unused) |
Lines 815-821
Link Here
|
815 |
send_eoi(); |
810 |
send_eoi(); |
816 |
} |
811 |
} |
817 |
|
812 |
|
818 |
#ifndef NO_X |
|
|
819 |
u_short |
813 |
u_short |
820 |
read_raw_kbd(int fd, u_short *code) |
814 |
read_raw_kbd(int fd, u_short *code) |
821 |
{ |
815 |
{ |
Lines 987-998
Link Here
|
987 |
return(0xffff); |
981 |
return(0xffff); |
988 |
} |
982 |
} |
989 |
} |
983 |
} |
990 |
#endif |
|
|
991 |
|
984 |
|
992 |
#ifndef NO_X |
|
|
993 |
void |
985 |
void |
994 |
video_async_event(int fd, int cond, void *arg __unused, regcontext_t *REGS __unused) |
986 |
video_async_event(int fd, int cond, void *arg, regcontext_t *REGS) |
995 |
{ |
987 |
{ |
|
|
988 |
#ifndef NO_X |
996 |
int int9 = 0; |
989 |
int int9 = 0; |
997 |
|
990 |
|
998 |
if (!(cond & AS_RD)) |
991 |
if (!(cond & AS_RD)) |
Lines 1042-1049
Link Here
|
1042 |
break; |
1035 |
break; |
1043 |
} |
1036 |
} |
1044 |
} |
1037 |
} |
1045 |
} |
|
|
1046 |
#endif |
1038 |
#endif |
|
|
1039 |
} |
1047 |
|
1040 |
|
1048 |
#ifndef NO_X |
1041 |
#ifndef NO_X |
1049 |
static int |
1042 |
static int |
Lines 1427-1433
Link Here
|
1427 |
tty_move(int r, int c) |
1420 |
tty_move(int r, int c) |
1428 |
{ |
1421 |
{ |
1429 |
row = r; |
1422 |
row = r; |
|
|
1423 |
BIOSrow=r; |
1430 |
col = c; |
1424 |
col = c; |
|
|
1425 |
BIOScol=c; |
1431 |
SetVREGCur(); |
1426 |
SetVREGCur(); |
1432 |
} |
1427 |
} |
1433 |
|
1428 |
|
Lines 1449-1458
Link Here
|
1449 |
{ |
1444 |
{ |
1450 |
int i; |
1445 |
int i; |
1451 |
|
1446 |
|
1452 |
if (row > (height - 1)) |
1447 |
if (row > (height - 1)) { |
1453 |
row = 0; |
1448 |
row = 0; |
|
|
1449 |
BIOSrow=0; |
1450 |
} |
1454 |
else if (++row >= height) { |
1451 |
else if (++row >= height) { |
1455 |
row = height - 1; |
1452 |
row = height - 1; |
|
|
1453 |
BIOSrow = height = 1; |
1456 |
if (scroll) { |
1454 |
if (scroll) { |
1457 |
memcpy(vmem, &vmem[width], 2 * width * (height - 1)); |
1455 |
memcpy(vmem, &vmem[width], 2 * width * (height - 1)); |
1458 |
for (i = 0; i < width; ++i) |
1456 |
for (i = 0; i < width; ++i) |
Lines 1494-1509
Link Here
|
1494 |
vmem[row * width + col] &= 0xff00; |
1492 |
vmem[row * width + col] &= 0xff00; |
1495 |
break; |
1493 |
break; |
1496 |
case '\t': |
1494 |
case '\t': |
1497 |
if (row > (height - 1)) |
1495 |
if (row > (height - 1)) { |
1498 |
row = 0; |
1496 |
row = 0; |
|
|
1497 |
BIOSrow = 0; |
1498 |
} |
1499 |
col = (col + 8) & ~0x07; |
1499 |
col = (col + 8) & ~0x07; |
|
|
1500 |
BIOScol = col; |
1500 |
if (col > width) { |
1501 |
if (col > width) { |
1501 |
col = 0; |
1502 |
col = 0; |
|
|
1503 |
BIOScol = 0; |
1502 |
tty_index(1); |
1504 |
tty_index(1); |
1503 |
} |
1505 |
} |
1504 |
break; |
1506 |
break; |
1505 |
case '\r': |
1507 |
case '\r': |
1506 |
col = 0; |
1508 |
col = 0; |
|
|
1509 |
BIOScol = 0; |
1507 |
break; |
1510 |
break; |
1508 |
case '\n': |
1511 |
case '\n': |
1509 |
tty_index(1); |
1512 |
tty_index(1); |
Lines 1511-1520
Link Here
|
1511 |
default: |
1514 |
default: |
1512 |
if (col >= width) { |
1515 |
if (col >= width) { |
1513 |
col = 0; |
1516 |
col = 0; |
|
|
1517 |
BIOScol = 0; |
1514 |
tty_index(1); |
1518 |
tty_index(1); |
1515 |
} |
1519 |
} |
1516 |
if (row > (height - 1)) |
1520 |
if (row > (height - 1)) { |
1517 |
row = 0; |
1521 |
row = 0; |
|
|
1522 |
BIOSrow = 0; |
1523 |
} |
1518 |
if (attr >= 0) |
1524 |
if (attr >= 0) |
1519 |
vmem[row * width + col] = attr & 0xff00; |
1525 |
vmem[row * width + col] = attr & 0xff00; |
1520 |
else |
1526 |
else |
Lines 1543-1552
Link Here
|
1543 |
while (n--) { |
1549 |
while (n--) { |
1544 |
if (col >= width) { |
1550 |
if (col >= width) { |
1545 |
col = 0; |
1551 |
col = 0; |
|
|
1552 |
BIOScol = 0; |
1546 |
tty_index(0); |
1553 |
tty_index(0); |
1547 |
} |
1554 |
} |
1548 |
if (row > (height - 1)) |
1555 |
if (row > (height - 1)) { |
1549 |
row = 0; |
1556 |
row = 0; |
|
|
1557 |
BIOSrow = 0; |
1558 |
} |
1550 |
if (attr >= 0) |
1559 |
if (attr >= 0) |
1551 |
vmem[row * width + col] = attr & 0xff00; |
1560 |
vmem[row * width + col] = attr & 0xff00; |
1552 |
else |
1561 |
else |
Lines 1554-1560
Link Here
|
1554 |
vmem[row * width + col++] |= c; |
1563 |
vmem[row * width + col++] |= c; |
1555 |
} |
1564 |
} |
1556 |
row = srow; |
1565 |
row = srow; |
|
|
1566 |
BIOSrow = srow; |
1557 |
col = scol; |
1567 |
col = scol; |
|
|
1568 |
BIOScol = scol; |
1558 |
SetVREGCur(); |
1569 |
SetVREGCur(); |
1559 |
} |
1570 |
} |
1560 |
|
1571 |
|
Lines 1574-1588
Link Here
|
1574 |
while (n--) { |
1585 |
while (n--) { |
1575 |
if (col >= wd) { |
1586 |
if (col >= wd) { |
1576 |
col = 0; |
1587 |
col = 0; |
|
|
1588 |
BIOScol = 0; |
1577 |
/* tty_index(0); *//* scroll up if last line is filled */ |
1589 |
/* tty_index(0); *//* scroll up if last line is filled */ |
1578 |
} |
1590 |
} |
1579 |
if (row > (ht - 1)) |
1591 |
if (row > (ht - 1)) { |
1580 |
row = 0; |
1592 |
row = 0; |
|
|
1593 |
BIOSrow = 0; |
1594 |
} |
1581 |
putchar_graphics(row * wd * CharHeight + col, c, attr); |
1595 |
putchar_graphics(row * wd * CharHeight + col, c, attr); |
1582 |
col++; |
1596 |
col++; |
1583 |
} |
1597 |
} |
1584 |
row = srow; |
1598 |
row = srow; |
|
|
1599 |
BIOSrow = 0; |
1585 |
col = scol; |
1600 |
col = scol; |
|
|
1601 |
BIOScol = scol; |
1586 |
SetVREGCur(); |
1602 |
SetVREGCur(); |
1587 |
|
1603 |
|
1588 |
return; |
1604 |
return; |
Lines 1641-1646
Link Here
|
1641 |
{ |
1657 |
{ |
1642 |
int r; |
1658 |
int r; |
1643 |
|
1659 |
|
|
|
1660 |
if(doormode) |
1661 |
return(0); |
1644 |
if ((r = nextchar) != 0) { |
1662 |
if ((r = nextchar) != 0) { |
1645 |
nextchar = 0; |
1663 |
nextchar = 0; |
1646 |
return(r & 0xff); |
1664 |
return(r & 0xff); |
Lines 1648-1654
Link Here
|
1648 |
|
1666 |
|
1649 |
if ((flag & TTYF_REDIRECT) && redirect0) { |
1667 |
if ((flag & TTYF_REDIRECT) && redirect0) { |
1650 |
char c; |
1668 |
char c; |
1651 |
if (read(STDIN_FILENO, &c, 1) != 1) |
1669 |
if (! doormode && read(STDIN_FILENO, &c, 1) != 1) |
1652 |
return(-1); |
1670 |
return(-1); |
1653 |
if (c == '\n') |
1671 |
if (c == '\n') |
1654 |
c = '\r'; |
1672 |
c = '\r'; |
Lines 2041-2047
Link Here
|
2041 |
font = XLoadQueryFont(dpy, FONTVGA); |
2059 |
font = XLoadQueryFont(dpy, FONTVGA); |
2042 |
|
2060 |
|
2043 |
if (font == NULL) |
2061 |
if (font == NULL) |
2044 |
err(1, "Could not open font ``%s''\n", xfont); |
2062 |
// err(1, "Could not open font ``%s''\n", xfont); |
|
|
2063 |
font = XLoadQueryFont(dpy, "fixed"); |
2045 |
|
2064 |
|
2046 |
gcv.font = font->fid; |
2065 |
gcv.font = font->fid; |
2047 |
XChangeGC(dpy, gc, GCFont, &gcv); |
2066 |
XChangeGC(dpy, gc, GCFont, &gcv); |