While calling VBIOS to set VESA mode, BIOS/GRUB can indicate VBIOS to clear
frame buffer, it can also indicate VBIOS to skip this and do the clearing
itself by access linear frame buffer directly.

Zhaoxin/Glenfly VBIOS is running at real mode and can only access the first
1M memory, which means it can't access linear frame buffer directly. So the
first way will take more time.

Add a patch here to use the second way to save time for Zhaoxin/Glenfly card.

Signed-off-by: Joanne Bao <joanne...@glenfly.com>
Signed-off-by: Tony W Wang-oc <tonywwang...@zhaoxin.com>
Tested-by: Sherry Zhang <sherryzh...@zhaoxin.com>
Suggested-by: Jason He <jaso...@zhaoxin.com>
---
 grub-core/video/i386/pc/vbe.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c
index a0bb9af09..7ad7cfeec 100644
--- a/grub-core/video/i386/pc/vbe.c
+++ b/grub-core/video/i386/pc/vbe.c
@@ -643,6 +643,38 @@ grub_vbe_set_video_mode (grub_uint32_t vbe_mode,
   if (grub_errno != GRUB_ERR_NONE)
     return grub_errno;
 
+  grub_uint32_t string_seg = (controller_info.oem_string_ptr & 0xFFFF0000) >> 
16;
+  grub_uint32_t string_offset = controller_info.oem_string_ptr & 0xFFFF;
+  const char * oem_string = (const char *) (string_seg << 4) + string_offset;
+
+  if (vbe_mode >= 0x100 && oem_string != NULL && *oem_string != '\0')
+    {
+      if (grub_strncmp(oem_string, "Zhaoxin", 7) == 0 || 
grub_strncmp(oem_string, "Glenfly", 7) == 0)
+        {
+          grub_uint8_t * fb_ptr;
+          struct grub_video_mode_info local_mode_info;
+          grub_size_t page_size;
+          grub_size_t vram_size = controller_info.total_memory << 16;
+          local_mode_info.height = new_vbe_mode_info.y_resolution;
+
+          if (controller_info.version >= 0x300)
+            local_mode_info.pitch = new_vbe_mode_info.lin_bytes_per_scan_line;
+          else
+            local_mode_info.pitch = new_vbe_mode_info.bytes_per_scan_line;
+
+          fb_ptr = (grub_uint8_t *) new_vbe_mode_info.phys_base_addr;
+
+          page_size = local_mode_info.pitch * local_mode_info.height;
+
+          if (vram_size >= 2 * page_size)
+            grub_memset(fb_ptr, 0, 2 * page_size);
+          else
+            grub_memset(fb_ptr, 0, page_size);
+
+          vbe_mode |= 1 << 15;
+        }
+    }
+
   /* Try to set video mode.  */
   status = grub_vbe_bios_set_mode (vbe_mode, 0);
   if (status != GRUB_VBE_STATUS_OK)
-- 
2.25.1


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to