All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Pelletier <subdino2004@yahoo.fr>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [Bulk] FIXME: These should be dynamically obtained from a terminal.
Date: Sun, 03 Jul 2005 23:16:58 +0200	[thread overview]
Message-ID: <42C855CA.2070805@yahoo.fr> (raw)
In-Reply-To: <42C85357.20500@yahoo.fr>

[-- Attachment #1: Type: text/plain, Size: 322 bytes --]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Vincent Pelletier wrote:
> In the attached patch,

*cough* *cough*

Vincent Pelletier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFCyFXJFEQoKRQyjtURAjFRAKCyEeBiF6HDVeeFajmy8oGfVWIrvQCfUiCG
hX6z+XtVX9llG10YKEi6t7A=
=tmOI
-----END PGP SIGNATURE-----

[-- Attachment #2: getwh.diff --]
[-- Type: text/plain, Size: 6478 bytes --]

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	3 Jul 2005 20:34:40 -0000
@@ -72,8 +72,10 @@ 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
+/*#define GRUB_TERM_WIDTH		80
+#define GRUB_TERM_HEIGHT	25*/
+#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 +144,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 +188,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: include/grub/i386/pc/vga.h
===================================================================
RCS file: /cvsroot/grub/grub2/include/grub/i386/pc/vga.h,v
retrieving revision 1.3
diff -u -p -r1.3 vga.h
--- include/grub/i386/pc/vga.h	4 Apr 2004 13:46:01 -0000	1.3
+++ include/grub/i386/pc/vga.h	3 Jul 2005 20:34:40 -0000
@@ -25,6 +25,9 @@
 /* Set the video mode to MODE and return the previous mode.  */
 unsigned char EXPORT_FUNC(grub_vga_set_mode) (unsigned char mode);
 
+/* Return the current video mode.  */
+unsigned char EXPORT_FUNC(grub_vga_get_mode) (void);
+
 /* Return a pointer to the ROM font table.  */
 unsigned char *EXPORT_FUNC(grub_vga_get_font) (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	3 Jul 2005 20:34:44 -0000
@@ -213,6 +213,12 @@ grub_checkkey (void)
 }
 
 grub_uint16_t
+grub_getwh (void)
+{
+  return (grub_cur_term->getwh) ();
+}
+
+grub_uint16_t
 grub_getxy (void)
 {
   return (grub_cur_term->getxy) ();
Index: kern/i386/pc/startup.S
===================================================================
RCS file: /cvsroot/grub/grub2/kern/i386/pc/startup.S,v
retrieving revision 1.13
diff -u -p -r1.13 startup.S
--- kern/i386/pc/startup.S	4 Apr 2004 13:46:02 -0000	1.13
+++ kern/i386/pc/startup.S	3 Jul 2005 20:34:44 -0000
@@ -1570,6 +1570,28 @@ FUNCTION(grub_vga_set_mode)
 
 
 /*
+ * unsigned char grub_vga_get_mode (void)
+ */
+FUNCTION(grub_vga_get_mode)
+	pushl	%ebp
+	pushl	%ebx
+
+	call	prot_to_real
+	.code16
+	/* get current mode */
+	xorw	%bx, %bx
+	movb	$0x0f, %ah
+	int	$0x10
+
+	DATA32	call	real_to_prot
+	.code32
+
+	popl	%ebx
+	popl	%ebp
+	ret
+
+
+/*
  * unsigned char *grub_vga_get_font (void)
  */
 FUNCTION(grub_vga_get_font)
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	3 Jul 2005 20:34:45 -0000
@@ -20,6 +20,7 @@
 #include <grub/machine/console.h>
 #include <grub/term.h>
 #include <grub/types.h>
+#include <grub/misc.h>
 
 grub_uint8_t grub_console_cur_color = 0x7;
 static grub_uint8_t grub_console_standard_color = 0x7;
@@ -74,6 +75,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; /* FIXME: Always true ?  */
+}
+
 static void
 grub_console_setcolorstate (grub_term_color_state state)
 {
@@ -107,6 +114,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	3 Jul 2005 20:34:46 -0000
@@ -473,6 +473,59 @@ grub_vga_putchar (grub_uint32_t c)
 }
 
 static grub_uint16_t
+grub_vga_getwh (void)
+{
+  return (TEXT_WIDTH << 8) | TEXT_HEIGHT;
+#if 0
+  static grub_uint16_t res;
+  unsigned char mode;
+  if (res)
+    return res;
+  /* FIXME : Assumed char size : w=8 h=16.  */
+  switch (mode = grub_vga_get_mode () )
+    {
+      case 0: /* text, 40x25 */
+      case 1:
+        res = (40 << 8) | 25;
+        break;
+      case 2: /* text, 80x25 */
+      case 3:
+        res = (80 << 8) | 25;
+        break;
+      case 8: /* graph, 160x200 */
+        res = (20 << 8) | 12;
+        break;
+      case 4: /* graph, 320x200 */
+      case 5:
+      case 9:
+      case 0xD:
+      case 0x13:
+        res = (40 << 8) | 12;
+        break;
+      case 6: /* graph, 640x200 */
+      case 0xA:
+      case 0xE:
+        res = (80 << 8) | 12;
+        break;
+      case 0xF: /* graph, 640x350 */
+      case 0x10:
+        res = (80 << 8) | 21;
+        break;
+      case 0x11: /* graph, 640x480 */
+      case 0x12:
+        res = (80 << 8) | 21;
+        break;
+      default: /* XXX: dumb values */
+        res = (10 << 8) | 10;
+        break;
+    }
+  grub_dprintf("terminal","Mode=%d, Val=0x%x, w=%d, h=%d",mode,res,(res&0xFF00)>>8,res&0xFF);
+  while(1);
+  return res;
+#endif
+}
+
+static grub_uint16_t
 grub_vga_getxy (void)
 {
   return ((xpos << 8) | ypos);
@@ -566,6 +619,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,

  reply	other threads:[~2005-07-03 21:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-03 21:06 FIXME: These should be dynamically obtained from a terminal Vincent Pelletier
2005-07-03 21:16 ` Vincent Pelletier [this message]
2005-07-04 23:05 ` Yoshinori K. Okuji
2005-07-04 23:19   ` Vincent Pelletier
2005-07-05 10:15   ` Marco Gerards
2005-07-05 15:56     ` Yoshinori K. Okuji
2005-07-05 16:26       ` Marco Gerards
2005-07-12 20:05         ` [PATCH] " Vincent Pelletier
2005-07-13  8:40           ` [PATCHv2] " Vincent Pelletier
2005-07-13 16:41             ` Marco Gerards
2005-07-13 21:29               ` Vincent Pelletier
2005-08-04 12:29                 ` Marco Gerards
2005-08-04 18:13                   ` Marco Gerards
2005-08-09  3:26                     ` Hollis Blanchard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42C855CA.2070805@yahoo.fr \
    --to=subdino2004@yahoo.fr \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.