Commit Graph

332 Commits

Author SHA1 Message Date
Kevin O'Connor a932b908db vgabios: Fix broken build resulting from e5749978.
The e5749978 commit added -fno-merge-constants to the compile flag.
That option changes the names of ".rodata" sections.  Update
vgalayout.lds.S so that the vgabios can continue to build.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-07-01 09:50:04 -04:00
David Woodhouse 67fd42cf16 vgabios: Use .code16 not .code16gcc
There's no need to use .code16gcc where we are writing assembler code
explicitly. It only affects word-size-ambiguous instructions, and we
should just be explicit. And we are.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2014-06-05 10:58:29 -04:00
Kevin O'Connor c58799cbee vgabios: Return from handle_1011() if handler found.
Fix cut-and-paste error in handle_1011() causing spurious debug_stub()
calls when CONFIG_VGA_STDVGA_PORTS is enabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-05-28 09:09:05 -04:00
Kevin O'Connor 3c37cdb197 vgabios: Add debug message if x86emu leal check triggers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-05-13 10:51:29 -04:00
Kevin O'Connor fe2cbf6d60 vgabios: Define PlatformRunningOn to make compile happy.
With CONFIG_COREBOOT=y, CONFIG_QEMU_HARDWARE=y, CONFIG_VGA_COREBOOT=y,
CONFIG_DEBUG_IO=y the compile would break because this variable was
missing.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-14 10:46:34 -04:00
Kevin O'Connor 028f3487cf Minor - replace some tab characters that slipped into the code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-11 12:08:33 -04:00
Kevin O'Connor 7c79029e43 vgabios: Initial support for coreboot native vga vgabios.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-11 11:26:23 -04:00
Kevin O'Connor 8f82a4fb4a vgabios: PMM scan was incorrectly depending on a zero %ds segment.
Make sure the PMM scanning code uses the GET_FARVAR macro.  (The
existing code only worked because SeaBIOS happens to call the vgabios
in bigreal mode with %ds == %ss = 0.)  Also, the scan doesn't require
bigreal mode - use accesses relative to the SEG_BIOS segment so that
the scan can work in regular real mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-11 11:26:23 -04:00
Kevin O'Connor 098c2fc934 vgabios: Add support for manipulating framebuffers in high memory.
Add code for manipulating "direct" style linear RGB framebuffers that
may be in high memory.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-11 11:26:23 -04:00
Kevin O'Connor a02d41806e vgabios: Introduce text_address().
Factor out code that calculates the text mode address of a given
character.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-11 11:26:23 -04:00
Kevin O'Connor f864b6023e vgabios: Rewrite vgafb.c graphics operations to set of 4 standard operators.
The vgabios graphics manipulations can all be implemented on top of 4
basic primitives: read 8 pixels, write 8 pixels, move pixels, and
clear pixels.  Implement these four operators for all the graphics
modes and rewrite the graphics functions in vgafb.c to use them.  This
simplifies the graphics code as the high level logic no longer needs
to be implemented for each graphical framebuffer type.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-11 11:26:23 -04:00
Kevin O'Connor 7fd2af6422 vgabios: Split vgafb_scroll() into separate move and clear functions.
Rewrite the low-level scroll code so that it is implemented using two
basic operations: move text and clear text.  This simplifies the
low-level code as it no longer needs to handle up scrolling vs down
scrolling.  Determining the direction of the scroll is now done in the
higher level (vgabios.c) code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-11 11:26:22 -04:00
Kevin O'Connor efbf4d6903 vgabios: Add option to control use of standard VGA IO ports.
Add option CONFIG_VGA_STDVGA_PORTS.  When this option is disabled, the
main BIOS code will not attempt to access any of the legacy VGA IO
ports.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-04-11 11:26:22 -04:00
Gerd Hoffmann 5d598779b0 vga: rework bar detection, add virtio-vga
Replace the heuristic which checks the bar 0 attributes to
figure whenever bar 0 or bar 1 has the linear framebuffer
with a vendor id check.

Add support for virtio-vga which uses bar 2 for the linear
framebuffer.

