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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>