History log of /freebsd-current/sys/dev/fb/vesa.c
Revision Date Author Comments
# 848a8bf3 12-Jan-2024 Mark Johnston <markj@FreeBSD.org>

fb: Check for errors from copyin()

When compiling with gcc, a function annotated with __result_use_check
cannot have its return value ignored with a void cast. So, try to
handle it.

MFC after: 1 week


# ddc8576d 26-Dec-2023 Mark Johnston <markj@FreeBSD.org>

fb: Explicitly handle errors when getting or setting a colour palette

In the VESA driver, simply ignore errors. It is not clear to me how to
return them to userspace.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

MFC after: 1 week


# 685dc743 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: one-line .c pattern

Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with: pfg
MFC After: 3 days
Sponsored by: Netflix


# 7ae99f80 22-Sep-2022 John Baldwin <jhb@FreeBSD.org>

pmap_unmapdev/bios: Accept a pointer instead of a vm_offset_t.

This matches the return type of pmap_mapdev/bios.

Reviewed by: kib, markj
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D36548


# 7029da5c 26-Feb-2020 Pawel Biernacki <kaktus@FreeBSD.org>

Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)

r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE. All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by: kib (mentor, blanket)
Commented by: kib, gallatin, melifaro
Differential Revision: https://reviews.freebsd.org/D23718


# 2058e7db 13-Nov-2019 Scott Long <scottl@FreeBSD.org>

Stop the VESA driver from whining loudly in the dmesg during boot on
systems that use EFI instead of BIOS.


# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.


# be4bf626 20-Apr-2017 Konstantin Belousov <kib@FreeBSD.org>

Write-combine framebuffer writes through user-space mappings, if possible.

Note that KVA mapping of the framebuffer already uses write-combining
mode, so the change, besides improving speed of user mode writes, also
satisfies requirement of the IA32 architecture of using consistent
caching modes for multiple mappings of the same page.

Reported and tested by: bde
Sponsored by: The FreeBSD Foundation
MFC after: 1 week


# ecb56aaf 20-Apr-2017 Bruce Evans <bde@FreeBSD.org>

Attempt to determine the modes in which 8-bit wide characters are actually
9 wide.

I only need this to improve the mouse cursor, but it has always been
needed to select and/or adjust fonts.

This is complicated because there are no standard parameter tables
giving this bit of information directly, and the device register bit
giving the information can't be trusted even if it is read from the
hardware. Use a heuristic to guess if the device register can be
trusted. (The device register is normally read from the BIOS mode
table, but on my system where the device register is wrong, the mode
table doesn't match the hardware and is not used; the device registers
are used in this case.)


# 3a98d83e 02-Apr-2017 Bruce Evans <bde@FreeBSD.org>

Reset the DAC to 6-bit mode before calling the BIOS to set the screen
mode. This works around bugs in at least 2 Intel BIOSes for our
subsequent setting of the DAC back to 8-bit mode. The bug caused dark
(mostly 1/4-intensity) colors for all except the first setting to a
VESA graphics mode (including for settings to the current mode).

Remove restoration (with less bits) of the palette in vesa_unload()
after resetting the DAC to 6-bit mode. Depend on the BIOS to keep
the palette consistent with the DAC for the simpler reset case like
we do everywhere else in places that are actually important.

Setting the video mode should reset everything to defaults, although
we usually don't want that. Even the buggy BIOSes set the DAC to the
default 6-bit mode, and set the palette to a default that matches the
DAC. We don't undo the reset for most things, but we do undo it for
the DAC (more precisely, we change to an 8-bit DAC if possible, and
this is the only way that we set to an 8-bit DAC; it is accidental
that if the DAC was in 8-bit mode from a previous mode switch then
setting it to 8-bit mode is an undo). The buggy BIOSes are confused
by our setting of the DAC to 8-bit mode in the "undo" case. They
should multiply palette entries by 4 to match, but they actually leave
all palette entries except #2 (green) and #248-255 (unused) untouched.
Green is mysteriously scaled from 0x2a to 0x6a, and #248-255 are scaled
correctly.