Cc: Dave Airlie <airlied@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2014-03-06 10:53:14 +01:00
Kevin O'Connor e8436b5bad vgabios: Fix PMM allocation request size.
The size of a PMM memory request is in "paragraphs" so the size needs
to be divided by 16.  Fix the request so only the desired 512 bytes is
allocated instead of 8K.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-03-05 10:20:25 -05:00
Kevin O'Connor 2620984b42 vgabios: Make sure stdvga_list_modes() doesn't overrun the buffer.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-02-11 17:46:54 -05:00
Kevin O'Connor 0910ddeb04 vgabios: Refactor write_teletype and write_chars.
Factor out the common code of writing to the screen and advancing the
cursor position to a new function write_char().  Eliminate
write_chars() and then simplify write_teletype().  Also, eliminate the
separate scroll_one() function as it no longer reduces stack space.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-02-08 16:43:30 -05:00
Kevin O'Connor e35753ecc9 vgabios: Don't interpret TAB character.
Several sources document that the Bell, Backspace, newline, and
carriage return characters are interpreted by int 10/0e.  There does
not seem to be any references to that function interpreting tab.  The
original "lgpl vgabios" has code for interpreting tab, but the code is
incorrect.  Finally, tests on an ATI vgabios indicate that tab is not
interpreted.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-02-08 12:29:20 -05:00
Kevin O'Connor 8032b8a0fe vgabios: Attempt to detect old x86emu and force a fault.
Check for cases where the leal instruction does not work.  This
instruction is known to not be emulated properly on old versions of
x86emu.  If a broken version of x86emu is found, force a fault that
x86emu will easily detect.  This should help prevent soft failures
when running old software.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-02-05 23:15:27 -05:00
Kevin O'Connor 20dc419306 vgabios: Simplify save/restore mechanism.
Reorganize the save/restore functions to eliminate some boilerplate
code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-02-05 20:52:25 -05:00
Kevin O'Connor da6a15762b vgabios: Simplify the bios save state area.
The structure of the "bios save state area" as returned by
handle_101c() and vbe_104f04() does not follow any particular order.
(And there does not appear to be any documentation that would require
it to follow a particular order.)

So, rearrange the layout of the struct to make save and restore
simpler.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-02-05 19:29:08 -05:00
Kevin O'Connor f5ec1e0a5e vgabios: Make sure exported structs use PACKED.
Commit ca668640 introduced structs for data returned from the
handle_101b and handle_101c calls.  However, the structs were not
declared as packed and that caused incorrect behavior for
handle_101b.  This was seen to break some old DOS programs (Win3 setup
and DISPLAY.SYS).  This patch adds in the necessary PACKED declaration
to the structs.

The 'struct saveBDAstate' remains un-packed, as it does not appear
that its contents are documented.  (And, its format already differs
from what was in the previous "lgpl vgabios".)

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-02-05 18:59:56 -05:00
Kevin O'Connor 940fc1fc58 debug: Only call serial_debug_preinit() at startup.
The serial_debug_preinit() function disables serial interrupts so that
the OS doesn't get confused by "transmit buffer empty" interrupts
caused when seabios writes to the serial port.  It's unnecessary
paranoia to keep rechecking that interrupts are disabled.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-01-22 17:30:30 -05:00
Kevin O'Connor feb0284e37 Small improvements to irqentry_extrastack assembler.
Simplify the entry assembler slightly.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-09 20:39:16 -05:00
Kevin O'Connor 41c6061d36 vgabios: Avoid memory references via %esp register in vgabios.
Win7 interprets the vgabios and it does not properly handle memory
references relative to the %esp register.  Commit 4a8b58cb introduced
some of these %esp references - rework that assembler to avoid these
instructions and make win7 happy.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-09 17:27:54 -05:00
Kevin O'Connor dab0a7407c vgabios: Move initialization code to new file vgainit.c.
Move the initialization code out of vgabios.c to a new file to reduce
the size of the vgabios.c file.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-04 10:34:18 -05:00
Kevin O'Connor 4a8b58cb6c vgabios: Support allocating an extra stack for vgabios calls and default on.
Add code to allocate an extra stack for the main vgabios int 0x10
entry point.  The allocation is done via the PMM spec and uses a PCI
v3 permanent low memory region request.  This request will work with
SeaBIOS - it is unknown how many other main BIOS implementations
support this PMM call.

The extra stack is useful for old DOS programs that call the VGABIOS
and expect it to work with very small amounts of stack space.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-04 10:34:18 -05:00
Kevin O'Connor 9332f9b172 vgabios: Work around lack of support for "calll" in x86emu emulation.
Replace 32 bit call instructions with 16 bit call instructions in the
vgabios to workaround problems in old versions of x86emu.  This change
allows fc13 and fc14 to boot.  (Other x86emu emulation bugs still
prevent fc11 and fc12 from booting.)

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-04 10:34:17 -05:00
Kevin O'Connor 06c6d47659 vgabios: Avoid possible divide by zero in bochsvga_set_displaystart.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-04 10:34:17 -05:00
Kevin O'Connor a9dcc88262 vgabios: Add bochsvga "HDTV" resolutions.
The same set of video modes were added to the "lgpl vgabios" in
release 0.7a.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-04 10:34:17 -05:00
Kevin O'Connor 1f31f00e96 vgabios: Support custom fonts in vga framebuffer text writing.
Obtain the font data from int 0x43 and int 0x1f, and obtain the font
height from the BDA.  This enables application overrides for the font
data.

