Commit Graph

332 Commits

Author SHA1 Message Date
Gerd Hoffmann 4d70b24b86 cbvga: factor out cbvga_setup_modes()
Factor out generic data structure setup code from cbvga_setup().

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2018-06-22 07:44:07 +02:00
Kevin O'Connor ef5fdc99b7 vga: Fix bug in stdvga_get_linesize()
Add required GET_GLOBAL() macro to vmode_g access.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2017-08-29 14:38:19 -04:00
Patrick Rudolph e30d51cc58 SeaVGABios/cbvga: Advertise compatible VESA modes
Advertise compatible VESA modes, that are smaller or equal to
coreboot's active framebuffer. Only modes that have the same Bpp
are advertise and can be selected.

Allows the Windows 7 bootloader NTLDR to show up in VESA mode.
Allows to show the Windows 7 boot logo.
Allows Windows to boot in safe mode and in normal boot using
VgaSave driver with resolution up to 1600x1200.

This fixes most likely other bootloader and operating systems as well,
in case the are relying on VESA framebuffer support.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2017-06-12 15:25:12 -04:00
Patrick Rudolph 6b69446de7 SeaVGABios/cbvga: Use active mode to clear screen
As coreboot framebuffer is immutable always use CBmodeinfo.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2017-06-12 15:17:10 -04:00
Patrick Rudolph 4902b8a703 SeaVGABIOS/vbe: Query driver for scanline pitch v2
Query the driver for the real scanline pitch in bytes.

As cbvga doesn't change the pitch on mode change, always
return the same pitch, that might exceed width times Bytes-per-pixel.

Report the default stdvga pitch for all other drivers.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2017-06-12 15:17:09 -04:00
Patrick Rudolph 4b42cc4b31 SeaVGABios/cbvga: Advertise correct pixel format
Accumulate the pixel format's bits instead relying on coreboot's
bits_per_pixel, which says nothing about the active pixel format.

Allows VBE to correctly advertise XRGB8 and BGRX8 framebuffer formats,
commonly used by coreboot.

Fixes at least Windows Bootloader and gfxboot.

Signed-off-by: Patrick Rudolph <siro@das-labor.org>
2017-06-12 15:10:05 -04:00
Paul Menzel 970af16e6e vgasrc: Increase debug level
You only want this information for debugging. As it also slows down the
boot considerably, as, for example, for every character of the GRUB
menu, something is sent over the serial console.

