Add configuration menu for the VGA ROM
[seabios.git] / vgasrc / vga.c
index 88cbb01fd39b707d9bd688e6c152bc56f4ffaf09..3988da9c9a58b451ace2829cd433a76e9d90b1f4 100644 (file)
 #include "biosvar.h" // GET_BDA
 #include "util.h" // memset
 #include "vgatables.h" // find_vga_entry
-
-// XXX
-#define CONFIG_VBE 0
-#define CONFIG_CIRRUS 0
+#include "optionroms.h" // struct pci_data
+#include "config.h" // CONFIG_*
 
 // XXX
 #define DEBUG_VGA_POST 1
 
 #define SET_VGA(var, val) SET_FARVAR(get_global_seg(), (var), (val))
 
+/****************************************************************
+ * PCI Data
+ ****************************************************************/
+#if CONFIG_VGA_PCI == 1
+struct pci_data rom_pci_data VAR16VISIBLE = {
+    .signature = PCI_ROM_SIGNATURE,
+    .vendor = CONFIG_VGA_VID,
+    .device = CONFIG_VGA_DID,
+    .dlen = 0x18,
+    .class_hi = 0x300,
+    .irevision = 1,
+    .type = PCIROM_CODETYPE_X86,
+    .indicator = 0x80,
+};
+#endif
 
 /****************************************************************
  * Helper functions
@@ -312,8 +325,8 @@ save_bda_state(u16 seg, struct saveBDAstate *info)
     SET_FARVAR(seg, info->video_pagestart, GET_BDA(video_pagestart));
     SET_FARVAR(seg, info->video_page, GET_BDA(video_page));
     /* current font */
-    SET_FARVAR(seg, *(u32*)&info->font0_off, GET_IVT(0x1f).segoff);
-    SET_FARVAR(seg, *(u32*)&info->font1_off, GET_IVT(0x43).segoff);
+    SET_FARVAR(seg, info->font0, GET_IVT(0x1f));
+    SET_FARVAR(seg, info->font1, GET_IVT(0x43));
 }
 
 static void
@@ -335,10 +348,8 @@ restore_bda_state(u16 seg, struct saveBDAstate *info)
     SET_BDA(video_pagestart, GET_FARVAR(seg, info->video_pagestart));
     SET_BDA(video_page, GET_FARVAR(seg, info->video_page));
     /* current font */
-    SET_IVT(0x1f, GET_FARVAR(seg, info->font0_seg)
-            , GET_FARVAR(seg, info->font0_off));
-    SET_IVT(0x43, GET_FARVAR(seg, info->font1_seg)
-            , GET_FARVAR(seg, info->font1_off));
+    SET_IVT(0x1f, GET_FARVAR(seg, info->font0));
+    SET_IVT(0x43, GET_FARVAR(seg, info->font1));
 }
 
 
@@ -361,11 +372,11 @@ handle_1000(struct bregs *regs)
     else
         regs->al = 0x30;
 
-    if (CONFIG_CIRRUS)
+    if (CONFIG_VGA_CIRRUS)
         cirrus_set_video_mode(mode);
 
-    if (CONFIG_VBE)
-        if (vbe_has_vbe_display())
+    if (CONFIG_VGA_BOCHS)
+        if (bochs_has_vbe_display())
             dispi_set_enable(VBE_DISPI_DISABLED);
 
     // find the entry in the video modes
@@ -425,8 +436,8 @@ handle_1000(struct bregs *regs)
 
     // FIXME We nearly have the good tables. to be reworked
     SET_BDA(dcc_index, 0x08);   // 8 is VGA should be ok for now
-    SET_BDA(video_savetable_ptr, (u32)video_save_pointer_table);
-    SET_BDA(video_savetable_seg, get_global_seg());
+    SET_BDA(video_savetable
+            , SEGOFF(get_global_seg(), (u32)video_save_pointer_table));
 
     // FIXME
     SET_BDA(video_msr, 0x00); // Unavailable on vanilla vga, but...
@@ -451,17 +462,17 @@ handle_1000(struct bregs *regs)
         call16_vgaint(0x1103, 0);
     }
     // Set the ints 0x1F and 0x43
