aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/fb/vesa.c
Commit message (Collapse)AuthorAgeFilesLines
* fb: Check for errors from copyin()Mark Johnston2024-01-121-3/+7
| | | | | | | | 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
* fb: Explicitly handle errors when getting or setting a colour paletteMark Johnston2023-12-271-8/+8
| | | | | | | | | | 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
* sys: Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-161-2/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | 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
* pmap_unmapdev/bios: Accept a pointer instead of a vm_offset_t.John Baldwin2022-09-221-2/+3
| | | | | | | | This matches the return type of pmap_mapdev/bios. Reviewed by: kib, markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D36548
* Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)Pawel Biernacki2020-02-261-1/+2
| | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=358333
* Stop the VESA driver from whining loudly in the dmesg during boot onScott Long2019-11-131-1/+11
| | | | | | | systems that use EFI instead of BIOS. Notes: svn path=/head/; revision=354683
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=326255
* Write-combine framebuffer writes through user-space mappings, if possible.Konstantin Belousov2017-04-201-0/+3
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=317196
* Attempt to determine the modes in which 8-bit wide characters are actuallyBruce Evans2017-04-201-0/+1
| | | | | | | | | | | | | | | | | | | 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.) Notes: svn path=/head/; revision=317190
* Reset the DAC to 6-bit mode before calling the BIOS to set the screenBruce Evans2017-04-021-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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). Notes: svn path=/head/; revision=316396
* Use MTX_SYSINIT for the VESA lock.John Baldwin2016-07-231-17/+3
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=303225
* vesa: fix panic on suspendRoger Pau Monné2016-07-201-2/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=303076
* Fix NULL-dereference panic if VESA reports zero modes.Alexander Motin2016-05-171-1/+2
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=300072
* sys: Make use of our rounddown() macro when sys/param.h is available.Pedro F. Giffuni2016-04-301-1/+1
| | | | | | | No functional change. Notes: svn path=/head/; revision=298848
* sys: use our nitems() macro when param.h is available.Pedro F. Giffuni2016-04-211-2/+2
| | | | | | | | | This should cover all the remaining cases in the kernel. Discussed in: freebsd-current Notes: svn path=/head/; revision=298431
* Pull in r267961 and r267973 again. Fix for issues reported will follow.Hans Petter Selasky2014-06-281-1/+0
| | | | Notes: svn path=/head/; revision=267992
* Revert r267961, r267973:Glen Barber2014-06-271-0/+1
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=267985
* Extend the meaning of the CTLFLAG_TUN flag to automatically check ifHans Petter Selasky2014-06-271-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=267961
* Reduce diff against stable/9 slightly.Jung-uk Kim2013-08-281-3/+2
| | | | Notes: svn path=/head/; revision=255004
* Do not save/restore video memory if we are not using linear frame buffer.Jung-uk Kim2013-08-281-22/+15
| | | | | | | Note this partially revert r233896. Notes: svn path=/head/; revision=254999
* Make sure to free stale buffer before allocating new one for safety.Jung-uk Kim2013-08-281-2/+6
| | | | Notes: svn path=/head/; revision=254998
* Avoid unnecessary signedness conversion.Jung-uk Kim2013-08-281-3/+3
| | | | Notes: svn path=/head/; revision=254997
* Limit the amount of video memory we map for the driver to the maximum value.Jung-uk Kim2013-03-271-5/+6
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=248799
* Save and restore VGA display memory between suspend and resume.Jung-uk Kim2012-04-041-14/+29
| | | | Notes: svn path=/head/; revision=233896
* Do not copy VESA state buffer if the VBE call has failed for any reason.Jung-uk Kim2012-04-041-2/+2
| | | | | | | Do not unnecessarily clear the state buffer before calling the function. Notes: svn path=/head/; revision=233894
* Do not reuse the previous address when restoring linear frame buffer.Jung-uk Kim2012-03-191-4/+6
| | | | Notes: svn path=/head/; revision=233187
* Save and restore linear frame buffer between suspend and resume.Jung-uk Kim2012-03-171-0/+19
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=233056
* Remove unnecessary static variable initializations and duplicate codes.Jung-uk Kim2012-03-161-52/+42
| | | | | | | Consistently use bcopy(9) over memcpy(9). Notes: svn path=/head/; revision=233054
* Do not unnecessarily clear display memory when switching modes.Jung-uk Kim2012-03-161-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=233042
* If the VBE implementation does not support save/restore function, defer toJung-uk Kim2012-02-231-8/+5
| | | | | | | VGA methods. Unconditionally reset the VESA adapter before restoring state. Notes: svn path=/head/; revision=232069
* Update my copyright date.Jung-uk Kim2012-02-231-1/+1
| | | | Notes: svn path=/head/; revision=232065
* Probe supported states for save/restore function. Some VBE implementationJung-uk Kim2012-02-231-11/+11
| | | | | | | refuses to save/restore states if an unsupported bit is set. Notes: svn path=/head/; revision=232063
* Fix a typo introduced in r231843.Jung-uk Kim2012-02-231-1/+1
| | | | Notes: svn path=/head/; revision=232061
* Set the initial mode for the adapter after executing VESA BIOS POST.Jung-uk Kim2012-02-161-2/+5
| | | | | | | There is no need to set initial mode for BIOS. Notes: svn path=/head/; revision=231843
* Make sure the VESA mode number is between 256 and 511 inclusive.Jung-uk Kim2012-02-161-2/+4
| | | | Notes: svn path=/head/; revision=231842
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.Ed Schouten2011-11-071-1/+1
| | | | | | | | | 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. Notes: svn path=/head/; revision=227309
* Fix segment:offset calculation of interrupt vector for relocated video BIOSJung-uk Kim2010-09-131-8/+6
| | | | | | | | | | 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 Notes: svn path=/head/; revision=212580
* Disable video ROM shadowing by default as I originally intended. I foundJung-uk Kim2010-09-021-2/+2
| | | | | | | | a case where video ROM for an IGP is too tightly coupled with system BIOS to get relocated. Notes: svn path=/head/; revision=212154
* Make sure the interrupt entry point is within the video ROM range. We mustJung-uk Kim2010-08-311-9/+15
| | | | | | | | | | | 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. Notes: svn path=/head/; revision=212070
* Fix a debugging message under bootverbose. This address is not linear.Jung-uk Kim2010-08-251-1/+1
| | | | Notes: svn path=/head/; revision=211829
* Add an experimental feature to shadow video BIOS. Long ago, this trick wasJung-uk Kim2010-08-251-10/+57
| | | | | | | | | | | | | 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. Notes: svn path=/head/; revision=211827
* Protect shared palette and state buffer with a mutex. Remove defunctJung-uk Kim2010-08-071-14/+27
| | | | | | | spltty() calls while I am here. Notes: svn path=/head/; revision=210994
* Initialize a variable before its use.Jung-uk Kim2010-07-131-1/+1
| | | | Notes: svn path=/head/; revision=210017
* Preallocate buffers for palette and state. Do not save DAC registers asJung-uk Kim2010-07-131-83/+58
| | | | | | | we reset DAC mode and restore palette data while we are resuming always. Notes: svn path=/head/; revision=210016
* Plug a possible memory leak.Jung-uk Kim2010-07-061-1/+1
| | | | | | | Submitted by: Yamagi Burmeister (lists at yamagi dot org) Notes: svn path=/head/; revision=209740
* Fix a possible null pointer dereference. A patch for -STABLE wasJung-uk Kim2010-07-061-0/+2
| | | | | | | Submitted by: Yamagi Burmeister (lists at yamagi dot org) Notes: svn path=/head/; revision=209737
* Use M_WAITOK for VESA BIOS initialization consistently.Jung-uk Kim2010-06-231-5/+5
| | | | Notes: svn path=/head/; revision=209491
* Let x86bios_alloc() pass contigmalloc(9) flags. Use it to set M_WAITOKJung-uk Kim2010-06-231-9/+7
| | | | | | | | from VESA BIOS initialization. All other malloc(9) uses in the function is blocking any way. Notes: svn path=/head/; revision=209472
* Restore the previous VESA mode after BIOS POST, just in case.Jung-uk Kim2010-05-181-0/+1
| | | | Notes: svn path=/head/; revision=208279