Our support for the 8-bit DAC had almost no effect except to enable
bugs. Syscons barely supports 16 colors, so it doesn't benefit much
from having a palette with 16 million colors instead of only 256K.
Applications can manage the palette using FBIO_{GET,SET}PALETTE, but
the palette managed by this is only used in the less interesting modes
(text and non-truecolor graphics modes up to 8 bits wide), and the
kernel loses the changes on any mode switch (including to another vt
in a different mode).


# ab59c4d9 23-Jul-2016 John Baldwin <jhb@FreeBSD.org>

Use MTX_SYSINIT for the VESA lock.

vesa_init_done isn't a reliable guard for the mutex init. If
vesa_configure() doesn't find valid VESA info it will not set
vesa_init_done, but the lock will remain initialized. Revert r303076
and use MTX_SYSINIT to deterministically init the lock.

Reviewed by: royger
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D7290


# c397b61e 20-Jul-2016 Roger Pau Monné <royger@FreeBSD.org>

vesa: fix panic on suspend

Fix the following panic seen when migrating a FreeBSD guest on Xen:

panic: mtx_lock() of destroyed mutex @ /usr/src/sys/dev/fb/vesa.c:541
cpuid = 0
KDB: stack backtrace:
db_trace_self_wrapper() at db_trace_self_wrapper+0x2b/frame 0xfffffe001d2fa4f0
vpanic() at vpanic+0x182/frame 0xfffffe001d2fa570
kassert_panic() at kassert_panic+0x126/frame 0xfffffe001d2fa5e0
__mtx_lock_flags() at __mtx_lock_flags+0x15b/frame 0xfffffe001d2fa630
vesa_bios_save_restore() at vesa_bios_save_restore+0x78/frame 0xfffffe001d2fa680
vga_suspend() at vga_suspend+0xa3/frame 0xfffffe001d2fa6b0
isavga_suspend() at isavga_suspend+0x1d/frame 0xfffffe001d2fa6d0
bus_generic_suspend_child() at bus_generic_suspend_child+0x44/frame
[...]

This is caused because vga_sub_configure (which is called if the VGA adapter
is attached after VESA tried to initialize), points to vesa_configure, which
doesn't initialize the VESA mutex. In order to fix it, make sure
vga_sub_configure points to vesa_load, so that all the needed vesa
components are properly initialized.

Sponsored by: Citrix Systems R&D
MFC after: 3 days
PR: 209203
Reviewed by: dumbbell
Differential revision: https://reviews.freebsd.org/D7196


# 0f85a96b 17-May-2016 Alexander Motin <mav@FreeBSD.org>

Fix NULL-dereference panic if VESA reports zero modes.

MFC after: 1 week


# 4ed3c0e7 30-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

sys: Make use of our rounddown() macro when sys/param.h is available.

No functional change.


# 323b076e 21-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

sys: use our nitems() macro when param.h is available.

This should cover all the remaining cases in the kernel.

Discussed in: freebsd-current


# af3b2549 27-Jun-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Pull in r267961 and r267973 again. Fix for issues reported will follow.


# 37a107a4 27-Jun-2014 Glen Barber <gjb@FreeBSD.org>

Revert r267961, r267973:

These changes prevent sysctl(8) from returning proper output,
such as:

1) no output from sysctl(8)
2) erroneously returning ENOMEM with tools like truss(1)
or uname(1)
truss: can not get etype: Cannot allocate memory


# 3da1cf1e 27-Jun-2014 Hans Petter Selasky <hselasky@FreeBSD.org>

