/*
* Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
*
- * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
- *
- * 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
+ * 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. 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
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
* limitations under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
+ *
+ * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
*/
/*
* VGA text console support.
*/
-#include <i386/pio.h>
+#include <architecture/i386/pio.h>
#include <console/video_console.h>
+#include "text_console.h"
/*
* Macros and typedefs.
/*
* 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 */
#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.
*/
/*
* 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.
csrpos_t to,
int count)
{
+ if (vram_start == 0) return;
kd_slmscu( vram_start + from, vram_start + to, count );
}
csrpos_t to,
int count )
{
+ if (vram_start == 0) return;
kd_slmscd( vram_start + from, vram_start + to, count );
}
int size,
char attr)
{
+ if (vram_start == 0) return;
kd_slmwd( vram_start + start, size,
((unsigned short) attr << 8) + SPACE_CHAR);
}
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
*
char ch, /* the character */
char attr ) /* its attribute */
{
+ if (vram_start == 0) return;
*(vram_start + pos) = ch;
*(vram_start + pos + 1) = attr;
}
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 );
}
/*
* 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;
* 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;
tc_show_cursor( int x, int y )
{
set_cursor_position( XY_TO_CSRPOS(x, y) );
+ set_cursor_enable( TRUE );
}
/*
* 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 );
}
/*
* 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;
* 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;
* Enable / disable the console.
*/
void
-tc_enable(boolean_t enable)
+tc_enable(__unused boolean_t enable)
{
}