Therefore, increase the debugging level to 9.

Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de>
2017-01-29 14:25:34 -05:00
Kevin O'Connor 8cdf0c5ab9 version: Update header files now that version.c is not auto generated
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-05 13:44:12 -04:00
Kevin O'Connor 65bc0a7bc9 vgautil: Move definitions from cbvga.h and clext.h to vgautil.h
These files only need to export simple function definitions - move
them to vgautil.h.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-05 11:53:32 -04:00
Kevin O'Connor c682ffe671 vgautil: Move generic definitions from stdvga.h to vgautil.h
Don't use stdvga.h for function definitions of code in stdvgamodes.c
and stdvgaio.c.  Move them to vgautil.h.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-05 11:48:20 -04:00
Kevin O'Connor 2f2ec113be vgautil: Add new header file with misc function and variable definitions
Move the generic function and variable definitions from vgabios.h to a
new file vgautil.h.  This reduces the size and complexity of
vgabios.h.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-05 11:28:19 -04:00
Kevin O'Connor 536129ac3a vgainit: Move video param setup to stdvga_build_video_param()
Move the full video_param_table[] setup (including the updating of the
BDA) to stdvga_build_video_param().

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-05 11:27:25 -04:00
Kevin O'Connor 0397e80528 vgafb: Move header definitions from vgabios.h to new file vgafb.h
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-04 17:53:45 -04:00
Kevin O'Connor 774f5cd627 swcursor: Concentrate swcursor logic in swcursor.c
The software cursor code is not frequently used (only the coreboot
framebuffer vga code uses it).  Move its logic out of the main code
and into swcursor.c.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-04 17:02:16 -04:00
Kevin O'Connor 27129d003f swcursor: Move swcursor code from vgafb.c to new file swcursor.c
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-08-04 16:27:03 -04:00
Kevin O'Connor 09e24ac187 vgabios: Simplify scroll logic
Introduce a new function vgafb_scroll() to scroll a window on the
screen and update vgabios.c to use only that function for scrolling.
This makes the low-level vgafb_move_chars() and vgafb_clear_chars()
local to vgafb.c, and it simplifies the callers.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-07-21 10:51:32 -04:00
Kevin O'Connor 13213a2522 vgabios: Simplify set_cursor_pos()
Rework set_cursor_pos() to be slightly simpler.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-07-04 12:31:50 -04:00
Kevin O'Connor b303687deb vgabios: Don't check for special case of page==0xff on external calls
The original "lgpl vgabios" internally used page=0xff as a mechanism
for specifying the current page.  It also would allow int1013 calls to
externally specify bh==0xff for the current page.  However, there is
no documentation supporting this as an externally available feature.
SeaVGABIOS does not need the internal shortcut; this patch removes the
code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-07-04 12:27:38 -04:00
Kevin O'Connor e5839eaffc vgabios: Remove special case of dh==0xff in handle_1013()
The original "lgpl vgabios" had a special case for dh==0xff in its
int1013 (write string) code.  There does not appear to be any VGABIOS
documentation supporting this as an externally available feature.  It
appears this was for its own internal use when writing its strings to
the screen.  SeaVGABIOS doesn't use this hack; this patch removes it
from the code.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2016-07-04 12:20:48 -04:00
Kevin O'Connor efd70a5006 build: Report gcc and binutils versions in debug log
Attempt to extract the gcc and binutils versions.  Report that
information in the debug log.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15 10:55:10 -04:00
Kevin O'Connor a6c877401b build: Rework version generation; don't allow make version override
Convert the script to generate the build version from a shell script
to a python script.

Remove the ability to override the version at build time via "make
VERSION=xyz".  Replace it with ability to add extra version
information at build time via "make EXTRAVERSION=xyz".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-15 10:55:03 -04:00
Stefan Weil 6bcacf7d19 Fix typos found by codespell
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-10-09 13:34:28 -04:00
Kevin O'Connor 33617ef43e vgafb: Minor - move gfx_common() variables outside of switch statement
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-08-04 09:19:03 -04:00
Kevin O'Connor f24eb2f853 build: CONFIG_VGA_FIXUP_ASM should depend on CONFIG_BUILD_VGABIOS
Add the dependency to CONFIG_VGA_FIXUP_ASM so the menu option only
appears when appropriate.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-06-15 10:19:05 -04:00
Gerd Hoffmann b972a962f7 vga: add virtio-vga to kconfig
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-06-11 09:23:03 +02:00
Gerd Hoffmann 87f848ec2d vga: rework virtio-vga support
Unlike planned earlier virtio-vga will be compatible with
the qemu stdvga, with the framebuffer in bar 0.  Drop the
virtio-vga chunk, update comment accordingly.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-06-11 09:23:03 +02:00
Gerd Hoffmann 9c6edc4d27 vga: simplify vga builds
Add a kconfig menu to pick the vga variant, stick the vendorr
and device ids as defaults into Kconfig.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
2015-06-11 09:23:03 +02:00
Kevin O'Connor 0b2165d191 vgabios: Emulate "leal" instruction
Emulate the "leal" instruction so that the vgabios can run on older
versions of x86emu.  (This removes the previous "leal" trap.)

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-04-11 14:36:59 -04:00
Kevin O'Connor 799b20b0db vgabios: Add config option for assembler fixups
Add a kconfig build option (CONFIG_VGA_FIXUP_ASM) to allow users to
build the vgabios without the complex assembler fixups that work
around emulator bugs.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-04-10 00:38:17 -04:00
Kevin O'Connor 3b9b9f2446 vgabios: Don't use "smsww" instruction - it confuses x86emu
Commit 251e2638 introduced the "smsww" instruction to the vgabios.
Unfortunately, it appears at least some versions of x86emu crash when
executing that instruction (eg, FC13 installer crashes).  That
instruction wasn't required to work around the problem fixed in
251e2638, so just avoid it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-04-10 00:38:17 -04:00
Kevin O'Connor 251e26388b vgabios: Don't use extra stack if it appears a modern OS is in use
If the last mode set (while not in vm86 mode) was done from a VBE mode
set call then disable the extra stack.  This works under the premise
that only a modern OS would invoke the VBE mode changing facilities
and a modern OS would always call the vgabios with sufficient stack
space.