Extend the meaning of the CTLFLAG_TUN flag to automatically check if
there is an environment variable which shall initialize the SYSCTL
during early boot. This works for all SYSCTL types both statically and
dynamically created ones, except for the SYSCTL NODE type and SYSCTLs
which belong to VNETs. A new flag, CTLFLAG_NOFETCH, has been added to
be used in the case a tunable sysctl has a custom initialisation
function allowing the sysctl to still be marked as a tunable. The
kernel SYSCTL API is mostly the same, with a few exceptions for some
special operations like iterating childrens of a static/extern SYSCTL
node. This operation should probably be made into a factored out
common macro, hence some device drivers use this. The reason for
changing the SYSCTL API was the need for a SYSCTL parent OID pointer
and not only the SYSCTL parent OID list pointer in order to quickly
generate the sysctl path. The motivation behind this patch is to avoid
parameter loading cludges inside the OFED driver subsystem. Instead of
adding special code to the OFED driver subsystem to post-load tunables
into dynamically created sysctls, we generalize this in the kernel.

Other changes:
- Corrected a possibly incorrect sysctl name from "hw.cbb.intr_mask"
to "hw.pcic.intr_mask".
- Removed redundant TUNABLE statements throughout the kernel.
- Some minor code rewrites in connection to removing not needed
TUNABLE statements.
- Added a missing SYSCTL_DECL().
- Wrapped two very long lines.
- Avoid malloc()/free() inside sysctl string handling, in case it is
called to initialize a sysctl from a tunable, hence malloc()/free() is
not ready when sysctls from the sysctl dataset are registered.
- Bumped FreeBSD version to indicate SYSCTL API change.

MFC after: 2 weeks
Sponsored by: Mellanox Technologies


# 10f1472e 28-Aug-2013 Jung-uk Kim <jkim@FreeBSD.org>

Reduce diff against stable/9 slightly.


# 663593f1 28-Aug-2013 Jung-uk Kim <jkim@FreeBSD.org>

Do not save/restore video memory if we are not using linear frame buffer.
Note this partially revert r233896.


# b1bba126 28-Aug-2013 Jung-uk Kim <jkim@FreeBSD.org>

Make sure to free stale buffer before allocating new one for safety.


# 7afb475f 28-Aug-2013 Jung-uk Kim <jkim@FreeBSD.org>

Avoid unnecessary signedness conversion.


# ba9855e3 27-Mar-2013 Jung-uk Kim <jkim@FreeBSD.org>

Limit the amount of video memory we map for the driver to the maximum value.
This basically restores the spirit of r203535, which was partially reverted
in r205557, while we still map fixed amount to work around transient issues
we experienced with r203535.

Prodded by: avg
Tested by: avg
MFC after: 1 week


# 4db9b6c3 04-Apr-2012 Jung-uk Kim <jkim@FreeBSD.org>

Save and restore VGA display memory between suspend and resume.


# 4c7a7f26 04-Apr-2012 Jung-uk Kim <jkim@FreeBSD.org>

Do not copy VESA state buffer if the VBE call has failed for any reason.
Do not unnecessarily clear the state buffer before calling the function.


# cd283487 19-Mar-2012 Jung-uk Kim <jkim@FreeBSD.org>

Do not reuse the previous address when restoring linear frame buffer.


# 9f524284 16-Mar-2012 Jung-uk Kim <jkim@FreeBSD.org>

Save and restore linear frame buffer between suspend and resume.

MFC after: 1 week


# 0b01dbd7 16-Mar-2012 Jung-uk Kim <jkim@FreeBSD.org>

Remove unnecessary static variable initializations and duplicate codes.
Consistently use bcopy(9) over memcpy(9).


# b1a499f3 16-Mar-2012 Jung-uk Kim <jkim@FreeBSD.org>

Do not unnecessarily clear display memory when switching modes.

MFC after: 3 days


# 7e330e82 23-Feb-2012 Jung-uk Kim <jkim@FreeBSD.org>