-    SET_IVT(0x1f, get_global_seg(), (u32)&vgafont8[128 * 8]);
+    SET_IVT(0x1f, SEGOFF(get_global_seg(), (u32)&vgafont8[128 * 8]));
 
     switch (cheight) {
     case 8:
-        SET_IVT(0x43, get_global_seg(), (u32)vgafont8);
+        SET_IVT(0x43, SEGOFF(get_global_seg(), (u32)vgafont8));
         break;
     case 14:
-        SET_IVT(0x43, get_global_seg(), (u32)vgafont14);
+        SET_IVT(0x43, SEGOFF(get_global_seg(), (u32)vgafont14));
         break;
     case 16:
-        SET_IVT(0x43, get_global_seg(), (u32)vgafont16);
+        SET_IVT(0x43, SEGOFF(get_global_seg(), (u32)vgafont16));
         break;
     }
 }
@@ -671,7 +682,7 @@ handle_101007(struct bregs *regs)
 static void
 handle_101008(struct bregs *regs)
 {
-    regs->bh = vgahw_get_overscan_border_color(regs);
+    regs->bh = vgahw_get_overscan_border_color();
 }
 
 static void
@@ -835,15 +846,15 @@ handle_101130(struct bregs *regs)
 {
     switch (regs->bh) {
     case 0x00: {
-        u32 segoff = GET_IVT(0x1f).segoff;
-        regs->es = segoff >> 16;
-        regs->bp = segoff;
+        struct segoff_s so = GET_IVT(0x1f);
+        regs->es = so.seg;
+        regs->bp = so.offset;
         break;
     }
     case 0x01: {
-        u32 segoff = GET_IVT(0x43).segoff;
-        regs->es = segoff >> 16;
-        regs->bp = segoff;
+        struct segoff_s so = GET_IVT(0x43);
+        regs->es = so.seg;
+        regs->bp = so.offset;
         break;
     }
     case 0x02:
@@ -1103,8 +1114,10 @@ handle_101b(struct bregs *regs)
     SET_FARVAR(seg, info->static_functionality_seg, get_global_seg());
 
     // Hard coded copy from BIOS area. Should it be cleaner ?
-    memcpy_far(seg, info->bda_0x49, SEG_BDA, (void*)0x49, 30);
-    memcpy_far(seg, info->bda_0x84, SEG_BDA, (void*)0x84, 3);
+    memcpy_far(seg, info->bda_0x49, SEG_BDA, (void*)0x49
+               , sizeof(info->bda_0x49));
+    memcpy_far(seg, info->bda_0x84, SEG_BDA, (void*)0x84
+               , sizeof(info->bda_0x84));
 
     SET_FARVAR(seg, info->dcc_index, GET_BDA(dcc_index));
     SET_FARVAR(seg, info->colors, 16);
@@ -1263,7 +1276,7 @@ handle_104fXX(struct bregs *regs)
 static void
 handle_104f(struct bregs *regs)
 {
-    if (! CONFIG_VBE || !vbe_has_vbe_display()) {
+    if (! CONFIG_VGA_BOCHS || !bochs_has_vbe_display()) {
         handle_104fXX(regs);
         return;
     }
@@ -1330,7 +1343,7 @@ handle_10(struct bregs *regs)
  ****************************************************************/
 
 static void
-init_bios_area()
+init_bios_area(void)
 {
     // init detected hardware BIOS Area
     // set 80x25 color (not clear from RBIL but usual)
@@ -1364,13 +1377,13 @@ vga_post(struct bregs *regs)
 
     init_bios_area();
 
-    if (CONFIG_VBE)
-        vbe_init();
+    if (CONFIG_VGA_BOCHS)
+        bochs_init();
 
     extern void entry_10(void);
-    SET_IVT(0x10, get_global_seg(), (u32)entry_10);
+    SET_IVT(0x10, SEGOFF(get_global_seg(), (u32)entry_10));
 
-    if (CONFIG_CIRRUS)
+    if (CONFIG_VGA_CIRRUS)
         cirrus_init();
 
     // XXX - clear screen and display info