Difference between revisions of "VGA support"

From coreboot
Jump to: navigation, search
(Perl script to dump out your video bios: syntax highlight test)
Line 1: Line 1:
 
There are two kinds of VGA devices
 
There are two kinds of VGA devices
    1. onboard vga
+
# on-board VGA
    2. addon card.
+
# add-on cards
 +
 
 +
= VGA initialization in coreboot v2 =
 +
 
 +
== General ==
  
 
You need to enable two CONFIG options in your Mainboard Option.lb
 
You need to enable two CONFIG options in your Mainboard Option.lb
    #VGA Console
 
    option CONFIG_CONSOLE_VGA=1
 
    option CONFIG_PCI_ROM_RUN=1
 
  
CONFIG_PCI_ROM_RUN will use the embedded x86 emulator to run the BIOS image in the expansion ROM of a PCI device.
+
  #VGA Console
CONFIG_CONSOLE_VGA will redirect console messages to the VGA screen once VGA card is initialized.
+
  option CONFIG_CONSOLE_VGA=1
 +
  option CONFIG_PCI_ROM_RUN=1
 +
 
 +
'''CONFIG_PCI_ROM_RUN''' will use the embedded x86 emulator to run the BIOS image in the expansion ROM of a PCI device.
 +
'''CONFIG_CONSOLE_VGA''' will redirect console messages to the VGA screen once VGA card is initialized.
  
 
For addon VGA cards, you don't have to do anything else besides these two CONFIG options.
 
For addon VGA cards, you don't have to do anything else besides these two CONFIG options.
 
If your mainboard has an onboard VGA chip and you insert another VGA addon card, the addon
 
If your mainboard has an onboard VGA chip and you insert another VGA addon card, the addon
 
VGA card will be used instead of the onboard VGA chip.
 
VGA card will be used instead of the onboard VGA chip.
 +
 +
== Onboard Video ==
  
 
If you want to use the onboard VGA chip, you have to add the following options in addition to the CONFIG options described above.
 
If you want to use the onboard VGA chip, you have to add the following options in addition to the CONFIG options described above.
Line 19: Line 26:
 
1. In the mainboard Config.lb (./src/mainboard/<mfg>/<board>/Config.lb) You need to specify the device number for your onboard VGA and the address that the video bios will show up at in the system.
 
1. In the mainboard Config.lb (./src/mainboard/<mfg>/<board>/Config.lb) You need to specify the device number for your onboard VGA and the address that the video bios will show up at in the system.
  
 +
<source lang = bash>
 
  device pci 9.0 on  # PCI
 
  device pci 9.0 on  # PCI
 
         chip drivers/pci/onboard
 
         chip drivers/pci/onboard
Line 26: Line 34:
 
         end
 
         end
 
  end
 
  end
 +
</source>
  
 
Replace the 9.0 with the dev.fn of your vga device.  You can find this number by doing a 'lspci' from the board booted under linux.
 
Replace the 9.0 with the dev.fn of your vga device.  You can find this number by doing a 'lspci' from the board booted under linux.
Line 34: Line 43:
 
in the normal section
 
in the normal section
  
      romimage "normal"
+
<source lang="bash">
      #      48K for SCSI FW or ATI ROM
+
romimage "normal"
      option ROM_SIZE = 475136
+
#      48K for SCSI FW or ATI ROM
 +
option ROM_SIZE = 475136
 +
</source>
  
 
or if you only have a "fallback" boot then use the "fallback" section instead.
 
or if you only have a "fallback" boot then use the "fallback" section instead.
Line 44: Line 55:
 
3. Finally, prepend your video bios to the coreboot.rom
 
3. Finally, prepend your video bios to the coreboot.rom
  
      cat <videobios.bin> coreboot.rom > final_coreboot.rom
+
<source lang="bash>
 +
cat <videobios.bin> coreboot.rom > final_coreboot.rom
 +
</source>
  
 
where <videobios.bin> is the name of your video bios image.
 
where <videobios.bin> is the name of your video bios image.

Revision as of 16:17, 18 June 2008

There are two kinds of VGA devices

  1. on-board VGA
  2. add-on cards

VGA initialization in coreboot v2

General

You need to enable two CONFIG options in your Mainboard Option.lb

 #VGA Console
 option CONFIG_CONSOLE_VGA=1
 option CONFIG_PCI_ROM_RUN=1

CONFIG_PCI_ROM_RUN will use the embedded x86 emulator to run the BIOS image in the expansion ROM of a PCI device. CONFIG_CONSOLE_VGA will redirect console messages to the VGA screen once VGA card is initialized.

For addon VGA cards, you don't have to do anything else besides these two CONFIG options. If your mainboard has an onboard VGA chip and you insert another VGA addon card, the addon VGA card will be used instead of the onboard VGA chip.

Onboard Video

If you want to use the onboard VGA chip, you have to add the following options in addition to the CONFIG options described above.

1. In the mainboard Config.lb (./src/mainboard/<mfg>/<board>/Config.lb) You need to specify the device number for your onboard VGA and the address that the video bios will show up at in the system.

 device pci 9.0 on  # PCI
         chip drivers/pci/onboard
                 device pci 9.0 on end
                 register "rom_address" = "0xfff80000" #512k image
                 #register "rom_address" = "0xfff00000" #1M image
         end
 end

Replace the 9.0 with the dev.fn of your vga device. You can find this number by doing a 'lspci' from the board booted under linux. Please make sure the device number is correct. Otherwise the config code can not compute the proper ROM address.

