grub/term/i386/pc/vga_text.c
robertmh ca25d8f0c1 2007-10-31 Robert Millan <rmh@aybabtu.com>
* configure.ac: Add `i386-linuxbios' to the list of supported targets.

	* conf/i386-linuxbios.rmk: New file.

	* kern/i386/pc/hardware.c: Likewise.
	* term/i386/pc/at_keyboard.c: Likewise.
	* term/i386/pc/vga_text.c: Likewise.

	* include/grub/i386/linuxbios/boot.h: Likewise.
	* include/grub/i386/linuxbios/console.h: Likewise.
	* include/grub/i386/linuxbios/init.h: Likewise.
	* include/grub/i386/linuxbios/kernel.h: Likewise.
	* include/grub/i386/linuxbios/loader.h: Likewise.
	* include/grub/i386/linuxbios/memory.h: Likewise.
	* include/grub/i386/linuxbios/serial.h: Likewise.
	* include/grub/i386/linuxbios/time.h: Likewise.

	* kern/i386/linuxbios/init.c: Likewise.
	* kern/i386/linuxbios/startup.S: Likewise.
	* kern/i386/linuxbios/table.c: Likewise.
2007-10-31 22:35:13 +00:00

111 lines
2.2 KiB
C

/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2007 Free Software Foundation, Inc.
*
* GRUB is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/machine/console.h>
#include <grub/types.h>
#define COLS 80
#define ROWS 25
static int grub_curr_x, grub_curr_y;
#define VGA_TEXT_SCREEN 0xb8000
static void
screen_write_char (int x, int y, short c)
{
((short *) VGA_TEXT_SCREEN)[y * COLS + x] = c;
}
static short
screen_read_char (int x, int y)
{
return ((short *) VGA_TEXT_SCREEN)[y * COLS + x];
}
static void
inc_y ()
{
grub_curr_x = 0;
if (grub_curr_y < ROWS - 1)
grub_curr_y++;
else
{
int x, y;
for (y = 0; y < ROWS; y++)
for (x = 0; x < COLS; x++)
screen_write_char (x, y, screen_read_char (x, y + 1));
}
}
static void
inc_x ()
{
if (grub_curr_x >= COLS - 2)
inc_y ();
else
grub_curr_x++;
}
void
grub_console_real_putchar (int c)
{
switch (c)
{
case '\b':
if (grub_curr_x != 0)
screen_write_char (grub_curr_x--, grub_curr_y, ' ');
break;
case '\n':
inc_y ();
break;
case '\r':
grub_curr_x = 0;
break;
default:
screen_write_char (grub_curr_x, grub_curr_y, c | (grub_console_cur_color << 8));
inc_x ();
}
}
grub_uint16_t
grub_console_getxy ()
{
return (grub_curr_x << 8) | grub_curr_y;
}
void
grub_console_gotoxy (grub_uint8_t x, grub_uint8_t y)
{
grub_curr_x = x;
grub_curr_y = y;
}
void
grub_console_cls ()
{
int i;
for (i = 0; i < ROWS * COLS; i++)
((short *) VGA_TEXT_SCREEN)[i] = ' ';
}
void
grub_console_setcursor (int on __attribute__ ((unused)))
{
/* Not implemented. */
}