If the VBE implementation does not support save/restore function, defer to
VGA methods. Unconditionally reset the VESA adapter before restoring state.


# e7d5cd47 23-Feb-2012 Jung-uk Kim <jkim@FreeBSD.org>

Update my copyright date.


# 257e5645 23-Feb-2012 Jung-uk Kim <jkim@FreeBSD.org>

Probe supported states for save/restore function. Some VBE implementation
refuses to save/restore states if an unsupported bit is set.


# 3dd6e888 23-Feb-2012 Jung-uk Kim <jkim@FreeBSD.org>

Fix a typo introduced in r231843.


# 1556e634 16-Feb-2012 Jung-uk Kim <jkim@FreeBSD.org>

Set the initial mode for the adapter after executing VESA BIOS POST.
There is no need to set initial mode for BIOS.


# 2f18ee9d 16-Feb-2012 Jung-uk Kim <jkim@FreeBSD.org>

Make sure the VESA mode number is between 256 and 511 inclusive.


# 6472ac3d 07-Nov-2011 Ed Schouten <ed@FreeBSD.org>

Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.

The SYSCTL_NODE macro defines a list that stores all child-elements of
that node. If there's no SYSCTL_DECL macro anywhere else, there's no
reason why it shouldn't be static.


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# f6ff063a 13-Sep-2010 Jung-uk Kim <jkim@FreeBSD.org>

Fix segment:offset calculation of interrupt vector for relocated video BIOS
when the original offset is bigger than size of one page. X86BIOS macros
cannot be used here because it is assumed address is only linear in a page.

Tested by: netchild


# 90017de9 02-Sep-2010 Jung-uk Kim <jkim@FreeBSD.org>

Disable video ROM shadowing by default as I originally intended. I found
a case where video ROM for an IGP is too tightly coupled with system BIOS
to get relocated.


# c74dea9c 31-Aug-2010 Jung-uk Kim <jkim@FreeBSD.org>

Make sure the interrupt entry point is within the video ROM range. We must
not change interrupt vector if it is not pointing the ROM itself. Actually,
we just fail shadowing altogether if that is the case because the shadowed
copy will be useless for sure and POST may not be relocatable or useful.
While I'm here, fix a debugging message under bootverbose, really. r211829
fixed one case but broke another. Mea Culpa.


# 2b137859 25-Aug-2010 Jung-uk Kim <jkim@FreeBSD.org>

Fix a debugging message under bootverbose. This address is not linear.


# a73f383e 25-Aug-2010 Jung-uk Kim <jkim@FreeBSD.org>

Add an experimental feature to shadow video BIOS. Long ago, this trick was
supported by many BIOSes to improve performance of VESA BIOS calls for real
mode OSes but it is not our intention here. However, this may help some
platforms where the video ROMs are inaccessible after suspend, for example.
Note it may consume up to 64K bytes of contiguous memory depending on video
controller model when it is enabled. This feature can be disabled by
setting zero to 'debug.vesa.shadow_rom' loader tunable via loader(8) or
loader.conf(5). The default is 1 (enabled), for now.


# 90f06c5e 06-Aug-2010 Jung-uk Kim <jkim@FreeBSD.org>

Protect shared palette and state buffer with a mutex. Remove defunct
spltty() calls while I am here.


# 708358cd 13-Jul-2010 Jung-uk Kim <jkim@FreeBSD.org>

Initialize a variable before its use.


# 917b850d 13-Jul-2010 Jung-uk Kim <jkim@FreeBSD.org>

Preallocate buffers for palette and state. Do not save DAC registers as
we reset DAC mode and restore palette data while we are resuming always.


# 061b7e54 06-Jul-2010 Jung-uk Kim <jkim@FreeBSD.org>

Plug a possible memory leak.

Submitted by: Yamagi Burmeister (lists at yamagi dot org)


# c3cbd412 06-Jul-2010 Jung-uk Kim <jkim@FreeBSD.org>