2. You still need to modify your target 'Config.lb' to reserve space for the additional video bios. Reduce the size of your coreboot image by the size of the video bios. You will prepend the video bios to the coreboot image in step 3.

in the normal section

romimage "normal"
#       48K for SCSI FW or ATI ROM
option ROM_SIZE = 475136

or if you only have a "fallback" boot then use the "fallback" section instead.

In the above example the bios chip is 512Kb part. The video bios is 48Kb. So (512*1024)-(48*1024) = 475136.

3. Finally, prepend your video bios to the coreboot.rom

Invalid language.

You need to specify a language like this: <source lang="html4strict">...</source>

Supported languages for syntax highlighting:

4cs, 6502acme, 6502kickass, 6502tasm, 68000devpac, abap, actionscript, actionscript3, ada, algol68, apache, applescript, apt_sources, arm, asm, asp, asymptote, autoconf, autohotkey, autoit, avisynth, awk, bascomavr, bash, basic4gl, bf, bibtex, blitzbasic, bnf, boo, c, c_loadrunner, c_mac, caddcl, cadlisp, cfdg, cfm, chaiscript, cil, clojure, cmake, cobol, coffeescript, cpp, cpp-qt, csharp, css, cuesheet, d, dcl, dcpu16, dcs, delphi, diff, div, dos, dot, e, ecmascript, eiffel, email, epc, erlang, euphoria, f1, falcon, fo, fortran, freebasic, freeswitch, fsharp, gambas, gdb, genero, genie, gettext, glsl, gml, gnuplot, go, groovy, gwbasic, haskell, haxe, hicest, hq9plus, html4strict, html5, icon, idl, ini, inno, intercal, io, j, java, java5, javascript, jquery, kixtart, klonec, klonecpp, latex, lb, ldif, lisp, llvm, locobasic, logtalk, lolcode, lotusformulas, lotusscript, lscript, lsl2, lua, m68k, magiksf, make, mapbasic, matlab, mirc, mmix, modula2, modula3, mpasm, mxml, mysql, nagios, netrexx, newlisp, nsis, oberon2, objc, objeck, ocaml, ocaml-brief, octave, oobas, oorexx, oracle11, oracle8, oxygene, oz, parasail, parigp, pascal, pcre, per, perl, perl6, pf, php, php-brief, pic16, pike, pixelbender, pli, plsql, postgresql, povray, powerbuilder, powershell, proftpd, progress, prolog, properties, providex, purebasic, pycon, pys60, python, q, qbasic, rails, rebol, reg, rexx, robots, rpmspec, rsplus, ruby, sas, scala, scheme, scilab, sdlbasic, smalltalk, smarty, spark, sparql, sql, stonescript, systemverilog, tcl, teraterm, text, thinbasic, tsql, typoscript, unicon, upc, urbi, uscript, vala, vb, vbnet, vedit, verilog, vhdl, vim, visualfoxpro, visualprolog, whitespace, whois, winbatch, xbasic, xml, xorg_conf, xpp, yaml, z80, zxbasic


cat <videobios.bin> coreboot.rom > final_coreboot.rom

where <videobios.bin> is the name of your video bios image. You need to make sure the final_coreboot.rom size is the size of your ROM chip. Normally 256kb, 512kb, or 1024Kb.

dd is helpfull to get your <videobios.bin> when booted under the factory BIOS.

How to compute the "rom_address" value

ROM (called 'flash' a lot) chips are located directly below 4Gbyte (0xffffffff) boundary.

So you need to calculate the address by subtracting the flash chip size (and adding the offset within the image)

In coreboot the offset within the image is 0, because its the first thing in the coreboot image.

So you need to compute the address in the systems memory space where the start of the video bios will show up.

To do this you take the 4Gb of address and subtract the size of your coreboot image.

0x100000000 - (ROM size in Kb * 1024)

You can do this in bash by:

biossize=256
printf "0x%x\n" $(( 0x100000000 - ($biossize*1024) ))

Addresses for popular chip sizes:

256K  0xfffc0000
512k  0xfff80000
1024k 0xfff00000
How to retrieve a good video bios

There are sites that have video bios roms on their website. (I know of this one for nvidia cards: [1])

However you should be able to retrieve your own video bios as well with linux.

  • Boot up a machine with a commercial bios (not coreboot) with the video card you wish to work under coreboot.
  • From the command line enter:
    dd if=/dev/mem of=vgabios.bin skip=1536 count=128 or
    dd if=/dev/mem of=vgabios.bin bs=1k count=64 skip=768
    This assumes you card's bios is cached at 0xc0000, and is 64K long. You
    can see where and how much your card's bios is using by
    doing a cat iomem | grep "Video ROM"
    • dd Explained (man dd to learn more):
      • if is the location to retrieve from.
      • of is the output file (your rom image)
      • skip jumps n blocks where the default n is 512 bytes
      • count is how many blocks you wish to read
      • bs is the block size
  • You now have a video bios image
Perl script to dump out your video bios

This is a simple script that computes the size and offset then uses the command dd to dump your video bios to a file.

 #!/usr/bin/perl
 
($range, $info) = split /:/, `grep "Video ROM" /proc/iomem`;
($start, $end) = split /-/, $range;
 
if( $start eq "" ) {
        print "Couldn't find Video ROM in /proc/iomem\n";
        exit;
}
 
$offset = hex "0x$start";
$tmp = hex "0x$end";
$size = 1 + $tmp - $offset;
 
$command = "dd if=/dev/mem of=saved_vgabios.bin bs=1c count=$size skip=$offset";
print "range = $range, start = $start, size = $size\n";
print "$command\n";
system $command;