* Helper functions
****************************************************************/
+// Return the bits per pixel in system memory for a given mode.
+int
+vga_bpp(struct vgamode_s *vmode_g)
+{
+ switch (GET_GLOBAL(vmode_g->memmodel)) {
+ case MM_TEXT:
+ return 16;
+ case MM_PLANAR:
+ return 1;
+ }
+ u8 depth = GET_GLOBAL(vmode_g->depth);
+ if (depth > 8)
+ return ALIGN(depth, 8);
+ return depth;
+}
+
u16
calc_page_size(u8 memmodel, u16 width, u16 height)
{
return;
// Calculate the memory address
- u16 nbcols = GET_BDA(video_cols);
- u16 address = (GET_BDA(video_pagesize) * cp.page
- + (cp.x + cp.y * nbcols) * 2);
-
- stdvga_set_cursor_pos(address / 2);
+ int address = (GET_BDA(video_pagesize) * cp.page
+ + (cp.x + cp.y * GET_BDA(video_cols)) * 2);
+ stdvga_set_cursor_pos(address);
}
static struct cursorpos
struct cursorpos cp = get_cursor_pos(page);
// Calculate memory address of start of page
- u8 memmodel = GET_GLOBAL(vmode_g->memmodel);
- u16 address = GET_BDA(video_pagesize) * page;
- stdvga_set_active_page(memmodel == MM_TEXT ? address / 2 : address);
+ int address = GET_BDA(video_pagesize) * page;
+ vgahw_set_displaystart(vmode_g, address);
// And change the BIOS page
SET_BDA(video_pagestart, address);
if (CONFIG_VGA_PCI) {
u16 bdf = regs->ax;
- if (pci_config_readw(bdf, PCI_VENDOR_ID) == CONFIG_VGA_VID
- && pci_config_readw(bdf, PCI_DEVICE_ID) == CONFIG_VGA_DID)
+ if ((pci_config_readw(bdf, PCI_VENDOR_ID)
+ == GET_GLOBAL(rom_pci_data.vendor))
+ && (pci_config_readw(bdf, PCI_DEVICE_ID)
+ == GET_GLOBAL(rom_pci_data.device)))
SET_VGA(VgaBDF, bdf);
}