2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * @OSF_FREE_COPYRIGHT@
27 * @APPLE_FREE_COPYRIGHT@
29 /* MACH PPC - video_console.c
31 * Original based on NetBSD's mac68k/dev/ite.c driver
33 * This driver differs in
35 * - Uses phys_copy and flush_cache to in several places
36 * for performance optimizations
38 * - Black background and white (character) foreground
39 * - Assumes 6100/7100/8100 class of machine
41 * The original header follows...
44 * NetBSD: ite.c,v 1.16 1995/07/17 01:24:34 briggs Exp
46 * Copyright (c) 1988 University of Utah.
47 * Copyright (c) 1990, 1993
48 * The Regents of the University of California. All rights reserved.
50 * This code is derived from software contributed to Berkeley by
51 * the Systems Programming Group of the University of Utah Computer
54 * Redistribution and use in source and binary forms, with or without
55 * modification, are permitted provided that the following conditions
57 * 1. Redistributions of source code must retain the above copyright
58 * notice, this list of conditions and the following disclaimer.
59 * 2. Redistributions in binary form must reproduce the above copyright
60 * notice, this list of conditions and the following disclaimer in the
61 * documentation and/or other materials provided with the distribution.
62 * 3. All advertising materials mentioning features or use of this software
63 * must display the following acknowledgement:
64 * This product includes software developed by the University of
65 * California, Berkeley and its contributors.
66 * 4. Neither the name of the University nor the names of its contributors
67 * may be used to endorse or promote products derived from this software
68 * without specific prior written permission.
70 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
71 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
72 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
73 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
74 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
75 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
76 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
77 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
78 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
79 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
82 * from: Utah $Hdr: ite.c 1.28 92/12/20$
84 * @(#)ite.c 8.2 (Berkeley) 1/12/94
90 * The ite module handles the system console; that is, stuff printed
91 * by the kernel and by user programs while "desktop" and X aren't
92 * running. Some (very small) parts are based on hp300's 4.4 ite.c,
93 * hence the above copyright.
95 * -- Brad and Lawrence, June 26th, 1994
99 #include <machine/machparam.h> /* spl definitions */
100 #include "iso_scan_font.h"
101 #include <pexpert/pexpert.h>
102 #include <pexpert/i386/boot.h>
103 #include <kern/time_out.h>
104 #include <kern/lock.h>
105 #include "video_console.h"
108 #define CHARHEIGHT 16
113 #define ATTR_REVERSE 4
116 ESnormal
, /* Nothing yet */
118 ESsquare
, /* Got ESC [ */
119 ESgetpars
, /* About to get or getting the parameters */
120 ESgotpars
, /* Finished getting the parameters */
121 ESfunckey
, /* Function key */
122 EShash
, /* DEC-specific stuff (screen align, etc.) */
123 ESsetG0
, /* Specify the G0 character set */
124 ESsetG1
, /* Specify the G1 character set */
127 ESignore
/* Ignore this sequence */
128 } vt100state
= ESnormal
;
130 static struct vc_info vinfo
;
131 #define IS_TEXT_MODE (vinfo.v_type == TEXT_MODE)
133 /* Calculated in vccninit(): */
134 static int vc_wrap_mode
= 1, vc_relative_origin
= 0;
135 static int vc_charset_select
= 0, vc_save_charset_s
= 0;
136 static int vc_charset
[2] = { 0, 0 };
137 static int vc_charset_save
[2] = { 0, 0 };
141 static int x
= 0, y
= 0, savex
, savey
;
142 static int par
[MAXPARS
], numpars
, hanging_cursor
, attr
, saveattr
;
144 /* VT100 tab stops & scroll region */
145 static char tab_stops
[255];
146 static int scrreg_top
, scrreg_bottom
;
149 void vc_flush_forward_buffer(void);
150 void vc_store_char(unsigned char);
153 * For the color support (Michel Pollet)
155 unsigned char vc_color_index_table
[33] =
156 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
157 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 };
159 unsigned long vc_color_depth_masks
[4] =
160 { 0x000000FF, 0x00007FFF, 0x00FFFFFF };
162 unsigned long vc_colors
[8][3] = {
163 { 0xFFFFFFFF, 0x00000000, 0x00000000 }, /* black */
164 { 0x23232323, 0x7C007C00, 0x00FF0000 }, /* red */
165 { 0xb9b9b9b9, 0x03e003e0, 0x0000FF00 }, /* green */
166 { 0x05050505, 0x7FE07FE0, 0x00FFFF00 }, /* yellow */
167 { 0xd2d2d2d2, 0x001f001f, 0x000000FF}, /* blue */
168 // { 0x80808080, 0x31933193, 0x00666699 }, /* blue */
169 { 0x18181818, 0x7C1F7C1F, 0x00FF00FF }, /* magenta */
170 { 0xb4b4b4b4, 0x03FF03FF, 0x0000FFFF }, /* cyan */
171 { 0x00000000, 0x7FFF7FFF, 0x00FFFFFF } /* white */
174 unsigned long vc_color_mask
= 0;
175 unsigned long vc_color_fore
= 0;
176 unsigned long vc_color_back
= 0;
177 int vc_normal_background
= 1;
180 * For the jump scroll and buffering (Michel Pollet)
181 * 80*22 means on a 80*24 screen, the screen will
182 * scroll jump almost a full screen
183 * keeping only what's necessary for you to be able to read ;-)
185 #define VC_MAX_FORWARD_SIZE (80*22)
188 * Delay between console updates in clock hz units, the larger the
189 * delay the fuller the jump-scroll buffer will be and so the faster the
190 * (scrolling) output. The smaller the delay, the less jerky the
191 * display. Heuristics show that at 10 touch-typists (Mike!) complain
193 #define VC_CONSOLE_UPDATE_TIMEOUT 5
195 static unsigned char vc_forward_buffer
[VC_MAX_FORWARD_SIZE
];
196 static long vc_forward_buffer_size
= 0;
197 decl_simple_lock_data(,vc_forward_lock
)
199 /* Set to 1 by initialize_screen() */
200 static int vc_initialized
= 0;
202 /* Function pointers initialized via initialize_screen() */
204 void (*initialize
)(struct vc_info
* vinfo_p
);
205 void (*paintchar
)(unsigned char c
, int x
, int y
, int attrs
);
206 void (*scrolldown
)(int num
);
207 void (*scrollup
)(int num
);
208 void (*clear_screen
)(int xx
, int yy
, int which
);
209 void (*show_cursor
)(int x
, int y
);
210 void (*hide_cursor
)(int x
, int y
);
211 void (*update_color
)(int color
, int fore
);
215 * New Rendering code from Michel Pollet
218 #define REN_MAX_DEPTH 32
219 /* that's the size for a 32 bits buffer... */
220 #define REN_MAX_SIZE (128L*1024)
221 unsigned char renderedFont
[REN_MAX_SIZE
];
223 /* Rendered Font Size */
224 unsigned long vc_rendered_font_size
= REN_MAX_SIZE
;
225 long vc_rendered_error
= 0;
227 /* If the one bit table was reversed */
228 short vc_one_bit_reversed
= 0;
230 /* Size of a character in the table (bytes) */
231 int vc_rendered_char_size
= 0;
235 # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
237 # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
238 # Background color codes:
239 # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
242 #define VC_RESET_BACKGROUND 40
243 #define VC_RESET_FOREGROUND 37
245 static void vc_color_set(int color
)
247 if (vinfo
.v_depth
< 8)
249 if (color
>= 30 && color
<= 37) {
250 vc_color_fore
= vc_colors
[color
-30][vc_color_index_table
[vinfo
.v_depth
]];
251 if ( vc_ops
.update_color
) vc_ops
.update_color(color
- 30, 1);
253 if (color
>= 40 && color
<= 47) {
254 vc_color_back
= vc_colors
[color
-40][vc_color_index_table
[vinfo
.v_depth
]];
255 if ( vc_ops
.update_color
) vc_ops
.update_color(color
- 40, 0);
256 vc_normal_background
= color
== 40;
260 static void vc_render_font(short olddepth
, short newdepth
)
262 int charIndex
; /* index in ISO font */
264 unsigned char *charptr
;
265 unsigned short *shortptr
;
266 unsigned long *longptr
;
267 } current
; /* current place in rendered font, multiple types. */
269 unsigned char *theChar
; /* current char in iso_font */
271 if (olddepth
== newdepth
)
272 return; /* nothing to do */
274 vc_rendered_font_size
= REN_MAX_SIZE
;
276 vc_rendered_char_size
= 16;
277 if (!vc_one_bit_reversed
) { /* reverse the font for the blitter */
279 for (i
= 0; i
< ((ISO_CHAR_MAX
-ISO_CHAR_MIN
+1) * vc_rendered_char_size
); i
++) {
281 unsigned char mask1
= 0x80;
282 unsigned char mask2
= 0x01;
283 unsigned char val
= 0;
285 if (iso_font
[i
] & mask1
)
290 renderedFont
[i
] = ~val
;
291 } else renderedFont
[i
] = 0xff;
293 vc_one_bit_reversed
= 1;
298 long csize
= newdepth
/ 8; /* bytes per pixel */
299 vc_rendered_char_size
= csize
? CHARHEIGHT
* (csize
* CHARWIDTH
) :
300 /* for 2 & 4 */ CHARHEIGHT
* (CHARWIDTH
/(6-newdepth
));
301 csize
= (ISO_CHAR_MAX
-ISO_CHAR_MIN
+1) * vc_rendered_char_size
;
302 if (csize
> vc_rendered_font_size
) {
303 vc_rendered_error
= csize
;
306 vc_rendered_font_size
= csize
;
309 current
.charptr
= renderedFont
;
311 for (charIndex
= ISO_CHAR_MIN
; charIndex
<= ISO_CHAR_MAX
; charIndex
++) {
313 for (line
= 0; line
< CHARHEIGHT
; line
++) {
314 unsigned char mask
= 1;
318 unsigned char value
= 0;
319 if (*theChar
& mask
) value
|= 0xC0; mask
<<= 1;
320 if (*theChar
& mask
) value
|= 0x30; mask
<<= 1;
321 if (*theChar
& mask
) value
|= 0x0C; mask
<<= 1;
322 if (*theChar
& mask
) value
|= 0x03;
324 *current
.charptr
++ = value
;
329 unsigned char value
= 0;
330 if (*theChar
& mask
) value
|= 0xF0; mask
<<= 1;
331 if (*theChar
& mask
) value
|= 0x0F;
333 *current
.charptr
++ = value
;
337 *current
.charptr
++ = (*theChar
& mask
) ? 0xff : 0;
340 *current
.shortptr
++ = (*theChar
& mask
) ? 0xFFFF : 0;
344 *current
.longptr
++ = (*theChar
& mask
) ? 0xFFFFFFFF : 0;
348 } while (mask
); /* while the single bit drops to the right */
354 static void vc_paint_char1(unsigned char ch
, int xx
, int yy
, int attrs
)
356 unsigned char *theChar
;
357 unsigned char *where
;
360 theChar
= (unsigned char*)(renderedFont
+ (ch
* vc_rendered_char_size
));
361 where
= (unsigned char*)(vinfo
.v_baseaddr
+
362 (yy
* CHARHEIGHT
* vinfo
.v_rowbytes
) +
365 if (!attrs
) for (i
= 0; i
< CHARHEIGHT
; i
++) { /* No attributes ? FLY !!!! */
368 where
= (unsigned char*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
369 } else for (i
= 0; i
< CHARHEIGHT
; i
++) { /* a little bit slower */
370 unsigned char val
= *theChar
++, save
= val
;
371 if (attrs
& ATTR_BOLD
) { /* bold support */
372 unsigned char mask1
= 0xC0, mask2
= 0x40;
374 for (bit
= 0; bit
< 7; bit
++) {
375 if ((save
& mask1
) == mask2
)
381 if (attrs
& ATTR_REVERSE
) val
= ~val
;
382 if (attrs
& ATTR_UNDER
&& i
== CHARHEIGHT
-1) val
= ~val
;
385 where
= (unsigned char*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
390 static void vc_paint_char2(unsigned char ch
, int xx
, int yy
, int attrs
)
392 unsigned short *theChar
;
393 unsigned short *where
;
396 theChar
= (unsigned short*)(renderedFont
+ (ch
* vc_rendered_char_size
));
397 where
= (unsigned short*)(vinfo
.v_baseaddr
+
398 (yy
* CHARHEIGHT
* vinfo
.v_rowbytes
) +
400 if (!attrs
) for (i
= 0; i
< CHARHEIGHT
; i
++) { /* No attributes ? FLY !!!! */
403 where
= (unsigned short*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
404 } else for (i
= 0; i
< CHARHEIGHT
; i
++) { /* a little bit slower */
405 unsigned short val
= *theChar
++, save
= val
;
406 if (attrs
& ATTR_BOLD
) { /* bold support */
407 unsigned short mask1
= 0xF000, mask2
= 0x3000;
409 for (bit
= 0; bit
< 7; bit
++) {
410 if ((save
& mask1
) == mask2
)
416 if (attrs
& ATTR_REVERSE
) val
= ~val
;
417 if (attrs
& ATTR_UNDER
&& i
== CHARHEIGHT
-1) val
= ~val
;
420 where
= (unsigned short*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
425 static void vc_paint_char4(unsigned char ch
, int xx
, int yy
, int attrs
)
427 unsigned long *theChar
;
428 unsigned long *where
;
431 theChar
= (unsigned long*)(renderedFont
+ (ch
* vc_rendered_char_size
));
432 where
= (unsigned long*)(vinfo
.v_baseaddr
+
433 (yy
* CHARHEIGHT
* vinfo
.v_rowbytes
) +
436 if (!attrs
) for (i
= 0; i
< CHARHEIGHT
; i
++) { /* No attributes ? FLY !!!! */
439 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
440 } else for (i
= 0; i
< CHARHEIGHT
; i
++) { /* a little bit slower */
441 unsigned long val
= *theChar
++, save
= val
;
442 if (attrs
& ATTR_BOLD
) { /* bold support */
443 unsigned long mask1
= 0xff000000, mask2
= 0x0F000000;
445 for (bit
= 0; bit
< 7; bit
++) {
446 if ((save
& mask1
) == mask2
)
452 if (attrs
& ATTR_REVERSE
) val
= ~val
;
453 if (attrs
& ATTR_UNDER
&& i
== CHARHEIGHT
-1) val
= ~val
;
456 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
461 static void vc_paint_char8c(unsigned char ch
, int xx
, int yy
, int attrs
)
463 unsigned long *theChar
;
464 unsigned long *where
;
467 theChar
= (unsigned long*)(renderedFont
+ (ch
* vc_rendered_char_size
));
468 where
= (unsigned long*)(vinfo
.v_baseaddr
+
469 (yy
* CHARHEIGHT
* vinfo
.v_rowbytes
) +
472 if (!attrs
) for (i
= 0; i
< CHARHEIGHT
; i
++) { /* No attr? FLY !*/
473 unsigned long *store
= where
;
475 for (x
= 0; x
< 2; x
++) {
476 unsigned long val
= *theChar
++;
477 val
= (vc_color_back
& ~val
) | (vc_color_fore
& val
);
481 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
482 } else for (i
= 0; i
< CHARHEIGHT
; i
++) { /* a little slower */
483 unsigned long *store
= where
, lastpixel
= 0;
485 for (x
= 0 ; x
< 2; x
++) {
486 unsigned long val
= *theChar
++, save
= val
;
487 if (attrs
& ATTR_BOLD
) { /* bold support */
488 if (lastpixel
&& !(save
& 0xFF000000))
490 if ((save
& 0xFFFF0000) == 0xFF000000)
492 if ((save
& 0x00FFFF00) == 0x00FF0000)
494 if ((save
& 0x0000FFFF) == 0x0000FF00)
497 if (attrs
& ATTR_REVERSE
) val
= ~val
;
498 if (attrs
& ATTR_UNDER
&& i
== CHARHEIGHT
-1) val
= ~val
;
500 val
= (vc_color_back
& ~val
) | (vc_color_fore
& val
);
502 lastpixel
= save
& 0xff;
505 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
509 static void vc_paint_char16c(unsigned char ch
, int xx
, int yy
, int attrs
)
511 unsigned long *theChar
;
512 unsigned long *where
;
515 theChar
= (unsigned long*)(renderedFont
+ (ch
* vc_rendered_char_size
));
516 where
= (unsigned long*)(vinfo
.v_baseaddr
+
517 (yy
* CHARHEIGHT
* vinfo
.v_rowbytes
) +
518 (xx
* CHARWIDTH
* 2));
520 if (!attrs
) for (i
= 0; i
< CHARHEIGHT
; i
++) { /* No attrs ? FLY ! */
521 unsigned long *store
= where
;
523 for (x
= 0; x
< 4; x
++) {
524 unsigned long val
= *theChar
++;
525 val
= (vc_color_back
& ~val
) | (vc_color_fore
& val
);
529 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
530 } else for (i
= 0; i
< CHARHEIGHT
; i
++) { /* a little bit slower */
531 unsigned long *store
= where
, lastpixel
= 0;
533 for (x
= 0 ; x
< 4; x
++) {
534 unsigned long val
= *theChar
++, save
= val
;
535 if (attrs
& ATTR_BOLD
) { /* bold support */
536 if (save
== 0xFFFF0000) val
|= 0xFFFF;
537 else if (lastpixel
&& !(save
& 0xFFFF0000))
540 if (attrs
& ATTR_REVERSE
) val
= ~val
;
541 if (attrs
& ATTR_UNDER
&& i
== CHARHEIGHT
-1) val
= ~val
;
543 val
= (vc_color_back
& ~val
) | (vc_color_fore
& val
);
546 lastpixel
= save
& 0x7fff;
549 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
553 static void vc_paint_char32c(unsigned char ch
, int xx
, int yy
, int attrs
)
555 unsigned long *theChar
;
556 unsigned long *where
;
559 theChar
= (unsigned long*)(renderedFont
+ (ch
* vc_rendered_char_size
));
560 where
= (unsigned long*)(vinfo
.v_baseaddr
+
561 (yy
* CHARHEIGHT
* vinfo
.v_rowbytes
) +
562 (xx
* CHARWIDTH
* 4));
564 if (!attrs
) for (i
= 0; i
< CHARHEIGHT
; i
++) { /* No attrs ? FLY ! */
565 unsigned long *store
= where
;
567 for (x
= 0; x
< 8; x
++) {
568 unsigned long val
= *theChar
++;
569 val
= (vc_color_back
& ~val
) | (vc_color_fore
& val
);
573 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
574 } else for (i
= 0; i
< CHARHEIGHT
; i
++) { /* a little slower */
575 unsigned long *store
= where
, lastpixel
= 0;
577 for (x
= 0 ; x
< 8; x
++) {
578 unsigned long val
= *theChar
++, save
= val
;
579 if (attrs
& ATTR_BOLD
) { /* bold support */
580 if (lastpixel
&& !save
)
583 if (attrs
& ATTR_REVERSE
) val
= ~val
;
584 if (attrs
& ATTR_UNDER
&& i
== CHARHEIGHT
-1) val
= ~val
;
586 val
= (vc_color_back
& ~val
) | (vc_color_fore
& val
);
591 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
597 * That's a plain dumb reverse of the cursor position
598 * It do a binary reverse, so it will not looks good when we have
599 * color support. we'll see that later
601 static void reversecursor(int xx
, int yy
)
604 unsigned char *charptr
;
605 unsigned short *shortptr
;
606 unsigned long *longptr
;
610 where
.longptr
= (unsigned long*)(vinfo
.v_baseaddr
+
611 (y
* CHARHEIGHT
* vinfo
.v_rowbytes
) +
612 (x
/** CHARWIDTH*/ * vinfo
.v_depth
));
613 for (line
= 0; line
< CHARHEIGHT
; line
++) {
614 switch (vinfo
.v_depth
) {
616 *where
.charptr
= ~*where
.charptr
;
619 *where
.shortptr
= ~*where
.shortptr
;
622 *where
.longptr
= ~*where
.longptr
;
624 /* that code still exists because since characters on the screen are
625 * of different colors that reverse function may not work if the
626 * cursor is on a character that is in a different color that the
627 * current one. When we have buffering, things will work better. MP
629 #ifdef 1 /*VC_BINARY_REVERSE*/
631 where
.longptr
[0] = ~where
.longptr
[0];
632 where
.longptr
[1] = ~where
.longptr
[1];
635 for (col
= 0; col
< 4; col
++)
636 where
.longptr
[col
] = ~where
.longptr
[col
];
639 for (col
= 0; col
< 8; col
++)
640 where
.longptr
[col
] = ~where
.longptr
[col
];
644 for (col
= 0; col
< 8; col
++)
645 where
.charptr
[col
] = where
.charptr
[col
] != (vc_color_fore
& vc_color_mask
) ?
646 vc_color_fore
& vc_color_mask
: vc_color_back
& vc_color_mask
;
649 for (col
= 0; col
< 8; col
++)
650 where
.shortptr
[col
] = where
.shortptr
[col
] != (vc_color_fore
& vc_color_mask
) ?
651 vc_color_fore
& vc_color_mask
: vc_color_back
& vc_color_mask
;
654 for (col
= 0; col
< 8; col
++)
655 where
.longptr
[col
] = where
.longptr
[col
] != (vc_color_fore
& vc_color_mask
) ?
656 vc_color_fore
& vc_color_mask
: vc_color_back
& vc_color_mask
;
660 where
.charptr
+= vinfo
.v_rowbytes
;
668 unsigned long *from
, *to
, linelongs
, i
, line
, rowline
, rowscanline
;
670 linelongs
= vinfo
.v_rowbytes
* CHARHEIGHT
/ 4;
671 rowline
= vinfo
.v_rowbytes
/ 4;
672 rowscanline
= vinfo
.v_rowscanbytes
/ 4;
674 to
= (unsigned long *) vinfo
.v_baseaddr
+ (scrreg_top
* linelongs
);
675 from
= to
+ (linelongs
* num
); /* handle multiple line scroll (Michel Pollet) */
677 i
= (scrreg_bottom
- scrreg_top
) - num
;
680 for (line
= 0; line
< CHARHEIGHT
; line
++) {
682 * Only copy what is displayed
685 bcopy((unsigned int) from
, (unsigned int) to
,
686 vinfo
.v_rowscanbytes
);
688 video_scroll_up((unsigned int) from
,
689 (unsigned int) (from
+(vinfo
.v_rowscanbytes
/4)),
698 /* Now set the freed up lines to the background colour */
701 to
= ((unsigned long *) vinfo
.v_baseaddr
+ (scrreg_top
* linelongs
))
702 + ((scrreg_bottom
- scrreg_top
- num
) * linelongs
);
704 for (linelongs
= CHARHEIGHT
* num
; linelongs
-- > 0;) {
706 for (i
= 0; i
< rowscanline
; i
++)
707 *to
++ = vc_color_back
;
717 unsigned long *from
, *to
, linelongs
, i
, line
, rowline
, rowscanline
;
719 linelongs
= vinfo
.v_rowbytes
* CHARHEIGHT
/ 4;
720 rowline
= vinfo
.v_rowbytes
/ 4;
721 rowscanline
= vinfo
.v_rowscanbytes
/ 4;
724 to
= (unsigned long *) vinfo
.v_baseaddr
+ (linelongs
* scrreg_bottom
)
725 - (rowline
- rowscanline
);
726 from
= to
- (linelongs
* num
); /* handle multiple line scroll (Michel Pollet) */
728 i
= (scrreg_bottom
- scrreg_top
) - num
;
731 for (line
= 0; line
< CHARHEIGHT
; line
++) {
733 * Only copy what is displayed
736 bcopy(from
-(vinfo
.v_rowscanbytes
/4), to
,
737 vinfo
.v_rowscanbytes
);
740 video_scroll_down((unsigned int) from
,
741 (unsigned int) (from
-(vinfo
.v_rowscanbytes
/4)),
750 /* Now set the freed up lines to the background colour */
752 to
= (unsigned long *) vinfo
.v_baseaddr
+ (linelongs
* scrreg_top
);
754 for (line
= CHARHEIGHT
* num
; line
> 0; line
--) {
757 for (i
= 0; i
< rowscanline
; i
++)
758 *(to
++) = vc_color_back
;
767 clear_line(int which
)
772 * This routine runs extremely slowly. I don't think it's
773 * used all that often, except for To end of line. I'll go
774 * back and speed this up when I speed up the whole vc
779 case 0: /* To end of line */
781 end
= vinfo
.v_columns
-1;
783 case 1: /* To start of line */
788 case 2: /* Whole line */
790 end
= vinfo
.v_columns
-1;
794 for (i
= start
; i
<= end
; i
++) {
795 vc_ops
.paintchar(' ', i
, y
, ATTR_NONE
);
801 clear_screen(int xx
, int yy
, int which
)
803 unsigned long *p
, *endp
, *row
;
805 int rowline
, rowlongs
;
807 rowline
= vinfo
.v_rowscanbytes
/ 4;
808 rowlongs
= vinfo
.v_rowbytes
/ 4;
810 p
= (unsigned long*) vinfo
.v_baseaddr
;;
811 endp
= (unsigned long*) vinfo
.v_baseaddr
;
813 linelongs
= vinfo
.v_rowbytes
* CHARHEIGHT
/ 4;
816 case 0: /* To end of screen */
818 if (y
< vinfo
.v_rows
- 1) {
819 p
+= (y
+ 1) * linelongs
;
820 endp
+= rowlongs
* vinfo
.v_height
;
823 case 1: /* To start of screen */
826 endp
+= (y
+ 1) * linelongs
;
829 case 2: /* Whole screen */
830 endp
+= rowlongs
* vinfo
.v_height
;
834 for (row
= p
; row
< endp
; row
+= rowlongs
) {
835 for (col
= 0; col
< rowline
; col
++)
836 *(row
+col
) = vc_color_back
;
846 for (i
= 0; i
<= vinfo
.v_columns
; i
++) {
847 tab_stops
[i
] = ((i
% 8) == 0);
857 scrreg_bottom
= vinfo
.v_rows
;
859 vc_charset
[0] = vc_charset
[1] = 0;
860 vc_charset_select
= 0;
862 vc_relative_origin
= 0;
863 vc_color_set(VC_RESET_BACKGROUND
);
864 vc_color_set(VC_RESET_FOREGROUND
);
869 putc_normal(unsigned char ch
)
872 case '\a': /* Beep */
874 if ( FALSE
&& !IS_TEXT_MODE
) {
876 * No sound hardware, invert the screen twice instead
880 /* XOR the screen twice */
881 for (i
= 0; i
< 2 ; i
++) {
882 /* For each row, xor the scanbytes */
883 for (ptr
= (unsigned long*)vinfo
.v_baseaddr
;
884 ptr
< (unsigned long*)(vinfo
.v_baseaddr
+
885 (vinfo
.v_height
* vinfo
.v_rowbytes
));
886 ptr
+= (vinfo
.v_rowbytes
/
887 sizeof (unsigned long*)))
889 j
< vinfo
.v_rowscanbytes
/
890 sizeof (unsigned long*);
898 case 127: /* Delete */
899 case '\b': /* Backspace */
900 if (hanging_cursor
) {
908 while (x
< vinfo
.v_columns
&& !tab_stops
[++x
]);
909 if (x
>= vinfo
.v_columns
)
910 x
= vinfo
.v_columns
-1;
914 case '\n': /* Line feed */
915 if (y
>= scrreg_bottom
-1 ) {
917 y
= scrreg_bottom
- 1;
921 /*break; Pass thru */
922 case '\r': /* Carriage return */
926 case 0x0e: /* Select G1 charset (Control-N) */
927 vc_charset_select
= 1;
929 case 0x0f: /* Select G0 charset (Control-O) */
930 vc_charset_select
= 0;
932 case 0x18 : /* CAN : cancel */
933 case 0x1A : /* like cancel */
934 /* well, i do nothing here, may be later */
936 case '\033': /* Escape */
942 if (hanging_cursor
) {
944 if (y
>= scrreg_bottom
-1 ) {
946 y
= scrreg_bottom
- 1;
952 vc_ops
.paintchar((ch
>= 0x60 && ch
<= 0x7f) ? ch
+ vc_charset
[vc_charset_select
]
954 if (x
== vinfo
.v_columns
- 1) {
955 hanging_cursor
= vc_wrap_mode
;
966 putc_esc(unsigned char ch
)
968 vt100state
= ESnormal
;
972 vt100state
= ESsquare
;
974 case 'c': /* Reset terminal */
976 vc_ops
.clear_screen(x
, y
, 2);
979 case 'D': /* Line feed */
981 if (y
>= scrreg_bottom
-1) {
983 y
= scrreg_bottom
- 1;
987 if (ch
== 'E') x
= 0;
989 case 'H': /* Set tab stop */
992 case 'M': /* Cursor up */
993 if (y
<= scrreg_top
) {
994 vc_ops
.scrolldown(1);
1003 case '7': /* Save cursor */
1007 vc_save_charset_s
= vc_charset_select
;
1008 vc_charset_save
[0] = vc_charset
[0];
1009 vc_charset_save
[1] = vc_charset
[1];
1011 case '8': /* Restore cursor */
1015 vc_charset_select
= vc_save_charset_s
;
1016 vc_charset
[0] = vc_charset_save
[0];
1017 vc_charset
[1] = vc_charset_save
[1];
1019 case 'Z': /* return terminal ID */
1021 case '#': /* change characters height */
1022 vt100state
= EScharsize
;
1025 vt100state
= ESsetG0
;
1027 case ')': /* character set sequence */
1028 vt100state
= ESsetG1
;
1033 /* Rest not supported */
1040 putc_askcmd(unsigned char ch
)
1042 if (ch
>= '0' && ch
<= '9') {
1043 par
[numpars
] = (10*par
[numpars
]) + (ch
-'0');
1046 vt100state
= ESnormal
;
1050 vc_relative_origin
= ch
== 'h';
1052 case 7: /* wrap around mode h=1, l=0*/
1053 vc_wrap_mode
= ch
== 'h';
1062 putc_charsizecmd(unsigned char ch
)
1064 vt100state
= ESnormal
;
1072 case '8' : /* fill 'E's */
1075 for (yy
= 0; yy
< vinfo
.v_rows
; yy
++)
1076 for (xx
= 0; xx
< vinfo
.v_columns
; xx
++)
1077 vc_ops
.paintchar('E', xx
, yy
, ATTR_NONE
);
1085 putc_charsetcmd(int charset
, unsigned char ch
)
1087 vt100state
= ESnormal
;
1093 vc_charset
[charset
] = 0;
1095 case '0' : /* Graphic characters */
1097 vc_charset
[charset
] = 0x21;
1104 putc_gotpars(unsigned char ch
)
1109 /* special case for vttest for handling cursor
1110 movement in escape sequences */
1112 vt100state
= ESgotpars
;
1115 vt100state
= ESnormal
;
1118 y
-= par
[0] ? par
[0] : 1;
1122 case 'B': /* Down */
1123 y
+= par
[0] ? par
[0] : 1;
1124 if (y
>= scrreg_bottom
)
1125 y
= scrreg_bottom
- 1;
1127 case 'C': /* Right */
1128 x
+= par
[0] ? par
[0] : 1;
1129 if (x
>= vinfo
.v_columns
)
1130 x
= vinfo
.v_columns
-1;
1132 case 'D': /* Left */
1133 x
-= par
[0] ? par
[0] : 1;
1137 case 'H': /* Set cursor position */
1139 x
= par
[1] ? par
[1] - 1 : 0;
1140 y
= par
[0] ? par
[0] - 1 : 0;
1141 if (vc_relative_origin
)
1145 case 'X': /* clear p1 characters */
1148 for (i
= x
; i
< x
+ par
[0]; i
++)
1149 vc_ops
.paintchar(' ', i
, y
, ATTR_NONE
);
1152 case 'J': /* Clear part of screen */
1153 vc_ops
.clear_screen(x
, y
, par
[0]);
1155 case 'K': /* Clear part of line */
1158 case 'g': /* tab stops */
1161 case 2: /* reset tab stops */
1164 case 3: /* Clear every tabs */
1168 for (i
= 0; i
<= vinfo
.v_columns
; i
++)
1177 case 'm': /* Set attribute */
1178 for (i
= 0; i
< numpars
; i
++) {
1182 vc_color_set(VC_RESET_BACKGROUND
);
1183 vc_color_set(VC_RESET_FOREGROUND
);
1192 attr
|= ATTR_REVERSE
;
1198 attr
&= ~ATTR_UNDER
;
1201 attr
&= ~ATTR_REVERSE
;
1204 case 25: /* blink/no blink */
1207 vc_color_set(par
[i
]);
1212 case 'r': /* Set scroll region */
1214 /* ensure top < bottom, and both within limits */
1215 if ((numpars
> 0) && (par
[0] < vinfo
.v_rows
)) {
1216 scrreg_top
= par
[0] ? par
[0] - 1 : 0;
1222 if ((numpars
> 1) && (par
[1] <= vinfo
.v_rows
) && (par
[1] > par
[0])) {
1223 scrreg_bottom
= par
[1];
1224 if (scrreg_bottom
> vinfo
.v_rows
)
1225 scrreg_bottom
= vinfo
.v_rows
;
1227 scrreg_bottom
= vinfo
.v_rows
;
1229 if (vc_relative_origin
)
1237 putc_getpars(unsigned char ch
)
1244 vt100state
= ESnormal
;
1248 if (ch
== ';' && numpars
< MAXPARS
- 1) {
1251 if (ch
>= '0' && ch
<= '9') {
1253 par
[numpars
] += ch
- '0';
1256 vt100state
= ESgotpars
;
1262 putc_square(unsigned char ch
)
1266 for (i
= 0; i
< MAXPARS
; i
++) {
1271 vt100state
= ESgetpars
;
1281 return; /* ignore null characters */
1284 switch (vt100state
) {
1285 default:vt100state
= ESnormal
; /* FALLTHROUGH */
1305 putc_charsizecmd(ch
);
1308 putc_charsetcmd(0, ch
);
1311 putc_charsetcmd(1, ch
);
1315 if (x
>= vinfo
.v_columns
) {
1316 x
= vinfo
.v_columns
- 1;
1321 if (y
>= vinfo
.v_rows
) {
1322 y
= vinfo
.v_rows
- 1;
1331 * Actually draws the buffer, handle the jump scroll
1333 void vc_flush_forward_buffer(void)
1335 if (vc_forward_buffer_size
) {
1337 vc_ops
.hide_cursor(x
, y
);
1341 int drawlen
= start
;
1343 int param
= 0, changebackground
= 0;
1344 enum vt100state_e vtState
= vt100state
;
1346 * In simple words, here we're pre-parsing the text to look for
1347 * + Newlines, for computing jump scroll
1348 * + /\033\[[0-9;]*]m/ to continue on
1349 * any other sequence will stop. We don't want to have cursor
1350 * movement escape sequences while we're trying to pre-scroll
1352 * We have to be extra carefull about the sequences that changes
1353 * the background color to prevent scrolling in those
1355 * That parsing was added to speed up 'man' and 'color-ls' a
1356 * zillion time (at least). It's worth it, trust me.
1357 * (mail Nick Stephen for a True Performance Graph)
1360 for (i
= start
; i
< vc_forward_buffer_size
&& plaintext
; i
++) {
1364 switch (vc_forward_buffer
[i
]) {
1374 switch (vc_forward_buffer
[i
]) {
1376 vtState
= ESgetpars
;
1378 changebackground
= 0;
1386 if ((vc_forward_buffer
[i
] >= '0' &&
1387 vc_forward_buffer
[i
] <= '9') ||
1388 vc_forward_buffer
[i
] == ';') {
1389 if (vc_forward_buffer
[i
] >= '0' &&
1390 vc_forward_buffer
[i
] <= '9')
1391 param
= (param
*10)+(vc_forward_buffer
[i
]-'0');
1393 if (param
>= 40 && param
<= 47)
1394 changebackground
= 1;
1395 if (!vc_normal_background
&&
1397 changebackground
= 1;
1400 break; /* continue on */
1402 vtState
= ESgotpars
;
1405 switch (vc_forward_buffer
[i
]) {
1408 if (param
>= 40 && param
<= 47)
1409 changebackground
= 1;
1410 if (!vc_normal_background
&&
1412 changebackground
= 1;
1413 if (changebackground
) {
1416 /* REALLY don't jump */
1418 /* Yup ! we've got it */
1433 * Then we look if it would be appropriate to forward jump
1434 * the screen before drawing
1436 if (jump
&& (scrreg_bottom
- scrreg_top
) > 2) {
1437 jump
-= scrreg_bottom
- y
- 1;
1439 if (jump
>= scrreg_bottom
- scrreg_top
)
1440 jump
= scrreg_bottom
- scrreg_top
-1;
1442 vc_ops
.scrollup(jump
);
1446 * and we draw what we've found to the parser
1448 for (i
= start
; i
< drawlen
; i
++)
1449 vc_putchar(vc_forward_buffer
[start
++]);
1451 * Continue sending characters to the parser until we're sure we're
1452 * back on normal characters.
1454 for (i
= start
; i
< vc_forward_buffer_size
&&
1455 vt100state
!= ESnormal
; i
++)
1456 vc_putchar(vc_forward_buffer
[start
++]);
1457 /* Then loop again if there still things to draw */
1458 } while (start
< vc_forward_buffer_size
);
1459 vc_forward_buffer_size
= 0;
1460 vc_ops
.show_cursor(x
, y
);
1465 vcputc(int l
, int u
, int c
)
1467 if ( vc_initialized
)
1470 vc_flush_forward_buffer();
1476 * Immediate character display.. kernel printf uses this. Make sure
1477 * pre-clock printfs get flushed and that panics get fully displayed.
1480 void cnputc(char ch
)
1486 * Store characters to be drawn 'later', handle overflows
1490 vc_store_char(unsigned char c
)
1493 /* Either we're really buffering stuff or we're not yet because
1494 * the probe hasn't been done. If we're not, then we can only
1495 * ever have a maximum of one character in the buffer waiting to
1499 vc_forward_buffer
[vc_forward_buffer_size
++] = (unsigned char)c
;
1501 switch (vc_forward_buffer_size
) {
1503 /* If we're adding the first character to the buffer,
1504 * start the timer, otherwise it is already running.
1507 case VC_MAX_FORWARD_SIZE
:
1508 vc_flush_forward_buffer();
1512 * the character will be flushed on timeout
1519 vc_initialize(struct vc_info
* vinfo_p
)
1521 vinfo
.v_rows
= vinfo
.v_height
/ CHARHEIGHT
;
1522 vinfo
.v_columns
= vinfo
.v_width
/ CHARWIDTH
;
1524 if (vinfo
.v_depth
>= 8) {
1525 vinfo
.v_rowscanbytes
= (vinfo
.v_depth
/ 8) * vinfo
.v_width
;
1527 vinfo
.v_rowscanbytes
= vinfo
.v_width
/ (8 / vinfo
.v_depth
);
1530 vc_render_font(1, vinfo
.v_depth
);
1531 vc_color_mask
= vc_color_depth_masks
[vc_color_index_table
[vinfo
.v_depth
]];
1533 switch (vinfo
.v_depth
) {
1536 vc_ops
.paintchar
= vc_paint_char1
;
1539 vc_ops
.paintchar
= vc_paint_char2
;
1542 vc_ops
.paintchar
= vc_paint_char4
;
1545 vc_ops
.paintchar
= vc_paint_char8c
;
1548 vc_ops
.paintchar
= vc_paint_char16c
;
1551 vc_ops
.paintchar
= vc_paint_char32c
;
1559 if (vinfo
.v_depth
>= 8)
1560 printf("\033[31mC\033[32mO\033[33mL\033[34mO\033[35mR\033[0m ");
1561 printf("video console at 0x%lx (%ldx%ldx%ld)\n", vinfo
.v_baseaddr
,
1562 vinfo
.v_width
, vinfo
.v_height
, vinfo
.v_depth
);
1564 #if 0 // XXX - FIXME
1566 * Added for the buffering and jump scrolling
1569 simple_lock_init(&vc_forward_lock
, ETAP_IO_TTY
);
1571 vc_forward_buffer_enabled
= 1;
1572 #else // FIXME TOO!!!
1574 simple_lock_init(&vc_forward_lock
, ETAP_IO_TTY
);
1579 struct vc_progress_element
{
1580 unsigned int version
;
1583 unsigned char count
;
1584 unsigned char res
[3];
1590 unsigned int res2
[3];
1591 unsigned char data
[0];
1593 typedef struct vc_progress_element vc_progress_element
;
1595 static vc_progress_element
* vc_progress
;
1596 static unsigned char * vc_progress_data
;
1597 static boolean_t vc_progress_enable
;
1598 static unsigned char * vc_clut
;
1599 static unsigned int vc_progress_tick
;
1600 static boolean_t vc_graphics_mode
;
1601 static boolean_t vc_acquired
;
1602 static boolean_t vc_need_clear
;
1604 void vc_blit_rect_8c( int x
, int y
,
1605 int width
, int height
,
1606 int transparent
, unsigned char * dataPtr
)
1608 volatile unsigned char * dst
;
1612 dst
= (unsigned char *)(vinfo
.v_baseaddr
+
1613 (y
* vinfo
.v_rowbytes
) +
1616 for( line
= 0; line
< height
; line
++) {
1617 for( col
= 0; col
< width
; col
++) {
1619 if( data
== transparent
)
1622 *(dst
+ col
) = data
;
1624 dst
= (volatile unsigned char *) (((int)dst
) + vinfo
.v_rowbytes
);
1629 void vc_blit_rect_8m( int x
, int y
,
1630 int width
, int height
,
1631 int transparent
, unsigned char * dataPtr
)
1633 volatile unsigned char * dst
;
1637 dst
= (unsigned char *)(vinfo
.v_baseaddr
+
1638 (y
* vinfo
.v_rowbytes
) +
1641 for( line
= 0; line
< height
; line
++) {
1642 for( col
= 0; col
< width
; col
++) {
1644 if( data
== transparent
)
1648 *(dst
+ col
) = ((19595 * vc_clut
[data
+ 0] +
1649 38470 * vc_clut
[data
+ 1] +
1650 7471 * vc_clut
[data
+ 2] ) / 65536);
1652 dst
= (volatile unsigned char *) (((int)dst
) + vinfo
.v_rowbytes
);
1656 void vc_blit_rect_16( int x
, int y
,
1657 int width
, int height
,
1658 int transparent
, unsigned char * dataPtr
)
1660 volatile unsigned short * dst
;
1664 dst
= (volatile unsigned short *)(vinfo
.v_baseaddr
+
1665 (y
* vinfo
.v_rowbytes
) +
1668 for( line
= 0; line
< height
; line
++) {
1669 for( col
= 0; col
< width
; col
++) {
1671 if( data
== transparent
)
1675 *(dst
+ col
) = ( (0xf8 & (vc_clut
[data
+ 0])) << 7)
1676 | ( (0xf8 & (vc_clut
[data
+ 1])) << 2)
1677 | ( (0xf8 & (vc_clut
[data
+ 2])) >> 3);
1679 dst
= (volatile unsigned short *) (((int)dst
) + vinfo
.v_rowbytes
);
1683 void vc_blit_rect_32( unsigned int x
, unsigned int y
,
1684 unsigned int width
, unsigned int height
,
1685 int transparent
, unsigned char * dataPtr
)
1687 volatile unsigned int * dst
;
1691 dst
= (volatile unsigned int *) (vinfo
.v_baseaddr
+
1692 (y
* vinfo
.v_rowbytes
) +
1695 for( line
= 0; line
< height
; line
++) {
1696 for( col
= 0; col
< width
; col
++) {
1698 if( data
== transparent
)
1702 *(dst
+ col
) = (vc_clut
[data
+ 0] << 16)
1703 | (vc_clut
[data
+ 1] << 8)
1704 | (vc_clut
[data
+ 2]);
1706 dst
= (volatile unsigned int *) (((int)dst
) + vinfo
.v_rowbytes
);
1710 void vc_blit_rect( int x
, int y
,
1711 int width
, int height
,
1712 int transparent
, unsigned char * dataPtr
)
1714 switch( vinfo
.v_depth
) {
1716 vc_blit_rect_8c( x
, y
, width
, height
, transparent
, dataPtr
);
1719 vc_blit_rect_16( x
, y
, width
, height
, transparent
, dataPtr
);
1722 vc_blit_rect_32( x
, y
, width
, height
, transparent
, dataPtr
);
1727 void vc_progress_task( void * arg
)
1730 int count
= (int) arg
;
1731 int x
, y
, width
, height
;
1732 unsigned char * data
;
1735 simple_lock(&vc_forward_lock
);
1737 if( vc_progress_enable
) {
1739 if( count
>= vc_progress
->count
)
1742 width
= vc_progress
->width
;
1743 height
= vc_progress
->height
;
1744 x
= vc_progress
->dx
;
1745 y
= vc_progress
->dy
;
1746 data
= vc_progress_data
;
1747 data
+= count
* width
* height
;
1748 if( 1 & vc_progress
->flags
) {
1749 x
+= (vinfo
.v_width
/ 2);
1750 x
+= (vinfo
.v_height
/ 2);
1752 vc_blit_rect( x
, y
, width
, height
,
1753 vc_progress
->transparent
,data
);
1755 timeout( vc_progress_task
, (void *) count
,
1758 simple_unlock(&vc_forward_lock
);
1762 void vc_display_icon( vc_progress_element
* desc
,
1763 unsigned char * data
)
1765 int x
, y
, width
, height
;
1767 if( vc_acquired
&& vc_graphics_mode
&& vc_clut
) {
1769 width
= desc
->width
;
1770 height
= desc
->height
;
1773 if( 1 & desc
->flags
) {
1774 x
+= (vinfo
.v_width
/ 2);
1775 y
+= (vinfo
.v_height
/ 2);
1777 vc_blit_rect( x
, y
, width
, height
, desc
->transparent
, data
);
1782 vc_progress_set( boolean_t enable
)
1790 simple_lock(&vc_forward_lock
);
1792 if( vc_progress_enable
!= enable
) {
1793 vc_progress_enable
= enable
;
1795 timeout(vc_progress_task
, (void *) 0,
1798 untimeout( vc_progress_task
, (void *) 0 );
1801 simple_unlock(&vc_forward_lock
);
1809 vc_progress_initialize( vc_progress_element
* desc
,
1810 unsigned char * data
,
1811 unsigned char * clut
)
1813 if( (!clut
) || (!desc
) || (!data
))
1818 vc_progress_data
= data
;
1819 vc_progress_tick
= vc_progress
->time
* hz
/ 1000;
1824 extern int disableConsoleOutput
;
1826 void vc_clear_screen( void )
1828 vc_ops
.hide_cursor(x
, y
);
1831 vc_ops
.clear_screen(x
, y
, 2);
1832 vc_ops
.show_cursor(x
, y
);
1836 initialize_screen(Boot_Video
* boot_vinfo
, int op
)
1840 vinfo
.v_width
= boot_vinfo
->v_width
;
1841 vinfo
.v_height
= boot_vinfo
->v_height
;
1842 vinfo
.v_depth
= boot_vinfo
->v_depth
;
1843 vinfo
.v_rowbytes
= boot_vinfo
->v_rowBytes
;
1844 vinfo
.v_baseaddr
= boot_vinfo
->v_baseAddr
;
1845 vinfo
.v_type
= boot_vinfo
->v_display
;
1849 // Text mode setup by the booter.
1851 vc_ops
.initialize
= tc_initialize
;
1852 vc_ops
.paintchar
= tc_putchar
;
1853 vc_ops
.scrolldown
= tc_scrolldown
;
1854 vc_ops
.scrollup
= tc_scrollup
;
1855 vc_ops
.clear_screen
= tc_clear_screen
;
1856 vc_ops
.hide_cursor
= tc_hide_cursor
;
1857 vc_ops
.show_cursor
= tc_show_cursor
;
1858 vc_ops
.update_color
= tc_update_color
;
1862 // Graphics mode setup by the booter.
1864 vc_ops
.initialize
= vc_initialize
;
1865 vc_ops
.paintchar
= 0;
1866 vc_ops
.scrolldown
= scrolldown
;
1867 vc_ops
.scrollup
= scrollup
;
1868 vc_ops
.clear_screen
= clear_screen
;
1869 vc_ops
.hide_cursor
= reversecursor
;
1870 vc_ops
.show_cursor
= reversecursor
;
1871 vc_ops
.update_color
= 0;
1874 vc_ops
.initialize(&vinfo
);
1876 // vc_clear_screen();
1883 case kPEGraphicsMode
:
1884 vc_graphics_mode
= TRUE
;
1885 disableConsoleOutput
= TRUE
;
1890 vc_graphics_mode
= FALSE
;
1891 disableConsoleOutput
= FALSE
;
1897 vc_progress_set( FALSE
);
1898 disableConsoleOutput
= FALSE
;
1899 if( vc_need_clear
) {
1900 vc_need_clear
= FALSE
;
1905 case kPEEnableScreen
:
1907 if( vc_graphics_mode
)
1908 vc_progress_set( TRUE
);
1914 case kPEDisableScreen
:
1915 vc_progress_set( FALSE
);
1918 case kPEAcquireScreen
:
1919 vc_need_clear
= (FALSE
== vc_acquired
);
1921 vc_progress_set( vc_graphics_mode
);
1922 disableConsoleOutput
= vc_graphics_mode
;
1923 if( vc_need_clear
&& !vc_graphics_mode
) {
1924 vc_need_clear
= FALSE
;
1929 case kPEReleaseScreen
:
1930 vc_acquired
= FALSE
;
1931 vc_progress_set( FALSE
);
1932 disableConsoleOutput
= TRUE
;