vgabios: Use bochsvga_ prefix for bochs vga functions.
[seabios.git] / vgasrc / vga.c
index 26f70ce5bfeff91fdf394ba80d959bdcba188b11..9e5884b75232cd09c22e256cd064c9e263af9821 100644 (file)
 #include "vgatables.h" // find_vga_entry
 #include "optionroms.h" // struct pci_data
 #include "config.h" // CONFIG_*
-#include "vbe.h" // vbe_*
+#include "vbe.h" // struct vbe_info
+#include "geodelx.h" // geodelx_init
+#include "bochsvga.h" // bochsvga_init
 
 // XXX
 #define DEBUG_VGA_POST 1
 #define DEBUG_VGA_10 3
 
-#define SET_VGA(var, val) SET_FARVAR(get_global_seg(), (var), (val))
 
 /****************************************************************
  * PCI Data
@@ -175,8 +176,7 @@ set_active_page(u8 page)
         // Start address
         address = SCREEN_IO_START(nbcols, nbrows, page);
     } else {
-        struct VideoParam_s *vparam_g = GET_GLOBAL(vmode_g->vparam);
-        address = page * GET_GLOBAL(vparam_g->slength);
+        address = page * GET_GLOBAL(vmode_g->slength);
     }
 
     vgahw_set_active_page(address);
@@ -394,8 +394,7 @@ vga_set_mode(u8 mode, u8 noclearmem)
             perform_gray_scale_summing(0x00, 0x100);
     }
 
-    struct VideoParam_s *vparam_g = GET_GLOBAL(vmode_g->vparam);
-    vgahw_set_mode(vparam_g);
+    vgahw_set_mode(vmode_g);
 
     if (noclearmem == 0x00)
         clear_screen(vmode_g);
@@ -406,12 +405,12 @@ vga_set_mode(u8 mode, u8 noclearmem)
         crtc_addr = VGAREG_MDA_CRTC_ADDRESS;
 
     // Set the BIOS mem
-    u16 cheight = GET_GLOBAL(vparam_g->cheight);
+    u16 cheight = GET_GLOBAL(vmode_g->cheight);
     SET_BDA(video_mode, mode);
-    SET_BDA(video_cols, GET_GLOBAL(vparam_g->twidth));
-    SET_BDA(video_pagesize, GET_GLOBAL(vparam_g->slength));
+    SET_BDA(video_cols, GET_GLOBAL(vmode_g->twidth));
+    SET_BDA(video_pagesize, GET_GLOBAL(vmode_g->slength));
     SET_BDA(crtc_address, crtc_addr);
-    SET_BDA(video_rows, GET_GLOBAL(vparam_g->theightm1));
+    SET_BDA(video_rows, GET_GLOBAL(vmode_g->theight)-1);
     SET_BDA(char_height, cheight);
     SET_BDA(video_ctl, (0x60 | noclearmem));
     SET_BDA(video_switches, 0xF9);
@@ -420,7 +419,7 @@ vga_set_mode(u8 mode, u8 noclearmem)
     // 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
-            , SEGOFF(get_global_seg(), (u32)video_save_pointer_table));
+            , SEGOFF(get_global_seg(), (u32)&video_save_pointer_table));
 
     // FIXME
     SET_BDA(video_msr, 0x00); // Unavailable on vanilla vga, but...
@@ -474,11 +473,14 @@ handle_1000(struct bregs *regs)
     else
         regs->al = 0x30;
 
-    if (CONFIG_VGA_CIRRUS)
-        cirrus_set_video_mode(mode);
+    if (CONFIG_VGA_CIRRUS) {
+        int ret = cirrus_set_video_mode(mode, noclearmem);
+        if (ret)
+            return;
+    }
 
-    if (vbe_enabled())
-        vbe_hires_enable(0);
+    if (bochsvga_enabled())
+        bochsvga_hires_enable(0);
 
     vga_set_mode(mode, noclearmem);
 }
@@ -1089,8 +1091,7 @@ handle_101a(struct bregs *regs)
 
 
 struct funcInfo {
-    u16 static_functionality_off;
-    u16 static_functionality_seg;
+    struct segoff_s static_functionality;
     u8 bda_0x49[30];
     u8 bda_0x84[3];
     u8 dcc_index;
@@ -1116,8 +1117,8 @@ handle_101b(struct bregs *regs)
     struct funcInfo *info = (void*)(regs->di+0);
     memset_far(seg, info, 0, sizeof(*info));
     // Address of static functionality table
-    SET_FARVAR(seg, info->static_functionality_off, (u32)static_functionality);
-    SET_FARVAR(seg, info->static_functionality_seg, get_global_seg());
+    SET_FARVAR(seg, info->static_functionality
+               , SEGOFF(get_global_seg(), (u32)static_functionality));
 
     // Hard coded copy from BIOS area. Should it be cleaner ?
     memcpy_far(seg, info->bda_0x49, SEG_BDA, (void*)0x49
@@ -1226,13 +1227,13 @@ handle_104f00(struct bregs *regs)
 
     SET_FARVAR(seg, info->oem_string,
             SEGOFF(get_global_seg(), (u32)VBE_OEM_STRING));
-    SET_FARVAR(seg, info->capabilities[0], 0x1); /* 8BIT DAC */
+    SET_FARVAR(seg, info->capabilities, 0x1); /* 8BIT DAC */
 
     /* We generate our mode list in the reserved field of the info block */
     SET_FARVAR(seg, info->video_mode, SEGOFF(seg, regs->di + 34));
 
     /* Total memory (in 64 blocks) */
