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

@ -1,3 +1,25 @@
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.
2005-08-03 Hollis Blanchard <hollis@penguinppc.org>
* include/grub/powerpc/ieee1275/ieee1275.h: Move ...

View file

@ -71,9 +71,9 @@ grub_term_color_state;
/* Menu-related geometrical constants. */
/* FIXME: These should be dynamically obtained from a terminal. */
#define GRUB_TERM_WIDTH 80
#define GRUB_TERM_HEIGHT 25
/* FIXME: Ugly way to get them form terminal. */
#define GRUB_TERM_WIDTH ((grub_getwh()&0xFF00)>>8)
#define GRUB_TERM_HEIGHT (grub_getwh()&0xFF)
/* The number of lines of "GRUB version..." at the top. */
#define GRUB_TERM_INFO_HEIGHT 1
@ -142,6 +142,9 @@ struct grub_term
/* Get a character. */
int (*getkey) (void);
/* Get the screen size. The return value is ((Width << 8) | Height). */
grub_uint16_t (*getwh) (void);
/* Get the cursor position. The return value is ((X << 8) | Y). */
grub_uint16_t (*getxy) (void);
@ -183,6 +186,7 @@ void EXPORT_FUNC(grub_putchar) (int c);
void EXPORT_FUNC(grub_putcode) (grub_uint32_t code);
int EXPORT_FUNC(grub_getkey) (void);
int EXPORT_FUNC(grub_checkkey) (void);
grub_uint16_t EXPORT_FUNC(grub_getwh) (void);
grub_uint16_t EXPORT_FUNC(grub_getxy) (void);
void EXPORT_FUNC(grub_gotoxy) (grub_uint8_t x, grub_uint8_t y);
void EXPORT_FUNC(grub_cls) (void);

View file

@ -1,6 +1,6 @@
/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 2002,2003 Free Software Foundation, Inc.
* Copyright (C) 2002,2003,2005 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
@ -90,6 +90,8 @@ grub_term_get_current (void)
void
grub_putcode (grub_uint32_t code)
{
int height = grub_getwh () & 255;
if (code == '\t' && grub_cur_term->getxy)
{
int n;
@ -108,14 +110,14 @@ grub_putcode (grub_uint32_t code)
grub_putcode ('\r');
grub_more_lines++;
/* XXX: Don't use a fixed height! */
if (grub_more && grub_more_lines == 24 - 1)
if (grub_more && grub_more_lines == height - 1)
{
char key;
int pos = grub_getxy ();
/* Show --MORE-- on the lower left side of the screen. */
grub_gotoxy (1, 24 - 1);
grub_gotoxy (1, height - 1);
grub_setcolorstate (GRUB_TERM_COLOR_HIGHLIGHT);
grub_printf ("--MORE--");
grub_setcolorstate (GRUB_TERM_COLOR_STANDARD);
@ -123,7 +125,7 @@ grub_putcode (grub_uint32_t code)
key = grub_getkey ();
/* Remove the message. */
grub_gotoxy (1, 24 -1);
grub_gotoxy (1, height - 1);
grub_printf (" ");
grub_gotoxy (pos >> 8, pos & 0xFF);
@ -218,6 +220,12 @@ grub_getxy (void)
return (grub_cur_term->getxy) ();
}
grub_uint16_t
grub_getwh (void)
{
return (grub_cur_term->getwh) ();
}
void
grub_gotoxy (grub_uint8_t x, grub_uint8_t y)
{

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,