This is an ugly hack to work around a problem Windows Vista (and
possibly later Windows releases) has with the VGA BIOS using a stack
in the e-segment.

Reported-by: Richard Laager <rlaager@wiktel.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-03-18 01:46:56 -04:00
Kevin O'Connor 184496863a vgabios: On bda_save_restore() the saved vbe_mode also has flags in it
When restoring a saved state, make sure to remove any flags from the
video mode prior to searching for that mode.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-03-17 10:52:16 -04:00
Kevin O'Connor e638f97da0 vgabios: Support emulated text in gfx_read_char()
When emulating text mode on "coreboot framebuffer" SeaVGABIOS, return
a foreground and background attribute from gfx_read_char() and prefer
returning a space character (instead of null) on blank cells.

This also returns the foreground color (instead of always returning
zero) for regular graphics mode gfx_read_char() calls.  This seems
fine as tests show other vgabios implementations also return various
values here.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-01-07 10:08:33 -05:00
Paolo Bonzini 60e0e55f21 vgabios: implement read char in graphics mode
GWBasic relies on this, so implement it to enable some serious retrocomputing.
There is no better way to do it than trying to match all characters one by one
against the current font.

This makes it possible to actually do something in SCREEN 1 and SCREEN 2
(without it, you can use graphics in the programs but not in direct mode).

I couldn't find documentation for what to return as the attribute, but
experimenting with DOSBox suggests 0 (and GWBasic accepts it).

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2015-01-06 09:54:44 -05:00
Paolo Bonzini 9c29148ea6 vgabios: fix graphics operation with Bochs VGA in non-DISPI modes
For legacy VGA modes that do not set the VBE_DISPI_ENABLED bit,
bochsvga_get_linelength returns 0.  Thus all characters are squashed
into the first scanline.  Fix this by falling back to stdvga for
the legacy modes.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2015-01-06 09:53:39 -05:00
Kevin O'Connor aa66d6539c Use an aligned stack offset when entering on the extra stack
The size of 'struct bregs' is not evenly divisible by four and where
the assembler placed a 'struct bregs' on the extra stack as part of
entering into the C functions it caused the C functions to run with a
non-aligned stack.  It's technically not correct to use an unaligned
stack and it is certainly less efficient.

