summaryrefslogtreecommitdiff
path: root/arch/x86/lib/video_bios.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2011-12-02 00:17:49 +0100
committerWolfgang Denk <wd@denx.de>2011-12-02 00:17:49 +0100
commit7708d8b352e9e595f6f08afd3206af6495c7dc09 (patch)
treefb9811040b2b1f55c44fc7274473f2ef0847c19b /arch/x86/lib/video_bios.c
parentd887ad54ca74063338bc3108beed0aa4f15d1f6b (diff)
parentf008b17f8c2995996b5d100b71f8851d6f74a136 (diff)
Merge branch 'master' of ssh://gemini/home/wd/git/u-boot/master
* 'master' of ssh://gemini/home/wd/git/u-boot/master: board/emk/top860/top860.c: Fix GCC 4.6 build warning board/sbc405/strataflash.c: Fix GCC 4.6 build warning arch/powerpc/cpu/mpc86xx/cpu.c: Fix GCC 4.6 build warning board/freescale/mpc8610hpcd/mpc8610hpcd.c: Fix GCC 4.6 build warning board/mpl/common/flash.c: Fix GCC 4.6 build warning post/board/lwmon5/gdc.c: Fix GCC 4.6 build warning drivers/usb/host/sl811-hcd.c: Fix GCC 4.6 build warning board/sandburst/common/flash.c: Fix GCC 4.6 build warning DB64460: Fix GCC 4.6 build warnings DB64360: Fix GCC 4.6 build warnings board/cray/L1/flash.c: Fix GCC 4.6 build warning drivers/block/sata_dwc.c: Fix GCC 4.6 build warning board/amirix/ap1000/flash.c: Fix GCC 4.6 build warning alpr board: Fix GCC 4.6 build warnings image: Don't detect XIP images as overlapping. image: Implement IH_TYPE_KERNEL_NOLOAD ppc4xx: Add Io64 board support ppc4xx: fix PMC440 painit command ppc4xx: remove invalid access to PCI_BRDGOPT2 register ppc4xx: use CONFIG_PCI_BOOTDELAY instead of private implementation mpc85xx: support for Freescale COM Express P2020 arch/powerpc/cpu/mpc8xxx/ddr/interactive.c: Fix GCC 4.6 build warning mpc85xx: support board-specific reset function powerpc/85xx: verify the localbus device tree address before booting the OS mpc8xxx: update module_type values from JEDEC DDR3 SPD Specification powerpc/p3060qds: Add board related support for P3060QDS platform powerpc/85xx: clean up and document the QE/FMAN microcode macros powerpc/85xx: always implement the work-around for Erratum SATA_A001 powerpc/85xx: CONFIG_FSL_SATA_V2 should be defined in config_mpc85xx.h powerpc/85xx: Add workaround for erratum A-003474 powerpc/85xx: fixup flexcan device tree clock-frequency powerpc/85xx: Add workaround for erratum CPU-A003999 x86: Fix some bugs in the i8402 driver when no controller is present x86: Make the i8042 driver checkpatch clean x86: Wrap small helper functions from libgcc to avoid an ABI mismatch x86: Import the glibc memset implementation x86: Fix a few recently added bugs x86: Don't relocate symbols which point to things that aren't relocated x86: Fix how the location of the realmode and bios blobs are calculated x86: Misc cleanups x86: Misc PCI touchups x86: Ensure IDT and GDT remain 16-byte aligned post relocation x86: Provide more configuration granularity x86: Add multiboot header sc520: Create arch asm-offsets x86: Punt cold- and warm-boot flags cosmetic: checkpatch cleanup of board/eNET/*.c cosmetic: checkpatch cleanup of arch/x86/lib/*.c cosmetic: checkpatch cleanup of arch/x86/cpu/sc520/*.c cosmetic: checkpatch cleanup of arch/x86/cpu/*.c x86: Call hang() on unrecoverable exception menu.c: use puts() instead of printf() where possible MAKEALL: drop obsolete mx31pdk_nand target dataflash: fix parameters order in write_dataflash() hawkboard: Replace HAWKBOARD_KICK{0, 1}_UNLOCK defines davinci_sonata: define CONFIG_MACH_TYPE for davinci_sonata board davinci_schmoogie: define CONFIG_MACH_TYPE for davinci_schmoogie board arm: a320evb: define mach-type in board config file OMAP3: Use sdelay from arch/arm/cpu/armv7/syslib.c instead of cloning that. Fix Stelian's email address DIU: 1080P and 720P support CFB: Fix font rendering on mx5 framebuffer
Diffstat (limited to 'arch/x86/lib/video_bios.c')
-rw-r--r--arch/x86/lib/video_bios.c130
1 files changed, 52 insertions, 78 deletions
diff --git a/arch/x86/lib/video_bios.c b/arch/x86/lib/video_bios.c
index 7574f771fdd..1e06759d9eb 100644
--- a/arch/x86/lib/video_bios.c
+++ b/arch/x86/lib/video_bios.c
@@ -28,86 +28,55 @@
#include <asm/realmode.h>
#include <asm/io.h>
#include <asm/pci.h>
+#include "bios.h"
#undef PCI_BIOS_DEBUG
#undef VGA_BIOS_DEBUG
#ifdef VGA_BIOS_DEBUG
-#define PRINTF(fmt,args...) printf (fmt ,##args)
+#define PRINTF(fmt, args...) printf(fmt, ##args)
#else
-#define PRINTF(fmt,args...)
+#define PRINTF(fmt, args...)
#endif
-#ifdef CONFIG_PCI
+#define PCI_CLASS_VIDEO 3
+#define PCI_CLASS_VIDEO_STD 0
+#define PCI_CLASS_VIDEO_PROG_IF_VGA 0
-#ifdef PCI_BIOS_DEBUG
-#define RELOC_16(seg, off) *(u32*)(seg << 4 | (u32)&off)
-extern u32 num_pci_bios_present;
-extern u32 num_pci_bios_find_device;
-extern u32 num_pci_bios_find_class;
-extern u32 num_pci_bios_generate_special_cycle;
-extern u32 num_pci_bios_read_cfg_byte;
-extern u32 num_pci_bios_read_cfg_word;
-extern u32 num_pci_bios_read_cfg_dword;
-extern u32 num_pci_bios_write_cfg_byte;
-extern u32 num_pci_bios_write_cfg_word;
-extern u32 num_pci_bios_write_cfg_dword;
-extern u32 num_pci_bios_get_irq_routing;
-extern u32 num_pci_bios_set_irq;
-extern u32 num_pci_bios_unknown_function;
-
-void print_bios_bios_stat(void)
-{
- printf("16 bit functions:\n");
- printf("pci_bios_present: %d\n", RELOC_16(0xf000, num_pci_bios_present));
- printf("pci_bios_find_device: %d\n", RELOC_16(0xf000, num_pci_bios_find_device));
- printf("pci_bios_find_class: %d\n", RELOC_16(0xf000, num_pci_bios_find_class));
- printf("pci_bios_generate_special_cycle: %d\n", RELOC_16(0xf000, num_pci_bios_generate_special_cycle));
- printf("pci_bios_read_cfg_byte: %d\n", RELOC_16(0xf000, num_pci_bios_read_cfg_byte));
- printf("pci_bios_read_cfg_word: %d\n", RELOC_16(0xf000, num_pci_bios_read_cfg_word));
- printf("pci_bios_read_cfg_dword: %d\n", RELOC_16(0xf000, num_pci_bios_read_cfg_dword));
- printf("pci_bios_write_cfg_byte: %d\n", RELOC_16(0xf000, num_pci_bios_write_cfg_byte));
- printf("pci_bios_write_cfg_word: %d\n", RELOC_16(0xf000, num_pci_bios_write_cfg_word));
- printf("pci_bios_write_cfg_dword: %d\n", RELOC_16(0xf000, num_pci_bios_write_cfg_dword));
- printf("pci_bios_get_irq_routing: %d\n", RELOC_16(0xf000, num_pci_bios_get_irq_routing));
- printf("pci_bios_set_irq: %d\n", RELOC_16(0xf000, num_pci_bios_set_irq));
- printf("pci_bios_unknown_function: %d\n", RELOC_16(0xf000, num_pci_bios_unknown_function));
-
-}
-#endif
-
-#ifdef CONFIG_VIDEO
-
-#define PCI_CLASS_VIDEO 3
-#define PCI_CLASS_VIDEO_STD 0
-#define PCI_CLASS_VIDEO_PROG_IF_VGA 0
-
-static struct pci_device_id supported[] = {
+DEFINE_PCI_DEVICE_TABLE(supported) = {
{PCI_VIDEO_VENDOR_ID, PCI_VIDEO_DEVICE_ID},
{}
};
static u32 probe_pci_video(void)
{
- pci_dev_t devbusfn;
+ struct pci_controller *hose;
+ pci_dev_t devbusfn = pci_find_devices(supported, 0);
- if ((devbusfn = pci_find_devices(supported, 0) != -1)) {
+ if ((devbusfn != -1)) {
u32 old;
u32 addr;
/* PCI video device detected */
printf("Found PCI VGA device at %02x.%02x.%x\n",
- PCI_BUS(devbusfn), PCI_DEV(devbusfn), PCI_FUNC(devbusfn));
+ PCI_BUS(devbusfn),
+ PCI_DEV(devbusfn),
+ PCI_FUNC(devbusfn));
/* Enable I/O decoding as well, PCI viudeo boards
* support I/O accesses, but they provide no
* bar register for this since the ports are fixed.
*/
- pci_write_config_word(devbusfn, PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_IO | PCI_COMMAND_MASTER);
+ pci_write_config_word(devbusfn,
+ PCI_COMMAND,
+ PCI_COMMAND_MEMORY |
+ PCI_COMMAND_IO |
+ PCI_COMMAND_MASTER);
/* Test the ROM decoder, do the device support a rom? */
pci_read_config_dword(devbusfn, PCI_ROM_ADDRESS, &old);
- pci_write_config_dword(devbusfn, PCI_ROM_ADDRESS, (u32)PCI_ROM_ADDRESS_MASK);
+ pci_write_config_dword(devbusfn, PCI_ROM_ADDRESS,
+ (u32)PCI_ROM_ADDRESS_MASK);
pci_read_config_dword(devbusfn, PCI_ROM_ADDRESS, &addr);
pci_write_config_dword(devbusfn, PCI_ROM_ADDRESS, old);
@@ -117,13 +86,14 @@ static u32 probe_pci_video(void)
}
/* device have a rom */
- if (pci_shadow_rom(devbusfn, (void*)0xc0000)) {
+ if (pci_shadow_rom(devbusfn, (void *)0xc0000)) {
printf("Shadowing of PCI VGA BIOS failed\n");
return 0;
}
/* Now enable lagacy VGA port access */
- if (pci_enable_legacy_video_ports(pci_bus_to_hose(PCI_BUS(devbusfn)))) {
+ hose = pci_bus_to_hose(PCI_BUS(devbusfn));
+ if (pci_enable_legacy_video_ports(hose)) {
printf("PCI VGA enable failed\n");
return 0;
}
@@ -131,7 +101,7 @@ static u32 probe_pci_video(void)
/* return the pci device info, that we'll need later */
return PCI_BUS(devbusfn) << 8 |
- PCI_DEV(devbusfn) << 3 | (PCI_FUNC(devbusfn)&7);
+ PCI_DEV(devbusfn) << 3 | (PCI_FUNC(devbusfn) & 7);
}
return 0;
@@ -142,13 +112,17 @@ static int probe_isa_video(void)
u32 ptr;
char *buf;
- if (0 == (ptr = isa_map_rom(0xc0000, 0x8000))) {
+ ptr = isa_map_rom(0xc0000, 0x8000);
+
+ if (!ptr)
return -1;
- }
- if (NULL == (buf=malloc(0x8000))) {
+
+ buf = malloc(0x8000);
+ if (!buf) {
isa_unmap_rom(ptr);
return -1;
}
+
if (readw(ptr) != 0xaa55) {
free(buf);
isa_unmap_rom(ptr);
@@ -156,9 +130,9 @@ static int probe_isa_video(void)
}
/* shadow the rom */
- memcpy(buf, (void*)ptr, 0x8000);
+ memcpy(buf, (void *)ptr, 0x8000);
isa_unmap_rom(ptr);
- memcpy((void*)0xc0000, buf, 0x8000);
+ memcpy((void *)0xc0000, buf, 0x8000);
free(buf);
@@ -168,35 +142,35 @@ static int probe_isa_video(void)
int video_bios_init(void)
{
struct pt_regs regs;
+ int size;
+ int i;
+ u8 sum;
/* clear the video bios area in case we warmbooted */
- memset((void*)0xc0000, 0, 0x8000);
+ memset((void *)0xc0000, 0, 0x8000);
memset(&regs, 0, sizeof(struct pt_regs));
- if (probe_isa_video()) {
+ if (probe_isa_video())
/* No ISA board found, try the PCI bus */
regs.eax = probe_pci_video();
- }
/* Did we succeed in mapping any video bios */
if (readw(0xc0000) == 0xaa55) {
- int size;
- int i;
- u8 sum;
-
PRINTF("Found video bios signature\n");
- size = 512*readb(0xc0002);
+ size = readb(0xc0002) * 512;
PRINTF("size %d\n", size);
- sum=0;
- for (i=0;i<size;i++) {
+ sum = 0;
+
+ for (i = 0; i < size; i++)
sum += readb(0xc0000 + i);
- }
- PRINTF("Checksum is %sOK\n",sum?"NOT ":"");
- if (sum) {
+
+ PRINTF("Checksum is %sOK\n", sum ? "NOT " : "");
+
+ if (sum)
return 1;
- }
- /* some video bioses (ATI Mach64) seem to think that
+ /*
+ * Some video bioses (ATI Mach64) seem to think that
* the original int 10 handler is always at
* 0xf000:0xf065 , place an iret instruction there
*/
@@ -205,18 +179,18 @@ int video_bios_init(void)
regs.esp = 0x8000;
regs.xss = 0x2000;
enter_realmode(0xc000, 3, &regs, &regs);
+
PRINTF("INT 0x10 vector after: %04x:%04x\n",
readw(0x42), readw(0x40));
- PRINTF("BIOS returned %scarry\n", regs.eflags & 1?"":"NOT ");
+ PRINTF("BIOS returned %scarry\n",
+ regs.eflags & 0x00000001 ? "" : "NOT ");
#ifdef PCI_BIOS_DEBUG
print_bios_bios_stat();
#endif
- return (regs.eflags & 1);
+ return regs.eflags & 0x00000001;
}
return 1;
}
-#endif
-#endif