This patch also unifies the variable naming between the
planar/CGA/linear character writing functions and uses the same names
that the screen scrolling functions use.

This patch also optimizes the inner loop of the CGA font writing to
reduce overall stack usage.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-04 10:34:17 -05:00
Kevin O'Connor 5b6936e0e8 vgabios: Load the DAC palette in "packed" modes on Cirrus and BochsVGA.
This is a port of a patch applied to the "lgpl vgabios" tree (that was
released in its v0.7a release).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-04 10:34:17 -05:00
Kevin O'Connor 4cd522e673 Move low-level hardware writing from output.c to new file hw/serialio.c.
Avoid hardware specific code in output.c.  This will reduce the amount
of change needed to output.c as support for more serial hardware is
added.

This patch also renames some functions to improve the naming scheme.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-12-04 10:34:17 -05:00
Kevin O'Connor 4ade523a9d Remove ioport.h; disperse its contents to other header files.
Move the inb(), insb(), etc. code from ioport.h to x86.h.  Move the
PORT_* definitions to their appropriate hardware files.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-28 22:10:31 -04:00
Kevin O'Connor 2e57c81f1d Move vbe.h to std/vbe.h.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor 8fb3a5edf3 Move optionroms.h to std/optionrom.h and util.h.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor 2d2fa31b37 Move function definitions for output.c from util.h to new file output.h.
Also, sort the order of include files in the c files.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor fa9c66a656 Rename util.c to string.c and introduce string.h.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:34 -04:00
Kevin O'Connor 0db698888c vgabios: Limit the range of the VBE number of "pages" parameter.
Looking at the output of other VGA BIOS implementations, it appears
that the number of available video pages reported is always between 1
and 127.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:33 -04:00
Kevin O'Connor 68f56aa6e9 vgabios: Rename stdvga_bpp_factor to stdvga_vram_ratio.
Invert the values returned by stdvga_bpp_factor and rename it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-18 20:48:33 -04:00
Gerd Hoffmann 53663503ab bochsvga: fallback to stdvga if dispi interface isn't present
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2013-09-16 10:54:54 +02:00
Kevin O'Connor 5d369d8d9e Move code centered around specific hardware devices to src/hw/
Move many C files from the src/ directory to the new src/hw/ directory.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-09-02 20:48:46 -04:00
Kevin O'Connor b7b92935df vgabios: Fix cirrus memory clear on mode switch.
The cirrus_clear_vram() code wasn't actually doing anything because of
a u8 overflow.  Fix that.

Fill with 0xff when performing a legacy cirrus mode switch (WinXP has
been observed to incorrectly render dialog boxes if the memory is
filled to 0).  This was the behavior of the original LGPL vgabios
code.  To support this, add mechanism (MF_LEGACY) to allow vga drivers
to detect if the mode switch is from vesa or int10.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-03-09 13:10:45 -05:00
Kevin O'Connor 9cba2b3d22 vgabios: Fix stdvga_perform_gray_scale_summing().
Fix conversion error that resulted in
stdvga_perform_gray_scale_summing not actually writing the new results
back.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-03-09 13:00:40 -05:00
Kevin O'Connor 89a2f96de4 Convert VAR16VISIBLE, VAR16EXPORT, and VAR32VISIBLE to VARFSEG.
Convert all users of the alternative variable exports to VARFSEG.
There isn't a significant distinction between the existing types of
exports, so it's simpler to just use one type going forward.

The new VARFSEG declaration is only emitting when in 32bit mode, so
update and move some variables as needed.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-18 23:36:03 -05:00
Laszlo Ersek 2eeafbf587 Enable VGA output when setting Cirrus-specific mode
This patch does the same for Cirrus as David's following patch for bochs,
originally posted under
<http://www.seabios.org/pipermail/seabios/2013-February/005434.html>:

  Enable VGA output when settings bochs-specific mode

  When used from OVMF+CSM, we got no video output. It appears that we were
  never enabling the display output except when configuring a text mode.
  Which never happens, in the OVMF+CSM case.

In my testing on RHEL-6.3 with OVMF -D CSM_ENABLE / CONFIG_CSM bios.bin /
CONFIG_QEMU vgabios.bin, using Cirrus, VESA mode 0x115 is selected (Direct
Color, 800x600x24).

According to <http://www.osdever.net/FreeVGA/vga/attrreg.htm>,

  cirrus_switch_mode()
    stdvga_attr_mask()

