From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1DspM3-0007RZ-QC for mharc-grub-devel@gnu.org; Wed, 13 Jul 2005 18:05:23 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1DspM0-0007Q9-48 for grub-devel@gnu.org; Wed, 13 Jul 2005 18:05:20 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1DspIy-0006JO-G7 for grub-devel@gnu.org; Wed, 13 Jul 2005 18:02:21 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DspIy-0006AX-8e for grub-devel@gnu.org; Wed, 13 Jul 2005 18:02:12 -0400 Received: from [217.12.11.34] (helo=smtp003.mail.ukl.yahoo.com) by monty-python.gnu.org with smtp (Exim 4.34) id 1DsovY-0005Q1-7i for grub-devel@gnu.org; Wed, 13 Jul 2005 17:38:00 -0400 Received: (qmail 88928 invoked from network); 13 Jul 2005 21:29:49 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.fr; h=Received:Message-ID:Date:From:User-Agent:X-Accept-Language:MIME-Version:To:Subject:References:In-Reply-To:X-Enigmail-Version:Content-Type; b=ZU6P+irYAZ47rJNApFHW9jzqVxLd6wjkAwpPqZNo6C7uG65XcKp64fef51wGwJGAey4k2xS6DRrzIwc7apuoBqyb6fHjHFJLMRC7pHnaVQ+/TxKMj3yiIA+rOWKD4PE1951ACnXIGsuUA0C/ZdIy6aKZQgv9ezVLCkbb6RI2Df0= ; Received: from unknown (HELO ?192.168.0.2?) (subdino2004@83.194.181.220 with plain) by smtp003.mail.ukl.yahoo.com with SMTP; 13 Jul 2005 21:29:48 -0000 Message-ID: <42D587CC.7000908@yahoo.fr> Date: Wed, 13 Jul 2005 23:29:48 +0200 From: Vincent Pelletier User-Agent: Debian Thunderbird 1.0.2 (X11/20050602) X-Accept-Language: en-us, en MIME-Version: 1.0 To: The development of GRUB 2 References: <42C85357.20500@yahoo.fr> <200507050105.54961.okuji@enbug.org> <87y88ltv78.fsf@student.han.nl> <200507051756.44065.okuji@enbug.org> <873bqtte1u.fsf@student.han.nl> <42D422A4.9030801@yahoo.fr> <42D4D367.3030402@yahoo.fr> <87slyi8xr7.fsf@student.han.nl> In-Reply-To: <87slyi8xr7.fsf@student.han.nl> X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/mixed; boundary="------------010607070302080808080202" Subject: Re: [PATCHv2] FIXME: These should be dynamically obtained from a terminal. X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jul 2005 22:05:20 -0000 This is a multi-part message in MIME format. --------------010607070302080808080202 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Marco Gerards wrote: > Nice! I will test this on both the PPC boxes I have. I hope it works too. I haven't see any variable naming standard in the ieee1275 docs, so I'm afraid it won't find the variables. > This looks fine. Please remove the `:' after the filename in case > something follows between the ()'s. For grub_vga_term you did not say > which member was added. Oops. Fixed below. > Please check for errors here. [...] > Same here. Done. I thought I checked all the possible errors though :'( . And I forgot those simple ones. > In mode 3 it is. Which is something we can assume, I hope. :) Removed the comment. First patch : 2005-07-13 Vincent Pelletier * include/grub/term.h (GRUB_TERM_WIDTH, GRUB_TERM_HEIGHT): Redefined to use grub_getwh. (struct grub_term): New field named getwh. (grub_getwh): New exported prototype. * kern/term.c (grub_getwh): New function. * term/i386/pc/console.c (grub_console_getwh): New function. (grub_console_term): New field named getwh and new initial value. * term/i386/pc/vga.c (grub_vga_getwh): New function. (grub_vga_term): New field named getwh and new initial value. Second patch : 2005-07-13 Vincent Pelletier * term/sparc64/ofconsole.c (grub_ofconsole_readkey): Use grub_ssize_t. (grub_ofconsole_getw): New function. (grub_ofconsole_cls): Don't clear screen when debug environment variable is set, regardless of its value. (grub_ofconsole_init): Use grub_ssize_t and unsigned char. (grub_ofconsole_term): New field named getwh and new initial value. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFC1YfMFEQoKRQyjtURAtliAJ9iZKLpn48u8arpEXsgLlm5GBSFPwCcCOMX ECZ8+QD/tK5cmdvciVRrnN8= =EbEg -----END PGP SIGNATURE----- --------------010607070302080808080202 Content-Type: text/plain; name="getwh3.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="getwh3.diff" Index: include/grub/term.h =================================================================== RCS file: /cvsroot/grub/grub2/include/grub/term.h,v retrieving revision 1.7 diff -u -p -r1.7 term.h --- include/grub/term.h 19 Feb 2005 20:56:07 -0000 1.7 +++ include/grub/term.h 13 Jul 2005 21:19:36 -0000 @@ -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); Index: kern/term.c =================================================================== RCS file: /cvsroot/grub/grub2/kern/term.c,v retrieving revision 1.7 diff -u -p -r1.7 term.c --- kern/term.c 4 Apr 2004 13:46:02 -0000 1.7 +++ kern/term.c 13 Jul 2005 21:19:37 -0000 @@ -218,6 +218,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) { Index: term/i386/pc/console.c =================================================================== RCS file: /cvsroot/grub/grub2/term/i386/pc/console.c,v retrieving revision 1.5 diff -u -p -r1.5 console.c --- term/i386/pc/console.c 15 Feb 2005 00:07:01 -0000 1.5 +++ term/i386/pc/console.c 13 Jul 2005 21:19:37 -0000 @@ -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_ter .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, Index: term/i386/pc/vga.c =================================================================== RCS file: /cvsroot/grub/grub2/term/i386/pc/vga.c,v retrieving revision 1.7 diff -u -p -r1.7 vga.c --- term/i386/pc/vga.c 2 Mar 2005 20:12:46 -0000 1.7 +++ term/i386/pc/vga.c 13 Jul 2005 21:19:38 -0000 @@ -473,6 +473,12 @@ grub_vga_putchar (grub_uint32_t c) } static grub_uint16_t +grub_vga_getwh (void) +{ + return (TEXT_WIDTH << 8) | TEXT_HEIGHT; +} + +static grub_uint16_t grub_vga_getxy (void) { return ((xpos << 8) | ypos); @@ -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, --------------010607070302080808080202 Content-Type: text/plain; name="sparc_getwh2.diff" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="sparc_getwh2.diff" diff -rup powerpc/ieee1275/ofconsole.c sparc64/ieee1275/ofconsole.c --- powerpc/ieee1275/ofconsole.c 2005-06-21 04:33:52.000000000 +0200 +++ sparc64/ieee1275/ofconsole.c 2005-07-13 23:25:39.000000000 +0200 @@ -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,53 @@ 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 config; + char *val; + grub_ssize_t lval; + static grub_uint8_t w, h; + + if (w && h) /* Once we have them, don't ask them again. */ + { + if (! grub_ieee1275_open ("/config", &config) && + config != -1) + { + if (! grub_ieee1275_get_property_length (config, "screen-#columns", + &lval) && lval != -1) + { + if ((val = grub_malloc (lval)) != 0) + { + if (! grub_ieee1275_get_property (config, "screen-#columns", + val, lval, 0)) + w = (grub_uint8_t) grub_strtoul (val, val + lval, 10); + grub_free (val); + } + } + if (! grub_ieee1275_get_property_length (config, "screen-#rows", + &lval) && lval != -1) + { + if ((val = grub_malloc (lval)) != 0) + { + if (! grub_ieee1275_get_property (config, "screen-#rows", + val, lval, 0)) + h = (grub_uint8_t) grub_strtoul (val, val + lval, 10); + grub_free (val); + } + } + } + } + + /* XXX: Default values from OpenBoot on my U10. */ + if (! w) + w = 80; + if (! h) + h = 34; + + return (w << 8) | h; +} + static void grub_ofconsole_gotoxy (grub_uint8_t x, grub_uint8_t y) { @@ -222,6 +269,8 @@ static void grub_ofconsole_cls (void) { /* Clear the screen. */ + if (grub_env_get ("debug")) + return; grub_ofconsole_writeesc ("\e[2J"); grub_gotoxy (0, 0); } @@ -241,8 +290,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 +336,7 @@ static struct grub_term grub_ofconsole_t .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, --------------010607070302080808080202-- ___________________________________________________________________________ Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger Téléchargez cette version sur http://fr.messenger.yahoo.com