Fix a possible null pointer dereference. A patch for -STABLE was

Submitted by: Yamagi Burmeister (lists at yamagi dot org)


# 28ef508f 23-Jun-2010 Jung-uk Kim <jkim@FreeBSD.org>

Use M_WAITOK for VESA BIOS initialization consistently.


# 362487c0 23-Jun-2010 Jung-uk Kim <jkim@FreeBSD.org>

Let x86bios_alloc() pass contigmalloc(9) flags. Use it to set M_WAITOK
from VESA BIOS initialization. All other malloc(9) uses in the function is
blocking any way.


# af25d42d 23-May-2010 Jung-uk Kim <jkim@FreeBSD.org>

MFC: r208279

Restore the previous video mode after VESA BIOS POST, just in case.


# a5386a13 23-May-2010 Jung-uk Kim <jkim@FreeBSD.org>

MFC: r208276

Remove unnecessary pointer increment. A wrong pointer may be passed to
free(9) and it can cause kernel panic when there are multiple graphics
controllers in the system.


# a46dd0b9 18-May-2010 Jung-uk Kim <jkim@FreeBSD.org>

Restore the previous VESA mode after BIOS POST, just in case.


# 842795ab 18-May-2010 Jung-uk Kim <jkim@FreeBSD.org>

Remove unnecessary pointer increment. A wrong pointer may be passed to
free(9) and it can cause kernel panic when there are multiple graphics
controllers in the system.

Tested by: Brandon Gooch (jamesbrandongooch at gmail dot com)
MFC after: 3 days


# 9a4f7ef7 26-Apr-2010 Jung-uk Kim <jkim@FreeBSD.org>

MFC: r206384

Allocate memory for VBE info block with malloc(9), not as static local.


# 004e8bae 07-Apr-2010 Jung-uk Kim <jkim@FreeBSD.org>

Allocate memory for VBE info block with malloc(9), not as static local.


# 7058bb70 31-Mar-2010 Jung-uk Kim <jkim@FreeBSD.org>

MFC: r205557, r205558, r205564, r205566, r205604, r205653

Sync. pixel mode support for VESA and VGA frame buffers with HEAD.

- Map entire video memory again. Although we do not use them all directly,
it seems VGA renderer may access unmapped memory region and cause kernel
panic.
- Fall back to VGA palette functions if VESA function failed and DAC is
still in 6-bit mode. Although we have to check non-VGA compatibility bit
here, it seems there are too many broken VESA BIOSes out to rely on it.
- Be careful when we determine bytes per scan line information. We compare
mode table data against minimum value. If the mode table does not make
sense, we set the minimum in the mode info.
- Teach VGA framebuffer about 8-bit palette format for VESA.
- Add my copyright here.


# bb6ba5f6 25-Mar-2010 Jung-uk Kim <jkim@FreeBSD.org>

Do not penalize correct or correctable VESA mode tables by calling another
VBE function. Most problems should be corrected by the mode table sanity
check and we only need the paranoid in extremely rare cases.


# 1e161437 24-Mar-2010 Jung-uk Kim <jkim@FreeBSD.org>

Teach VGA framebuffer about 8-bit palette format for VESA.


# b266b96a 23-Mar-2010 Jung-uk Kim <jkim@FreeBSD.org>

Add my copyright here. It seems I have contributed enough code. :-)


# 3b56b13e 23-Mar-2010 Jung-uk Kim <jkim@FreeBSD.org>

Be extremely careful when we determine bytes per scan line information.
First, we compare mode table data against minimum value. If the mode table
does not make sense, we set the minimum in the mode info. When we actually
set the mode, we try VESA BIOS function and compare it against the previous
value. If it makes more sense, update the information.


# 51cb3184 23-Mar-2010 Jung-uk Kim <jkim@FreeBSD.org>