currently keeps/sets the "Attribute Controller Graphics Enable" bit set in
the "Attribute Mode Control Register". When invoked from OVMF+CSM, that is
not enough however, so let's do the same as for Bochs:

  stdvga_attrindex_write(0x20);

which corresponds to setting the "Palette Address Source" bit in the
"Attribute Address Register":

  "This bit is set to 0 to load color values to the registers in the
  internal palette. It is set to 1 for normal operation of the attribute
  controller. [...]"

clext_set_mode()
  stdvga_set_mode() -- for regular modes
    stdvga_attrindex_write() -- existing call
  cirrus_switch_mode() -- for Cirrus modes
    stdvga_attrindex_write() -- call added by this patch

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2013-02-16 20:01:45 -05:00
David Woodhouse 0069a314b3 Enable VGA output when settings bochs-specific mode
When used from OVMF+CSM, we got no video output. It appears that we were
never enabling the display output except when configuring a text mode.
Which never happens, in the OVMF+CSM case.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
2013-02-16 20:01:39 -05:00
Christian Gmeiner 1337eb38bf geodevga: fix wrong define name
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2013-02-15 22:52:18 -05:00
Christian Gmeiner 0f5628d164 geodevga: add debug to msr functions
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2013-02-15 22:52:18 -05:00
Christian Gmeiner 42f33ffd9a geodevga: move output setup to own function
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2013-02-15 22:52:18 -05:00
Christian Gmeiner 320570821a geodevga: move framebuffer setup
Framebuffer setup has nothing to do with dc_setup(..) so
move it to  geodevga_init(..).

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2013-02-15 22:52:18 -05:00
Christian Gmeiner bb7e54a1b2 geodevga: fix errors in geode_fp_* functions
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2013-02-15 22:52:18 -05:00
Kevin O'Connor 58b157f8fa vgabios: Bochs/QEMU vgabios support should depend on CONFIG_QEMU.
The Cirrus, Standard VGA, and Bochs VGA should depend on CONFIG_QEMU
and not CONFIG_COREBOOT.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-13 19:36:02 -05:00
Kevin O'Connor d83c87bb20 Normalize POST initialization function name suffixes.
The POST phase has to invoke many initialization functions, and these
functions can have complex inter-dependencies.  Try to categorize the
functions into 4 classes:

preinit - functions called very early in POST where function ordering
    is very important and the code has limited access to other
    interfaces.

init - functions that initialize internal interfaces and standard
    external interfaces.  This code is generally not dependent on
    particular hardware and typically does not communicate directly
    with any hardware devices.

setup - functions which access hardware or are dependent on particular
    hardware or platform devices.

prepboot - functions that finalize internal interfaces and that
    prepare for the boot phase.

This patch attempts to normalize the suffixes - functions that used
_init(), _setup(), _finalize(), or similar that did not follow the
above pattern were renamed.  Other than function name changes, there
should be no code impact to this patch.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2013-02-05 20:00:29 -05:00
Paolo Bonzini 4bd8aebf35 vgabios: implement AX=1120H..1124H functions
These function only have to set INT 1Fh and INT 43h, and set
the BDA height + number of rows.

