]> git.sur5r.net Git - u-boot/blobdiff - arch/x86/lib/bios.c
bios: vesa: Guard setting vesa mode with CONFIG_FRAMEBUFFER_SET_VESA_MODE
[u-boot] / arch / x86 / lib / bios.c
index 42853489fb5ab76d4efbdd670a75c299ddb6727c..f9092fdc65183dacbd1774acfbbdb2451bbcab11 100644 (file)
@@ -157,7 +157,7 @@ static void setup_realmode_idt(void)
         for (i = 0; i < 256; i++) {
                idts[i].cs = 0;
                idts[i].offset = 0x1000 + (i * __idt_handler_size);
-               write_idt_stub((void *)((u32)idts[i].offset), i);
+               write_idt_stub((void *)((ulong)idts[i].offset), i);
        }
 
        /*
@@ -185,6 +185,7 @@ static void setup_realmode_idt(void)
        write_idt_stub((void *)0xffe6e, 0x1a);
 }
 
+#ifdef CONFIG_FRAMEBUFFER_SET_VESA_MODE
 static u8 vbe_get_mode_info(struct vbe_mode_info *mi)
 {
        u16 buffer_seg;
@@ -207,12 +208,14 @@ static u8 vbe_get_mode_info(struct vbe_mode_info *mi)
 
 static u8 vbe_set_mode(struct vbe_mode_info *mi)
 {
-       debug("VBE: Setting VESA mode %#04x\n", mi->video_mode);
+       int video_mode = mi->video_mode;
+
+       debug("VBE: Setting VESA mode %#04x\n", video_mode);
        /* request linear framebuffer mode */
-       mi->video_mode |= (1 << 14);
+       video_mode |= (1 << 14);
        /* don't clear the framebuffer, we do that later */
-       mi->video_mode |= (1 << 15);
-       realmode_interrupt(0x10, VESA_SET_MODE, mi->video_mode,
+       video_mode |= (1 << 15);
+       realmode_interrupt(0x10, VESA_SET_MODE, video_mode,
                           0x0000, 0x0000, 0x0000, 0x0000);
 
        return 0;
@@ -225,7 +228,7 @@ static void vbe_set_graphics(int vesa_mode, struct vbe_mode_info *mode_info)
        mode_info->video_mode = (1 << 14) | vesa_mode;
        vbe_get_mode_info(mode_info);
 
-       framebuffer = (unsigned char *)mode_info->vesa.phys_base_ptr;
+       framebuffer = (unsigned char *)(ulong)mode_info->vesa.phys_base_ptr;
        debug("VBE: resolution:  %dx%d@%d\n",
              le16_to_cpu(mode_info->vesa.x_resolution),
              le16_to_cpu(mode_info->vesa.y_resolution),
@@ -236,12 +239,15 @@ static void vbe_set_graphics(int vesa_mode, struct vbe_mode_info *mode_info)
                return;
        }
 
+       mode_info->video_mode &= 0x3ff;
        vbe_set_mode(mode_info);
 }
+#endif /* CONFIG_FRAMEBUFFER_SET_VESA_MODE */
 
-void bios_run_on_x86(pci_dev_t pcidev, unsigned long addr, int vesa_mode,
+void bios_run_on_x86(struct udevice *dev, unsigned long addr, int vesa_mode,
                     struct vbe_mode_info *mode_info)
 {
+       pci_dev_t pcidev = dm_pci_get_bdf(dev);
        u32 num_dev;
 
        num_dev = PCI_BUS(pcidev) << 8 | PCI_DEV(pcidev) << 3 |
@@ -269,8 +275,10 @@ void bios_run_on_x86(pci_dev_t pcidev, unsigned long addr, int vesa_mode,
                      0x0);
        debug("done\n");
 
+#ifdef CONFIG_FRAMEBUFFER_SET_VESA_MODE
        if (vesa_mode != -1)
                vbe_set_graphics(vesa_mode, mode_info);
+#endif
 }
 
 asmlinkage int interrupt_handler(u32 intnumber, u32 gsfs, u32 dses,