Fall back to VGA palette functions if VESA function failed and DAC is still
in 6-bit mode. Although we have to check non-VGA compatibility bit here,
it seems there are too many broken VESA BIOSes out to rely on it.


# 5fb3ac06 23-Mar-2010 Jung-uk Kim <jkim@FreeBSD.org>

Map entire video memory again. This is a partial backout of r203535.
Although we do not use them all directly, it seems VGA render may access
unmapped memory region and cause kernel panic.


# aa3d547d 01-Mar-2010 Xin LI <delphij@FreeBSD.org>

MFC x86emu/x86bios emulator and make previously i386 only dpms and vesa
framebuffer driver, etc. work on FreeBSD/amd64.

A significant amount of improvements were done by jkim@ during the recent
months to make vesa(4) work better, over the initial code import. This
work is based on OpenBSD's x86emu implementation and contributed by
paradox <ddkprog yahoo com> and swell.k at gmail com.

Hopefully I have stolen all their work to 8-STABLE :)

All bugs in this commit are mine, as usual.


# 8d521790 23-Feb-2010 Jung-uk Kim <jkim@FreeBSD.org>

Yet another attempt to make palette loading more safer:

- Add a separate palette data for 8-bit DAC mode when SC_PIXEL_MODE is set
and fill it up with default gray-scale palette data for text. Now we don't
have to set `hint.sc.0.vesa_mode' to get the default palette data.
- Add a new adapter flag, V_ADP_DAC8 to track whether the controller is
using 8-bit palette format and load correct palette when switching modes.
- Set 8-bit DAC mode only for non-VGA compatible graphics mode.


# 0dc682e0 22-Feb-2010 Jung-uk Kim <jkim@FreeBSD.org>

Re-add accidentally removed pixel format for direct memory model.


# 316bcf56 05-Feb-2010 Jung-uk Kim <jkim@FreeBSD.org>

Map and report actual video memory we need.


# f801fa10 05-Feb-2010 Jung-uk Kim <jkim@FreeBSD.org>

Replace some homegrown functions with better/correct ones.


# bfd1f292 03-Feb-2010 Jung-uk Kim <jkim@FreeBSD.org>

Remove dead code and fix style(9) bugs.


# c5813a50 03-Feb-2010 Jung-uk Kim <jkim@FreeBSD.org>

Use bytes per scan line from mode table. The previous implementation did
not reflect actual number of bytes when it was not exactly width * bpp * 8.


# a95cde01 03-Feb-2010 Jung-uk Kim <jkim@FreeBSD.org>

Correct virtual address of frame buffer for non-linear mode.

Reported by: Marc UBM Bocklet (ubm dot freebsd at googlemail dot com)


# dd6155ac 27-Jan-2010 Jung-uk Kim <jkim@FreeBSD.org>

Use VESA palette load/save functions if VESA BIOS says the current palette
format is higher than 6-bit instead of relying VGA compatibility flag.
This fixes palette problem of NVIDIA GeForce 6600. Reduce code differences
between palette load/save functions while we are here.

Tested by: danfe


# cfd7bace 29-Dec-2009 Robert Noland <rnoland@FreeBSD.org>

Update d_mmap() to accept vm_ooffset_t and vm_memattr_t.

This replaces d_mmap() with the d_mmap2() implementation and also
changes the type of offset to vm_ooffset_t.

Purge d_mmap2().

All driver modules will need to be rebuilt since D_VERSION is also
bumped.

Reviewed by: jhb@
MFC after: Not in this lifetime...


# 2f28bf30 12-Nov-2009 Jung-uk Kim <jkim@FreeBSD.org>

- Remove a redundant check for dpms(4).
- Test a cheaper function first.


# 2259d74c 05-Nov-2009 Jung-uk Kim <jkim@FreeBSD.org>

Save/restore VGA state from vga_pci.c instead of relying on vga_isa.c.
It was not working because we were saving its state after the device was
powered down. Simplify vesa_load_state() as the culprit is fixed now.


# 00b9e39e 04-Nov-2009 Jung-uk Kim <jkim@FreeBSD.org>

Do not probe video mode if we are not going to use it.


# 421cd2f2 03-Nov-2009 Jung-uk Kim <jkim@FreeBSD.org>

Restore color palette format if we reset video mode.


# 761eeb5f 03-Nov-2009 Jung-uk Kim <jkim@FreeBSD.org>

Fix VESA color palette corruption:

- VBE 3.0 says palette format resets to 6-bit mode when video mode changes.
We simply set 8-bit mode when we switch modes if the adapter supports it.
- VBE 3.0 also says if the mode is not VGA compatible, we must use VBE
function to save/restore palette. Otherwise, VGA function may be used.
Thus, reinstate the save/load palette functions only for non-VGA compatible
modes regardless of its palette format.
- Let vesa(4) set VESA modes even if vga(4) claims to support it.
- Reset default palette if VESA pixel mode is set initially.
- Fix more style nits.


# 9871fde4 23-Oct-2009 Jung-uk Kim <jkim@FreeBSD.org>

Remove a redundant byte swapping in the previous commit.


# a0ce3346 23-Oct-2009 Jung-uk Kim <jkim@FreeBSD.org>

- When we restore VESA state, try BIOS POST earlier. VESA restore state
function may not work properly if we don't. Turn off hardware cursor as
vesa_set_mode() does.
- Add VBE 3.0 specific fields in VESA mode structure and pack it. Note
the padding is 190 bytes although VBE 3.0 says 189 bytes. It must be wrong
because the size of structure becomes 255 bytes and the specification says
it must be 256 bytes in total. In fact, an example code in the spec. does
it right, though. While we are at it, fix some i386-isms.
- Remove state buffer size limitation. It is no longer necessary since
sys/compat/x86bios/x86bios.c r198251.
- Move int 0x10 vector test into vesa_bios_post() as we always do it anyway.


# 3219f535 19-Oct-2009 Jung-uk Kim <jkim@FreeBSD.org>

Rewrite x86bios and update its dependent drivers.

- Do not map entire real mode memory (1MB). Instead, we map IVT/BDA and
ROM area separately. Most notably, ROM area is mapped as device memory
(uncacheable) as it should be. User memory is dynamically allocated and
free'ed with contigmalloc(9) and contigfree(9). Remove now redundant and
potentially dangerous x86bios_alloc.c. If this emulator ever grows to
support non-PC hardware, we may implement it with rman(9) later.
- Move all host-specific initializations from x86emu_util.c to x86bios.c and
remove now unnecessary x86emu_util.c. Currently, non-PC hardware is not
supported. We may use bus_space(9) later when the KPI is fixed.
- Replace all bzero() calls for emulated registers with more obviously named
x86bios_init_regs(). This function also initializes DS and SS properly.
- Add x86bios_get_intr(). This function checks if the interrupt vector is
available for the platform. It is not necessary for PC-compatible hardware
but it may be needed later. ;-)
- Do not try turning off monitor if DPMS does not support the state.
- Allocate stable memory for VESA OEM strings instead of just holding
pointers to them. They may or may not be accessible always. Fix a memory
leak of video mode table while I am here.
- Add (experimental) BIOS POST call for vesa(4). This function calls VGA
BIOS POST code from the current VGA option ROM. Some video controllers
cannot save and restore the state properly even if it is claimed to be
supported. Usually the symptom is blank display after resuming from suspend
state. If the video mode does not match the previous mode after restoring,
we try BIOS POST and force the known good initial state. Some magic was
taken from NetBSD (and it was taken from vbetool, I believe.)
- Add a loader tunable for vgapci(4) to give a hint to dpms(4) and vesa(4)
to identify who owns the VESA BIOS. This is very useful for multi-display
adapter setup. By default, the POST video controller is automatically
probed and the tunable "hw.pci.default_vgapci_unit" is set to corresponding
vgapci unit number. You may override it from loader but it is very unlikely
to be necessary. Unfortunately only AGP/PCI/PCI-E controllers can be
matched because ISA controller does not have necessary device IDs.
- Fix a long standing bug in state save/restore function. The state buffer
pointer should be ES:BX, not ES:DI according to VBE 3.0. If it ever worked,
that's because BX was always zero. :-)
- Clean up register initializations more clearer per VBE 3.0.
- Fix a lot of style issues with vesa(4).


# 54680451 25-Sep-2009 Jung-uk Kim <jkim@FreeBSD.org>

Reject some VESA graphics modes if the controller does not have enough
memory to support them. Some adapters have expansible memory slots but
video mode table is static. In this case, unusable modes may be reported.

Submitted by: paradox (ddkprog yahoo com) (initial patch)


# 57f20544 24-Sep-2009 Xin LI <delphij@FreeBSD.org>

Fix LINT build.


# 4d849a58 24-Sep-2009 Jung-uk Kim <jkim@FreeBSD.org>

Some broken VESA BIOSes, e.g., IBM T23, return wrong value from
vesa_bios_get_line_length() in graphics mode. Always calculate the value
from known video info instead.

Submitted by: paradox (ddkprog yahoo com)


# a8672748 24-Sep-2009 Jung-uk Kim <jkim@FreeBSD.org>

- Use FreeBSD function naming convention.
- Change x86biosCall() to more appropriate x86bios_intr().[1]

Discussed with: delphij, paradox (ddkprog yahoo com)
Submitted by: paradox (ddkprog yahoo com)[1]


# 19de5df5 23-Sep-2009 Jung-uk Kim <jkim@FreeBSD.org>

Move sys/dev/x86bios to sys/compat/x86bios.

It may not be optimal but it is clearly better than the old place.

OK'ed by: delphij, paradox (ddkprog yahoo com)


# f27b147e 22-Sep-2009 Xin LI <delphij@FreeBSD.org>

Initialize registers to zero before calling the interrupt handlers inside
emulator. This fixes VESA related freeze observed on some systems.

Submitted by: paradox <ddkprog yahoo com>


# 13c937f8 21-Sep-2009 Xin LI <delphij@FreeBSD.org>

Style(9) fixes.

Submitted by: swell.k at gmail.com


# 205d67b0 21-Sep-2009 Xin LI <delphij@FreeBSD.org>

Collapase interrupt supporting functions to a new module, and switch from
x86emu to this new module.

This changeset also brings a fix for bugs introduced with the initial
x86emu commit, which prevents the user from using some display mode or
cause instant reboots during mode switch.

Submitted by: paradox <ddkprog yahoo com>


# afb9e5cf 18-Sep-2009 Jung-uk Kim <jkim@FreeBSD.org>

Change cache attribute for VESA frame buffer from UC to write-combining.
This improves scrolling speed for high resolution graphics mode console.


# ee5e90da 09-Sep-2009 Xin LI <delphij@FreeBSD.org>

- Teach vesa(4) and dpms(4) about x86emu. [1]
- Add vesa kernel options for amd64.
- Connect libvgl library and splash kernel modules to amd64 build.
- Connect manual page dpms(4) to amd64 build.
- Remove old vesa/dpms files.

Submitted by: paradox <ddkprog yahoo com> [1], swell k at gmail.com
(with some minor tweaks)


# f45c063a 09-Sep-2009 Xin LI <delphij@FreeBSD.org>

Copy the following files to new places, a subsequent commit would remove
them from the old place. This commit necessary so that the tree would not
enter a broken state.

sys/i386/isa/vesa.c -> dev/fb/vesa.c
sys/i386/include/pc/vesa.h -> dev/fb/vesa.h
sys/i386/isa/dpms.c -> dev/dpms/dpms.c