]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
x86: video: Allow video ROM execution to fall back to the other method
authorSimon Glass <sjg@chromium.org>
Wed, 28 Jan 2015 05:13:34 +0000 (22:13 -0700)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 1 Sep 2015 10:59:06 +0000 (12:59 +0200)
If the BIOS emulator is not available, allow use of native execution if
available, and vice versa. This can be controlled by the caller.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
arch/x86/cpu/ivybridge/gma.c
drivers/pci/pci_rom.c
drivers/video/vesa_fb.c
include/pci_rom.h

index 6cf9654e02a872d327e6c3b5f7a5a0e09dae3033..821ea25019f963f125fbe8c63237b66399db35a2 100644 (file)
@@ -758,7 +758,8 @@ int gma_func0_init(pci_dev_t dev, struct pci_controller *hose,
 
 #ifdef CONFIG_VIDEO
        start = get_timer(0);
-       ret = pci_run_vga_bios(dev, int15_handler, false);
+       ret = pci_run_vga_bios(dev, int15_handler, PCI_ROM_USE_NATIVE |
+                              PCI_ROM_ALLOW_FALLBACK);
        debug("BIOS ran in %lums\n", get_timer(start));
 #endif
        /* Post VBIOS init */
index 5729a152e5bb00ed759dfe90bd7750f10b7e20b7..48c0a77fdd4e4e9bbd5ff6f1d3ff6fe8139d31d5 100644 (file)
@@ -228,11 +228,12 @@ int vbe_get_video_info(struct graphic_device *gdev)
 #endif
 }
 
-int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), bool emulate)
+int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), int exec_method)
 {
        struct pci_rom_header *rom, *ram;
        int vesa_mode = -1;
        uint16_t class;
+       bool emulate;
        int ret;
 
        /* Only execute VGA ROMs */
@@ -262,6 +263,29 @@ int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), bool emulate)
        vesa_mode = CONFIG_FRAMEBUFFER_VESA_MODE;
 #endif
        debug("Selected vesa mode %#x\n", vesa_mode);
+
+       if (exec_method & PCI_ROM_USE_NATIVE) {
+#ifdef CONFIG_X86
+               emulate = false;
+#else
+               if (!(exec_method & PCI_ROM_ALLOW_FALLBACK)) {
+                       printf("BIOS native execution is only available on x86\n");
+                       return -ENOSYS;
+               }
+               emulate = true;
+#endif
+       } else {
+#ifdef CONFIG_BIOSEMU
+               emulate = true;
+#else
+               if (!(exec_method & PCI_ROM_ALLOW_FALLBACK)) {
+                       printf("BIOS emulation not available - see CONFIG_BIOSEMU\n");
+                       return -ENOSYS;
+               }
+               emulate = false;
+#endif
+       }
+
        if (emulate) {
 #ifdef CONFIG_BIOSEMU
                BE_VGAInfo *info;
@@ -274,9 +298,6 @@ int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), bool emulate)
                                  vesa_mode, &mode_info);
                if (ret)
                        return ret;
-#else
-               printf("BIOS emulation not available - see CONFIG_BIOSEMU\n");
-               return -ENOSYS;
 #endif
        } else {
 #ifdef CONFIG_X86
@@ -284,9 +305,6 @@ int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), bool emulate)
 
                bios_run_on_x86(dev, (unsigned long)ram, vesa_mode,
                                &mode_info);
-#else
-               printf("BIOS native execution is only available on x86\n");
-               return -ENOSYS;
 #endif
        }
        debug("Final vesa mode %#x\n", mode_info.video_mode);
index 3a0fea2584fcc2c1be2a089653151920a90e82d3..9164f8d166631ce436b5a13b473d80a068280842 100644 (file)
@@ -42,8 +42,8 @@ void *video_hw_init(void)
                        printf("no card detected\n");
                        return NULL;
                }
-               printf("bdf %x\n", dev);
-               ret = pci_run_vga_bios(dev, NULL, true);
+               ret = pci_run_vga_bios(dev, NULL, PCI_ROM_USE_NATIVE |
+                                      PCI_ROM_ALLOW_FALLBACK);
                if (ret) {
                        printf("failed to run video BIOS: %d\n", ret);
                        return NULL;
@@ -59,7 +59,7 @@ void *video_hw_init(void)
        sprintf(gdev->modeIdent, "%dx%dx%d", gdev->winSizeX, gdev->winSizeY,
                bits_per_pixel);
        printf("%s\n", gdev->modeIdent);
-       debug("Framex buffer at %x\n", gdev->pciBase);
+       debug("Frame buffer at %x\n", gdev->pciBase);
 
        return (void *)gdev;
 }
index 4ba36eb1b7bd079311d59523d14ad41f4d0962fc..2f1665d17ac90608964bf4e41ae547c4fb32275c 100644 (file)
@@ -33,14 +33,25 @@ struct pci_rom_data {
        uint16_t reserved_2;
 };
 
+/*
+ * Determines which execution method is used and whether we allow falling back
+ * to the other if the requested method is not available.
+ */
+enum pci_rom_emul {
+       PCI_ROM_EMULATE         = 0 << 0,
+       PCI_ROM_USE_NATIVE      = 1 << 0,
+       PCI_ROM_ALLOW_FALLBACK  = 1 << 1,
+};
+
  /**
  * pci_run_vga_bios() - Run the VGA BIOS in an x86 PC
  *
  * @dev:       Video device containing the BIOS
  * @int15_handler:     Function to call to handle int 0x15
- * @emulate:   true to use the x86 emulator, false to run native
+ * @exec_method:       flags from enum pci_rom_emul
  */
-int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void), bool emulate);
+int pci_run_vga_bios(pci_dev_t dev, int (*int15_handler)(void),
+                    int exec_method);
 
 /**
  * board_map_oprom_vendev() - map several PCI IDs to the one the ROM expects