aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2014-10-17 21:37:23 -0400
committerKevin O'Connor <kevin@koconnor.net>2014-10-27 11:00:32 -0400
commitf7f22630fdf50f6da973d9df210b7c8e32849975 (patch)
tree16511aee5e7dc236a51210ddb00469b708bc98d8
parent9978d49d1c858087de518a1d7391ba88aa0f5109 (diff)
downloadseabios-f7f22630fdf50f6da973d9df210b7c8e32849975.zip
seabios-f7f22630fdf50f6da973d9df210b7c8e32849975.tar.gz
seabios-f7f22630fdf50f6da973d9df210b7c8e32849975.tar.bz2
vgabios: Cache a pointer to the current mode struct in the BDA
Cache a pointer to the current mode 'vgamode_s' struct in the BDA to avoid doing a linear scan of all available vga modes when the struct is needed. This uses an additional two bytes in the BDA (at offset 0xbc). It's possible this could conflict with some other software, but that seams unlikely because that part of the BDA seems reserved for BIOS and VGABIOS uses. (And neither SeaBIOS nor Bochs BIOS currently make use of that area.) Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--vgasrc/vgabios.c8
-rw-r--r--vgasrc/vgabios.h1
2 files changed, 7 insertions, 2 deletions
diff --git a/vgasrc/vgabios.c b/vgasrc/vgabios.c
index d36b62a..fcc5b34 100644
--- a/vgasrc/vgabios.c
+++ b/vgasrc/vgabios.c
@@ -261,7 +261,10 @@ bda_save_restore(int cmd, u16 seg, void *data)
, sizeof(info->bda_0x49));
memcpy_far(SEG_BDA, (void*)0x84, seg, info->bda_0x84
, sizeof(info->bda_0x84));
- SET_BDA_EXT(vbe_mode, GET_FARVAR(seg, info->vbe_mode));
+ u16 vbe_mode = GET_FARVAR(seg, info->vbe_mode);
+ SET_BDA_EXT(vbe_mode, vbe_mode);
+ struct vgamode_s *vmode_g = vgahw_find_mode(vbe_mode);
+ SET_BDA_EXT(vgamode_offset, (u32)vmode_g);
SET_IVT(0x1f, GET_FARVAR(seg, info->font0));
SET_IVT(0x43, GET_FARVAR(seg, info->font1));
}
@@ -276,7 +279,7 @@ bda_save_restore(int cmd, u16 seg, void *data)
struct vgamode_s *
get_current_mode(void)
{
- return vgahw_find_mode(GET_BDA_EXT(vbe_mode) & ~MF_VBEFLAGS);
+ return (void*)(GET_BDA_EXT(vgamode_offset)+0);
}
// Setup BDA after a mode switch.
@@ -302,6 +305,7 @@ vga_set_mode(int mode, int flags)
else
SET_BDA(video_mode, 0xff);
SET_BDA_EXT(vbe_mode, mode | (flags & MF_VBEFLAGS));
+ SET_BDA_EXT(vgamode_offset, (u32)vmode_g);
if (memmodel == MM_TEXT) {
SET_BDA(video_cols, width);
SET_BDA(video_rows, height-1);
diff --git a/vgasrc/vgabios.h b/vgasrc/vgabios.h
index 70682c9..d17b48f 100644
--- a/vgasrc/vgabios.h
+++ b/vgasrc/vgabios.h
@@ -81,6 +81,7 @@ struct gfx_op {
struct vga_bda_s {
u8 vbe_flag;
u16 vbe_mode;
+ u16 vgamode_offset;
} PACKED;
#define GET_BDA_EXT(var) \