I could not find out whether AX=1120h should also set the character
height to 8.  I think not, because INT 43h might still point to
14- or 16-pixel high characters and in this case INT 1Fh will not
be used at all.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-01-12 17:00:50 -05:00
Christian Gmeiner 02203b5302 geodevga: Setup flat panel if needed
This patch does basic setup of the flat panel and turns the
panel on.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-10-07 22:05:42 -04:00
Christian Gmeiner fad37fd6d1 geodevga: Add defines for VP_MSR_PADSEL
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-10-07 22:05:33 -04:00
Christian Gmeiner eac884ddf3 geodevga: Setup output based on .config
The geode hardware can be configured to use different
outputs. This patch adds support this feature based on
the current .config

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-10-07 22:05:19 -04:00
Christian Gmeiner 5556f21048 geodevga: Add configuration option for output modes
Geode GX2 and LX are supporting Flat Panels. Add new
configuration options to support different output modes.
You can choose between:
* CRT
* Flat Panel
* CRT and Flat Panel

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-10-07 22:04:52 -04:00
Christian Gmeiner f6930c52f9 geodevga: Add VP_MSR_CONFIG defines
This patch adds all needed defines to setup the wanted
output mode.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-10-07 22:04:39 -04:00
Christian Gmeiner 5506376f8b geodevga: Add some basic flat panel defines
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-10-07 22:04:27 -04:00
Christian Gmeiner 119ece9b82 geodevga: Add functions to work with fp register
The Flat Panel Display Controller belongs to the Video
Processor unit but its register are starting at offset
0x400. Provide functions to work with fp register.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-10-07 22:04:12 -04:00
Christian Gmeiner 286e01365d geodevga: Rename defines to better match a well defined naming schema
The following nameing schema is used:
    PART_REGISTER_BIT_DESCRIPTION

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-10-07 22:03:46 -04:00
Kevin O'Connor ef7f73fa23 geodevga: Access global variables using GET_GLOBAL/SET_VGA macros.
The vgabios runs in 16bit mode so all global variables must be
accessed via macros.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-09-16 13:24:30 -04:00
Christian Gmeiner a1a3283825 Report stdvga modes in VBE via int10 (AX = 4F00h)
As all supported graphic adapters are supporting VGA we should
list them in int10 (AX = 4F00h). Also clext.c and bochsvga.c
are haveing a function named like is_XXX_mode() which checks
if its a default VGA mode or a VESA mode. If its a normal VGA
mode stdvga_set_mode() gets called.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-09-10 20:30:57 -04:00
Kevin O'Connor 58dd051810 vgabios: Add support for text and cga modes to vbe_104f01().
Attempt to handle cga and text modes in the vbe get_mode_info call.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-09-08 13:56:48 -04:00
Kevin O'Connor 49ddd9ebbe vgabios: Check for relocatable windows before advertising support for it.
Use the VBE_win_granularity field to determine if the memory windows
are relocatable.  (Bochs and Cirrus vga support relocatable windows
while the standard vga controller does not.)

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-09-04 13:16:36 -04:00
Kevin O'Connor ef4f9e1837 vgabios: Ignore mode flags in vbe get_mode_info call.
Ignore any mode flags a caller may have set on the vbe get_mode_info
call.  The spec doesn't require ignoring of flags, but it appears at
least some real-world vgabios vbe implementations do this.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-09-03 13:54:28 -04:00
Kevin O'Connor f47461f455 Geode vga: Use standard format read/write_mask register functions.
Rework the Geode code to use the same style register accessors as the
standard vga code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-09-03 12:32:01 -04:00
Christian Gmeiner d136fd7944 Add helper functions to access DC and VP register
This change introduces some helper functions, which are making
the code more readable and easier to debug.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-09-03 12:09:13 -04:00
Christian Gmeiner 11ebc7d3de Change return values for vp_setup() and dc_setup()
There is no reason to have a return code for vp_setup()
and dc_setup(). So get rid of them.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-09-03 12:09:13 -04:00
Christian Gmeiner 7bec6dba51 Add global struct geode
This struct is used to store some PCI BAR values, which are used
during hw init.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-09-03 12:04:56 -04:00
Christian Gmeiner 517f7426a9 Update VBE variables
Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-09-03 12:04:56 -04:00
Christian Gmeiner 9de339d1f5 Add framebuffer size detection
It is possible to read out the framebuffer size via msr. The size
information is needed for VESA later.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-09-03 12:04:56 -04:00
Christian Gmeiner 0155aef19a Remove Extened CRTC Register functions
As the access the DC registers via memory, we dont need to
work with the extended CRTC register to setup the DC-VGA-mapping.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-09-03 12:04:55 -04:00
Christian Gmeiner efb9784015 Remove all dc_ functions as they are not needed anymore
As we access teh DC registers via memory we do not need all
the DC-VGA-mapping functions anymore.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-09-03 12:04:55 -04:00
Christian Gmeiner c13c181a9d Access DC registers via geode_mem[Read|Write]
There is no reason to access the DC registers via VGA
memory mapping if we could the access via memory.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
2012-09-03 12:04:55 -04:00
Kevin O'Connor b306459d2d Use cpu_to_be32() (and related) instead of htonl (and related).
Unify the syntax for byte swab calls.

This also fixes a bug in coreboot due to the lack of a be64_to_cpu()
call.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-09-02 16:00:03 -04:00
Kevin O'Connor e51316d0cc Minor - remove CLEARBITS_BDA and SETBITS_BDA macros.
Remove these infrequently used macros and replace with explicit
GET_BDA/SET_BDA calls.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-06-10 09:09:22 -04:00
Kevin O'Connor 4562bf654c vgabios: Improve Kconfig descriptions for the vga card types.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-04-16 21:21:28 -04:00
Kevin O'Connor a0263083cb Misc compile fixes for gcc v3.4.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-04-14 20:22:18 -04:00
Julian Pidancet a23a951416 vgabios: Fetch _rom_header_size from the global segment when computing the ROM's checksum
Otherwise, checksum_far is getting called with zero as the length
parameter, and the ROM checksum in the header end up beeing zero
after vga_post() is called.

Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
2012-03-06 07:18:38 -05:00
Kevin O'Connor 7b975e51fc vgabios: int1009 handler bug limits count to 256 characters.
Fix bug (u8 overflow) causing large screen fills to fail.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-03-06 07:18:38 -05:00
Kevin O'Connor 900ded0968 vgabios: Fixup clext far return instruction.
Fix typo causing incorrect far return instruction - use explicit ATT
syntax - "lretw".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-03-06 07:18:38 -05:00
Kevin O'Connor 6ee837b660 vgabios: Some tweaks to optimize stack space.
Gcc seems to handle passing structs by value if they are 4 bytes in
size instead of 3 bytes.  So, add a pad byte to struct carattr and
struct cursorpos.