-    SET_FARVAR(seg, info->total_memory, vbe_total_mem());
+    SET_FARVAR(seg, info->total_memory, bochsvga_total_mem());
 
     SET_FARVAR(seg, info->oem_vendor_string,
             SEGOFF(get_global_seg(), (u32)VBE_VENDOR_STRING));
@@ -1242,7 +1243,7 @@ handle_104f00(struct bregs *regs)
             SEGOFF(get_global_seg(), (u32)VBE_REVISION_STRING));
 
     /* Fill list of modes */
-    vbe_list_modes(seg, regs->di + 32);
+    bochsvga_list_modes(seg, regs->di + 32);
 
     regs->al = regs->ah; /* 0x4F, Function supported */
     regs->ah = 0x0; /* 0x0, Function call successful */
@@ -1259,7 +1260,7 @@ handle_104f01(struct bregs *regs)
 
     dprintf(1, "VBE mode info request: %x\n", mode);
 
-    rc = vbe_mode_info(mode, &modeinfo);
+    rc = bochsvga_mode_info(mode, &modeinfo);
     if (rc) {
         dprintf(1, "VBE mode %x not found\n", mode);
         regs->ax = 0x100;
@@ -1284,7 +1285,7 @@ handle_104f01(struct bregs *regs)
     SET_FARVAR(seg, info->win_size, 64); /* Bank size 64K */
     SET_FARVAR(seg, info->winA_seg, 0xA000);
     SET_FARVAR(seg, info->winB_seg, 0x0);
-    SET_FARVAR(seg, info->win_func_ptr, 0x0);
+    SET_FARVAR(seg, info->win_func_ptr.segoff, 0x0);
     SET_FARVAR(seg, info->bytes_per_scanline, modeinfo.linesize);
     SET_FARVAR(seg, info->xres, modeinfo.width);
     SET_FARVAR(seg, info->yres, modeinfo.height);
@@ -1379,24 +1380,24 @@ handle_104f02(struct bregs *regs)
     if (mode < 0x100) { /* VGA */
         dprintf(1, "set VGA mode %x\n", mode);
 
-        vbe_hires_enable(0);
+        bochsvga_hires_enable(0);
         vga_set_mode(mode, 0);
     } else { /* VBE */
-        rc = vbe_mode_info(mode & 0x1ff, &modeinfo);
+        rc = bochsvga_mode_info(mode & 0x1ff, &modeinfo);
         if (rc) {
             dprintf(1, "VBE mode %x not found\n", mode & 0x1ff);
             regs->ax = 0x100;
             return;
         }
-        vbe_hires_enable(1);
-        vbe_set_mode(mode & 0x1ff, &modeinfo);
+        bochsvga_hires_enable(1);
+        bochsvga_set_mode(mode & 0x1ff, &modeinfo);
 
         if (mode & 0x4000) {
             /* Linear frame buffer */
             /* XXX: ??? */
         }
         if (!(mode & 0x8000)) {
-            vbe_clear_scr();
+            bochsvga_clear_scr();
         }
     }
 
@@ -1407,10 +1408,10 @@ handle_104f02(struct bregs *regs)
 static void
 handle_104f03(struct bregs *regs)
 {
-    if (!vbe_hires_enabled()) {
+    if (!bochsvga_hires_enabled()) {
         regs->bx = GET_BDA(video_mode);
     } else {
-        regs->bx = vbe_curr_mode();
+        regs->bx = bochsvga_curr_mode();
     }
 
     dprintf(1, "VBE current mode=%x\n", regs->bx);
@@ -1471,7 +1472,7 @@ handle_104fXX(struct bregs *regs)
 static void
 handle_104f(struct bregs *regs)
 {
-    if (!vbe_enabled()) {
+    if (!bochsvga_enabled()) {
         handle_104fXX(regs);
         return;
     }
@@ -1570,9 +1571,12 @@ vga_post(struct bregs *regs)
 
     vgahw_init();
 
+    if (CONFIG_VGA_GEODELX)
+        geodelx_init();
+
     init_bios_area();
 
-    vbe_init(regs->ah, regs->al);
+    bochsvga_init(regs->ah, regs->al);
 
     extern void entry_10(void);
     SET_IVT(0x10, SEGOFF(get_global_seg(), (u32)entry_10));
@@ -1582,9 +1586,7 @@ vga_post(struct bregs *regs)
 
     // XXX - clear screen and display info
 
-    // XXX: fill it
-    SET_VGA(video_save_pointer_table[0], (u32)video_param_table);
-    SET_VGA(video_save_pointer_table[1], get_global_seg());
+    build_video_param();
 
     // Fixup checksum
     extern u8 _rom_header_size, _rom_header_checksum;