This patch avoids using BREGS_size (the sizeof struct bregs) and
instead introduces PUSHBREGS_size (the size of the general purpose
registers in struct bregs) in the assembler.  Where the code actually
did use the %cs:%ip and flags, an extra 8 (instead of 6) bytes are
added to maintain a sane alignment.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-11-12 12:17:57 -05:00
Kevin O'Connor b4eb6fc5cc vgabios: Add software cursor capability
Add mechanism for drawing a cursor to the framebuffer to implement a
cursor in software.  The timer interrupt is "hooked" so that the
cursor can blink.  This can be useful for "coreboot native vga".

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-11-12 12:17:57 -05:00
Kevin O'Connor 6fed307251 vgabios: Support emulating text mode attributes while in graphics mode
Add support for simple text mode attribute emulation while in graphics
mode.  This improves text highlighting and background color on some
boot-loaders.  Enable it only for CBVGA vgabios and only when a text
mode is requested.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-11-12 12:17:57 -05:00
Kevin O'Connor 136d4ec190 vgabios: Add support for reading framebuffer in "direct" mode
Support reading high memory "direct" framebuffers and translating the
results to 8 bit attribute values.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27 11:03:12 -04:00
Kevin O'Connor 12900b1a24 vgabios: Fill in available legacy modes in video_func_static at runtime
Instead of hard coding the list of modes, fill them in from the list
of supported modes.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27 11:03:12 -04:00
Kevin O'Connor 63977905a0 vgabios: Move standard table definitions to std/vga.h
Move the standard video bios definitions into a new header file.
Also, define a struct with the layout for the static functionality
table.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27 11:03:12 -04:00
Kevin O'Connor c5acee4d8d vgabios: Only set the dcc_index=8 if stdvga ports are available
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27 11:03:12 -04:00
Kevin O'Connor 5b89d959a6 vgabios: Only init BDA device details in init_bios_area()
Don't set the device details when changing modes, and don't set mode
details outside of mode setting.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27 11:03:12 -04:00
Kevin O'Connor c9aecfcd14 vgabios: Refactor get/set_cursor_shape() code
Rework the code so that it is possible to calculate the current cursor
shape even when not changing it.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27 11:02:28 -04:00
Kevin O'Connor 479fd7255f vgabios: Set cursor shape fixes
The "cursor scaling" mode is determined by the first bit of the
video_ctl bda value, not the modeset_ctl value.  Also, on a
set_scan_lines() call, the shape should be set to lines-3/lines-2 and
the shape must be set after char_height has been updated.

The existing cursor shape code matches the legacy "lgpl vgabios", but
the behavior doesn't match bios documentation nor observations with an
ati vga bios.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27 11:02:28 -04:00
Kevin O'Connor f4b1dbc9ac vgabios: Rename vbe_flags to flags
Allow the custom bda field vbe_flags to be used for flags outside of
vbe.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27 11:01:26 -04:00
Kevin O'Connor 7217ae7bea vgabios: Don't pass vmode_g to vgafb_move_chars() / vgafb_clear_chars()
Now that a pointer to the current video mode info struct is cached in
memory, it's not necessary to pass the struct into the vgafb code.
The vgafb code can lookup the struct itself.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27 11:00:32 -04:00
Kevin O'Connor f7f22630fd vgabios: Cache a pointer to the current mode struct in the BDA
Cache a pointer to the current mode 'vgamode_s' struct in the BDA to
avoid doing a linear scan of all available vga modes when the struct
is needed.

This uses an additional two bytes in the BDA (at offset 0xbc).  It's
possible this could conflict with some other software, but that seams
unlikely because that part of the BDA seems reserved for BIOS and
VGABIOS uses.  (And neither SeaBIOS nor Bochs BIOS currently make use
of that area.)

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27 11:00:32 -04:00
Kevin O'Connor 9978d49d1c vgabios: Don't declare custom internal BDA storage in std/bda.h
The vgabios uses storage in the BDA at offset 0xb9 for internal custom
storage (the contents do not appear to be part of any bios standard).
Move the description of this custom vgabios area from std/bda.h to
vgasrc/vgabios.h.  Add two new macros (GET_BDA_EXT and SET_BDA_EXT).
This should make it more clear that the area is for custom internal
storage.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27 11:00:32 -04:00
Kevin O'Connor 46000f5608 Create assembler macros for saving and restoring 'struct bregs'
Create macros SAVEBREGS_POP_DSEAX and RESTOREBREGS_DSEAX for saving
and restoring the cpu state.  These are similar to the existing
PUSHBREGS and POPBREGS macros.

This also fixes a bug in __farcall16 which inadvertently restored %ds
in %es and vice-versa.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
2014-10-27 10:56:54 -04:00
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