Reorganize set_cursor_pos(), verify_scroll(), and handle_1013() so
there are less live variables.

Don't inline the VBE functions into the main handler code.  Code
calling VBE functions are newer and are more likely to provide
adequate stack space - inlining can cause more stack usage for older
functions (which may be stack constrained).

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-13 20:09:02 -05:00
Kevin O'Connor 4c85a263af vgabios: Minor vgabios fixes.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-12 11:50:52 -05:00
Kevin O'Connor 815411307e vgabios: Claim VBE 3 support; minor VBE cleanups.
Claim support for VBE3 - that spec is actually more lenient for
required minimum support.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-12 11:49:25 -05:00
Kevin O'Connor 9d8408834f vgabios: Add version string to debug output.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-11 11:02:03 -05:00
Kevin O'Connor 36feea9317 Direct compile 16bit C code instead of including via .S files.
Create a ".code16gcc" directive in src/code16gcc.s and use
-Wa,src/code16gcc.s to tell gcc to compile directly to 16bit code.
This eliminates the need to compile the C code to assembler and
include in romlayout.S and vgaentry.S.  This also allows those two
assembler files to be compiled with debugging (-g) enabled.

Also, includes some Makefile cleanups.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-11 10:49:45 -05:00
Kevin O'Connor 197ea6c9b6 vgabios: Don't allow building of emulator vgaroms on coreboot.
If coreboot building is selected, don't allow the emulator based vga
roms to be selected.  Also, clarify the help text to make this clear.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-07 21:05:49 -05:00
Gerd Hoffmann 091dd17e8d vga: fix bochs lfb size display
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2012-02-06 19:14:41 -05:00
Kevin O'Connor 2469f89528 vgabios: Implement VBE save/restore state function (func 04).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-04 12:41:13 -05:00
Kevin O'Connor 9f857fc97c vgabios: Move save/restore state code from vgabios.c to stdvga.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-04 12:41:04 -05:00
Kevin O'Connor e737b178e1 vgabios: Add support for VBE get/set dac palette format (func 08).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-04 11:08:39 -05:00
Kevin O'Connor cfd7ef9d8b vgabios: Handle VGA option rom being re-run.
Check for the case where the option rom is executed a second time - in
that case re-init the hardware, but do not set any variables.  This
should make the rom better behaving when run from S3 resume.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-02 22:52:17 -05:00
Kevin O'Connor b88869564b vgabios: Fix screen attrs on cga scroll.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-02 20:56:38 -05:00
Kevin O'Connor 9a4d0c1c86 vgabios: Simplify cga/packed character screen writing.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-02 20:56:10 -05:00
Kevin O'Connor 933bb76da7 vgabios: Move bocshvga mode checking from runtime to init.
Check mode validity at init.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 22:00:05 -05:00
Kevin O'Connor 987029a971 vgabios: Minor - organize cirrus code so like functions are near each other.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 21:59:05 -05:00
Kevin O'Connor a96d4909c1 vgabios: Simplify cirrus find mode code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 21:59:00 -05:00
Kevin O'Connor c8845029a7 vgabios: Rework bochsvga mode switching.
Make the bochsvga mode switch more similar to the original lgpl
vgabios code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 21:58:49 -05:00
Kevin O'Connor 3524453b5d vgabios: Fix linelength calculations in bochsvga and vbe.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 21:58:38 -05:00
Kevin O'Connor 2af8ba1ab2 vgabios: Compare PCI ids against pci rom struct instead of config settings.
QEMU can update the pci rom struct - so use that as the location to
determine if the pci address passed into the option rom is accurate.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 20:43:20 -05:00
Kevin O'Connor 2bd4531436 vgabios: handle vmware vga in bochsvga.
The vmware vga emulated by qemu has a I/O region in pci bar 0.
The framebuffer is in pci bar 1.  Handle that by checking the
type of bar 0 in case it is a I/O bar use bar 1 instead.

