[SeaBIOS] [PATCH 03/10] vgabios: Extract out current mode finding into new function.

Kevin O'Connor kevin at koconnor.net
Sat Jan 28 05:27:14 CET 2012


Signed-off-by: Kevin O'Connor <kevin at koconnor.net>
---
 vgasrc/vgabios.c |   13 ++++++++++++-
 vgasrc/vgabios.h |    1 +
 vgasrc/vgafb.c   |   11 +++++------
 3 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c
index 5ce7c0c..62b09b4 100644
--- a/vgasrc/vgabios.c
+++ b/vgasrc/vgabios.c
@@ -151,7 +151,7 @@ set_active_page(u8 page)
         return;
 
     // Get the mode
-    struct vgamode_s *vmode_g = vgahw_find_mode(GET_BDA(video_mode));
+    struct vgamode_s *vmode_g = get_current_mode();
     if (!vmode_g)
         return;
 
@@ -336,6 +336,17 @@ restore_bda_state(u16 seg, struct saveBDAstate *info)
     SET_IVT(0x43, GET_FARVAR(seg, info->font1));
 }
 
+
+/****************************************************************
+ * Mode setting
+ ****************************************************************/
+
+struct vgamode_s *
+get_current_mode(void)
+{
+    return vgahw_find_mode(GET_BDA(video_mode));
+}
+
 // Setup BDA after a mode switch.
 void
 modeswitch_set_bda(int mode, int flags, struct vgamode_s *vmode_g)
diff --git a/vgasrc/vgabios.h b/vgasrc/vgabios.h
index 6895a39..6a3a379 100644
--- a/vgasrc/vgabios.h
+++ b/vgasrc/vgabios.h
@@ -82,6 +82,7 @@ struct cursorpos {
     u8 x, y, page;
 };
 u16 calc_page_size(u8 memmodel, u16 width, u16 height);
+struct vgamode_s *get_current_mode(void);
 void modeswitch_set_bda(int mode, int flags, struct vgamode_s *vmode_g);
 
 // vgafb.c
diff --git a/vgasrc/vgafb.c b/vgasrc/vgafb.c
index 71a5719..f0bd71e 100644
--- a/vgasrc/vgafb.c
+++ b/vgasrc/vgafb.c
@@ -7,7 +7,6 @@
 
 #include "biosvar.h" // GET_BDA
 #include "util.h" // memset_far
-#include "vgahw.h" // vgahw_find_mode
 #include "stdvga.h" // stdvga_planar4_plane
 
 
@@ -171,7 +170,7 @@ void
 vgafb_scroll(int nblines, int attr, struct cursorpos ul, struct cursorpos lr)
 {
     // Get the mode
-    struct vgamode_s *vmode_g = vgahw_find_mode(GET_BDA(video_mode));
+    struct vgamode_s *vmode_g = get_current_mode();
     if (!vmode_g)
         return;
 
@@ -339,7 +338,7 @@ void
 vgafb_write_char(struct cursorpos cp, struct carattr ca)
 {
     // Get the mode
-    struct vgamode_s *vmode_g = vgahw_find_mode(GET_BDA(video_mode));
+    struct vgamode_s *vmode_g = get_current_mode();
     if (!vmode_g)
         return;
 
@@ -365,7 +364,7 @@ struct carattr
 vgafb_read_char(struct cursorpos cp)
 {
     // Get the mode
-    struct vgamode_s *vmode_g = vgahw_find_mode(GET_BDA(video_mode));
+    struct vgamode_s *vmode_g = get_current_mode();
     if (!vmode_g)
         goto fail;
 
@@ -397,7 +396,7 @@ void
 vgafb_write_pixel(u8 color, u16 x, u16 y)
 {
     // Get the mode
-    struct vgamode_s *vmode_g = vgahw_find_mode(GET_BDA(video_mode));
+    struct vgamode_s *vmode_g = get_current_mode();
     if (!vmode_g)
         return;
 
@@ -453,7 +452,7 @@ u8
 vgafb_read_pixel(u16 x, u16 y)
 {
     // Get the mode
-    struct vgamode_s *vmode_g = vgahw_find_mode(GET_BDA(video_mode));
+    struct vgamode_s *vmode_g = get_current_mode();
     if (!vmode_g)
         return 0;
 
-- 
1.7.6.4




More information about the SeaBIOS mailing list