2 * Copyright (c) 2000-2002 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@
30 * NetBSD: ite.c,v 1.16 1995/07/17 01:24:34 briggs Exp
32 * Copyright (c) 1988 University of Utah.
33 * Copyright (c) 1990, 1993
34 * The Regents of the University of California. All rights reserved.
36 * This code is derived from software contributed to Berkeley by
37 * the Systems Programming Group of the University of Utah Computer
40 * Redistribution and use in source and binary forms, with or without
41 * modification, are permitted provided that the following conditions
43 * 1. Redistributions of source code must retain the above copyright
44 * notice, this list of conditions and the following disclaimer.
45 * 2. Redistributions in binary form must reproduce the above copyright
46 * notice, this list of conditions and the following disclaimer in the
47 * documentation and/or other materials provided with the distribution.
48 * 3. All advertising materials mentioning features or use of this software
49 * must display the following acknowledgement:
50 * This product includes software developed by the University of
51 * California, Berkeley and its contributors.
52 * 4. Neither the name of the University nor the names of its contributors
53 * may be used to endorse or promote products derived from this software
54 * without specific prior written permission.
56 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
57 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
58 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
59 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
60 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
61 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
62 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
64 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
65 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 * from: Utah $Hdr: ite.c 1.28 92/12/20$
70 * @(#)ite.c 8.2 (Berkeley) 1/12/94
76 * The ite module handles the system console; that is, stuff printed
77 * by the kernel and by user programs while "desktop" and X aren't
78 * running. Some (very small) parts are based on hp300's 4.4 ite.c,
79 * hence the above copyright.
81 * -- Brad and Lawrence, June 26th, 1994
87 #include <console/video_console.h>
88 #include <kern/debug.h>
89 #include <kern/lock.h>
91 #include <kern/time_out.h>
92 #include <vm/vm_kern.h>
93 #include <pexpert/pexpert.h>
98 * Generic Console (Front-End)
99 * ---------------------------
102 struct vc_info vinfo
;
103 /* if panicDialogDesired is true then we use the panic dialog when its */
104 /* allowed otherwise we won't use the panic dialog even if it is allowed */
105 boolean_t panicDialogDesired
;
108 extern int disableConsoleOutput
;
109 static boolean_t gc_enabled
= FALSE
;
110 static boolean_t gc_initialized
= FALSE
;
111 static boolean_t vm_initialized
= FALSE
;
114 void (*initialize
)(struct vc_info
* info
);
115 void (*enable
)(boolean_t enable
);
116 void (*paint_char
)(int xx
, int yy
, unsigned char ch
, int attrs
, unsigned char ch_previous
, int attrs_previous
);
117 void (*clear_screen
)(int xx
, int yy
, int top
, int bottom
, int which
);
118 void (*scroll_down
)(int num
, int top
, int bottom
);
119 void (*scroll_up
)(int num
, int top
, int bottom
);
120 void (*hide_cursor
)(int xx
, int yy
);
121 void (*show_cursor
)(int xx
, int yy
);
122 void (*update_color
)(int color
, boolean_t fore
);
125 static unsigned char * gc_buffer_attributes
= NULL
;
126 static unsigned char * gc_buffer_characters
= NULL
;
127 static unsigned char * gc_buffer_colorcodes
= NULL
;
128 static unsigned long gc_buffer_columns
= 0;
129 static unsigned long gc_buffer_rows
= 0;
130 static unsigned long gc_buffer_size
= 0;
131 decl_simple_lock_data(,gc_buffer_lock
)
135 # 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
137 # 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
138 # Background color codes:
139 # 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
145 #define ATTR_REVERSE 4
147 #define COLOR_BACKGROUND 0
148 #define COLOR_FOREGROUND 7
150 #define COLOR_CODE_GET(code, fore) (((code) & ((fore) ? 0xF0 : 0x0F)) >> ((fore) ? 4 : 0))
151 #define COLOR_CODE_SET(code, color, fore) (((code) & ((fore) ? 0x0F : 0xF0)) | ((color) << ((fore) ? 4 : 0)))
153 static unsigned char gc_color_code
= 0;
157 static int gc_x
= 0, gc_y
= 0, gc_savex
, gc_savey
;
158 static int gc_par
[MAXPARS
], gc_numpars
, gc_hanging_cursor
, gc_attr
, gc_saveattr
;
160 /* VT100 tab stops & scroll region */
161 static char gc_tab_stops
[255];
162 static int gc_scrreg_top
, gc_scrreg_bottom
;
165 ESnormal
, /* Nothing yet */
167 ESsquare
, /* Got ESC [ */
168 ESgetpars
, /* About to get or getting the parameters */
169 ESgotpars
, /* Finished getting the parameters */
170 ESfunckey
, /* Function key */
171 EShash
, /* DEC-specific stuff (screen align, etc.) */
172 ESsetG0
, /* Specify the G0 character set */
173 ESsetG1
, /* Specify the G1 character set */
176 ESignore
/* Ignore this sequence */
177 } gc_vt100state
= ESnormal
;
179 static int gc_wrap_mode
= 1, gc_relative_origin
= 0;
180 static int gc_charset_select
= 0, gc_save_charset_s
= 0;
181 static int gc_charset
[2] = { 0, 0 };
182 static int gc_charset_save
[2] = { 0, 0 };
184 static void gc_clear_line(int xx
, int yy
, int which
);
185 static void gc_clear_screen(int xx
, int yy
, int top
, int bottom
, int which
);
186 static void gc_enable(boolean_t enable
);
187 static void gc_hide_cursor(int xx
, int yy
);
188 static void gc_initialize(struct vc_info
* info
);
189 static void gc_paint_char(int xx
, int yy
, unsigned char ch
, int attrs
);
190 static void gc_putchar(char ch
);
191 static void gc_putc_askcmd(unsigned char ch
);
192 static void gc_putc_charsetcmd(int charset
, unsigned char ch
);
193 static void gc_putc_charsizecmd(unsigned char ch
);
194 static void gc_putc_esc(unsigned char ch
);
195 static void gc_putc_getpars(unsigned char ch
);
196 static void gc_putc_gotpars(unsigned char ch
);
197 static void gc_putc_normal(unsigned char ch
);
198 static void gc_putc_square(unsigned char ch
);
199 static void gc_refresh_screen(void);
200 static void gc_reset_screen(void);
201 static void gc_reset_tabs(void);
202 static void gc_reset_vt100(void);
203 static void gc_scroll_down(int num
, int top
, int bottom
);
204 static void gc_scroll_up(int num
, int top
, int bottom
);
205 static void gc_show_cursor(int xx
, int yy
);
206 static void gc_update_color(int color
, boolean_t fore
);
207 extern int vcputc(int l
, int u
, int c
);
210 gc_clear_line(int xx
, int yy
, int which
)
215 * This routine runs extremely slowly. I don't think it's
216 * used all that often, except for To end of line. I'll go
217 * back and speed this up when I speed up the whole vc
222 case 0: /* To end of line */
224 end
= vinfo
.v_columns
-1;
226 case 1: /* To start of line */
230 case 2: /* Whole line */
232 end
= vinfo
.v_columns
-1;
236 for (i
= start
; i
<= end
; i
++) {
237 gc_paint_char(i
, yy
, ' ', ATTR_NONE
);
243 gc_clear_screen(int xx
, int yy
, int top
, int bottom
, int which
)
248 simple_lock(&gc_buffer_lock
);
250 if ( xx
< gc_buffer_columns
&& yy
< gc_buffer_rows
&& bottom
<= gc_buffer_rows
)
252 unsigned long start
, end
;
255 case 0: /* To end of screen */
256 start
= (yy
* gc_buffer_columns
) + xx
;
257 end
= (bottom
* gc_buffer_columns
) - 1;
259 case 1: /* To start of screen */
260 start
= (top
* gc_buffer_columns
);
261 end
= (yy
* gc_buffer_columns
) + xx
;
263 case 2: /* Whole screen */
264 start
= (top
* gc_buffer_columns
);
265 end
= (bottom
* gc_buffer_columns
) - 1;
269 memset(gc_buffer_attributes
+ start
, 0x00, end
- start
+ 1);
270 memset(gc_buffer_characters
+ start
, 0x00, end
- start
+ 1);
271 memset(gc_buffer_colorcodes
+ start
, gc_color_code
, end
- start
+ 1);
274 simple_unlock(&gc_buffer_lock
);
277 gc_ops
.clear_screen(xx
, yy
, top
, bottom
, which
);
281 gc_enable( boolean_t enable
)
283 unsigned char * buffer_attributes
;
284 unsigned char * buffer_characters
;
285 unsigned char * buffer_colorcodes
;
286 unsigned long buffer_columns
;
287 unsigned long buffer_rows
;
288 unsigned long buffer_size
;
292 if ( enable
== FALSE
)
294 disableConsoleOutput
= TRUE
;
296 gc_ops
.enable(FALSE
);
300 simple_lock( &gc_buffer_lock
);
302 if ( gc_buffer_size
)
304 buffer_attributes
= gc_buffer_attributes
;
305 buffer_characters
= gc_buffer_characters
;
306 buffer_colorcodes
= gc_buffer_colorcodes
;
307 buffer_size
= gc_buffer_size
;
309 gc_buffer_attributes
= NULL
;
310 gc_buffer_characters
= NULL
;
311 gc_buffer_colorcodes
= NULL
;
312 gc_buffer_columns
= 0;
316 simple_unlock( &gc_buffer_lock
);
319 kfree( (vm_offset_t
)buffer_attributes
, buffer_size
);
320 kfree( (vm_offset_t
)buffer_characters
, buffer_size
);
321 kfree( (vm_offset_t
)buffer_colorcodes
, buffer_size
);
325 simple_unlock( &gc_buffer_lock
);
331 if ( vm_initialized
)
333 buffer_columns
= vinfo
.v_columns
;
334 buffer_rows
= vinfo
.v_rows
;
335 buffer_size
= buffer_columns
* buffer_rows
;
339 buffer_attributes
= (unsigned char *) kalloc( buffer_size
);
340 buffer_characters
= (unsigned char *) kalloc( buffer_size
);
341 buffer_colorcodes
= (unsigned char *) kalloc( buffer_size
);
343 if ( buffer_attributes
== NULL
||
344 buffer_characters
== NULL
||
345 buffer_colorcodes
== NULL
)
347 if ( buffer_attributes
) kfree( (vm_offset_t
)buffer_attributes
, buffer_size
);
348 if ( buffer_characters
) kfree( (vm_offset_t
)buffer_characters
, buffer_size
);
349 if ( buffer_colorcodes
) kfree( (vm_offset_t
)buffer_colorcodes
, buffer_size
);
357 memset( buffer_attributes
, 0x00, buffer_size
);
358 memset( buffer_characters
, 0x00, buffer_size
);
359 memset( buffer_colorcodes
, 0x0F, buffer_size
);
365 simple_lock( &gc_buffer_lock
);
367 gc_buffer_attributes
= buffer_attributes
;
368 gc_buffer_characters
= buffer_characters
;
369 gc_buffer_colorcodes
= buffer_colorcodes
;
370 gc_buffer_columns
= buffer_columns
;
371 gc_buffer_rows
= buffer_rows
;
372 gc_buffer_size
= buffer_size
;
374 simple_unlock( &gc_buffer_lock
);
381 disableConsoleOutput
= FALSE
;
386 gc_hide_cursor(int xx
, int yy
)
391 simple_lock(&gc_buffer_lock
);
393 if ( xx
< gc_buffer_columns
&& yy
< gc_buffer_rows
)
395 unsigned long index
= (yy
* gc_buffer_columns
) + xx
;
396 unsigned char attribute
= gc_buffer_attributes
[index
];
397 unsigned char character
= gc_buffer_characters
[index
];
398 unsigned char colorcode
= gc_buffer_colorcodes
[index
];
399 unsigned char colorcodesave
= gc_color_code
;
401 simple_unlock(&gc_buffer_lock
);
404 gc_update_color(COLOR_CODE_GET(colorcode
, TRUE
), TRUE
);
405 gc_update_color(COLOR_CODE_GET(colorcode
, FALSE
), FALSE
);
407 gc_ops
.paint_char(xx
, yy
, character
, attribute
, 0, 0);
409 gc_update_color(COLOR_CODE_GET(colorcodesave
, TRUE
), TRUE
);
410 gc_update_color(COLOR_CODE_GET(colorcodesave
, FALSE
), FALSE
);
414 simple_unlock(&gc_buffer_lock
);
417 gc_ops
.hide_cursor(xx
, yy
);
422 gc_initialize(struct vc_info
* info
)
424 if ( gc_initialized
== FALSE
)
427 simple_lock_init(&gc_buffer_lock
, ETAP_IO_TTY
);
429 gc_initialized
= TRUE
;
432 gc_ops
.initialize(info
);
439 gc_paint_char(int xx
, int yy
, unsigned char ch
, int attrs
)
444 simple_lock(&gc_buffer_lock
);
446 if ( xx
< gc_buffer_columns
&& yy
< gc_buffer_rows
)
448 unsigned long index
= (yy
* gc_buffer_columns
) + xx
;
450 gc_buffer_attributes
[index
] = attrs
;
451 gc_buffer_characters
[index
] = ch
;
452 gc_buffer_colorcodes
[index
] = gc_color_code
;
455 simple_unlock(&gc_buffer_lock
);
458 gc_ops
.paint_char(xx
, yy
, ch
, attrs
, 0, 0);
465 return; /* ignore null characters */
467 switch (gc_vt100state
) {
468 default:gc_vt100state
= ESnormal
; /* FALLTHROUGH */
488 gc_putc_charsizecmd(ch
);
491 gc_putc_charsetcmd(0, ch
);
494 gc_putc_charsetcmd(1, ch
);
498 if (gc_x
>= vinfo
.v_columns
) {
499 gc_x
= vinfo
.v_columns
- 1;
504 if (gc_y
>= vinfo
.v_rows
) {
505 gc_y
= vinfo
.v_rows
- 1;
514 gc_putc_askcmd(unsigned char ch
)
516 if (ch
>= '0' && ch
<= '9') {
517 gc_par
[gc_numpars
] = (10*gc_par
[gc_numpars
]) + (ch
-'0');
520 gc_vt100state
= ESnormal
;
524 gc_relative_origin
= ch
== 'h';
526 case 7: /* wrap around mode h=1, l=0*/
527 gc_wrap_mode
= ch
== 'h';
536 gc_putc_charsetcmd(int charset
, unsigned char ch
)
538 gc_vt100state
= ESnormal
;
544 gc_charset
[charset
] = 0;
546 case '0' : /* Graphic characters */
548 gc_charset
[charset
] = 0x21;
555 gc_putc_charsizecmd(unsigned char ch
)
557 gc_vt100state
= ESnormal
;
565 case '8' : /* fill 'E's */
568 for (yy
= 0; yy
< vinfo
.v_rows
; yy
++)
569 for (xx
= 0; xx
< vinfo
.v_columns
; xx
++)
570 gc_paint_char(xx
, yy
, 'E', ATTR_NONE
);
578 gc_putc_esc(unsigned char ch
)
580 gc_vt100state
= ESnormal
;
584 gc_vt100state
= ESsquare
;
586 case 'c': /* Reset terminal */
588 gc_clear_screen(gc_x
, gc_y
, 0, vinfo
.v_rows
, 2);
591 case 'D': /* Line feed */
593 if (gc_y
>= gc_scrreg_bottom
-1) {
594 gc_scroll_up(1, gc_scrreg_top
, gc_scrreg_bottom
);
595 gc_y
= gc_scrreg_bottom
- 1;
599 if (ch
== 'E') gc_x
= 0;
601 case 'H': /* Set tab stop */
602 gc_tab_stops
[gc_x
] = 1;
604 case 'M': /* Cursor up */
605 if (gc_y
<= gc_scrreg_top
) {
606 gc_scroll_down(1, gc_scrreg_top
, gc_scrreg_bottom
);
607 gc_y
= gc_scrreg_top
;
615 case '7': /* Save cursor */
618 gc_saveattr
= gc_attr
;
619 gc_save_charset_s
= gc_charset_select
;
620 gc_charset_save
[0] = gc_charset
[0];
621 gc_charset_save
[1] = gc_charset
[1];
623 case '8': /* Restore cursor */
626 gc_attr
= gc_saveattr
;
627 gc_charset_select
= gc_save_charset_s
;
628 gc_charset
[0] = gc_charset_save
[0];
629 gc_charset
[1] = gc_charset_save
[1];
631 case 'Z': /* return terminal ID */
633 case '#': /* change characters height */
634 gc_vt100state
= EScharsize
;
637 gc_vt100state
= ESsetG0
;
639 case ')': /* character set sequence */
640 gc_vt100state
= ESsetG1
;
645 /* Rest not supported */
652 gc_putc_getpars(unsigned char ch
)
655 gc_vt100state
= ESask
;
659 gc_vt100state
= ESnormal
;
663 if (ch
== ';' && gc_numpars
< MAXPARS
- 1) {
666 if (ch
>= '0' && ch
<= '9') {
667 gc_par
[gc_numpars
] *= 10;
668 gc_par
[gc_numpars
] += ch
- '0';
671 gc_vt100state
= ESgotpars
;
677 gc_putc_gotpars(unsigned char ch
)
682 /* special case for vttest for handling cursor
683 movement in escape sequences */
685 gc_vt100state
= ESgotpars
;
688 gc_vt100state
= ESnormal
;
691 gc_y
-= gc_par
[0] ? gc_par
[0] : 1;
692 if (gc_y
< gc_scrreg_top
)
693 gc_y
= gc_scrreg_top
;
696 gc_y
+= gc_par
[0] ? gc_par
[0] : 1;
697 if (gc_y
>= gc_scrreg_bottom
)
698 gc_y
= gc_scrreg_bottom
- 1;
700 case 'C': /* Right */
701 gc_x
+= gc_par
[0] ? gc_par
[0] : 1;
702 if (gc_x
>= vinfo
.v_columns
)
703 gc_x
= vinfo
.v_columns
-1;
706 gc_x
-= gc_par
[0] ? gc_par
[0] : 1;
710 case 'H': /* Set cursor position */
712 gc_x
= gc_par
[1] ? gc_par
[1] - 1 : 0;
713 gc_y
= gc_par
[0] ? gc_par
[0] - 1 : 0;
714 if (gc_relative_origin
)
715 gc_y
+= gc_scrreg_top
;
716 gc_hanging_cursor
= 0;
718 case 'X': /* clear p1 characters */
721 for (i
= gc_x
; i
< gc_x
+ gc_par
[0]; i
++)
722 gc_paint_char(i
, gc_y
, ' ', ATTR_NONE
);
725 case 'J': /* Clear part of screen */
726 gc_clear_screen(gc_x
, gc_y
, 0, vinfo
.v_rows
, gc_par
[0]);
728 case 'K': /* Clear part of line */
729 gc_clear_line(gc_x
, gc_y
, gc_par
[0]);
731 case 'g': /* tab stops */
734 case 2: /* reset tab stops */
735 /* gc_reset_tabs(); */
737 case 3: /* Clear every tabs */
741 for (i
= 0; i
<= vinfo
.v_columns
; i
++)
746 gc_tab_stops
[gc_x
] = 0;
750 case 'm': /* Set attribute */
751 for (i
= 0; i
< gc_numpars
; i
++) {
755 gc_update_color(COLOR_BACKGROUND
, FALSE
);
756 gc_update_color(COLOR_FOREGROUND
, TRUE
);
759 gc_attr
|= ATTR_BOLD
;
762 gc_attr
|= ATTR_UNDER
;
765 gc_attr
|= ATTR_REVERSE
;
768 gc_attr
&= ~ATTR_BOLD
;
771 gc_attr
&= ~ATTR_UNDER
;
774 gc_attr
&= ~ATTR_REVERSE
;
777 case 25: /* blink/no blink */
780 if (gc_par
[i
] >= 30 && gc_par
[i
] <= 37)
781 gc_update_color(gc_par
[i
] - 30, TRUE
);
782 if (gc_par
[i
] >= 40 && gc_par
[i
] <= 47)
783 gc_update_color(gc_par
[i
] - 40, FALSE
);
788 case 'r': /* Set scroll region */
790 /* ensure top < bottom, and both within limits */
791 if ((gc_numpars
> 0) && (gc_par
[0] < vinfo
.v_rows
)) {
792 gc_scrreg_top
= gc_par
[0] ? gc_par
[0] - 1 : 0;
793 if (gc_scrreg_top
< 0)
798 if ((gc_numpars
> 1) && (gc_par
[1] <= vinfo
.v_rows
) && (gc_par
[1] > gc_par
[0])) {
799 gc_scrreg_bottom
= gc_par
[1];
800 if (gc_scrreg_bottom
> vinfo
.v_rows
)
801 gc_scrreg_bottom
= vinfo
.v_rows
;
803 gc_scrreg_bottom
= vinfo
.v_rows
;
805 if (gc_relative_origin
)
806 gc_y
= gc_scrreg_top
;
813 gc_putc_normal(unsigned char ch
)
816 case '\a': /* Beep */
818 case 127: /* Delete */
819 case '\b': /* Backspace */
820 if (gc_hanging_cursor
) {
821 gc_hanging_cursor
= 0;
828 while (gc_x
< vinfo
.v_columns
&& !gc_tab_stops
[++gc_x
]);
829 if (gc_x
>= vinfo
.v_columns
)
830 gc_x
= vinfo
.v_columns
-1;
834 case '\n': /* Line feed */
835 if (gc_y
>= gc_scrreg_bottom
-1 ) {
836 gc_scroll_up(1, gc_scrreg_top
, gc_scrreg_bottom
);
837 gc_y
= gc_scrreg_bottom
- 1;
842 case '\r': /* Carriage return */
844 gc_hanging_cursor
= 0;
846 case 0x0e: /* Select G1 charset (Control-N) */
847 gc_charset_select
= 1;
849 case 0x0f: /* Select G0 charset (Control-O) */
850 gc_charset_select
= 0;
852 case 0x18 : /* CAN : cancel */
853 case 0x1A : /* like cancel */
854 /* well, i do nothing here, may be later */
856 case '\033': /* Escape */
857 gc_vt100state
= ESesc
;
858 gc_hanging_cursor
= 0;
862 if (gc_hanging_cursor
) {
864 if (gc_y
>= gc_scrreg_bottom
-1 ) {
865 gc_scroll_up(1, gc_scrreg_top
, gc_scrreg_bottom
);
866 gc_y
= gc_scrreg_bottom
- 1;
870 gc_hanging_cursor
= 0;
872 gc_paint_char(gc_x
, gc_y
, (ch
>= 0x60 && ch
<= 0x7f) ? ch
+ gc_charset
[gc_charset_select
]
874 if (gc_x
== vinfo
.v_columns
- 1) {
875 gc_hanging_cursor
= gc_wrap_mode
;
886 gc_putc_square(unsigned char ch
)
890 for (i
= 0; i
< MAXPARS
; i
++) {
895 gc_vt100state
= ESgetpars
;
902 gc_refresh_screen(void)
907 simple_lock(&gc_buffer_lock
);
909 if ( gc_buffer_size
)
911 unsigned char colorcodesave
= gc_color_code
;
912 unsigned long column
, row
;
915 for ( index
= 0, row
= 0 ; row
< gc_buffer_rows
; row
++ )
917 for ( column
= 0 ; column
< gc_buffer_columns
; index
++, column
++ )
919 if ( gc_buffer_colorcodes
[index
] != gc_color_code
)
921 gc_update_color(COLOR_CODE_GET(gc_buffer_colorcodes
[index
], TRUE
), TRUE
);
922 gc_update_color(COLOR_CODE_GET(gc_buffer_colorcodes
[index
], FALSE
), FALSE
);
925 gc_ops
.paint_char(column
, row
, gc_buffer_characters
[index
], gc_buffer_attributes
[index
], 0, 0);
929 if ( colorcodesave
!= gc_color_code
)
931 gc_update_color(COLOR_CODE_GET(colorcodesave
, TRUE
), TRUE
);
932 gc_update_color(COLOR_CODE_GET(colorcodesave
, FALSE
), FALSE
);
936 simple_unlock(&gc_buffer_lock
);
941 gc_reset_screen(void)
943 gc_hide_cursor(gc_x
, gc_y
);
946 gc_clear_screen(gc_x
, gc_y
, 0, vinfo
.v_rows
, 2);
947 gc_show_cursor(gc_x
, gc_y
);
955 for (i
= 0; i
<= vinfo
.v_columns
; i
++) {
956 gc_tab_stops
[i
] = ((i
% 8) == 0);
966 gc_scrreg_bottom
= vinfo
.v_rows
;
968 gc_charset
[0] = gc_charset
[1] = 0;
969 gc_charset_select
= 0;
971 gc_relative_origin
= 0;
972 gc_update_color(COLOR_BACKGROUND
, FALSE
);
973 gc_update_color(COLOR_FOREGROUND
, TRUE
);
977 gc_scroll_down(int num
, int top
, int bottom
)
982 simple_lock(&gc_buffer_lock
);
984 if ( bottom
<= gc_buffer_rows
)
986 unsigned char colorcodesave
= gc_color_code
;
987 unsigned long column
, row
;
988 unsigned long index
, jump
;
990 jump
= num
* gc_buffer_columns
;
992 for ( row
= bottom
- 1 ; row
>= top
+ num
; row
-- )
994 index
= row
* gc_buffer_columns
;
996 for ( column
= 0 ; column
< gc_buffer_columns
; index
++, column
++ )
998 if ( gc_buffer_attributes
[index
] != gc_buffer_attributes
[index
- jump
] ||
999 gc_buffer_characters
[index
] != gc_buffer_characters
[index
- jump
] ||
1000 gc_buffer_colorcodes
[index
] != gc_buffer_colorcodes
[index
- jump
] )
1002 if ( gc_color_code
!= gc_buffer_colorcodes
[index
- jump
] )
1004 gc_update_color(COLOR_CODE_GET(gc_buffer_colorcodes
[index
- jump
], TRUE
), TRUE
);
1005 gc_update_color(COLOR_CODE_GET(gc_buffer_colorcodes
[index
- jump
], FALSE
), FALSE
);
1008 if ( gc_buffer_colorcodes
[index
] != gc_buffer_colorcodes
[index
- jump
] )
1010 gc_ops
.paint_char( /* xx */ column
,
1012 /* ch */ gc_buffer_characters
[index
- jump
],
1013 /* attrs */ gc_buffer_attributes
[index
- jump
],
1014 /* ch_previous */ 0,
1015 /* attrs_previous */ 0 );
1019 gc_ops
.paint_char( /* xx */ column
,
1021 /* ch */ gc_buffer_characters
[index
- jump
],
1022 /* attrs */ gc_buffer_attributes
[index
- jump
],
1023 /* ch_previous */ gc_buffer_characters
[index
],
1024 /* attrs_previous */ gc_buffer_attributes
[index
] );
1027 gc_buffer_attributes
[index
] = gc_buffer_attributes
[index
- jump
];
1028 gc_buffer_characters
[index
] = gc_buffer_characters
[index
- jump
];
1029 gc_buffer_colorcodes
[index
] = gc_buffer_colorcodes
[index
- jump
];
1034 if ( colorcodesave
!= gc_color_code
)
1036 gc_update_color(COLOR_CODE_GET(colorcodesave
, TRUE
), TRUE
);
1037 gc_update_color(COLOR_CODE_GET(colorcodesave
, FALSE
), FALSE
);
1040 simple_unlock(&gc_buffer_lock
);
1045 simple_unlock(&gc_buffer_lock
);
1048 gc_ops
.scroll_down(num
, top
, bottom
);
1051 /* Now set the freed up lines to the background colour */
1053 gc_clear_screen(vinfo
.v_columns
- 1, top
+ num
- 1, top
, bottom
, 1);
1057 gc_scroll_up(int num
, int top
, int bottom
)
1062 simple_lock(&gc_buffer_lock
);
1064 if ( bottom
<= gc_buffer_rows
)
1066 unsigned char colorcodesave
= gc_color_code
;
1067 unsigned long column
, row
;
1068 unsigned long index
, jump
;
1070 jump
= num
* gc_buffer_columns
;
1072 for ( row
= top
; row
< bottom
- num
; row
++ )
1074 index
= row
* gc_buffer_columns
;
1076 for ( column
= 0 ; column
< gc_buffer_columns
; index
++, column
++ )
1078 if ( gc_buffer_attributes
[index
] != gc_buffer_attributes
[index
+ jump
] ||
1079 gc_buffer_characters
[index
] != gc_buffer_characters
[index
+ jump
] ||
1080 gc_buffer_colorcodes
[index
] != gc_buffer_colorcodes
[index
+ jump
] )
1082 if ( gc_color_code
!= gc_buffer_colorcodes
[index
+ jump
] )
1084 gc_update_color(COLOR_CODE_GET(gc_buffer_colorcodes
[index
+ jump
], TRUE
), TRUE
);
1085 gc_update_color(COLOR_CODE_GET(gc_buffer_colorcodes
[index
+ jump
], FALSE
), FALSE
);
1088 if ( gc_buffer_colorcodes
[index
] != gc_buffer_colorcodes
[index
+ jump
] )
1090 gc_ops
.paint_char( /* xx */ column
,
1092 /* ch */ gc_buffer_characters
[index
+ jump
],
1093 /* attrs */ gc_buffer_attributes
[index
+ jump
],
1094 /* ch_previous */ 0,
1095 /* attrs_previous */ 0 );
1099 gc_ops
.paint_char( /* xx */ column
,
1101 /* ch */ gc_buffer_characters
[index
+ jump
],
1102 /* attrs */ gc_buffer_attributes
[index
+ jump
],
1103 /* ch_previous */ gc_buffer_characters
[index
],
1104 /* attrs_previous */ gc_buffer_attributes
[index
] );
1107 gc_buffer_attributes
[index
] = gc_buffer_attributes
[index
+ jump
];
1108 gc_buffer_characters
[index
] = gc_buffer_characters
[index
+ jump
];
1109 gc_buffer_colorcodes
[index
] = gc_buffer_colorcodes
[index
+ jump
];
1115 if ( colorcodesave
!= gc_color_code
)
1117 gc_update_color(COLOR_CODE_GET(colorcodesave
, TRUE
), TRUE
);
1118 gc_update_color(COLOR_CODE_GET(colorcodesave
, FALSE
), FALSE
);
1121 simple_unlock(&gc_buffer_lock
);
1126 simple_unlock(&gc_buffer_lock
);
1129 gc_ops
.scroll_up(num
, top
, bottom
);
1132 /* Now set the freed up lines to the background colour */
1134 gc_clear_screen(0, bottom
- num
, top
, bottom
, 0);
1138 gc_show_cursor(int xx
, int yy
)
1143 simple_lock(&gc_buffer_lock
);
1145 if ( xx
< gc_buffer_columns
&& yy
< gc_buffer_rows
)
1147 unsigned long index
= (yy
* gc_buffer_columns
) + xx
;
1148 unsigned char attribute
= gc_buffer_attributes
[index
];
1149 unsigned char character
= gc_buffer_characters
[index
];
1150 unsigned char colorcode
= gc_buffer_colorcodes
[index
];
1151 unsigned char colorcodesave
= gc_color_code
;
1153 simple_unlock(&gc_buffer_lock
);
1156 gc_update_color(COLOR_CODE_GET(colorcode
, FALSE
), TRUE
);
1157 gc_update_color(COLOR_CODE_GET(colorcode
, TRUE
), FALSE
);
1159 gc_ops
.paint_char(xx
, yy
, character
, attribute
, 0, 0);
1161 gc_update_color(COLOR_CODE_GET(colorcodesave
, TRUE
), TRUE
);
1162 gc_update_color(COLOR_CODE_GET(colorcodesave
, FALSE
), FALSE
);
1166 simple_unlock(&gc_buffer_lock
);
1169 gc_ops
.show_cursor(xx
, yy
);
1174 gc_update_color(int color
, boolean_t fore
)
1176 gc_color_code
= COLOR_CODE_SET(gc_color_code
, color
, fore
);
1177 gc_ops
.update_color(color
, fore
);
1181 vcputc(int l
, int u
, int c
)
1183 if ( gc_enabled
|| debug_mode
)
1185 gc_hide_cursor(gc_x
, gc_y
);
1187 gc_show_cursor(gc_x
, gc_y
);
1194 * Video Console (Back-End)
1195 * ------------------------
1199 * For the color support (Michel Pollet)
1201 static unsigned char vc_color_index_table
[33] =
1202 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1203 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 };
1205 static unsigned long vc_colors
[8][3] = {
1206 { 0xFFFFFFFF, 0x00000000, 0x00000000 }, /* black */
1207 { 0x23232323, 0x7C007C00, 0x00FF0000 }, /* red */
1208 { 0xb9b9b9b9, 0x03e003e0, 0x0000FF00 }, /* green */
1209 { 0x05050505, 0x7FE07FE0, 0x00FFFF00 }, /* yellow */
1210 { 0xd2d2d2d2, 0x001f001f, 0x000000FF}, /* blue */
1211 // { 0x80808080, 0x31933193, 0x00666699 }, /* blue */
1212 { 0x18181818, 0x7C1F7C1F, 0x00FF00FF }, /* magenta */
1213 { 0xb4b4b4b4, 0x03FF03FF, 0x0000FFFF }, /* cyan */
1214 { 0x00000000, 0x7FFF7FFF, 0x00FFFFFF } /* white */
1217 static unsigned long vc_color_fore
= 0;
1218 static unsigned long vc_color_back
= 0;
1221 * New Rendering code from Michel Pollet
1224 /* Rendered Font Buffer */
1225 static unsigned char *vc_rendered_font
= NULL
;
1227 /* Rendered Font Size */
1228 static unsigned long vc_rendered_font_size
= 0;
1230 /* Size of a character in the table (bytes) */
1231 static int vc_rendered_char_size
= 0;
1233 #define REN_MAX_DEPTH 32
1234 static unsigned char vc_rendered_char
[ISO_CHAR_HEIGHT
* ((REN_MAX_DEPTH
/ 8) * ISO_CHAR_WIDTH
)];
1236 static void vc_clear_screen(int xx
, int yy
, int scrreg_top
, int scrreg_bottom
, int which
);
1237 static void vc_enable(boolean_t enable
);
1238 static void vc_initialize(struct vc_info
* vinfo_p
);
1239 static void vc_paint_char(int xx
, int yy
, unsigned char ch
, int attrs
, unsigned char ch_previous
, int attrs_previous
);
1240 static void vc_paint_char_8(int xx
, int yy
, unsigned char ch
, int attrs
, unsigned char ch_previous
, int attrs_previous
);
1241 static void vc_paint_char_16(int xx
, int yy
, unsigned char ch
, int attrs
, unsigned char ch_previous
, int attrs_previous
);
1242 static void vc_paint_char_32(int xx
, int yy
, unsigned char ch
, int attrs
, unsigned char ch_previous
, int attrs_previous
);
1243 static void vc_render_char(unsigned char ch
, unsigned char *renderptr
, short newdepth
);
1244 static void vc_render_font(short newdepth
);
1245 static void vc_reverse_cursor(int xx
, int yy
);
1246 static void vc_scroll_down(int num
, int scrreg_top
, int scrreg_bottom
);
1247 static void vc_scroll_up(int num
, int scrreg_top
, int scrreg_bottom
);
1248 static void vc_update_color(int color
, boolean_t fore
);
1251 vc_clear_screen(int xx
, int yy
, int scrreg_top
, int scrreg_bottom
, int which
)
1253 unsigned long *p
, *endp
, *row
;
1255 int rowline
, rowlongs
;
1260 linelongs
= vinfo
.v_rowbytes
* (ISO_CHAR_HEIGHT
>> 2);
1261 rowline
= vinfo
.v_rowscanbytes
>> 2;
1262 rowlongs
= vinfo
.v_rowbytes
>> 2;
1264 p
= (unsigned long*) vinfo
.v_baseaddr
;
1265 endp
= (unsigned long*) vinfo
.v_baseaddr
;
1268 case 0: /* To end of screen */
1269 gc_clear_line(xx
, yy
, 0);
1270 if (yy
< scrreg_bottom
- 1) {
1271 p
+= (yy
+ 1) * linelongs
;
1272 endp
+= scrreg_bottom
* linelongs
;
1275 case 1: /* To start of screen */
1276 gc_clear_line(xx
, yy
, 1);
1277 if (yy
> scrreg_top
) {
1278 p
+= scrreg_top
* linelongs
;
1279 endp
+= yy
* linelongs
;
1282 case 2: /* Whole screen */
1283 p
+= scrreg_top
* linelongs
;
1284 if (scrreg_bottom
== vinfo
.v_rows
) {
1285 endp
+= rowlongs
* vinfo
.v_height
;
1287 endp
+= scrreg_bottom
* linelongs
;
1292 for (row
= p
; row
< endp
; row
+= rowlongs
) {
1293 for (col
= 0; col
< rowline
; col
++)
1294 *(row
+col
) = vc_color_back
;
1299 vc_enable(boolean_t enable
)
1303 vc_render_font(vinfo
.v_depth
);
1308 vc_initialize(struct vc_info
* vinfo_p
)
1310 vinfo
.v_rows
= vinfo
.v_height
/ ISO_CHAR_HEIGHT
;
1311 vinfo
.v_columns
= vinfo
.v_width
/ ISO_CHAR_WIDTH
;
1312 vinfo
.v_rowscanbytes
= (vinfo
.v_depth
/ 8) * vinfo
.v_width
;
1316 vc_paint_char(int xx
, int yy
, unsigned char ch
, int attrs
, unsigned char ch_previous
, int attrs_previous
)
1321 switch( vinfo
.v_depth
) {
1323 vc_paint_char_8(xx
, yy
, ch
, attrs
, ch_previous
, attrs_previous
);
1326 vc_paint_char_16(xx
, yy
, ch
, attrs
, ch_previous
, attrs_previous
);
1329 vc_paint_char_32(xx
, yy
, ch
, attrs
, ch_previous
, attrs_previous
);
1335 vc_paint_char_8(int xx
, int yy
, unsigned char ch
, int attrs
, unsigned char ch_previous
, int attrs_previous
)
1337 unsigned long *theChar
;
1338 unsigned long *where
;
1341 if (vc_rendered_font
) {
1342 theChar
= (unsigned long*)(vc_rendered_font
+ (ch
* vc_rendered_char_size
));
1344 vc_render_char(ch
, vc_rendered_char
, 8);
1345 theChar
= (unsigned long*)(vc_rendered_char
);
1347 where
= (unsigned long*)(vinfo
.v_baseaddr
+
1348 (yy
* ISO_CHAR_HEIGHT
* vinfo
.v_rowbytes
) +
1349 (xx
* ISO_CHAR_WIDTH
));
1351 if (!attrs
) for (i
= 0; i
< ISO_CHAR_HEIGHT
; i
++) { /* No attr? FLY !*/
1352 unsigned long *store
= where
;
1354 for (x
= 0; x
< 2; x
++) {
1355 unsigned long val
= *theChar
++;
1356 val
= (vc_color_back
& ~val
) | (vc_color_fore
& val
);
1360 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
1361 } else for (i
= 0; i
< ISO_CHAR_HEIGHT
; i
++) { /* a little slower */
1362 unsigned long *store
= where
, lastpixel
= 0;
1364 for (x
= 0 ; x
< 2; x
++) {
1365 unsigned long val
= *theChar
++, save
= val
;
1366 if (attrs
& ATTR_BOLD
) { /* bold support */
1367 if (lastpixel
&& !(save
& 0xFF000000))
1369 if ((save
& 0xFFFF0000) == 0xFF000000)
1371 if ((save
& 0x00FFFF00) == 0x00FF0000)
1373 if ((save
& 0x0000FFFF) == 0x0000FF00)
1376 if (attrs
& ATTR_REVERSE
) val
= ~val
;
1377 if (attrs
& ATTR_UNDER
&& i
== ISO_CHAR_HEIGHT
-1) val
= ~val
;
1379 val
= (vc_color_back
& ~val
) | (vc_color_fore
& val
);
1381 lastpixel
= save
& 0xff;
1384 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
1390 vc_paint_char_16(int xx
, int yy
, unsigned char ch
, int attrs
, unsigned char ch_previous
, int attrs_previous
)
1392 unsigned long *theChar
;
1393 unsigned long *where
;
1396 if (vc_rendered_font
) {
1397 theChar
= (unsigned long*)(vc_rendered_font
+ (ch
* vc_rendered_char_size
));
1399 vc_render_char(ch
, vc_rendered_char
, 16);
1400 theChar
= (unsigned long*)(vc_rendered_char
);
1402 where
= (unsigned long*)(vinfo
.v_baseaddr
+
1403 (yy
* ISO_CHAR_HEIGHT
* vinfo
.v_rowbytes
) +
1404 (xx
* ISO_CHAR_WIDTH
* 2));
1406 if (!attrs
) for (i
= 0; i
< ISO_CHAR_HEIGHT
; i
++) { /* No attrs ? FLY ! */
1407 unsigned long *store
= where
;
1409 for (x
= 0; x
< 4; x
++) {
1410 unsigned long val
= *theChar
++;
1411 val
= (vc_color_back
& ~val
) | (vc_color_fore
& val
);
1415 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
1416 } else for (i
= 0; i
< ISO_CHAR_HEIGHT
; i
++) { /* a little bit slower */
1417 unsigned long *store
= where
, lastpixel
= 0;
1419 for (x
= 0 ; x
< 4; x
++) {
1420 unsigned long val
= *theChar
++, save
= val
;
1421 if (attrs
& ATTR_BOLD
) { /* bold support */
1422 if (save
== 0xFFFF0000) val
|= 0xFFFF;
1423 else if (lastpixel
&& !(save
& 0xFFFF0000))
1426 if (attrs
& ATTR_REVERSE
) val
= ~val
;
1427 if (attrs
& ATTR_UNDER
&& i
== ISO_CHAR_HEIGHT
-1) val
= ~val
;
1429 val
= (vc_color_back
& ~val
) | (vc_color_fore
& val
);
1432 lastpixel
= save
& 0x7fff;
1435 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
1441 vc_paint_char_32(int xx
, int yy
, unsigned char ch
, int attrs
, unsigned char ch_previous
, int attrs_previous
)
1443 unsigned long *theChar
;
1444 unsigned long *theCharPrevious
;
1445 unsigned long *where
;
1448 if (vc_rendered_font
) {
1449 theChar
= (unsigned long*)(vc_rendered_font
+ (ch
* vc_rendered_char_size
));
1450 theCharPrevious
= (unsigned long*)(vc_rendered_font
+ (ch_previous
* vc_rendered_char_size
));
1452 vc_render_char(ch
, vc_rendered_char
, 32);
1453 theChar
= (unsigned long*)(vc_rendered_char
);
1454 theCharPrevious
= NULL
;
1457 theCharPrevious
= NULL
;
1459 if (attrs_previous
) {
1460 theCharPrevious
= NULL
;
1462 where
= (unsigned long*)(vinfo
.v_baseaddr
+
1463 (yy
* ISO_CHAR_HEIGHT
* vinfo
.v_rowbytes
) +
1464 (xx
* ISO_CHAR_WIDTH
* 4));
1466 if (!attrs
) for (i
= 0; i
< ISO_CHAR_HEIGHT
; i
++) { /* No attrs ? FLY ! */
1467 unsigned long *store
= where
;
1469 for (x
= 0; x
< 8; x
++) {
1470 unsigned long val
= *theChar
++;
1471 if (theCharPrevious
== NULL
|| val
!= *theCharPrevious
++ ) {
1472 val
= (vc_color_back
& ~val
) | (vc_color_fore
& val
);
1479 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
1480 } else for (i
= 0; i
< ISO_CHAR_HEIGHT
; i
++) { /* a little slower */
1481 unsigned long *store
= where
, lastpixel
= 0;
1483 for (x
= 0 ; x
< 8; x
++) {
1484 unsigned long val
= *theChar
++, save
= val
;
1485 if (attrs
& ATTR_BOLD
) { /* bold support */
1486 if (lastpixel
&& !save
)
1489 if (attrs
& ATTR_REVERSE
) val
= ~val
;
1490 if (attrs
& ATTR_UNDER
&& i
== ISO_CHAR_HEIGHT
-1) val
= ~val
;
1492 val
= (vc_color_back
& ~val
) | (vc_color_fore
& val
);
1497 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
1503 vc_render_char(unsigned char ch
, unsigned char *renderptr
, short newdepth
)
1506 unsigned char *charptr
;
1507 unsigned short *shortptr
;
1508 unsigned long *longptr
;
1509 } current
; /* current place in rendered font, multiple types. */
1511 unsigned char *theChar
; /* current char in iso_font */
1515 current
.charptr
= renderptr
;
1516 theChar
= iso_font
+ (ch
* ISO_CHAR_HEIGHT
);
1518 for (line
= 0; line
< ISO_CHAR_HEIGHT
; line
++) {
1519 unsigned char mask
= 1;
1523 *current
.charptr
++ = (*theChar
& mask
) ? 0xFF : 0;
1526 *current
.shortptr
++ = (*theChar
& mask
) ? 0xFFFF : 0;
1530 *current
.longptr
++ = (*theChar
& mask
) ? 0xFFFFFFFF : 0;
1534 } while (mask
); /* while the single bit drops to the right */
1540 vc_render_font(short newdepth
)
1542 static short olddepth
= 0;
1544 int charindex
; /* index in ISO font */
1546 if (vm_initialized
== FALSE
) {
1547 return; /* nothing to do */
1549 if (olddepth
== newdepth
&& vc_rendered_font
) {
1550 return; /* nothing to do */
1552 if (vc_rendered_font
) {
1553 kfree((vm_offset_t
)vc_rendered_font
, vc_rendered_font_size
);
1556 vc_rendered_char_size
= ISO_CHAR_HEIGHT
* ((newdepth
/ 8) * ISO_CHAR_WIDTH
);
1557 vc_rendered_font_size
= (ISO_CHAR_MAX
-ISO_CHAR_MIN
+1) * vc_rendered_char_size
;
1558 vc_rendered_font
= (unsigned char *) kalloc(vc_rendered_font_size
);
1560 if (vc_rendered_font
== NULL
) {
1561 vc_rendered_font_size
= 0;
1565 for (charindex
= ISO_CHAR_MIN
; charindex
<= ISO_CHAR_MAX
; charindex
++) {
1566 vc_render_char(charindex
, vc_rendered_font
+ (charindex
* vc_rendered_char_size
), newdepth
);
1569 olddepth
= newdepth
;
1573 vc_reverse_cursor(int xx
, int yy
)
1575 unsigned long *where
;
1581 where
= (unsigned long*)(vinfo
.v_baseaddr
+
1582 (yy
* ISO_CHAR_HEIGHT
* vinfo
.v_rowbytes
) +
1583 (xx
/** ISO_CHAR_WIDTH*/ * vinfo
.v_depth
));
1584 for (line
= 0; line
< ISO_CHAR_HEIGHT
; line
++) {
1585 switch (vinfo
.v_depth
) {
1587 where
[0] = ~where
[0];
1588 where
[1] = ~where
[1];
1591 for (col
= 0; col
< 4; col
++)
1592 where
[col
] = ~where
[col
];
1595 for (col
= 0; col
< 8; col
++)
1596 where
[col
] = ~where
[col
];
1599 where
= (unsigned long*)(((unsigned char*)where
)+vinfo
.v_rowbytes
);
1604 vc_scroll_down(int num
, int scrreg_top
, int scrreg_bottom
)
1606 unsigned long *from
, *to
, linelongs
, i
, line
, rowline
, rowscanline
;
1611 linelongs
= vinfo
.v_rowbytes
* (ISO_CHAR_HEIGHT
>> 2);
1612 rowline
= vinfo
.v_rowbytes
>> 2;
1613 rowscanline
= vinfo
.v_rowscanbytes
>> 2;
1615 to
= (unsigned long *) vinfo
.v_baseaddr
+ (linelongs
* scrreg_bottom
)
1616 - (rowline
- rowscanline
);
1617 from
= to
- (linelongs
* num
); /* handle multiple line scroll (Michel Pollet) */
1619 i
= (scrreg_bottom
- scrreg_top
) - num
;
1622 for (line
= 0; line
< ISO_CHAR_HEIGHT
; line
++) {
1624 * Only copy what is displayed
1626 video_scroll_down((unsigned int) from
,
1627 (unsigned int) (from
-(vinfo
.v_rowscanbytes
>> 2)),
1637 vc_scroll_up(int num
, int scrreg_top
, int scrreg_bottom
)
1639 unsigned long *from
, *to
, linelongs
, i
, line
, rowline
, rowscanline
;
1644 linelongs
= vinfo
.v_rowbytes
* (ISO_CHAR_HEIGHT
>> 2);
1645 rowline
= vinfo
.v_rowbytes
>> 2;
1646 rowscanline
= vinfo
.v_rowscanbytes
>> 2;
1648 to
= (unsigned long *) vinfo
.v_baseaddr
+ (scrreg_top
* linelongs
);
1649 from
= to
+ (linelongs
* num
); /* handle multiple line scroll (Michel Pollet) */
1651 i
= (scrreg_bottom
- scrreg_top
) - num
;
1654 for (line
= 0; line
< ISO_CHAR_HEIGHT
; line
++) {
1656 * Only copy what is displayed
1658 video_scroll_up((unsigned int) from
,
1659 (unsigned int) (from
+(vinfo
.v_rowscanbytes
>> 2)),
1669 vc_update_color(int color
, boolean_t fore
)
1674 vc_color_fore
= vc_colors
[color
][vc_color_index_table
[vinfo
.v_depth
]];
1676 vc_color_back
= vc_colors
[color
][vc_color_index_table
[vinfo
.v_depth
]];
1681 * Video Console (Back-End): Icon Control
1682 * --------------------------------------
1685 struct vc_progress_element
{
1686 unsigned int version
;
1689 unsigned char count
;
1690 unsigned char res
[3];
1696 unsigned int res2
[3];
1697 unsigned char data
[0];
1699 typedef struct vc_progress_element vc_progress_element
;
1701 static vc_progress_element
* vc_progress
;
1702 static const unsigned char * vc_progress_data
;
1703 static const unsigned char * vc_progress_alpha
;
1704 static boolean_t vc_progress_enable
;
1705 static const unsigned char * vc_clut
;
1706 static const unsigned char * vc_clut8
;
1707 static unsigned char vc_revclut8
[256];
1708 static unsigned int vc_progress_tick
;
1709 static boolean_t vc_needsave
;
1710 static vm_address_t vc_saveunder
;
1711 static vm_size_t vc_saveunder_len
;
1712 decl_simple_lock_data(,vc_progress_lock
)
1714 static void vc_blit_rect( int x
, int y
, int width
, int height
,
1715 const unsigned char * dataPtr
, const unsigned char * alphaPtr
,
1716 vm_address_t backBuffer
, boolean_t save
, boolean_t static_alpha
);
1717 static void vc_blit_rect_8( int x
, int y
, int width
, int height
,
1718 const unsigned char * dataPtr
, const unsigned char * alphaPtr
,
1719 unsigned char * backBuffer
, boolean_t save
, boolean_t static_alpha
);
1720 static void vc_blit_rect_16( int x
, int y
, int width
, int height
,
1721 const unsigned char * dataPtr
, const unsigned char * alphaPtr
,
1722 unsigned short * backBuffer
, boolean_t save
, boolean_t static_alpha
);
1723 static void vc_blit_rect_32( int x
, int y
, int width
, int height
,
1724 const unsigned char * dataPtr
, const unsigned char * alphaPtr
,
1725 unsigned int * backBuffer
, boolean_t save
, boolean_t static_alpha
);
1726 extern void vc_display_icon( vc_progress_element
* desc
, const unsigned char * data
);
1727 extern void vc_progress_initialize( vc_progress_element
* desc
, const unsigned char * data
, const unsigned char * clut
);
1728 static void vc_progress_set( boolean_t enable
, unsigned int initial_tick
);
1729 static void vc_progress_task( void * arg
);
1731 static void vc_blit_rect( int x
, int y
,
1732 int width
, int height
,
1733 const unsigned char * dataPtr
,
1734 const unsigned char * alphaPtr
,
1735 vm_address_t backBuffer
,
1736 boolean_t save
, boolean_t static_alpha
)
1741 switch( vinfo
.v_depth
) {
1743 if( vc_clut8
== vc_clut
)
1744 vc_blit_rect_8( x
, y
, width
, height
, dataPtr
, alphaPtr
, (unsigned char *) backBuffer
, save
, static_alpha
);
1747 vc_blit_rect_16( x
, y
, width
, height
, dataPtr
, alphaPtr
, (unsigned short *) backBuffer
, save
, static_alpha
);
1750 vc_blit_rect_32( x
, y
, width
, height
, dataPtr
, alphaPtr
, (unsigned int *) backBuffer
, save
, static_alpha
);
1755 static void vc_blit_rect_8( int x
, int y
,
1756 int width
, int height
,
1757 const unsigned char * dataPtr
,
1758 const unsigned char * alphaPtr
,
1759 unsigned char * backPtr
,
1760 boolean_t save
, boolean_t static_alpha
)
1762 volatile unsigned char * dst
;
1766 dst
= (unsigned char *)(vinfo
.v_baseaddr
+
1767 (y
* vinfo
.v_rowbytes
) +
1770 for( line
= 0; line
< height
; line
++) {
1771 for( col
= 0; col
< width
; col
++) {
1773 if( dataPtr
!= 0) data
= *dataPtr
++;
1774 else if( alphaPtr
!= 0) data
= vc_revclut8
[*alphaPtr
++];
1775 *(dst
+ col
) = data
;
1777 dst
= (volatile unsigned char *) (((int)dst
) + vinfo
.v_rowbytes
);
1781 static void vc_blit_rect_16( int x
, int y
,
1782 int width
, int height
,
1783 const unsigned char * dataPtr
,
1784 const unsigned char * alphaPtr
,
1785 unsigned short * backPtr
,
1786 boolean_t save
, boolean_t static_alpha
)
1788 volatile unsigned short * dst
;
1790 unsigned int data
, index
, alpha
, back
;
1792 dst
= (volatile unsigned short *)(vinfo
.v_baseaddr
+
1793 (y
* vinfo
.v_rowbytes
) +
1796 for( line
= 0; line
< height
; line
++) {
1797 for( col
= 0; col
< width
; col
++) {
1803 if( alphaPtr
&& backPtr
) {
1805 alpha
= *alphaPtr
++;
1808 if( vc_clut
[index
+ 0] > alpha
)
1809 data
|= (((vc_clut
[index
+ 0] - alpha
) & 0xf8) << 7);
1810 if( vc_clut
[index
+ 1] > alpha
)
1811 data
|= (((vc_clut
[index
+ 1] - alpha
) & 0xf8) << 2);
1812 if( vc_clut
[index
+ 2] > alpha
)
1813 data
|= (((vc_clut
[index
+ 2] - alpha
) & 0xf8) >> 3);
1817 back
= *(dst
+ col
);
1820 back
= (((((back
& 0x7c00) * alpha
) + 0x3fc00) >> 8) & 0x7c00)
1821 | (((((back
& 0x03e0) * alpha
) + 0x01fe0) >> 8) & 0x03e0)
1822 | (((((back
& 0x001f) * alpha
) + 0x000ff) >> 8) & 0x001f);
1827 if ( !static_alpha
) {
1828 back
= (((((back
& 0x7c00) * alpha
) + 0x3fc00) >> 8) & 0x7c00)
1829 | (((((back
& 0x03e0) * alpha
) + 0x01fe0) >> 8) & 0x03e0)
1830 | (((((back
& 0x001f) * alpha
) + 0x000ff) >> 8) & 0x001f);
1838 data
= ( (0xf8 & (vc_clut
[index
+ 0])) << 7)
1839 | ( (0xf8 & (vc_clut
[index
+ 1])) << 2)
1840 | ( (0xf8 & (vc_clut
[index
+ 2])) >> 3);
1843 *(dst
+ col
) = data
;
1845 dst
= (volatile unsigned short *) (((int)dst
) + vinfo
.v_rowbytes
);
1849 static void vc_blit_rect_32( int x
, int y
,
1850 int width
, int height
,
1851 const unsigned char * dataPtr
,
1852 const unsigned char * alphaPtr
,
1853 unsigned int * backPtr
,
1854 boolean_t save
, boolean_t static_alpha
)
1856 volatile unsigned int * dst
;
1858 unsigned int data
, index
, alpha
, back
;
1860 dst
= (volatile unsigned int *) (vinfo
.v_baseaddr
+
1861 (y
* vinfo
.v_rowbytes
) +
1864 for( line
= 0; line
< height
; line
++) {
1865 for( col
= 0; col
< width
; col
++) {
1871 if( alphaPtr
&& backPtr
) {
1873 alpha
= *alphaPtr
++;
1876 if( vc_clut
[index
+ 0] > alpha
)
1877 data
|= ((vc_clut
[index
+ 0] - alpha
) << 16);
1878 if( vc_clut
[index
+ 1] > alpha
)
1879 data
|= ((vc_clut
[index
+ 1] - alpha
) << 8);
1880 if( vc_clut
[index
+ 2] > alpha
)
1881 data
|= ((vc_clut
[index
+ 2] - alpha
));
1885 back
= *(dst
+ col
);
1888 back
= (((((back
& 0x00ff00ff) * alpha
) + 0x00ff00ff) >> 8) & 0x00ff00ff)
1889 | (((((back
& 0x0000ff00) * alpha
) + 0x0000ff00) >> 8) & 0x0000ff00);
1894 if ( !static_alpha
) {
1895 back
= (((((back
& 0x00ff00ff) * alpha
) + 0x00ff00ff) >> 8) & 0x00ff00ff)
1896 | (((((back
& 0x0000ff00) * alpha
) + 0x0000ff00) >> 8) & 0x0000ff00);
1904 data
= (vc_clut
[index
+ 0] << 16)
1905 | (vc_clut
[index
+ 1] << 8)
1906 | (vc_clut
[index
+ 2]);
1909 *(dst
+ col
) = data
;
1911 dst
= (volatile unsigned int *) (((int)dst
) + vinfo
.v_rowbytes
);
1915 void vc_display_icon( vc_progress_element
* desc
,
1916 const unsigned char * data
)
1918 int x
, y
, width
, height
;
1920 if( vc_progress_enable
&& vc_clut
) {
1922 width
= desc
->width
;
1923 height
= desc
->height
;
1926 if( 1 & desc
->flags
) {
1927 x
+= ((vinfo
.v_width
- width
) / 2);
1928 y
+= ((vinfo
.v_height
- height
) / 2);
1930 vc_blit_rect( x
, y
, width
, height
, data
, NULL
, (vm_address_t
) NULL
, FALSE
, TRUE
);
1935 vc_progress_initialize( vc_progress_element
* desc
,
1936 const unsigned char * data
,
1937 const unsigned char * clut
)
1939 if( (!clut
) || (!desc
) || (!data
))
1945 vc_progress_data
= data
;
1946 if( 2 & vc_progress
->flags
)
1947 vc_progress_alpha
= vc_progress_data
1948 + vc_progress
->count
* vc_progress
->width
* vc_progress
->height
;
1950 vc_progress_alpha
= NULL
;
1951 vc_progress_tick
= vc_progress
->time
* hz
/ 1000;
1953 simple_lock_init(&vc_progress_lock
, ETAP_IO_TTY
);
1957 vc_progress_set( boolean_t enable
, unsigned int initial_tick
)
1960 vm_address_t saveBuf
= 0;
1961 vm_size_t saveLen
= 0;
1964 unsigned char pdata8
;
1965 unsigned short pdata16
;
1966 unsigned short * buf16
;
1967 unsigned int pdata32
;
1968 unsigned int * buf32
;
1974 saveLen
= vc_progress
->width
* vc_progress
->height
* vinfo
.v_depth
/ 8;
1975 saveBuf
= kalloc( saveLen
);
1977 switch( vinfo
.v_depth
) {
1979 for( count
= 0; count
< 256; count
++) {
1980 vc_revclut8
[count
] = vc_clut
[0x01 * 3];
1981 pdata8
= (vc_clut
[0x01 * 3] * count
+ 0x0ff) >> 8;
1982 for( index
= 0; index
< 256; index
++) {
1983 if( (pdata8
== vc_clut
[index
* 3 + 0]) &&
1984 (pdata8
== vc_clut
[index
* 3 + 1]) &&
1985 (pdata8
== vc_clut
[index
* 3 + 2])) {
1986 vc_revclut8
[count
] = index
;
1991 memset( (void *) saveBuf
, 0x01, saveLen
);
1995 buf16
= (unsigned short *) saveBuf
;
1996 pdata16
= ((vc_clut
[0x01 * 3 + 0] & 0xf8) << 7)
1997 | ((vc_clut
[0x01 * 3 + 0] & 0xf8) << 2)
1998 | ((vc_clut
[0x01 * 3 + 0] & 0xf8) >> 3);
1999 for( count
= 0; count
< saveLen
/ 2; count
++)
2000 buf16
[count
] = pdata16
;
2004 buf32
= (unsigned int *) saveBuf
;
2005 pdata32
= ((vc_clut
[0x01 * 3 + 0] & 0xff) << 16)
2006 | ((vc_clut
[0x01 * 3 + 1] & 0xff) << 8)
2007 | ((vc_clut
[0x01 * 3 + 2] & 0xff) << 0);
2008 for( count
= 0; count
< saveLen
/ 4; count
++)
2009 buf32
[count
] = pdata32
;
2015 simple_lock(&vc_progress_lock
);
2017 if( vc_progress_enable
!= enable
) {
2018 vc_progress_enable
= enable
;
2021 vc_saveunder
= saveBuf
;
2022 vc_saveunder_len
= saveLen
;
2025 timeout(vc_progress_task
, (void *) 0,
2029 saveBuf
= vc_saveunder
;
2030 saveLen
= vc_saveunder_len
;
2032 vc_saveunder_len
= 0;
2034 untimeout( vc_progress_task
, (void *) 0 );
2038 simple_unlock(&vc_progress_lock
);
2042 kfree( saveBuf
, saveLen
);
2045 static void vc_progress_task( void * arg
)
2048 int count
= (int) arg
;
2049 int x
, y
, width
, height
;
2050 const unsigned char * data
;
2053 simple_lock(&vc_progress_lock
);
2055 if( vc_progress_enable
) {
2058 if( count
>= vc_progress
->count
)
2061 width
= vc_progress
->width
;
2062 height
= vc_progress
->height
;
2063 x
= vc_progress
->dx
;
2064 y
= vc_progress
->dy
;
2065 data
= vc_progress_data
;
2066 data
+= count
* width
* height
;
2067 if( 1 & vc_progress
->flags
) {
2068 x
+= ((vinfo
.v_width
- width
) / 2);
2069 y
+= ((vinfo
.v_height
- height
) / 2);
2071 vc_blit_rect( x
, y
, width
, height
,
2072 NULL
, data
, vc_saveunder
,
2073 vc_needsave
, (0 == (4 & vc_progress
->flags
)) );
2074 vc_needsave
= FALSE
;
2076 timeout( vc_progress_task
, (void *) count
,
2079 simple_unlock(&vc_progress_lock
);
2084 * Generic Console (Front-End): Master Control
2085 * -------------------------------------------
2089 #include <console/i386/text_console.h>
2090 #endif /* __i386__ */
2092 static boolean_t gc_acquired
= FALSE
;
2093 static boolean_t gc_graphics_boot
= FALSE
;
2095 static unsigned int lastVideoPhys
= 0;
2096 static unsigned int lastVideoVirt
= 0;
2097 static unsigned int lastVideoSize
= 0;
2101 initialize_screen(Boot_Video
* boot_vinfo
, unsigned int op
)
2105 vinfo
.v_name
[0] = 0;
2106 vinfo
.v_width
= boot_vinfo
->v_width
;
2107 vinfo
.v_height
= boot_vinfo
->v_height
;
2108 vinfo
.v_depth
= boot_vinfo
->v_depth
;
2109 vinfo
.v_rowbytes
= boot_vinfo
->v_rowBytes
;
2110 vinfo
.v_physaddr
= boot_vinfo
->v_baseAddr
;
2111 vinfo
.v_baseaddr
= vinfo
.v_physaddr
;
2112 vinfo
.v_type
= boot_vinfo
->v_display
;
2114 if ( (vinfo
.v_type
== TEXT_MODE
) )
2116 // Text mode setup by the booter.
2117 gc_ops
.initialize
= tc_initialize
;
2118 gc_ops
.enable
= tc_enable
;
2119 gc_ops
.paint_char
= tc_paint_char
;
2120 gc_ops
.clear_screen
= tc_clear_screen
;
2121 gc_ops
.scroll_down
= tc_scroll_down
;
2122 gc_ops
.scroll_up
= tc_scroll_up
;
2123 gc_ops
.hide_cursor
= tc_hide_cursor
;
2124 gc_ops
.show_cursor
= tc_show_cursor
;
2125 gc_ops
.update_color
= tc_update_color
;
2130 // Graphics mode setup by the booter.
2131 gc_ops
.initialize
= vc_initialize
;
2132 gc_ops
.enable
= vc_enable
;
2133 gc_ops
.paint_char
= vc_paint_char
;
2134 gc_ops
.scroll_down
= vc_scroll_down
;
2135 gc_ops
.scroll_up
= vc_scroll_up
;
2136 gc_ops
.clear_screen
= vc_clear_screen
;
2137 gc_ops
.hide_cursor
= vc_reverse_cursor
;
2138 gc_ops
.show_cursor
= vc_reverse_cursor
;
2139 gc_ops
.update_color
= vc_update_color
;
2142 gc_initialize(&vinfo
);
2144 #ifdef GRATEFULDEBUGGER
2145 GratefulDebInit((bootBumbleC
*)boot_vinfo
); /* Re-initialize GratefulDeb */
2146 #endif /* GRATEFULDEBUGGER */
2151 case kPEGraphicsMode
:
2152 panicDialogDesired
= TRUE
;
2153 gc_graphics_boot
= TRUE
;
2157 panicDialogDesired
= FALSE
;
2158 gc_graphics_boot
= FALSE
;
2161 case kPEAcquireScreen
:
2162 if ( gc_acquired
) break;
2164 vc_progress_set( gc_graphics_boot
, 2 * hz
);
2165 gc_enable( !gc_graphics_boot
);
2169 case kPEEnableScreen
:
2174 panicDialogDesired
= FALSE
;
2175 if ( gc_acquired
== FALSE
) break;
2176 if ( gc_graphics_boot
== FALSE
) break;
2178 vc_progress_set( FALSE
, 0 );
2182 case kPEDisableScreen
:
2186 case kPEReleaseScreen
:
2187 gc_acquired
= FALSE
;
2189 vc_progress_set( FALSE
, 0 );
2192 #ifdef GRATEFULDEBUGGER
2193 GratefulDebInit(0); /* Stop grateful debugger */
2194 #endif /* GRATEFULDEBUGGER */
2197 #ifdef GRATEFULDEBUGGER
2198 if ( boot_vinfo
) GratefulDebInit((bootBumbleC
*)boot_vinfo
); /* Re initialize GratefulDeb */
2199 #endif /* GRATEFULDEBUGGER */
2203 initialize_screen(Boot_Video
* boot_vinfo
, unsigned int op
)
2205 unsigned int fbsize
;
2206 unsigned int newVideoVirt
;
2211 // bcopy((const void *)boot_vinfo, (void *)&boot_video_info, sizeof(boot_video_info));
2214 * First, check if we are changing the size and/or location of the framebuffer
2217 vinfo
.v_name
[0] = 0;
2218 vinfo
.v_width
= boot_vinfo
->v_width
;
2219 vinfo
.v_height
= boot_vinfo
->v_height
;
2220 vinfo
.v_depth
= boot_vinfo
->v_depth
;
2221 vinfo
.v_rowbytes
= boot_vinfo
->v_rowBytes
;
2222 vinfo
.v_physaddr
= boot_vinfo
->v_baseAddr
; /* Get the physical address */
2224 kprintf("initialize_screen: b=%08X, w=%08X, h=%08X, r=%08X\n", /* (BRINGUP) */
2225 vinfo
.v_physaddr
, vinfo
.v_width
, vinfo
.v_height
, vinfo
.v_rowbytes
); /* (BRINGUP) */
2227 if (!vinfo
.v_physaddr
) /* Check to see if we have a framebuffer */
2229 kprintf("initialize_screen: No video - forcing serial mode\n"); /* (BRINGUP) */
2230 vinfo
.v_depth
= 0; /* vc routines are nop */
2231 (void)switch_to_serial_console(); /* Switch into serial mode */
2232 gc_graphics_boot
= FALSE
; /* Say we are not in graphics mode */
2233 disableConsoleOutput
= FALSE
; /* Allow printfs to happen */
2239 * Note that for the first time only, boot_vinfo->v_baseAddr is physical.
2242 if (kernel_map
!= VM_MAP_NULL
) /* If VM is up, we are given a virtual address */
2244 fbppage
= pmap_find_phys(kernel_pmap
, (addr64_t
)boot_vinfo
->v_baseAddr
); /* Get the physical address of frame buffer */
2245 if(!fbppage
) /* Did we find it? */
2247 panic("initialize_screen: Strange framebuffer - addr = %08X\n", boot_vinfo
->v_baseAddr
);
2249 vinfo
.v_physaddr
= (fbppage
<< 12) | (boot_vinfo
->v_baseAddr
& PAGE_MASK
); /* Get the physical address */
2254 fbsize
= round_page_32(vinfo
.v_height
* vinfo
.v_rowbytes
); /* Remember size */
2256 if ((lastVideoPhys
!= vinfo
.v_physaddr
) || (fbsize
> lastVideoSize
)) /* Did framebuffer change location or get bigger? */
2258 newVideoVirt
= io_map_spec((vm_offset_t
)vinfo
.v_physaddr
, fbsize
); /* Allocate address space for framebuffer */
2260 if (lastVideoVirt
) /* Was the framebuffer mapped before? */
2262 pmap_remove(kernel_pmap
, trunc_page_64(lastVideoVirt
),
2263 round_page_64(lastVideoVirt
+ lastVideoSize
)); /* Toss mappings */
2265 if(lastVideoVirt
<= vm_last_addr
) /* Was this not a special pre-VM mapping? */
2267 kmem_free(kernel_map
, lastVideoVirt
, lastVideoSize
); /* Toss kernel addresses */
2271 lastVideoPhys
= vinfo
.v_physaddr
; /* Remember the framebuffer address */
2272 lastVideoSize
= fbsize
; /* Remember the size */
2273 lastVideoVirt
= newVideoVirt
; /* Remember the virtual framebuffer address */
2277 vinfo
.v_baseaddr
= lastVideoVirt
; /* Set the new framebuffer address */
2280 if ( (vinfo
.v_type
== TEXT_MODE
) )
2282 // Text mode setup by the booter.
2284 gc_ops
.initialize
= tc_initialize
;
2285 gc_ops
.enable
= tc_enable
;
2286 gc_ops
.paint_char
= tc_paint_char
;
2287 gc_ops
.clear_screen
= tc_clear_screen
;
2288 gc_ops
.scroll_down
= tc_scroll_down
;
2289 gc_ops
.scroll_up
= tc_scroll_up
;
2290 gc_ops
.hide_cursor
= tc_hide_cursor
;
2291 gc_ops
.show_cursor
= tc_show_cursor
;
2292 gc_ops
.update_color
= tc_update_color
;
2295 #endif /* __i386__ */
2297 // Graphics mode setup by the booter.
2299 gc_ops
.initialize
= vc_initialize
;
2300 gc_ops
.enable
= vc_enable
;
2301 gc_ops
.paint_char
= vc_paint_char
;
2302 gc_ops
.scroll_down
= vc_scroll_down
;
2303 gc_ops
.scroll_up
= vc_scroll_up
;
2304 gc_ops
.clear_screen
= vc_clear_screen
;
2305 gc_ops
.hide_cursor
= vc_reverse_cursor
;
2306 gc_ops
.show_cursor
= vc_reverse_cursor
;
2307 gc_ops
.update_color
= vc_update_color
;
2310 gc_initialize(&vinfo
);
2312 #ifdef GRATEFULDEBUGGER
2313 GratefulDebInit((bootBumbleC
*)boot_vinfo
); /* Re-initialize GratefulDeb */
2314 #endif /* GRATEFULDEBUGGER */
2319 case kPEGraphicsMode
:
2320 panicDialogDesired
= TRUE
;
2321 gc_graphics_boot
= TRUE
;
2325 panicDialogDesired
= FALSE
;
2326 gc_graphics_boot
= FALSE
;
2329 case kPEAcquireScreen
:
2330 if ( gc_acquired
) break;
2332 vc_progress_set( gc_graphics_boot
, 2 * hz
);
2333 gc_enable( !gc_graphics_boot
);
2337 case kPEEnableScreen
:
2342 panicDialogDesired
= FALSE
;
2343 if ( gc_acquired
== FALSE
) break;
2344 if ( gc_graphics_boot
== FALSE
) break;
2346 vc_progress_set( FALSE
, 0 );
2350 case kPEDisableScreen
:
2354 case kPEReleaseScreen
:
2355 gc_acquired
= FALSE
;
2357 vc_progress_set( FALSE
, 0 );
2360 #ifdef GRATEFULDEBUGGER
2361 GratefulDebInit(0); /* Stop grateful debugger */
2362 #endif /* GRATEFULDEBUGGER */
2365 #ifdef GRATEFULDEBUGGER
2366 if ( boot_vinfo
) GratefulDebInit((bootBumbleC
*)boot_vinfo
); /* Re initialize GratefulDeb */
2367 #endif /* GRATEFULDEBUGGER */
2372 refresh_screen(void)
2376 gc_refresh_screen();
2377 gc_show_cursor(gc_x
, gc_y
);
2384 extern struct { long msg_magic
; long msg_bufx
; long msg_bufr
; char msg_bufc
[]; } * msgbufp
;
2386 vm_initialized
= TRUE
;
2388 if ( gc_graphics_boot
== FALSE
)
2394 initialize_screen( 0, kPEReleaseScreen
);
2397 initialize_screen( 0, kPEAcquireScreen
);
2399 for ( index
= 0 ; index
< msgbufp
->msg_bufx
; index
++ )
2401 vcputc( 0, 0, msgbufp
->msg_bufc
[index
] );
2403 if ( msgbufp
->msg_bufc
[index
] == '\n' )
2405 vcputc( 0, 0,'\r' );