vgabios: Move BDA setting from driver code to common code.

Always setup the BDA on a mode switch.  Call that BDA setup code

Also, always set vbe_mode and use that for finding the current mode
and for reporting the mode to vbe callers.

Signed-off-by: Kevin O'Connor <>
diff --git a/vgasrc/vgahw.h b/vgasrc/vgahw.h
index 1101e51..bb5112a 100644
--- a/vgasrc/vgahw.h
+++ b/vgasrc/vgahw.h
@@ -17,12 +17,12 @@
     return stdvga_find_mode(mode);
-static inline int vgahw_set_mode(int mode, int flags) {
+static inline int vgahw_set_mode(struct vgamode_s *vmode_g, int flags) {
-        return clext_set_mode(mode, flags);
+        return clext_set_mode(vmode_g, flags);
-        return bochsvga_set_mode(mode, flags);
-    return stdvga_set_mode(mode, flags);
+        return bochsvga_set_mode(vmode_g, flags);
+    return stdvga_set_mode(vmode_g, flags);
 static inline void vgahw_list_modes(u16 seg, u16 *dest, u16 *last) {