entries_pageable set TRUE for buffer map (set vm_map.c change).
[unix-history] / usr / src / sys / i386 / stand / cga.c
CommitLineData
11b2c0e9 1/*-
2ae79493
KB
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
11b2c0e9
WN
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
6837e0f1 8 * %sccs.include.redist.c%
11b2c0e9 9 *
2ae79493 10 * @(#)cga.c 8.1 (Berkeley) %G%
11b2c0e9
WN
11 */
12
38a01dbe 13#include <sys/param.h>
11b2c0e9 14
11b2c0e9
WN
15#define COL 80
16#define ROW 25
17#define CHR 2
fd277b5d
WN
18#define MONO_BASE 0x3B4
19#define MONO_BUF 0xB0000
20#define CGA_BASE 0x3D4
21#define CGA_BUF 0xB8000
11b2c0e9 22
fd277b5d
WN
23static u_char att = 0x7 ;
24u_char *Crtat = (u_char *)CGA_BUF;
11b2c0e9 25
fd277b5d
WN
26static unsigned int addr_6845 = CGA_BASE;
27cursor(pos)
28int pos;
29{
30 outb(addr_6845,14);
31 outb(addr_6845+1,pos >> 8);
32 outb(addr_6845,15);
33 outb(addr_6845+1,pos&0xff);
34}
35
36sput(c)
37u_char c;
38{
39
40 static u_char *crtat = 0;
41 unsigned cursorat; u_short was;
42 u_char *cp;
11b2c0e9
WN
43
44 if (crtat == 0) {
fd277b5d
WN
45
46 /* XXX probe to find if a color or monochrome display */
47 was = *(u_short *)Crtat;
48 *(u_short *)Crtat = 0xA55A;
49 if (*(u_short *)Crtat != 0xA55A) {
50 Crtat = (u_char *) MONO_BUF;
51 addr_6845 = MONO_BASE;
52 }
53 *(u_short *)Crtat = was;
54
55 /* Extract cursor location */
56 outb(addr_6845,14);
57 cursorat = inb(addr_6845+1)<<8 ;
58 outb(addr_6845,15);
59 cursorat |= inb(addr_6845+1);
60
61 if(cursorat <= COL*ROW) {
62 crtat = Crtat + cursorat*CHR;
63 att = crtat[1]; /* use current attribute present */
64 } else crtat = Crtat;
65
66 /* clean display */
67 for (cp = crtat; cp < Crtat+ROW*COL*CHR; cp += 2) {
68 cp[0] = ' ';
69 cp[1] = att;
70 }
11b2c0e9 71 }
fd277b5d
WN
72
73 switch (c) {
11b2c0e9
WN
74
75 case '\t':
fd277b5d
WN
76 do
77 sput(' ');
78 while ((int)crtat % (8*CHR));
11b2c0e9
WN
79 break;
80
81 case '\010':
fd277b5d 82 crtat -= CHR;
11b2c0e9
WN
83 break;
84
85 case '\r':
fd277b5d 86 crtat -= (crtat - Crtat) % (COL*CHR);
11b2c0e9
WN
87 break;
88
89 case '\n':
fd277b5d 90 crtat += COL*CHR ;
11b2c0e9
WN
91 break;
92
93 default:
fd277b5d
WN
94 crtat[0] = c;
95 crtat[1] = att;
96 crtat += CHR;
11b2c0e9
WN
97 break ;
98 }
fd277b5d
WN
99
100#ifndef SMALL
101 /* implement a scroll */
102 if (crtat >= Crtat+COL*ROW*CHR) {
103 /* move text up */
104 bcopy(Crtat+COL*CHR, Crtat, COL*(ROW-1)*CHR);
105
106 /* clear line */
107 for (cp = Crtat+ COL*(ROW-1)*CHR;
108 cp < Crtat + COL*ROW*CHR ; cp += 2)
109 cp[0] = ' ';
110
111 crtat -= COL*CHR ;
112 }
113#endif
114
115 cursor((crtat-Crtat)/CHR);
11b2c0e9 116}