All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] Multiboot video support
Date: Fri, 15 Jan 2010 16:44:50 +0100	[thread overview]
Message-ID: <4B508D72.3050508@gmail.com> (raw)
In-Reply-To: <4B5080BB.90204@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 208 bytes --]

Vladimir 'phi-coder/phcoder' Serbinenko wrote:
> Added EGA text support
>   
Non-VBE parts reviewed and comitted. Resending VBE parts.
>
>   


-- 
Regards
Vladimir 'φ-coder/phcoder' Serbinenko


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: mbivid.diff --]
[-- Type: text/x-diff; name="mbivid.diff", Size: 5400 bytes --]

=== added file 'ChangeLog.mbivid'
--- ChangeLog.mbivid	1970-01-01 00:00:00 +0000
+++ ChangeLog.mbivid	2010-01-15 15:35:51 +0000
@@ -0,0 +1,9 @@
+2010-01-14  Vladimir Serbinenko  <phcoder@gmail.com>
+
+	VBE multiboot support.
+
+	* loader/i386/multiboot_mbi.c (HAS_VBE): New constant.
+	(grub_multiboot_get_mbi_size) [HAS_VBE]: Account for VBE structures.
+	(grub_multiboot_make_mbi) [HAS_VBE]: Likewise.
+	(fill_vbe_info) [HAS_VBE]: New function.
+	(retrieve_video_parameters) [HAS_VBE]: Call fill_vbe_info.

=== modified file 'loader/i386/multiboot.c'
--- loader/i386/multiboot.c	2010-01-15 15:30:57 +0000
+++ loader/i386/multiboot.c	2010-01-15 15:31:45 +0000
@@ -20,7 +20,6 @@
 /*
  *  FIXME: The following features from the Multiboot specification still
  *         need to be implemented:
- *  - VBE support
  *  - symbol table
  *  - drives table
  *  - ROM configuration table

=== modified file 'loader/i386/multiboot_mbi.c'
--- loader/i386/multiboot_mbi.c	2010-01-15 15:30:57 +0000
+++ loader/i386/multiboot_mbi.c	2010-01-15 15:32:50 +0000
@@ -35,9 +35,11 @@
 #include <grub/i386/pc/vbe.h>
 #define DEFAULT_VIDEO_MODE "text"
 #define HAS_VGA_TEXT 1
+#define HAS_VBE 1
 #else
 #define DEFAULT_VIDEO_MODE "auto"
 #define HAS_VGA_TEXT 0
+#define HAS_VBE 0
 #endif
 
 struct module
@@ -91,6 +93,10 @@
   return sizeof (struct multiboot_info) + ALIGN_UP (cmdline_size, 4)
     + modcnt * sizeof (struct multiboot_mod_list) + total_modcmd
     + ALIGN_UP (sizeof(PACKAGE_STRING), 4) + grub_get_multiboot_mmap_len ()
+#if HAS_VBE
+    + sizeof (struct grub_vbe_info_block)
+    + sizeof (struct grub_vbe_mode_info_block)
+#endif
     + 256 * sizeof (struct multiboot_color);
 }
 
@@ -153,6 +159,78 @@
   return err;
 }
 
+#if HAS_VBE
+static grub_err_t
+fill_vbe_info (struct multiboot_info *mbi, grub_uint8_t *ptrorig,
+	       grub_uint32_t ptrdest, int fill_generic)
+{
+  grub_vbe_status_t status;
+  grub_uint32_t vbe_mode;
+  void *scratch = (void *) GRUB_MEMORY_MACHINE_SCRATCH_ADDR;
+  struct grub_vbe_mode_info_block *mode_info;
+    
+  status = grub_vbe_bios_get_controller_info (scratch);
+  if (status != GRUB_VBE_STATUS_OK)
+    return grub_error (GRUB_ERR_IO, "Can't get controller info.");
+  
+  mbi->vbe_control_info = ptrdest;
+  grub_memcpy (ptrorig, scratch, sizeof (struct grub_vbe_info_block));
+  ptrorig += sizeof (struct grub_vbe_info_block);
+  ptrdest += sizeof (struct grub_vbe_info_block);
+  
+  status = grub_vbe_bios_get_mode (scratch);
+  vbe_mode = *(grub_uint32_t *) scratch;
+  if (status != GRUB_VBE_STATUS_OK)
+    return grub_error (GRUB_ERR_IO, "can't get VBE mode");
+  mbi->vbe_mode = vbe_mode;
+
+  mode_info = (struct grub_vbe_mode_info_block *) ptrorig;
+  mbi->vbe_mode_info = ptrdest;
+  /* get_mode_info isn't available for mode 3.  */
+  if (vbe_mode == 3)
+    {
+      grub_memset (mode_info, 0, sizeof (struct grub_vbe_mode_info_block));
+      mode_info->memory_model = GRUB_VBE_MEMORY_MODEL_TEXT;
+      mode_info->x_resolution = 80;
+      mode_info->y_resolution = 25;
+    }
+  else
+    {
+      status = grub_vbe_bios_get_mode_info (vbe_mode, scratch);
+      if (status != GRUB_VBE_STATUS_OK)
+	return grub_error (GRUB_ERR_IO, "can't get mode info");
+      grub_memcpy (mode_info, scratch,
+		   sizeof (struct grub_vbe_mode_info_block));
+    }
+  ptrorig += sizeof (struct grub_vbe_mode_info_block);
+  ptrdest += sizeof (struct grub_vbe_mode_info_block);
+      
+  /* FIXME: retrieve those.  */
+  mbi->vbe_interface_seg = 0;
+  mbi->vbe_interface_off = 0;
+  mbi->vbe_interface_len = 0;
+  
+  mbi->flags |= MULTIBOOT_INFO_VBE_INFO;
+
+  if (fill_generic && mode_info->memory_model == GRUB_VBE_MEMORY_MODEL_TEXT)
+    {
+      mbi->framebuffer_addr = 0xb8000;
+
+      mbi->framebuffer_pitch = 2 * mode_info->x_resolution;	
+      mbi->framebuffer_width = mode_info->x_resolution;
+      mbi->framebuffer_height = mode_info->y_resolution;
+
+      mbi->framebuffer_bpp = 16;
+
+      mbi->framebuffer_type = MULTIBOOT_FRAMEBUFFER_TYPE_EGA_TEXT;
+
+      mbi->flags |= MULTIBOOT_INFO_FRAMEBUFFER_INFO;
+    }
+
+  return GRUB_ERR_NONE;
+}
+#endif
+
 static grub_err_t
 retrieve_video_parameters (struct multiboot_info *mbi,
 			   grub_uint8_t *ptrorig, grub_uint32_t ptrdest)
