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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
All three scroll function variants have the same format, but those
that have an implicit character width or height of 1 have those
multiplications omitted. Add those multiplications back in (the
compiler will optimize them away) so all the variants look similar.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Fix missing divide by 2 in CGA mode scroll. Consistently use
cheight/2 for all uses.
Planar graphics character write has a read to video memory with a side
effect - mark that as volatile so the compiler doesn't optimize it
away.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use the same function signature for cirrus, bochsvga, geodelx, and
stdvga init code.
Have each hardware type explicitly call stdvga_init when needed.
To unify bochsvga_init() signature, store the device BDF passed into
the optionrom init code in a global variable (VgaBDF).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Use the same function signature for cirrus, bochsvga, and stdvga
set_mode code.
Make both the int1000 interface and the VBE 104f02 interface use the
same set_mode function.
Where clext and bochsvga need to fallback to the standard vga mode
switching, have them call vgastd_mode_switch directly.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Split out the BDA setup part of vga_set_mode to new function
modeswitch_set_bda. Move the remaining parts (palette loading, screen
clearing, font loading) of vga_set_mode into stdvga_set_mode.
Add new mode switching flags and pass them to stdvga_set_mode, so it
does not need to inspect modeset_ctl directly.
Move code needed by stdvga_set_mode (perform_gray_scale_summing,
clear_screen) to stdvga.c.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The calls to set_cursor_shape, set_cursor_pos, and set_active_page
have no impact other than to set the BDA variables, because the
standard vga mode switch already programed the registers these
functions set. So, just setup the BDA directly.
The stdvga_set_text_block_specifier call is unnecessary - it sets
a register which is already programmed that way.
Call stdvga_get_crtc() to obtain the crtc address instead of inferring
it from the memory model.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't call int10 to load the fonts - instead call the font loading
functions directly.
Theoretically, this could change behavior if an external program has
captured int10 and redirects the font loading calls. However, there
does not seem to be any indication that an external app could expect
that to work.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The low level VGA code shouldn't depend on the crtc address stored in
the BDA - it can find the address on its own.
The cirrus_get_crtc() function is the same - replace it with
stdvga_get_crtc().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Although the VBE3 spec says there is 189 bytes of pad at the end of
the vbe_info struct, the spec also says the total struct size should
be 256 bytes. The VBE2 spec uses sufficient pad to get to 256 bytes.
So, assume the spec was off by one and make the pad 190 bytes.
Also, use u32 for capabilities and 'struct segoff_s' for
win_func_ptr.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
GeodeLX support based on a patch sent by Chris Kindt on 20090825. The
patch provides basic support for running the vga bios on a Geode
device.
The original patch has been updated with the following:
* Updates to merge with the current code,
* geode specific timings are loaded at init time
* PCI code was dropped as the current code now supports pci
* Updates for Kconfig
* dropped redundant lxdprintf
* dropped geode_demo screen writing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It appears some emulators look for a signature at offset 0x1e of the
option rom. So, port the signature from the LGPL bios.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Now that all the mode info is available in vga_modes, generate the
externally visible video_param_table data from it.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Now that all the info in video_param_table is also in vgamode_s, use
the info in vgamode_s throughout the code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It allowed me to boot Windows 7 with Qemu BOCHS VGA emulation and it
seemed to work fine. It probably needs some further testing though.
Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
This patch adds a configuration menu for the VGA ROM, it also allow
the creation of a PCI header so the ROM can be extracted from a PCI
device.
V2: Default Device IDs and Vendor IDs values for Cirrus and Bochs are now set
by Kconfig.
Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
Allows the ROM to be extracted from a PCI device.
V2: * Declare the PCI header in C
* Replace #ifdef CONFIG_VGA_PCI with #if CONFIG_VGA_PCI == 1
Signed-off-by: Julian Pidancet <julian.pidancet@gmail.com>
Implement -ffunction-sections and -fdata-sections in both 32bit and
16bit code.
Make sure all sections have unique names (even asm and discarded
sections).
Enhance tools/layoutrom.py script to find all sections reachable from
exported 16bit code - prune all other sections.
Mark sections with "export" if they can be visible outside of code -
these sections wont be dropped when pruning unused sections.
Remove remaining "biosfn_" prefixes from functions.
Don't use register names as function parameters.
vgafb_read_pixel should return a value (instead of passing in a pointer)
Pass pointer to cursor position into write_string and write_teletype.
Handle flag processing of write_string in handle_1013.
Implement a tail-recursive scroll_one() function.
Introduce memcpy_stride and memset_stride functions.
Simplify the moves and fills using src and dest pointers.
Don't nest for loops - just use one loop for copies.
Rename biosfn_scroll to vgafb_scroll.
Break function up into per-mode scroll function.
Pass row/col params in a 'struct cursorpos'.
Encode direction as sign in nblines.
Move parameter checking to callers.
Add enhancement to 'attr' for using mode specific default attribute.
Also, make get_cursor_pos local to vga.c.
Move hardware IO accessor functions to vgaio.c.
Move framebuffer and font manipulation code to vgafb.c.
Also, have biosfn_write_teletype use biosfn_write_char_attr/only.
Also, breakout set_scan_lines() functionality from biosfn_load_text_X.
The irq entry points now push the handler address and jump to a
function that does parameter setup. This reduces the code size
because the entry setup isn't repeated for every handler.
This is an initial import of the code from:
http://www.nongnu.org/vgabios/
The code has been ported from bcc to gcc and gas.
This is an initial import - many functions have not been ported; many
bugs are present.