2005-08-04 Marco Gerards <metgerards@student.han.nl>

* kern/term.c (grub_putcode): Use `grub_getwh' instead of
	hardcoded value.

	From Vincent Pelletier  <subdino2004@yahoo.fr>
	* include/grub/term.h (GRUB_TERM_WIDTH, GRUB_TERM_HEIGHT):
	Redefined to use grub_getwh.
	(grub_term): New member named getwh.
	(grub_getwh): New prototype.
	* kern/term.c (grub_getwh): New function.
	* term/i386/pc/console.c (grub_console_getwh): New function.
	(grub_console_term): New member `getwh'.
	* term/i386/pc/vga.c (grub_vga_getwh): New function.
	(grub_vga_term): New member `getwh'.
	* term/sparc64/ofconsole.c (grub_ofconsole_readkey): Use
	grub_ssize_t.
	(grub_ofconsole_getw): New function.
	(grub_ofconsole_init): Use grub_ssize_t and unsigned char.
	(grub_ofconsole_term): New field named getwh and new initial
	value.
This commit is contained in:
marco_g 2005-08-04 18:10:51 +00:00
parent 3be7266d92
commit 267f6cd9ca
6 changed files with 114 additions and 13 deletions

View file

@ -74,6 +74,12 @@ grub_console_putchar (grub_uint32_t c)
grub_console_real_putchar (c);
}
static grub_uint16_t
grub_console_getwh (void)
{
return (80 << 8) | 25;
}
static void
grub_console_setcolorstate (grub_term_color_state state)
{
@ -107,6 +113,7 @@ static struct grub_term grub_console_term =
.putchar = grub_console_putchar,
.checkkey = grub_console_checkkey,
.getkey = grub_console_getkey,
.getwh = grub_console_getwh,
.getxy = grub_console_getxy,
.gotoxy = grub_console_gotoxy,
.cls = grub_console_cls,

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2000,2001,2002,2003,2004 Free Software Foundation, Inc.
* Copyright (C) 2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -472,6 +472,12 @@ grub_vga_putchar (grub_uint32_t c)
#endif
}
static grub_uint16_t
grub_vga_getwh (void)
{
return (TEXT_WIDTH << 8) | TEXT_HEIGHT;
}
static grub_uint16_t
grub_vga_getxy (void)
{
@ -566,6 +572,7 @@ static struct grub_term grub_vga_term =
.putchar = grub_vga_putchar,
.checkkey = grub_console_checkkey,
.getkey = grub_console_getkey,
.getwh = grub_vga_getwh,
.getxy = grub_vga_getxy,
.gotoxy = grub_vga_gotoxy,
.cls = grub_vga_cls,

View file

@ -1,7 +1,7 @@
/* ofconsole.c -- Open Firmware console for GRUB. */
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2003, 2004 Free Software Foundation, Inc.
* Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -120,7 +120,7 @@ static int
grub_ofconsole_readkey (int *key)
{
char c;
int actual = 0;
grub_ssize_t actual = 0;
grub_ieee1275_read (stdin_ihandle, &c, 1, &actual);
@ -207,6 +207,58 @@ grub_ofconsole_getxy (void)
return ((grub_curr_x - 1) << 8) | grub_curr_y;
}
static grub_uint16_t
grub_ofconsole_getwh (void)
{
grub_ieee1275_ihandle_t options;
char *val;
grub_ssize_t lval;
static grub_uint8_t w, h;
/* Once we have them, don't ask them again. */
if (!w || !h)
{
if (! grub_ieee1275_finddevice ("/options", &options)
&& options != -1)
{
if (! grub_ieee1275_get_property_length (options, "screen-#columns",
&lval) && lval != -1)
{
val = grub_malloc (lval);
if (val)
{
if (! grub_ieee1275_get_property (options, "screen-#columns",
val, lval, 0))
w = (grub_uint8_t) grub_strtoul (val, val + lval, 10);
grub_free (val);
}
}
if (! grub_ieee1275_get_property_length (options, "screen-#rows",
&lval) && lval != -1)
{
val = grub_malloc (lval);
if (val)
{
if (! grub_ieee1275_get_property (options, "screen-#rows",
val, lval, 0))
h = (grub_uint8_t) grub_strtoul (val, val + lval, 10);
grub_free (val);
}
}
}
}
/* Use a small console by default. */
if (! w)
w = 80;
if (! h)
h = 24;
return (w << 8) | h;
}
static void
grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y)
{
@ -241,8 +293,8 @@ grub_ofconsole_refresh (void)
static grub_err_t
grub_ofconsole_init (void)
{
char data[4];
grub_size_t actual;
unsigned char data[4];
grub_ssize_t actual;
int col;
if (grub_ieee1275_get_property (grub_ieee1275_chosen, "stdout", data,
@ -287,6 +339,7 @@ static struct grub_term grub_ofconsole_term =
.checkkey = grub_ofconsole_checkkey,
.getkey = grub_ofconsole_getkey,
.getxy = grub_ofconsole_getxy,
.getwh = grub_ofconsole_getwh,
.gotoxy = grub_ofconsole_gotoxy,
.cls = grub_ofconsole_cls,
.setcolorstate = grub_ofconsole_setcolorstate,