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 extern int asc_ringbell(); //In IOBSDConsole.cpp
877 rang
= asc_ringbell();
879 if ( !rang
&& !IS_TEXT_MODE
) {
881 * No sound hardware, invert the screen twice instead
885 /* XOR the screen twice */
886 for (i
= 0; i
< 2 ; i
++) {
887 /* For each row, xor the scanbytes */
888 for (ptr
= (unsigned long*)vinfo
.v_baseaddr
;
889 ptr
< (unsigned long*)(vinfo
.v_baseaddr
+
890 (vinfo
.v_height
* vinfo
.v_rowbytes
));
891 ptr
+= (vinfo
.v_rowbytes
/
892 sizeof (unsigned long*)))
894 j
< vinfo
.v_rowscanbytes
/
895 sizeof (unsigned long*);
903 case 127: /* Delete */
904 case '\b': /* Backspace */
905 if (hanging_cursor
) {
913 while (x
< vinfo
.v_columns
&& !tab_stops
[++x
]);
914 if (x
>= vinfo
.v_columns
)
915 x
= vinfo
.v_columns
-1;
919 case '\n': /* Line feed */
920 if (y
>= scrreg_bottom
-1 ) {
922 y
= scrreg_bottom
- 1;
926 /*break; Pass thru */
927 case '\r': /* Carriage return */
931 case 0x0e: /* Select G1 charset (Control-N) */
932 vc_charset_select
= 1;
934 case 0x0f: /* Select G0 charset (Control-O) */
935 vc_charset_select
= 0;
937 case 0x18 : /* CAN : cancel */
938 case 0x1A : /* like cancel */
939 /* well, i do nothing here, may be later */
941 case '\033': /* Escape */
947 if (hanging_cursor
) {
949 if (y
>= scrreg_bottom
-1 ) {
951 y
= scrreg_bottom
- 1;
957 vc_ops
.paintchar((ch
>= 0x60 && ch
<= 0x7f) ? ch
+ vc_charset
[vc_charset_select
]
959 if (x
== vinfo
.v_columns
- 1) {
960 hanging_cursor
= vc_wrap_mode
;
971 putc_esc(unsigned char ch
)
973 vt100state
= ESnormal
;
977 vt100state
= ESsquare
;
979 case 'c': /* Reset terminal */
981 vc_ops
.clear_screen(x
, y
, 2);
984 case 'D': /* Line feed */
986 if (y
>= scrreg_bottom
-1) {
988 y
= scrreg_bottom
- 1;
992 if (ch
== 'E') x
= 0;
994 case 'H': /* Set tab stop */
997 case 'M': /* Cursor up */
998 if (y
<= scrreg_top
) {
999 vc_ops
.scrolldown(1);
1008 case '7': /* Save cursor */
1012 vc_save_charset_s
= vc_charset_select
;
1013 vc_charset_save
[0] = vc_charset
[0];
1014 vc_charset_save
[1] = vc_charset
[1];
1016 case '8': /* Restore cursor */
1020 vc_charset_select
= vc_save_charset_s
;
1021 vc_charset
[0] = vc_charset_save
[0];
1022 vc_charset
[1] = vc_charset_save
[1];
1024 case 'Z': /* return terminal ID */
1026 case '#': /* change characters height */
1027 vt100state
= EScharsize
;
1030 vt100state
= ESsetG0
;
1032 case ')': /* character set sequence */
1033 vt100state
= ESsetG1
;
1038 /* Rest not supported */
1045 putc_askcmd(unsigned char ch
)
1047 if (ch
>= '0' && ch
<= '9') {
1048 par
[numpars
] = (10*par
[numpars
]) + (ch
-'0');
1051 vt100state
= ESnormal
;
1055 vc_relative_origin
= ch
== 'h';
1057 case 7: /* wrap around mode h=1, l=0*/
1058 vc_wrap_mode
= ch
== 'h';
1067 putc_charsizecmd(unsigned char ch
)
1069 vt100state
= ESnormal
;
1077 case '8' : /* fill 'E's */
1080 for (yy
= 0; yy
< vinfo
.v_rows
; yy
++)
1081 for (xx
= 0; xx
< vinfo
.v_columns
; xx
++)
1082 vc_ops
.paintchar('E', xx
, yy
, ATTR_NONE
);
1090 putc_charsetcmd(int charset
, unsigned char ch
)
1092 vt100state
= ESnormal
;
1098 vc_charset
[charset
] = 0;
1100 case '0' : /* Graphic characters */
1102 vc_charset
[charset
] = 0x21;
1109 putc_gotpars(unsigned char ch
)
1114 /* special case for vttest for handling cursor
1115 movement in escape sequences */
1117 vt100state
= ESgotpars
;
1120 vt100state
= ESnormal
;
1123 y
-= par
[0] ? par
[0] : 1;
1127 case 'B': /* Down */
1128 y
+= par
[0] ? par
[0] : 1;
1129 if (y
>= scrreg_bottom
)
1130 y
= scrreg_bottom
- 1;
1132 case 'C': /* Right */
1133 x
+= par
[0] ? par
[0] : 1;
1134 if (x
>= vinfo
.v_columns
)
1135 x
= vinfo
.v_columns
-1;
1137 case 'D': /* Left */
1138 x
-= par
[0] ? par
[0] : 1;
1142 case 'H': /* Set cursor position */
1144 x
= par
[1] ? par
[1] - 1 : 0;
1145 y
= par
[0] ? par
[0] - 1 : 0;
1146 if (vc_relative_origin
)
1150 case 'X': /* clear p1 characters */
1153 for (i
= x
; i
< x
+ par
[0]; i
++)
1154 vc_ops
.paintchar(' ', i
, y
, ATTR_NONE
);
1157 case 'J': /* Clear part of screen */
1158 vc_ops
.clear_screen(x
, y
, par
[0]);
1160 case 'K': /* Clear part of line */
1163 case 'g': /* tab stops */
1166 case 2: /* reset tab stops */
1169 case 3: /* Clear every tabs */
1173 for (i
= 0; i
<= vinfo
.v_columns
; i
++)
1182 case 'm': /* Set attribute */
1183 for (i
= 0; i
< numpars
; i
++) {
1187 vc_color_set(VC_RESET_BACKGROUND
);
1188 vc_color_set(VC_RESET_FOREGROUND
);
1197 attr
|= ATTR_REVERSE
;
1203 attr
&= ~ATTR_UNDER
;
1206 attr
&= ~ATTR_REVERSE
;
1209 case 25: /* blink/no blink */
1212 vc_color_set(par
[i
]);
1217 case 'r': /* Set scroll region */
1219 /* ensure top < bottom, and both within limits */
1220 if ((numpars
> 0) && (par
[0] < vinfo
.v_rows
)) {
1221 scrreg_top
= par
[0] ? par
[0] - 1 : 0;
1227 if ((numpars
> 1) && (par
[1] <= vinfo
.v_rows
) && (par
[1] > par
[0])) {
1228 scrreg_bottom
= par
[1];
1229 if (scrreg_bottom
> vinfo
.v_rows
)
1230 scrreg_bottom
= vinfo
.v_rows
;
1232 scrreg_bottom
= vinfo
.v_rows
;
1234 if (vc_relative_origin
)
1242 putc_getpars(unsigned char ch
)
1249 vt100state
= ESnormal
;
1253 if (ch
== ';' && numpars
< MAXPARS
- 1) {
1256 if (ch
>= '0' && ch
<= '9') {
1258 par
[numpars
] += ch
- '0';
1261 vt100state
= ESgotpars
;
1267 putc_square(unsigned char ch
)
1271 for (i
= 0; i
< MAXPARS
; i
++) {
1276 vt100state
= ESgetpars
;
1286 return; /* ignore null characters */
1289 switch (vt100state
) {
1290 default:vt100state
= ESnormal
; /* FALLTHROUGH */
1310 putc_charsizecmd(ch
);
1313 putc_charsetcmd(0, ch
);
1316 putc_charsetcmd(1, ch
);
1320 if (x
>= vinfo
.v_columns
) {
1321 x
= vinfo
.v_columns
- 1;
1326 if (y
>= vinfo
.v_rows
) {
1327 y
= vinfo
.v_rows
- 1;
1336 * Actually draws the buffer, handle the jump scroll
1338 void vc_flush_forward_buffer(void)
1340 if (vc_forward_buffer_size
) {
1342 vc_ops
.hide_cursor(x
, y
);
1346 int drawlen
= start
;
1348 int param
= 0, changebackground
= 0;
1349 enum vt100state_e vtState
= vt100state
;
1351 * In simple words, here we're pre-parsing the text to look for
1352 * + Newlines, for computing jump scroll
1353 * + /\033\[[0-9;]*]m/ to continue on
1354 * any other sequence will stop. We don't want to have cursor
1355 * movement escape sequences while we're trying to pre-scroll
1357 * We have to be extra carefull about the sequences that changes
1358 * the background color to prevent scrolling in those
1360 * That parsing was added to speed up 'man' and 'color-ls' a
1361 * zillion time (at least). It's worth it, trust me.
1362 * (mail Nick Stephen for a True Performance Graph)
1365 for (i
= start
; i
< vc_forward_buffer_size
&& plaintext
; i
++) {
1369 switch (vc_forward_buffer
[i
]) {
1379 switch (vc_forward_buffer
[i
]) {
1381 vtState
= ESgetpars
;
1383 changebackground
= 0;
1391 if ((vc_forward_buffer
[i
] >= '0' &&
1392 vc_forward_buffer
[i
] <= '9') ||
1393 vc_forward_buffer
[i
] == ';') {
1394 if (vc_forward_buffer
[i
] >= '0' &&
1395 vc_forward_buffer
[i
] <= '9')
1396 param
= (param
*10)+(vc_forward_buffer
[i
]-'0');
1398 if (param
>= 40 && param
<= 47)
1399 changebackground
= 1;
1400 if (!vc_normal_background
&&
1402 changebackground
= 1;
1405 break; /* continue on */
1407 vtState
= ESgotpars
;
1410 switch (vc_forward_buffer
[i
]) {
1413 if (param
>= 40 && param
<= 47)
1414 changebackground
= 1;
1415 if (!vc_normal_background
&&
1417 changebackground
= 1;
1418 if (changebackground
) {
1421 /* REALLY don't jump */
1423 /* Yup ! we've got it */
1438 * Then we look if it would be appropriate to forward jump
1439 * the screen before drawing
1441 if (jump
&& (scrreg_bottom
- scrreg_top
) > 2) {
1442 jump
-= scrreg_bottom
- y
- 1;
1444 if (jump
>= scrreg_bottom
- scrreg_top
)
1445 jump
= scrreg_bottom
- scrreg_top
-1;
1447 vc_ops
.scrollup(jump
);
1451 * and we draw what we've found to the parser
1453 for (i
= start
; i
< drawlen
; i
++)
1454 vc_putchar(vc_forward_buffer
[start
++]);
1456 * Continue sending characters to the parser until we're sure we're
1457 * back on normal characters.
1459 for (i
= start
; i
< vc_forward_buffer_size
&&
1460 vt100state
!= ESnormal
; i
++)
1461 vc_putchar(vc_forward_buffer
[start
++]);
1462 /* Then loop again if there still things to draw */
1463 } while (start
< vc_forward_buffer_size
);
1464 vc_forward_buffer_size
= 0;
1465 vc_ops
.show_cursor(x
, y
);
1470 vcputc(int l
, int u
, int c
)
1472 if ( vc_initialized
)
1475 vc_flush_forward_buffer();
1481 * Immediate character display.. kernel printf uses this. Make sure
1482 * pre-clock printfs get flushed and that panics get fully displayed.
1485 void cnputc(char ch
)
1491 * Store characters to be drawn 'later', handle overflows
1495 vc_store_char(unsigned char c
)
1498 /* Either we're really buffering stuff or we're not yet because
1499 * the probe hasn't been done. If we're not, then we can only
1500 * ever have a maximum of one character in the buffer waiting to
1504 vc_forward_buffer
[vc_forward_buffer_size
++] = (unsigned char)c
;
1506 switch (vc_forward_buffer_size
) {
1508 /* If we're adding the first character to the buffer,
1509 * start the timer, otherwise it is already running.
1512 case VC_MAX_FORWARD_SIZE
:
1513 vc_flush_forward_buffer();
1517 * the character will be flushed on timeout
1524 vc_initialize(struct vc_info
* vinfo_p
)
1526 vinfo
.v_rows
= vinfo
.v_height
/ CHARHEIGHT
;
1527 vinfo
.v_columns
= vinfo
.v_width
/ CHARWIDTH
;
1529 if (vinfo
.v_depth
>= 8) {
1530 vinfo
.v_rowscanbytes
= (vinfo
.v_depth
/ 8) * vinfo
.v_width
;
1532 vinfo
.v_rowscanbytes
= vinfo
.v_width
/ (8 / vinfo
.v_depth
);
1535 vc_render_font(1, vinfo
.v_depth
);
1536 vc_color_mask
= vc_color_depth_masks
[vc_color_index_table
[vinfo
.v_depth
]];
1538 switch (vinfo
.v_depth
) {
1541 vc_ops
.paintchar
= vc_paint_char1
;
1544 vc_ops
.paintchar
= vc_paint_char2
;
1547 vc_ops
.paintchar
= vc_paint_char4
;
1550 vc_ops
.paintchar
= vc_paint_char8c
;
1553 vc_ops
.paintchar
= vc_paint_char16c
;
1556 vc_ops
.paintchar
= vc_paint_char32c
;
1564 if (vinfo
.v_depth
>= 8)
1565 printf("\033[31mC\033[32mO\033[33mL\033[34mO\033[35mR\033[0m ");
1566 printf("video console at 0x%lx (%ldx%ldx%ld)\n", vinfo
.v_baseaddr
,
1567 vinfo
.v_width
, vinfo
.v_height
, vinfo
.v_depth
);
1569 #if 0 // XXX - FIXME
1571 * Added for the buffering and jump scrolling
1574 simple_lock_init(&vc_forward_lock
, ETAP_IO_TTY
);
1576 vc_forward_buffer_enabled
= 1;
1577 #else // FIXME TOO!!!
1579 simple_lock_init(&vc_forward_lock
, ETAP_IO_TTY
);
1584 struct vc_progress_element
{
1585 unsigned int version
;
1588 unsigned char count
;
1589 unsigned char res
[3];
1595 unsigned int res2
[3];
1596 unsigned char data
[0];
1598 typedef struct vc_progress_element vc_progress_element
;
1600 static vc_progress_element
* vc_progress
;
1601 static unsigned char * vc_progress_data
;
1602 static boolean_t vc_progress_enable
;
1603 static unsigned char * vc_clut
;
1604 static unsigned int vc_progress_tick
;
1605 static boolean_t vc_graphics_mode
;
1606 static boolean_t vc_acquired
;
1607 static boolean_t vc_need_clear
;
1609 void vc_blit_rect_8c( int x
, int y
,
1610 int width
, int height
,
1611 int transparent
, unsigned char * dataPtr
)
1613 volatile unsigned char * dst
;
1617 dst
= (unsigned char *)(vinfo
.v_baseaddr
+
1618 (y
* vinfo
.v_rowbytes
) +
1621 for( line
= 0; line
< height
; line
++) {
1622 for( col
= 0; col
< width
; col
++) {
1624 if( data
== transparent
)
1627 *(dst
+ col
) = data
;
1629 dst
= (volatile unsigned char *) (((int)dst
) + vinfo
.v_rowbytes
);
1634 void vc_blit_rect_8m( int x
, int y
,
1635 int width
, int height
,
1636 int transparent
, unsigned char * dataPtr
)
1638 volatile unsigned char * dst
;
1642 dst
= (unsigned char *)(vinfo
.v_baseaddr
+
1643 (y
* vinfo
.v_rowbytes
) +
1646 for( line
= 0; line
< height
; line
++) {
1647 for( col
= 0; col
< width
; col
++) {
1649 if( data
== transparent
)
1653 *(dst
+ col
) = ((19595 * vc_clut
[data
+ 0] +
1654 38470 * vc_clut
[data
+ 1] +
1655 7471 * vc_clut
[data
+ 2] ) / 65536);
1657 dst
= (volatile unsigned char *) (((int)dst
) + vinfo
.v_rowbytes
);
1661 void vc_blit_rect_16( int x
, int y
,
1662 int width
, int height
,
1663 int transparent
, unsigned char * dataPtr
)
1665 volatile unsigned short * dst
;
1669 dst
= (volatile unsigned short *)(vinfo
.v_baseaddr
+
1670 (y
* vinfo
.v_rowbytes
) +
1673 for( line
= 0; line
< height
; line
++) {
1674 for( col
= 0; col
< width
; col
++) {
1676 if( data
== transparent
)
1680 *(dst
+ col
) = ( (0xf8 & (vc_clut
[data
+ 0])) << 7)
1681 | ( (0xf8 & (vc_clut
[data
+ 1])) << 2)
1682 | ( (0xf8 & (vc_clut
[data
+ 2])) >> 3);
1684 dst
= (volatile unsigned short *) (((int)dst
) + vinfo
.v_rowbytes
);
1688 void vc_blit_rect_32( unsigned int x
, unsigned int y
,
1689 unsigned int width
, unsigned int height
,
1690 int transparent
, unsigned char * dataPtr
)
1692 volatile unsigned int * dst
;
1696 dst
= (volatile unsigned int *) (vinfo
.v_baseaddr
+
1697 (y
* vinfo
.v_rowbytes
) +
1700 for( line
= 0; line
< height
; line
++) {
1701 for( col
= 0; col
< width
; col
++) {
1703 if( data
== transparent
)
1707 *(dst
+ col
) = (vc_clut
[data
+ 0] << 16)
1708 | (vc_clut
[data
+ 1] << 8)
1709 | (vc_clut
[data
+ 2]);
1711 dst
= (volatile unsigned int *) (((int)dst
) + vinfo
.v_rowbytes
);
1715 void vc_blit_rect( int x
, int y
,
1716 int width
, int height
,
1717 int transparent
, unsigned char * dataPtr
)
1719 switch( vinfo
.v_depth
) {
1721 vc_blit_rect_8c( x
, y
, width
, height
, transparent
, dataPtr
);
1724 vc_blit_rect_16( x
, y
, width
, height
, transparent
, dataPtr
);
1727 vc_blit_rect_32( x
, y
, width
, height
, transparent
, dataPtr
);
1732 void vc_progress_task( void * arg
)
1735 int count
= (int) arg
;
1736 int x
, y
, width
, height
;
1737 unsigned char * data
;
1740 simple_lock(&vc_forward_lock
);
1742 if( vc_progress_enable
) {
1744 if( count
>= vc_progress
->count
)
1747 width
= vc_progress
->width
;
1748 height
= vc_progress
->height
;
1749 x
= vc_progress
->dx
;
1750 y
= vc_progress
->dy
;
1751 data
= vc_progress_data
;
1752 data
+= count
* width
* height
;
1753 if( 1 & vc_progress
->flags
) {
1754 x
+= (vinfo
.v_width
/ 2);
1755 x
+= (vinfo
.v_height
/ 2);
1757 vc_blit_rect( x
, y
, width
, height
,
1758 vc_progress
->transparent
,data
);
1760 timeout( vc_progress_task
, (void *) count
,
1763 simple_unlock(&vc_forward_lock
);
1767 void vc_display_icon( vc_progress_element
* desc
,
1768 unsigned char * data
)
1770 int x
, y
, width
, height
;
1772 if( vc_acquired
&& vc_graphics_mode
&& vc_clut
) {
1774 width
= desc
->width
;
1775 height
= desc
->height
;
1778 if( 1 & desc
->flags
) {
1779 x
+= (vinfo
.v_width
/ 2);
1780 y
+= (vinfo
.v_height
/ 2);
1782 vc_blit_rect( x
, y
, width
, height
, desc
->transparent
, data
);
1787 vc_progress_set( boolean_t enable
)
1795 simple_lock(&vc_forward_lock
);
1797 if( vc_progress_enable
!= enable
) {
1798 vc_progress_enable
= enable
;
1800 timeout(vc_progress_task
, (void *) 0,
1803 untimeout( vc_progress_task
, (void *) 0 );
1806 simple_unlock(&vc_forward_lock
);
1814 vc_progress_initialize( vc_progress_element
* desc
,
1815 unsigned char * data
,
1816 unsigned char * clut
)
1818 if( (!clut
) || (!desc
) || (!data
))
1823 vc_progress_data
= data
;
1824 vc_progress_tick
= vc_progress
->time
* hz
/ 1000;
1829 extern int disableConsoleOutput
;
1831 void vc_clear_screen( void )
1833 vc_ops
.hide_cursor(x
, y
);
1836 vc_ops
.clear_screen(x
, y
, 2);
1837 vc_ops
.show_cursor(x
, y
);
1841 initialize_screen(Boot_Video
* boot_vinfo
, int op
)
1845 vinfo
.v_width
= boot_vinfo
->v_width
;
1846 vinfo
.v_height
= boot_vinfo
->v_height
;
1847 vinfo
.v_depth
= boot_vinfo
->v_depth
;
1848 vinfo
.v_rowbytes
= boot_vinfo
->v_rowBytes
;
1849 vinfo
.v_baseaddr
= boot_vinfo
->v_baseAddr
;
1850 vinfo
.v_type
= boot_vinfo
->v_display
;
1854 // Text mode setup by the booter.
1856 vc_ops
.initialize
= tc_initialize
;
1857 vc_ops
.paintchar
= tc_putchar
;
1858 vc_ops
.scrolldown
= tc_scrolldown
;
1859 vc_ops
.scrollup
= tc_scrollup
;
1860 vc_ops
.clear_screen
= tc_clear_screen
;
1861 vc_ops
.hide_cursor
= tc_hide_cursor
;
1862 vc_ops
.show_cursor
= tc_show_cursor
;
1863 vc_ops
.update_color
= tc_update_color
;
1867 // Graphics mode setup by the booter.
1869 vc_ops
.initialize
= vc_initialize
;
1870 vc_ops
.paintchar
= 0;
1871 vc_ops
.scrolldown
= scrolldown
;
1872 vc_ops
.scrollup
= scrollup
;
1873 vc_ops
.clear_screen
= clear_screen
;
1874 vc_ops
.hide_cursor
= reversecursor
;
1875 vc_ops
.show_cursor
= reversecursor
;
1876 vc_ops
.update_color
= 0;
1879 vc_ops
.initialize(&vinfo
);
1881 // vc_clear_screen();
1888 case kPEGraphicsMode
:
1889 vc_graphics_mode
= TRUE
;
1890 disableConsoleOutput
= TRUE
;
1895 vc_graphics_mode
= FALSE
;
1896 disableConsoleOutput
= FALSE
;
1902 vc_progress_set( FALSE
);
1903 disableConsoleOutput
= FALSE
;
1904 if( vc_need_clear
) {
1905 vc_need_clear
= FALSE
;
1910 case kPEEnableScreen
:
1912 if( vc_graphics_mode
)
1913 vc_progress_set( TRUE
);
1919 case kPEDisableScreen
:
1920 vc_progress_set( FALSE
);
1923 case kPEAcquireScreen
:
1924 vc_need_clear
= (FALSE
== vc_acquired
);
1926 vc_progress_set( vc_graphics_mode
);
1927 disableConsoleOutput
= vc_graphics_mode
;
1928 if( vc_need_clear
&& !vc_graphics_mode
) {
1929 vc_need_clear
= FALSE
;
1934 case kPEReleaseScreen
:
1935 vc_acquired
= FALSE
;
1936 vc_progress_set( FALSE
);
1937 disableConsoleOutput
= TRUE
;