X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/55e303ae13a4cf49d70f2294092726f2fffb9ef2..4452a7af2eac33dbad800bcc91f2399d62c18f53:/osfmk/console/i386/text_console.c diff --git a/osfmk/console/i386/text_console.c b/osfmk/console/i386/text_console.c index 37154d4f7..ba0fc3392 100644 --- a/osfmk/console/i386/text_console.c +++ b/osfmk/console/i386/text_console.c @@ -1,16 +1,19 @@ /* * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. * - * @APPLE_LICENSE_HEADER_START@ - * - * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. + * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ * * This file contains Original Code and/or Modifications of Original Code * as defined in and that are subject to the Apple Public Source License * Version 2.0 (the 'License'). You may not use this file except in - * compliance with the License. Please obtain a copy of the License at - * http://www.opensource.apple.com/apsl/ and read it before using this - * file. + * compliance with the License. The rights granted to you under the License + * may not be used to create, or enable the creation or redistribution of, + * unlawful or unlicensed copies of an Apple operating system, or to + * circumvent, violate, or enable the circumvention or violation of, any + * terms of an Apple operating system software license agreement. + * + * Please obtain a copy of the License at + * http://www.opensource.apple.com/apsl/ and read it before using this file. * * The Original Code and all software distributed under the License are * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER @@ -20,7 +23,7 @@ * Please see the License for the specific language governing rights and * limitations under the License. * - * @APPLE_LICENSE_HEADER_END@ + * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ */ /* @@ -29,8 +32,9 @@ * VGA text console support. */ -#include +#include #include +#include "text_console.h" /* * Macros and typedefs. @@ -50,6 +54,7 @@ typedef short csrpos_t; /* cursor position, ONE_SPACE bytes per char */ /* * Commands sent to graphics adapter. */ +#define VGA_C_START 0x0a /* cursor start position, on/off bit */ #define VGA_C_LOW 0x0f /* return low byte of cursor addr */ #define VGA_C_HIGH 0x0e /* high byte */ @@ -59,6 +64,12 @@ typedef short csrpos_t; /* cursor position, ONE_SPACE bytes per char */ #define VGA_ATTR_NORMAL 0x07 #define VGA_ATTR_REVERSE 0x70 +/* + * Cursor Start Register bit fields. + */ +#define VGA_CURSOR_CS 0x1F +#define VGA_CURSOR_ON 0x20 + /* * Convert from XY coordinate to a location in display memory. */ @@ -67,13 +78,14 @@ typedef short csrpos_t; /* cursor position, ONE_SPACE bytes per char */ /* * Globals. */ -static short vga_idx_reg = 0; /* location of VGA index register */ -static short vga_io_reg = 0; /* location of VGA data register */ -static short vga_cols = 80; /* number of columns */ -static short vga_rows = 25; /* number of rows */ -static char vga_attr = 0; /* current character attribute */ -static char vga_attr_rev = 0; /* current reverse attribute */ -static char * vram_start = 0; /* VM start of VGA frame buffer */ +static short vga_idx_reg = 0; /* location of VGA index register */ +static short vga_io_reg = 0; /* location of VGA data register */ +static short vga_cols = 80; /* number of columns */ +static short vga_rows = 25; /* number of rows */ +static char vga_attr = 0; /* current character attribute */ +static char vga_attr_rev = 0; /* current reverse attribute */ +static char vga_cursor_start = 0; /* cached cursor start scan line */ +static char * vram_start = 0; /* VM start of VGA frame buffer */ /* * Functions in kdasm.s. @@ -92,6 +104,7 @@ move_up( csrpos_t from, csrpos_t to, int count) { + if (vram_start == 0) return; kd_slmscu( vram_start + from, vram_start + to, count ); } @@ -105,6 +118,7 @@ move_down( csrpos_t from, csrpos_t to, int count ) { + if (vram_start == 0) return; kd_slmscd( vram_start + from, vram_start + to, count ); } @@ -118,6 +132,7 @@ clear_block( csrpos_t start, int size, char attr) { + if (vram_start == 0) return; kd_slmwd( vram_start + start, size, ((unsigned short) attr << 8) + SPACE_CHAR); } @@ -142,6 +157,19 @@ set_cursor_position( csrpos_t newpos ) outb(vga_io_reg, (unsigned char)(curpos & 0xff)); } +/* + * set_cursor_enable + * + * Allow the cursor to be turned on or off. + */ +static void +set_cursor_enable( boolean_t enable ) +{ + outb(vga_idx_reg, VGA_C_START); + outb(vga_io_reg, vga_cursor_start | + (enable == TRUE ? VGA_CURSOR_ON : 0)); +} + /* * display_char * @@ -152,6 +180,7 @@ display_char( csrpos_t pos, /* where to put it */ char ch, /* the character */ char attr ) /* its attribute */ { + if (vram_start == 0) return; *(vram_start + pos) = ch; *(vram_start + pos + 1) = attr; } @@ -172,7 +201,12 @@ vga_init(int cols, int rows, unsigned char * addr) vga_attr = VGA_ATTR_NORMAL; vga_attr_rev = VGA_ATTR_REVERSE; - set_cursor_position(0); + /* cache cursor start position */ + outb(vga_idx_reg, VGA_C_START); + vga_cursor_start = inb(vga_io_reg) & VGA_CURSOR_CS; + + /* defaults to a hidden hw cursor */ + set_cursor_enable( FALSE ); } /* @@ -181,7 +215,7 @@ vga_init(int cols, int rows, unsigned char * addr) * Scroll the screen up 'n' character lines. */ void -tc_scroll_up( int lines, int top, int bottom ) +tc_scroll_up( int lines, __unused int top, __unused int bottom ) { csrpos_t to; csrpos_t from; @@ -205,7 +239,7 @@ tc_scroll_up( int lines, int top, int bottom ) * Scrolls the screen down 'n' character lines. */ void -tc_scroll_down( int lines, int top, int bottom ) +tc_scroll_down( int lines, __unused int top, __unused int bottom ) { csrpos_t to; csrpos_t from; @@ -287,6 +321,7 @@ void tc_show_cursor( int x, int y ) { set_cursor_position( XY_TO_CSRPOS(x, y) ); + set_cursor_enable( TRUE ); } /* @@ -295,9 +330,9 @@ tc_show_cursor( int x, int y ) * Hide the hardware cursor. */ void -tc_hide_cursor( int x, int y ) +tc_hide_cursor( __unused int x, __unused int y ) { - return; + set_cursor_enable( FALSE ); } /* @@ -307,7 +342,8 @@ tc_hide_cursor( int x, int y ) * relative to the current cursor position. */ void -tc_clear_screen(int x, int y, int top, int bottom, int operation) +tc_clear_screen(int x, int y, __unused int top, __unused int bottom, + int operation) { csrpos_t start; int count; @@ -338,7 +374,8 @@ tc_clear_screen(int x, int y, int top, int bottom, int operation) * and attributes. */ void -tc_paint_char( int x, int y, unsigned char ch, int attrs, unsigned char ch_previous, int attrs_previous ) +tc_paint_char(int x, int y, unsigned char ch, int attrs, + __unused unsigned char ch_previous, __unused int attrs_previous) { char my_attr = vga_attr; @@ -353,7 +390,7 @@ tc_paint_char( int x, int y, unsigned char ch, int attrs, unsigned char ch_previ * Enable / disable the console. */ void -tc_enable(boolean_t enable) +tc_enable(__unused boolean_t enable) { }