Also make bochsbios report lfb size in debug output.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 20:42:06 -05:00
Kevin O'Connor d9211ee9e3 vgabios: Update copyright statements in bochsvga.c and vbe.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 20:40:47 -05:00
Kevin O'Connor 31f67ae978 vgabios: Fix missing "extern" declaration on vbe variables.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 20:39:41 -05:00
Kevin O'Connor f98bbf09fc vgabios: Move stdvga_set_mode() to stdvgamodes.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 20:39:27 -05:00
Kevin O'Connor 1692007a5f vgabios: Minor - pass display address to stdvga_set_cursor_pos().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 20:39:21 -05:00
Kevin O'Connor 59f75d4bdc vgabios: Add VBE power management (10h) stub function.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 20:39:09 -05:00
Kevin O'Connor d61fc53a60 vgabios: Add support for VBE get/set display start function.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 20:39:03 -05:00
Kevin O'Connor 3876b53122 vgabios: Add support for vbe get/set line length function.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 20:38:49 -05:00
Kevin O'Connor 9961f9958c vgabios: Add support for vesa get/set window function.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 20:37:02 -05:00
Kevin O'Connor e6bc4c1c58 vgabios: Move BDA setting from driver code to common code.
Always setup the BDA on a mode switch.  Call that BDA setup code
unconditionally.

Also, always set vbe_mode and use that for finding the current mode
and for reporting the mode to vbe callers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-02-01 20:35:48 -05:00
Kevin O'Connor 4a73f93396 vgabios: Extract out current mode finding into new function.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-21 11:08:35 -05:00
Kevin O'Connor 0377602ae6 vgabios: Set cwidth/cheight/sstart in vgamode_s for cirrus/bochs.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-21 11:00:11 -05:00
Kevin O'Connor 5e1694c71d vgabios: Use stored total memory in cirrus code instead of recalculating.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-21 10:43:30 -05:00
Kevin O'Connor 8cf8f8e6ce vgabios: Check that the PCI BDF passed in is valid before using.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-19 21:34:44 -05:00
Kevin O'Connor 160d34abce vgabios: Simplify planar4 vgafb code.
Don't bother programming the vga registers to manipulate the
framebuffer when in planar4 mode.  Instead, just switch between the
four planes and do the manipulation with regular reads and writes.
This makes the code simpler to understand (the vga hardware
manipulations are arcane and complex).

Note, this could make text scrolling in planar4 mode slower and more
likely to result in tearing.  However, it's unlikely anything
important uses the vgabios in planar4 mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-19 21:33:23 -05:00
Kevin O'Connor 707d2168f5 vgabios: Use regular pci_config_readl func in geode code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-16 12:03:19 -05:00
Kevin O'Connor 69b01cbdb3 vgabios: Don't have geode code peak into stdvga mode struct.
Create a wrapper (stdvga_override_crtc) so the Geode code doesn't need
to access the stdvga mode tables directly.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-16 12:03:14 -05:00
Kevin O'Connor b3df857fe6 vgabios: Make VBE code depend on a config setting.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-16 12:02:44 -05:00
Kevin O'Connor 5f4ce9e9be vgabios: Move vgabios Kconfig definitions to vgasrc/Kconfig.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-16 12:02:39 -05:00
Kevin O'Connor 4ad2d107be vgabios: Rename vgatables.c to stdvgamodes.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-16 12:01:16 -05:00
Kevin O'Connor aad3b695b7 vgabios: Move video_param_table definition to vgabios.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-16 12:01:12 -05:00
Kevin O'Connor efb4523d4b vgabios: Move static_functionality[] from vgatables.c to vgabios.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-16 12:00:58 -05:00
Kevin O'Connor 2c23a7ab6a vgabios: Use standard VGA IO wrappers in geodevga.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-16 11:59:32 -05:00
Kevin O'Connor add3becb5d vgabios: Use standard VGA IO wrappers in clext.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-16 11:58:08 -05:00
Kevin O'Connor 184705fc8c vgabios: Use standard VGA IO wrapper functions in bochsvga.
Also, this alters some of the IO port settings in bochsvga_set_mode to
fix what looks like errors during the asm to C conversion.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-16 11:52:46 -05:00
Kevin O'Connor 86d2e004e2 vgabios: Use standard VGA IO wrapper functions in stdvga.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-16 11:51:37 -05:00
Kevin O'Connor 3471fdbe63 vgabios: Add wrapper functions for accessing standard VGA registers.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-16 11:50:42 -05:00
Kevin O'Connor 97cc354a02 vgabios: Add cirrus linear framebuffer detection; enable VBE in cirrus.
Extract Cirrus framebuffer address from PCI config space.

Enable VBE code for Cirrus cards.