@@ -173,8 +251,13 @@
   grub_video_get_palette (0, ARRAY_SIZE (palette), palette);
 
   driv_id = grub_video_get_driver_id ();
+#if HAS_VGA_TEXT
+  if (driv_id == GRUB_VIDEO_DRIVER_NONE)
+    return fill_vbe_info (mbi, ptrorig, ptrdest, 1);
+#else
   if (driv_id == GRUB_VIDEO_DRIVER_NONE)
     return GRUB_ERR_NONE;
+#endif
 
   err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
   if (err)
@@ -222,6 +305,11 @@
 
   mbi->flags |= MULTIBOOT_INFO_FRAMEBUFFER_INFO;
 
+#if HAS_VBE
+  if (driv_id == GRUB_VIDEO_DRIVER_VBE)
+    return fill_vbe_info (mbi, ptrorig, ptrdest, 0);
+#endif
+
   return GRUB_ERR_NONE;
 }
 
@@ -308,6 +396,12 @@
       grub_print_error ();
       grub_errno = GRUB_ERR_NONE;
     }
+#if HAS_VBE
+  ptrorig += sizeof (struct grub_vbe_info_block);
+  ptrdest += sizeof (struct grub_vbe_info_block);
+  ptrorig += sizeof (struct grub_vbe_mode_info_block);
+  ptrdest += sizeof (struct grub_vbe_mode_info_block);
+#endif
 
   return GRUB_ERR_NONE;
 }


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 293 bytes --]

  reply	other threads:[~2010-01-15 15:45 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-14 14:55 [PATCH] Multiboot video support Vladimir 'φ-coder/phcoder' Serbinenko
2010-01-15 14:50 ` Vladimir 'phi-coder/phcoder' Serbinenko
2010-01-15 15:44   ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2010-01-19 22:41     ` Robert Millan
2010-01-20 11:43 ` Michal Suchanek
2010-01-24 19:02   ` Robert Millan
2010-01-24 21:05     ` Vladimir 'φ-coder/phcoder' Serbinenko
2010-01-24 23:29       ` Michal Suchanek
2010-01-25  7:37         ` Robert Millan
2010-01-25  9:26           ` Michal Suchanek

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=4B508D72.3050508@gmail.com \
    --to=phcoder@gmail.com \
    --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.