Also, rework bochsvga code to use direct PCI accesses instead of
calling into the BIOS.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:20:07 -05:00
Kevin O'Connor e91ec7c773 vgabios: Hook up Cirrus extended bios functions.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:20:04 -05:00
Kevin O'Connor e19a68f5ac vgabios: Make cirrus line lengths standard.
Only two modes don't match their expected line length.  One looks like
a bug (it has a virtual line length of 1280 for a screen of 1600
bytes) and one looks like an optimization (2048 vs 1920).  Change the
mode line lengths to exactly match the expected line lengths so that
the VBE code is correct.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:19:58 -05:00
Kevin O'Connor 643290fb1f vgabios: Unify cirrus and vbe vesa functions.
Unify the code for the Cirrus and VBE vesa functions 00-03.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:19:50 -05:00
Kevin O'Connor 3339c05f19 vgabios: Make VBE code independent of bochsvga.
Introduce new global variables (VBE_enabled, VBE_total_memory,
VBE_capabilities, VBE_framebuffer) to replace the need for function
calls that were specific to bochsvga.

Replace info received from bochsvga_mode_info with info found in
vgahw_find_mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:19:45 -05:00
Kevin O'Connor 34203cdf8a vgabios: Unify code to generate the vbe mode list.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:19:39 -05:00
Kevin O'Connor c4a0b976c0 vgabios: Use vgamode_s in cirrus and bochsvga mode tables.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:19:30 -05:00
Kevin O'Connor 10dff3db24 vgabios: Extract out common parts of struct vgamode_s.
Extract out the fields in 'struct vgamode_s' that are used in the main
code.  The remaining fields are specific to the standard vga hardware
driver.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:19:25 -05:00
Kevin O'Connor 83047be58e vgabios: Unify page size calculations; remove page size from vgamode_s.
The previous code could obtain the page size in different ways - from
vmode_g->sslength, from SCREEN_MEM_START, or by manually multiplying
cols and rows.  Add a new func (calc_page_size) and use that in areas
that need to calculate the page size.

Convert readers of the page size to read it from the "video_pagesize"
entry in the BDA instead of recalculating it.

Remove the page size from struct vgamode_s (slength) as it is now
calculated dynamically.  The new calculated versions are different
from the existing values exported in video_param_table.  However, the
existing values (for CGA) did not look correct - I compared the values
to those exported by two other VGA BIOS manufacturers and used the
values that look more standard.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:19:20 -05:00
Kevin O'Connor bb17d84468 vgabios: Add memmodel field to bochsvga mode list.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:19:12 -05:00
Kevin O'Connor 80da87da8d vgabios: Make struct vgamode_s more similar to bochs/cirrus mode tables.
For graphics modes, store pixel width/height instead of text
width/height.  Add explicit char width field.  Where needed, calculate
text width/height from pixel width/height by dividing pixel count by
character size.

Rename some fields and change field sizes to match cirrus/bochs
definitions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:19:04 -05:00
Kevin O'Connor 2c8ba89aab vgabios: Remove dummy 0xfe mode from list of cirrus modes.
The 0xfe mode isn't a real mode, it's a place holder for settings
needed to switch back to non-cirrus modes.  Handle it that way.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:18:54 -05:00
Kevin O'Connor 4519197f2e vgabios: Add char width to stdvga mode table.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 17:18:43 -05:00
Kevin O'Connor b451f18969 vgabios: Use standard naming for cirrus memmodel.
The cirrus mode array stores memmodel as vesacolortype - rename it to
'memmodel' and use common field names.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 12:59:46 -05:00
Kevin O'Connor d4398adab6 vgabios: Use vesa style memory model flags in stdvga code.
Replace the custom flags with the flags defined in the VBE spec.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 12:59:46 -05:00
Kevin O'Connor ddb8047f61 vgabios: Actually remove vgasrc/geodelx.[ch] - fixup of patch apply.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-14 12:57:03 -05:00
Nils 24ddd8678c vgabios: Add the geode GX2 functionality.
Signed-off-by: Nils Jacobs <njacobs8 at adsltotaal.nl>
2012-01-14 12:15:14 -05:00
Nils e8b184fe57 vgabios: Some little geode cleanup.
Signed-off-by: Nils Jacobs <njacobs8 at adsltotaal.nl>
2012-01-14 12:13:34 -05:00
Nils 31eabf9ba8 vgabios: Make the naming in the LX code generic to Geode.
Signed-off-by: Nils Jacobs <njacobs8 at adsltotaal.nl>
2012-01-14 12:11:41 -05:00
Kevin O'Connor b937397765 vgabios: Add scrolling for linear (packed pixel) graphics mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2012-01-01 11:04:42 -05:00