Commit Graph

304 Commits

Author SHA1 Message Date
Ed Maste
185aba2dcf vt: add three more cp437 mappings for vga textmode
In UTF-8 locales mandoc uses a number of characters outside of the Basic
Latin group, e.g. from general punctuation or miscellaneous mathematical
symbols, and these rendered as ? in text mode.

This change adds (char, replacement, code point, description):

    – - U+2013 En Dash
    ⟨ < U+27E8 Mathematical Left Angle Bracket
    ⟩ > U+27E9 Mathematical Right Angle Bracket

This change addresses some common cases; there are others that still
need to be added after a more thorough review.

PR:		227409
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2018-04-12 02:10:01 +00:00
Brooks Davis
6469bdcdb6 Move most of the contents of opt_compat.h to opt_global.h.
opt_compat.h is mentioned in nearly 180 files. In-progress network
driver compabibility improvements may add over 100 more so this is
closer to "just about everywhere" than "only some files" per the
guidance in sys/conf/options.

Keep COMPAT_LINUX32 in opt_compat.h as it is confined to a subset of
sys/compat/linux/*.c.  A fake _COMPAT_LINUX option ensure opt_compat.h
is created on all architectures.

Move COMPAT_LINUXKPI to opt_dontuse.h as it is only used to control the
set of compiled files.

Reviewed by:	kib, cem, jhb, jtl
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D14941
2018-04-06 17:35:35 +00:00
Gordon Tetlow
9f6fffc731 Limit glyph count in vtfont_load to avoid integer overflow.
Invalid font data passed to PIO_VFONT can result in an integer overflow
in glyphsize.  Characters may then be drawn on the console using glyph
map entries that point beyond the end of allocated glyph memory,
resulting in a kernel memory disclosure.

Submitted by:	emaste
Reported by:	Dr. Silvio Cesare of InfoSect
Security:	CVE-2018-6917
Security:	FreeBSD-SA-18:04.vt
Sponsored by:	The FreeBSD Foundation
2018-04-04 05:21:46 +00:00
Roger Pau Monné
c2272faa06 vt_vga: check if VGA is available from ACPI FADT table
On x86 the IA-PC Boot Flags in the FADT can signal whether VGA is
available or not.

Sponsored by:		Citrix systems R&D
Reviewed by:		marcel
Differential revision:	https://reviews.freebsd.org/D14397
2018-03-13 09:38:53 +00:00
Nathan Whitehorn
f9edb09d70 Move the powerpc64 direct map base address from zero to high memory. This
accomplishes a few things:
- Makes NULL an invalid address in the kernel, which is useful for catching
  bugs.
- Lays groundwork for radix-tree translation on POWER9, which requires the
  direct map be at high memory.
- Similarly lays groundwork for a direct map on 64-bit Book-E.

The new base address is chosen as the base of the fourth radix quadrant
(the minimum kernel address in this translation mode) and because all
supported CPUs ignore at least the first two bits of addresses in real
mode, allowing direct-map addresses to be used in real-mode handlers.
This is required by Linux and is part of the architecture standard
starting in POWER ISA 3, so can be relied upon.

Reviewed by:	jhibbits, Breno Leitao
Differential Revision:	D14499
2018-03-07 17:08:07 +00:00
John Baldwin
642ffab5fc Avoid grabbing locks when grabbing the vt(4) console for DDB.
Trying to grab locks during cngrab() when entering the debugger is
deadlock prone as all other CPUs are already halted (and thus unable
to release locks) when cngrab() is invoked.  One could instead use
try-locks.  However, the case that the try-lock fails still has to
be handled.  In addition, if the try-lock works it doesn't provide
any greater ordering guarantees than is already provided by entering
and exiting DDB.  It is simpler to define a simpler path for the
case that the try-lock would fail and always use that when entering
DDB.  Messing with timers, etc. when entering DDB is dubious even if
the try-lock succeeds.

This patch attempts to use the smallest possible set of operations to
grab the vt(4) console when entering DDB without using any locks.

Reviewed by:	emaste
Tested by:	Matthew Macy
MFC after:	1 week
2018-02-22 02:26:29 +00:00
Oleksandr Tymoshenko
de87887b78 Fix GCC build broken by r32744
Indicate in function declaration that vt_palette_init does not take any arguments
2017-12-31 23:40:06 +00:00
Oleksandr Tymoshenko
c127b9f9d1 Unbreak build broken by r327444
During review iterations function signature has changed in definition
but not in actual call. Fix call to match the definition.

Reported by:	Herbert J. Skuhra
Pointyhat to: gonzo
MFC after:	2 weeks
2017-12-31 21:29:20 +00:00
Oleksandr Tymoshenko
29f61a2f42 vt(4): add support for configurable console palette
Introduce new set of loader tunables kern.vt.color.N.rgb, where N is a
number from 0 to 15. The value is either comma-separated list decimal
numbers ranging from 0 to 255 that represent values of red, green, and
blue components respectively (i.e. "128,128,128") or 6-digit hex triplet
commonly used to represent colors in HTML or xterm settings (i.e. #808080)

Each tunable overrides one of the 16 hardcoded palette codes and can be set
in loader.conf(5)

Reviewed by:	bcr(docs), jilles, manu, ray
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D13645
2017-12-31 20:21:05 +00:00
Nathan Whitehorn
223d42a4de Check more aggressively for whether the desired properties actually exist.
If they don't, the code would look up some random part of the device tree
and seize the console inappropriately.

MFC after:	2 weeks
2017-12-30 20:23:14 +00:00
Justin Hibbits
823cdec7bb Allow custom overrides of mmap attribute for VT framebuffer
Summary:
As in /dev/fb, allow the framebuffer driver to override the default memattr for
mmap(2).  This is analogous to the change in 306555.

Reviewed By: ray
Differential Revision: https://reviews.freebsd.org/D13331
2017-12-06 02:06:14 +00:00
Ed Maste
e1734edf76 Implement "vidcontrol -h <history_size>" for vt(4)
PR:		210415
Submitted by:	Siva Mahadevan
Reviewed by:	ray (earlier)
MFC after:	1 month
Relnotes:	yes
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D11814
2017-12-05 22:19:59 +00:00
Pedro F. Giffuni
718cf2ccb9 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.
2017-11-27 14:52:40 +00:00
Hans Petter Selasky
5c4155867a Implement missing KDGETMODE IOCTL in VT.
Obtained from:	Johannes Lundberg <yohanesu75@gmail.com>
Sponsored by:	Mellanox Technologies
MFC after:	1 week
2017-11-11 20:12:48 +00:00
Vladimir Kondratyev
d52d8bce16 sysmouse(4): Fix ums(4)-style T-axis reporting via evdev protocol
- Do not report T-axis wheel events as button presses
- Reverse T-axis to match Linux
- Remove wrong comment. T-axis buttons state should be checked by level not
    by edge to allow continuous wheel tilt reporting

Reviewed by:		gonzo
Approved by:		gonzo (mentor)
MFC after:		2 weeks
Differential Revision:	https://reviews.freebsd.org/D12676
2017-11-01 22:30:36 +00:00
Bruce Evans
15e0c6511a Fix syscons escape sequence for setting the local cursor type. This sequence
was aliased to a vt sequence, causing and fixing various bugs.

For syscons, this restores support for arg 2 which sets blinking block
too forcefully, and restores bugs for arg 0 and 1.  Arg 2 is used for
vs in the cons25 entry in termcap, but I've never noticed an application
that uses this.  The bugs involve replacing local settings by global
ones and need better handling of defaults to fix.

For vt, this requires moving the aliasing code from teken to vt where
it belongs.  This sequences is very important for cons25 compatibility
in vt since it is used by the cons25 termcap entries for ve, vi and
vs.  vt can't properly support vs for either cons25 or xterm since it
doesn't support blinking.  For xterm, the termcap entry for vs asks
for something different using 12;25h instead of 25h.

Rename C25CURS for this to C25LCT and change its description to be closer
to echoing the old comment about it.  CURS is too generic.

Fix missing syscons escape sequence for setting the global cursor shape
(and type).  Only support this in syscons since vt can't emulate anything
in it.
2017-08-18 15:40:40 +00:00
Enji Cooper
e6b01ed73a Use nitems(..) when computing max instead of the longhand version of
the same logic

MFC after:	1 month
2017-06-14 02:28:10 +00:00
Jonathan T. Looney
dd776f4593 With EARLY_AP_STARTUP enabled, we are seeing crashes in softclock_call_cc()
during bootup. Debugging information shows that softclock_call_cc() is
trying to execute the vt_consdev.vd_timer callout, and the callout
structure contains a NULL c_func.

This appears to be due to a race between vt_upgrade() running
callout_reset() and vt_resume_flush_timer() calling callout_schedule().

Fix the race by ensuring that vd_timer_armed is always set before
attempting to (re)schedule the callout.

Discussed with:	emaste
MFC after:	2 weeks
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D9828
2017-06-08 20:47:18 +00:00
Jung-uk Kim
e314be0a8d - Revert r317171. [1]
- Fix overlapping corners and fix an off-by-one bug.

MFC after:	3 days
Requested by:	emaste [1]
2017-05-15 23:12:04 +00:00
Jung-uk Kim
a0f9777dc4 Simplify the code a bit. No functional change. 2017-04-28 16:42:52 +00:00
Jung-uk Kim
0e37dd1fee Fix end coordinate of the drawable area of border. Although the name tr_end
suggests it is the end coordinate, tr_end.tp_row is width and tr_end.tp_col
is height of the drawable area in reality.

PR:		202288
2017-04-28 16:39:09 +00:00
Jung-uk Kim
2696ce471c Revert r316796. It is not necessary since r317173. 2017-04-19 22:43:11 +00:00
Jung-uk Kim
b249b33322 Always clear borders when the terminal is flushed.
PR:		202288
2017-04-19 22:41:24 +00:00
Jung-uk Kim
5971d9cf1c Micro-optimize vt_set_border(). 2017-04-19 22:21:15 +00:00
Jung-uk Kim
bae56e46c4 Attempt to clear logos more thoroughly.
PR:		202288
Reviewed by:	cem
2017-04-13 23:00:26 +00:00
Bruce Evans
4eb235fb4f Fix bright colors for syscons, and make them work for the first time
for vt.  Restore syscons' rendering of background (bg) brightness as
foreground (fg) blinking and vice versa, and add rendering of blinking
as background brightness to vt.

Bright/saturated is conflated with light/white in the implementation
and in this description.

Bright colors were broken in all cases, but appeared to work in the
only case shown by "vidcontrol show".  A boldness hack was applied
only in 1 layering-violation place (for some syscons sequences) where
it made some cases seem to work but was undone by clearing bold using
ANSI sequences, and more seriously was not undone when setting
ANSI/xterm dark colors so left them bright.  Move this hack to drivers.

The boldness hack is only for fg brightness.  Restore/add a similar hack
for bg brightness rendered as fg blinking and vice versa.  This works
even better for vt, since vt changes the default text mode to give the
more useful bg brightness instead of fg blinking.

The brightness bit in colors was unnecessarily removed by the boldness
hack.  In other cases, it was lost later by teken_256to8().  Use
teken_256to16() to not lose it.  teken_256to8() was intended to be
used for bg colors to allow finer or bg-specific control for the more
difficult reduction to 8; however, since 16 bg colors actually work
on VGA except in syscons text mode and the conversion isn't subtle
enough to significantly in that mode, teken_256to8() is not used now.

There are still bugs, especially in vidcontrol, if bright/blinking
background colors are set.

Restore XOR logic for bold/bright fg in syscons (don't change OR
logic for vt).  Remove broken ifdef on FG_UNDERLINE and its wrong
or missing bit and restore the correct hard-coded bit.  FG_UNDERLINE
is only for mono mode which is not really supported.

Restore XOR logic for blinking/bright bg in syscons (in vt, add
OR logic and render as bright bg).  Remove related broken ifdef
on BG_BLINKING and its missing bit and restore the correct
hard-coded bit.  The same bit means blinking or bright bg depending
on the mode, and we want to ignore the difference everywhere.

Simplify conversions of attributes in syscons.  Don't pretend to
support bold fonts.  Don't support unusual encodings of brightness.
It is as good as possible to map 16 VGA colors to 16 xterm-16
colors.  E.g., VGA brown -> xterm-16 Olive will be converted back
to VGA brown, so we don't need to convert to xterm-256 Brown.  Teken
cons25 compatibility code already does the same, and duplicates some
small tables.  This is mostly for the sc -> te direction.  The other
direction uses teken_256to16() which is too generic.
2017-03-18 11:13:54 +00:00
Ravi Pokala
07a4559495 Un-break vt(4) for {powerpc,powerpc64,sparc64} LINT kernel builds
The {powerpc,powerpc64,sparc64} LINT kernel builds fail with this error:

    sys/dev/vt/vt_buf.c:198: warning: 'vtbuf_htw' defined but not used

Move vtbuf_htw() inside the '#if SC_NO_CUTPASTE' block where it belongs, and
put it in the proper order.

This fixes the immedate issue w/ vt(4), but all three then fail on different
issues.

Reviewed by:	emaste
2017-02-15 17:33:03 +00:00
Aleksandr Rybalko
c0e295def7 o Reset mouse selection when new lines reach selection lines.
o Fix how selection handled on display.

Submitted by:	hselasky
Reviewed by:	hselasky, emaste(previous version)
Todo:		track mouse select direction.
2017-02-10 13:28:30 +00:00
Oleksandr Tymoshenko
4af79d4f2b [evdev] Adds evdev support to sysmouse(4) driver
For horizontal (T-axis) wheel reporting which is not supported by
sysmouse protocol kern.evdev.sysmouse_t_axis sysctl is introduced.
It can take following values:

0 - no T-axis events (default)
1 - T-axis events are originated in ums(4) driver.
2 - T-axis events are originated in psm(4) driver.

Submitted by:	Vladimir Kondratiev <wulf@cicgroup.ru>
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D8597
2016-12-10 18:07:16 +00:00
Ed Maste
1982043961 vt: fix old keyboard release in CONS_SETKBD
On the first switch we previously released the newly allocated keyboard
instead of the old one. Keyboard state was very confused afterwards for
further keyboard switches.

Submitted by:	bde
2016-08-18 16:22:40 +00:00
Ed Maste
8ee0bdb9fb vt: lock Giant around kbd calls in CONS_GETINFO
Note that keyboards are stored in an array and are not freed (just
"unregistered" by clearing some fields) so a race would be limited to
obtaining stale information about an unregistered keyboard.

Reported by:	CTurt
MFC after:	3 days
2016-07-26 15:34:26 +00:00
Conrad Meyer
f41bde667c Increase vt(4) framebuffer maximum size
And rename "DEFAULT" constants to the more accurate "MAX."

PR:		210382
Submitted by:	Felix <felixphew0 at gmail.com>
Reviewed by:	wblock, cem
Tested by:	Dave Cottlehuber <dch at skunkwerks.at>
2016-07-19 19:20:47 +00:00
Pedro F. Giffuni
4ed3c0e713 sys: Make use of our rounddown() macro when sys/param.h is available.
No functional change.
2016-04-30 14:41:18 +00:00
Pedro F. Giffuni
057b4402bf sys/dev: extend use of the howmany() macro when available.
We have a howmany() macro in the <sys/param.h> header that is
convenient to re-use as it makes things easier to read.
2016-04-26 15:03:15 +00:00
Pedro F. Giffuni
d9c9c81c08 sys: use our roundup2/rounddown2() macros when param.h is available.
rounddown2 tends to produce longer lines than the original code
and when the code has a high indentation level it was not really
advantageous to do the replacement.

This tries to strike a balance between readability using the macros
and flexibility of having the expressions, so not everything is
converted.
2016-04-21 19:57:40 +00:00
Pedro F. Giffuni
74b8d63dcc Cleanup unnecessary semicolons from the kernel.
Found with devel/coccinelle.
2016-04-10 23:07:00 +00:00
Sepherosa Ziehau
9a4a2c61df vt: Use textmode when we're running on hypervisors
The graphic mode is noticeably slow on hypervisors, especially
on Hyper-V (1 second to each line).

Submitted by:	Dexuan Cui <decui microsoft com>
Reviewed by:	kib, sephe, royger (early loader version)
MFC after:	1 week
Sponsored by:	Microsoft OSTC
Differential Revision:	https://reviews.freebsd.org/D5739
2016-03-28 07:36:54 +00:00
Svatopluk Kraus
b352b10400 As <machine/vm.h> is included from <vm/vm.h>, there is no need to
include it explicitly when <vm/vm.h> is already included.

Reviewed by:	alc, kib
Differential Revision:	https://reviews.freebsd.org/D5380
2016-02-22 09:10:23 +00:00
Svatopluk Kraus
a1e1814d76 As <machine/pmap.h> is included from <vm/pmap.h>, there is no need to
include it explicitly when <vm/pmap.h> is already included.

Reviewed by:	alc, kib
Differential Revision:	https://reviews.freebsd.org/D5373
2016-02-22 09:02:20 +00:00
Andrew Turner
45fd186285 Allow callers of OF_decode_addr to get the size of the found mapping. This
will allow for code that uses the old fdt_get_range and fdt_regsize
functions to find a range, map it, access, then unmap to replace this, up
to and including the map, with a call to OF_decode_addr.

As this function should only be used in the early boot code the unmap is
mostly do document we no longer need the mapping as it's a no-op, at least
on arm.

Reviewed by:	jhibbits
Sponsored by:	ABT Systems Ltd
Differential Revision:	https://reviews.freebsd.org/D5258
2016-02-16 15:18:12 +00:00
Nathan Whitehorn
bb0455d7dd Make graphical consoles work under PowerKVM. Without using hypercalls, it is
not possible to write the framebuffer before pmap is up. Solve this by
deferring initialization until that happens, like on PS3.

MFC after:	1 week
2016-01-09 21:28:56 +00:00
Conrad Meyer
15d449a5ad vt_cpulogos: Resize all terms/windows when tearing down logos
PR:		202288 (partial)
Tested by:	Jakob Alvermark
Reviewed by:	ed
Approved by:	markj (mentor)
Sponsored by:	EMC / Isilon Storage Division
Differential Revision:	https://reviews.freebsd.org/D3388
2015-08-21 15:21:56 +00:00
Marcel Moolenaar
ec6b1f6acc Support frame buffers that are larger than the default screen
size as defined by VT_FB_DEFAULT_WIDTH and VT_FB_DEFAULT_HEIGHT
(at this time 2048x1200). The default is really a max. We cap
the height and width to those defaults and position the screen
in the center of the frame buffer.

Ideally we use a bigger font to utility the entire real estate
that is the frame buffer, but that's seen as an improvement over
making it work first.

PR:		193745
2015-08-18 00:47:02 +00:00
Marcel Moolenaar
296a51148d Improve support for Macs that have a stride not equal to the
horizonal resolution (width). In those cases fb_bpp ended up
completely wrong -- as in 6 bytes per pixel or something like
that. Since we already have a way to calculate fb_depth given
the masks and fb_bpp is effectively the same as fb_depth, all
we need to do is make sure fb_bpp is rounded to the next
multiple of the number of bits in a byte -- we assume we can
divide by the number of bits in a byte throughout vt(4).
While here:
-   simplify how we calculate fb_depth.
-   use fb_bpp instead of fb_depth to calculate fb_stride;
    we know we can divide fb_bpp.
-   don't limit fb_width and fb_height by VT_FB_DEFAULT_WIDTH
    and VT_FB_DEFAULT_HEIGHT (resp.). Those constants have
    not relation to the size of the frame buffer.

This at least fixes "lower-resolution" Macs. We're talking
1280x1024 or so. There still is a problem with 27" Macs,
which typically have a horizontal resolution over 2K.

PR:		193745 (partial)
Ok'd by:	emaste@
2015-08-15 16:13:28 +00:00
Marcel Moolenaar
8bd2e88e36 Improve the VT initialization message: have it say what the
resolution is. For text mode this is the number of columns
by the number of rows. Include the name of the driver in a
much less prominent way.
2015-08-15 15:44:09 +00:00
Marcel Moolenaar
6280434f9a Fix text mode operation.
We first map 64KB at 0xA0000 and then determine whether to work
in text or graphics mode.  When graphics mode, the mapping is
precisely what we need and everything is fine.  But text mode,
has the frame buffer relocated to 0xB8000. We didn't map that
much to safely add 0x18000 bytes to the base address.

Now we first check whether to work in text or graphics mode and
then map the frame buffer at the right address and with the
right size (0xA0000+64KB for graphics, 0xB8000+32KB for text).

PR:		202276
Tested by:	ed@
2015-08-13 14:43:11 +00:00
Marcel Moolenaar
7ef5e8bc80 Better support memory mapped console devices, such as VGA and EFI
frame buffers and memory mapped UARTs.

1.  Delay calling cninit() until after pmap_bootstrap(). This makes
    sure we have PMAP initialized enough to add translations. Keep
    kdb_init() after cninit() so that we have console when we need
    to break into the debugger on boot.
2.  Unfortunately, the ATPIC code had be moved as well so as to
    avoid a spurious trap #30. The reason for which is not known
    at this time.
3.  In pmap_mapdev_attr(), when we need to map a device prior to the
    VM system being initialized, use virtual_avail as the KVA to map
    the device at. In particular, avoid using the direct map on amd64
    because we can't demote by virtue of not being able to allocate
    yet. Keep track of the translation.
    Re-use the translation after the VM has been initialized to not
    waste KVA and to satisfy the assumption in uart(4) that the handle
    returned for the low-level console is the same as later returned
    when the device is probed and attached.
4.  In pmap_unmapdev() remove the mapping from the table when called
    pre-init. Otherwise keep the mapping. During bus probe and attach
    device resources are mapped and unmapped multiple times, which
    would have us destroy the mapping used by the low-level console.
5.  In pmap_init(), set pmap_initialized to signal that we're not
    pre-init anymore. On amd64, bring the direct map in sync with the
    translations created at that time.
6.  Implement bus_space_map() and bus_space_unmap() for real: when
    the tag corresponds to memory space, call the corresponding
    pmap_mapdev() and pmap_unmapdev() functions to construct and
    actual handle.
7.  In efifb.c and vt_vga.c, remove the crutches and hacks and simply
    call pmap_mapdev_attr() or bus_space_map() as desired.

Notes:
1.  uart(4) already used bus_space_map() during low-level console
    setup but since serial ports have traditionally been I/O port
    based, the lack of a proper implementation for said function
    was not a problem. It has always supported memory mapped UARTs
    for low-level consoles by setting hw.uart.console accordingly.
2.  The use of the direct map on amd64 without setting caching
    attributes has been a bigger problem than previously thought.
    This change has the fortunate (and unexpected) side-effect of
    fixing various EFI frame buffer problems (though not all).

PR: 191564, 194952

Special thanks to:
1.  XipLink, Inc -- generously donated an Intel Bay Trail E3800
    based eval board (ADLE3800PC).
2.  The FreeBSD Foundation, in particular emaste@ -- for UEFI
    support in general and testing.
3.  Everyone who tested the proposed for PR 191564.
4.  jhb@ and kib@ for being a soundboard and applying a clue bat
    if so needed.
2015-08-12 15:26:32 +00:00
Marius Strobl
d75accb539 - Use __FBSDID().
- Const'ify cons_to_vga_colors.
- Fix line wrapping.

MFC after:	3 days
2015-07-27 14:34:32 +00:00
Marius Strobl
0309276c28 - Nuke dupe $FreeBSD$.
- Fix whitespace.

MFC after:	3 days
2015-07-27 14:03:34 +00:00
Conrad Meyer
6b8c5d92a4 vt: cpu logos: Correct reversed 0/1 beastie descriptions
Differential Revision:	https://reviews.freebsd.org/D3158
Approved by:	markj (mentor)
Obtained from:	Pavel Timofeev
MFC after:	1 week
2015-07-22 23:30:54 +00:00
Conrad Meyer
f39130e75d vt: Change default CPU logo to Orb
Differential Revision:	https://reviews.freebsd.org/D3156
Approved by:	markj (mentor)
MFC after:	1 week
2015-07-22 23:23:12 +00:00
Conrad Meyer
6d2b01fc54 vt: Default to cpu logos off
Apologies, this was how it was supposed to land. Mea culpa.

Differential Revision:	https://reviews.freebsd.org/D3157
Reviewed by:	gnn, hiren
Approved by:	markj (mentor)
MFC after:	1 week
2015-07-22 23:19:53 +00:00
Conrad Meyer
8ef2f53c59 vt_core.c: Use do/while to highlight missed semi-colon errors
Also, fix some nearby #define whitespace while here.

(Style cleanup for r285794.)

Suggested by:	jmg

Differential Revision:	https://reviews.freebsd.org/D3154
Approved by:	markj (mentor)
MFC after:	1 week
Sponsored by:	EMC / Isilon Storage Division
2015-07-22 18:50:47 +00:00
Conrad Meyer
5f7d6682c5 vt: Unbreak build on no-splash configurations
PR:		201751
Differential Revision:	https://reviews.freebsd.org/D3151
Tested by:	Andrey Fesenko
Approved by:	markj (mentor)
MFC after:	1 week
2015-07-22 15:30:10 +00:00
Conrad Meyer
75ac3a7359 vt: Draw logos per CPU core
This feature is inspired by another Unix-alike OS commonly found on
airplane headrests.

A number of beasties[0] are drawn at top of framebuffer during boot,
based on the number of active SMP CPUs[1]. Console buffer output
continues to scroll in the screen area below beastie(s)[2].

After some time[3] has passed, the beasties are erased leaving the
entire terminal for use.

Includes two 80x80 vga16 beastie graphics and an 80x80 vga16 orb
graphic. (The graphics are RLE compressed to save some space -- 3x 3200
bytes uncompressed, or 4208 compressed.)

[0]: The user may select the style of beastie with

    kern.vt.splash_cpu_style=(0|1|2)

[1]: Or the number may be overridden with tunable kern.vt.splash_ncpu.
[2]: https://www.youtube.com/watch?v=UP2jizfr3_o
[3]: Configurable with kern.vt.splash_cpu_duration (seconds, def. 10).

Differential Revision:	https://reviews.freebsd.org/D2181
Reviewed by:	dumbbell, emaste
Approved by:	markj (mentor)
MFC after:	2 weeks
2015-07-21 20:33:36 +00:00
Conrad Meyer
bcfb2e3dd2 vt: De-static VT_SYSCTL_INT-defined objects
Explicitly mark existing VT_SYSCTL_INTs static. This is in preparation for
D2181.

Reviewed by:	dumbbell, emaste
Approved by:	markj (mentor)
MFC after:	1 week
2015-07-21 20:30:06 +00:00
Mark Murray
d1b06863fb Huge cleanup of random(4) code.
* GENERAL
- Update copyright.
- Make kernel options for RANDOM_YARROW and RANDOM_DUMMY. Set
  neither to ON, which means we want Fortuna
- If there is no 'device random' in the kernel, there will be NO
  random(4) device in the kernel, and the KERN_ARND sysctl will
  return nothing. With RANDOM_DUMMY there will be a random(4) that
  always blocks.
- Repair kern.arandom (KERN_ARND sysctl). The old version went
  through arc4random(9) and was a bit weird.
- Adjust arc4random stirring a bit - the existing code looks a little
  suspect.
- Fix the nasty pre- and post-read overloading by providing explictit
  functions to do these tasks.
- Redo read_random(9) so as to duplicate random(4)'s read internals.
  This makes it a first-class citizen rather than a hack.
- Move stuff out of locked regions when it does not need to be
  there.
- Trim RANDOM_DEBUG printfs. Some are excess to requirement, some
  behind boot verbose.
- Use SYSINIT to sequence the startup.
- Fix init/deinit sysctl stuff.
- Make relevant sysctls also tunables.
- Add different harvesting "styles" to allow for different requirements
  (direct, queue, fast).
- Add harvesting of FFS atime events. This needs to be checked for
  weighing down the FS code.
- Add harvesting of slab allocator events. This needs to be checked for
  weighing down the allocator code.
- Fix the random(9) manpage.
- Loadable modules are not present for now. These will be re-engineered
  when the dust settles.
- Use macros for locks.
- Fix comments.

* src/share/man/...
- Update the man pages.

* src/etc/...
- The startup/shutdown work is done in D2924.

* src/UPDATING
- Add UPDATING announcement.

* src/sys/dev/random/build.sh
- Add copyright.
- Add libz for unit tests.

* src/sys/dev/random/dummy.c
- Remove; no longer needed. Functionality incorporated into randomdev.*.

* live_entropy_sources.c live_entropy_sources.h
- Remove; content moved.
- move content to randomdev.[ch] and optimise.

* src/sys/dev/random/random_adaptors.c src/sys/dev/random/random_adaptors.h
- Remove; plugability is no longer used. Compile-time algorithm
  selection is the way to go.

* src/sys/dev/random/random_harvestq.c src/sys/dev/random/random_harvestq.h
- Add early (re)boot-time randomness caching.

* src/sys/dev/random/randomdev_soft.c src/sys/dev/random/randomdev_soft.h
- Remove; no longer needed.

* src/sys/dev/random/uint128.h
- Provide a fake uint128_t; if a real one ever arrived, we can use
  that instead. All that is needed here is N=0, N++, N==0, and some
  localised trickery is used to manufacture a 128-bit 0ULLL.

* src/sys/dev/random/unit_test.c src/sys/dev/random/unit_test.h
- Improve unit tests; previously the testing human needed clairvoyance;
  now the test will do a basic check of compressibility. Clairvoyant
  talent is still a good idea.
- This is still a long way off a proper unit test.

* src/sys/dev/random/fortuna.c src/sys/dev/random/fortuna.h
- Improve messy union to just uint128_t.
- Remove unneeded 'static struct fortuna_start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
  it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
  functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])

* src/sys/dev/random/yarrow.c src/sys/dev/random/yarrow.h
- Improve messy union to just uint128_t.
- Remove unneeded 'staic struct start_cache'.
- Tighten up up arithmetic.
- Provide a method to allow eternal junk to be introduced; harden
  it against blatant by compress/hashing.
- Assert that locks are held correctly.
- Fix the nasty pre- and post-read overloading by providing explictit
  functions to do these tasks.
- Turn into self-sufficient module (no longer requires randomdev_soft.[ch])
- Fix some magic numbers elsewhere used as FAST and SLOW.

Differential Revision: https://reviews.freebsd.org/D2025
Reviewed by: vsevolod,delphij,rwatson,trasz,jmg
Approved by: so (delphij)
2015-06-30 17:00:45 +00:00
Hans Petter Selasky
b1b7114036 Ensure the result from signed subtraction under modulus does not
become negative.

Submitted by:		Oliver Pinter <oliver.pinter@hardenedbsd.org>
MFC after:		3 days
2015-05-10 17:11:04 +00:00
Hans Petter Selasky
e4a5ee711a The "SYSCTL_INT()" default value is only used for read only SYSCTLs
and is not applicable unless the integer pointer is NULL. Set it to
zero to avoid confusion. While at it remove extra semicolon at the end
of the "VT_SYSCTL_INT()" macro.

MFC after:		1 week
2015-05-08 16:37:40 +00:00
Hans Petter Selasky
4ee69cc712 Prevent switching to NULL or own window in the "vt_proc_window_switch"
function. This fixes an issue where X11 keyboard input can appear
stuck. The cause of the problem is a duplicate TTY device window
switch IOCTL during boot, which leaves the "vt_switch_timer" running,
because the current window is already selected. While at it factor out
some NULL checks.

PR:			200032
Differential Revision:	https://reviews.freebsd.org/D2480
Reported by:		several people
MFC after:		1 week
Reviewed by:		emaste
2015-05-08 16:19:01 +00:00
Ed Maste
2c48063b30 vt: fix vt_fb_bitblt_bitmap mask corruption
Previously the mask wrapped when one or more of the mask bytes extended
past the right edge of the window. Simplify the logic and use the same
byte offset and bit in both the pattern and mask.

PR:		199648
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D2360
2015-04-29 20:30:11 +00:00
Roger Pau Monné
f0e31fe074 vt_vga: add a timeout while waiting for vertical retrace
On one of my systems FreeBSD will fail to boot because vt_vga gets stuck
waiting for the vertical retrace if there's no monitor attached. Fix this by
adding a timeout and exiting if the vertical retrace times out.

Sponsored by: Citrix Systems R&D
Reviewed by: emaste, dumbbell
Differential Revision: https://reviews.freebsd.org/D2397
2015-04-29 12:53:41 +00:00
Ed Maste
382abd8c81 vt(4): Simplify mouse area detection
vt_is_cursor_in_area needs to return true if any part of the mouse
cursor is visible in the rectangle area. Replace the existing test with
a simpler version of a test for overlapping rectangles.

Differential Revision:	https://reviews.freebsd.org/D2356
Reviewed by:	ray
Sponsored by:	The FreeBSD Foundation
2015-04-24 17:36:26 +00:00
Ed Maste
a04eaf906b Increase vt font limits to allow use of GNU Unifont
PR:		199438
Submitted by:	Ting-Wei Lan <lantw44@gmail.com>
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
2015-04-14 19:18:34 +00:00
Nathan Whitehorn
25023a8a88 Let unchangeable 8-bit frame buffers have vaguely correct colors.
MFC after:	2 weeks
2015-03-10 17:04:11 +00:00
Hans Petter Selasky
a985ae9b4a Add support for USB display link adapters to the FB and VT drivers.
The vtophys() function is used to get the physical page address for
the virtually allocated frame buffers when a physically continuous
memory area is not available. This change also allows removing the
masking of the FB_FLAG_NOMMAP flag in the PS3 syscons driver.

The FB and VT drivers were tested using X.org/xf86-video-scfb and
syscons.
2015-03-07 20:45:15 +00:00
Jean-Sébastien Pédron
76e2f97656 vt(4): Add support to "downgrade" from eg. vt_fb to vt_vga
The main purpose of this feature is to be able to unload a KMS driver.

When going back from the current vt(4) backend to the previous backend,
the previous backend is reinitialized with the special VDF_DOWNGRADE
flag set. Then the current driver is terminated with the new "vd_fini"
callback.

In the case of vt_fb and vt_vga, this allows the former to pass the
vgapci device vt_fb used to vt_vga so the device can be rePOSTed.

Differential Revision:	https://reviews.freebsd.org/D687
2015-03-01 12:54:22 +00:00
Andriy Gapon
7116636e6b vt: move suspend/resume event handlers registration outside of mutex scope
This is to avoid a witness warning about a waiting memory allocation in
the evnt hanlder registration code.

Reported by:	markj
MFC after:	3 days
X-MFC with:	r277795
2015-02-16 13:02:00 +00:00
Alexey Dokuchaev
4182ffcf3e Improve vt(4) default mouse pointer image. Previous one looked rather ugly,
especially on native monitor resolutions.  This one essentially matches X11
default pointer.

Differential Revision:	https://reviews.freebsd.org/D1801
No objection from:	emaste
Approved by:		adrian, dumbbell
2015-02-13 13:55:38 +00:00
Rui Paulo
bae1c14d6b vtvga: improve the device description. 2015-02-05 19:36:29 +00:00
Xin LI
9049b13f8f Use unsigned int for index value.
Without this change a local attacker could trigger a panic by
tricking the kernel into accessing undefined kernel memory.

We would like to acknowledge Francisco Falcon from CORE Security
Technologies who discovered the issue and reported to the
FreeBSD Security Team.

More information can be found at CORE Security's advisory at:
http://www.coresecurity.com/content/freebsd-kernel-multiple-vulnerabilities

This is an errata candidate for releng/10.1 and releng/9.3.  Earlier
releases are not affected.

Reported by:	Francisco Falcon from CORE Security Technologies
Security:	CVE-2014-0998
Reviewed by:	dumbbell
MFC after:	3 days
2015-01-27 19:35:41 +00:00
Andriy Gapon
85f95fffd7 hook userland threads suspend + resume into acpi suspend code
Also, split power_suspend into power_suspend and power_suspend_early.

power_suspend_early is called before the userland is frozen.
power_suspend is called after the userland is frozen.

Currently only VT switching is hooked to power_suspend_early.
This is needed because switching away from X server requires its
cooperation, so obviously X server must not be frozen when that happens.

Freezing userland during ACPI suspend is useful because not all drivers
correctly handle suspension concurrent with other activity.  This is
especially applicable to drivers ported from other operating systems
that suspend all software activity between placing drivers and hardware
into suspended state.
In particular drm2/radeon (radeonkms) depends on the described
procedure.  The driver does not have any internal synchronization
between suspension activities and processing of userland requests.

Many thanks to kib for the code that allows to freeze and thaw all
userland threads.

Note that ideally we also need to park / inhibit (non-special) kernel
threads as well to ensure that they do not call into drivers.

MFC after:	17 days
2015-01-27 17:33:18 +00:00
Andriy Gapon
6dfa4578d6 vt(4): Use power_{suspend,resume} event handlers to implement
suspend/resume

The goal is to avoid that the vt(4) resume happens before the video
display is resumed. The original patch was provided by Andriy Gapon.

This new patch registers the handlers in vt_upgrade(). This is done
once, thanks to the VDF_ASYNC flag. I abused this flag because it was
already abused by the keyboard allocation. The event handlers then call
the backend if it provides callbacks for suspend/resume.

Differential Revision:	https://reviews.freebsd.org/D1004
On behalf of:	dumbbell
MFC after:	2 weeks
2015-01-27 15:28:46 +00:00
Nathan Whitehorn
f1d2752f31 Make PS3 work with the userspace kboot loader. loader.ps3 will disappear
from the tree in the near future.

Done at:	Hackathon
2015-01-05 00:50:16 +00:00
Hans Petter Selasky
110cd60a28 The "vt_suspend_flush_timer()" function is sometimes called locked
which prevents us from doing a "callout_drain()" call. The callout in
question has a lock associated with it and we are not freeing the
callout. That means we can use the "callout_stop()" function to
atomically stop the callback iff the "callout_stop()" function is
called locked. This patch applies proper locking to "callout_stop()"
and replaces a "callout_drain()" with a "callout_stop()".

MFC after:    1 week
2015-01-02 13:35:10 +00:00
Roger Pau Monné
bc59086c88 vt_vga: fix an off-by-one error
This correctly sets the end of the memory region registered by vt_vga.

Reported by:	marius
2014-12-30 08:50:50 +00:00
Roger Pau Monné
3761128490 Partially revert "vt: register the memory regions used by the vt drivers"
Revert the EFI part of r276064 until I can test it properly on a real EFI
system. This was causing problems to people booting using UEFI and vt.

Reported by:	O. Hartmann <ohartman@zedat.fu-berlin.de>
2014-12-30 08:50:07 +00:00
Ed Maste
a09a539f06 Support ALT_BREAK_TO_DEBUGGER in vt(4)
Submitted by:	Andre Albsmeier on -hackers
2014-12-27 04:21:24 +00:00
Roger Pau Monné
acb332a8a1 vt: register the memory regions used by the vt drivers
Current VT drivers don't register the memory regions they use with the
nexus. This patch makes vt_vga and vt_efifb register the memory regions they
use.

This is needed (at least) for Xen support, since the FreeBSD kernel will try
to use the holes in the memory map to map memory from other domains and
setup it's grant table.

Sponsored by:		Citrix Systems R&D
Reported by:		sbruno
Tested by:		emaste
Reviewed by:		ray
PR:			195537
Differential Revision:	https://reviews.freebsd.org/D1291
2014-12-22 16:46:07 +00:00
Jean-Sébastien Pédron
0d265707aa vt(4): Support syscons' SC_HISTORY_SIZE to configure history size
Therefore, to set histry size to 2000 lines, add the following line to
your kernel configuration file:
    options SC_HISTORY_SIZE=2000

The default history remains at 500 lines.

MFC after:	1 week
2014-11-04 23:51:35 +00:00
Jean-Sébastien Pédron
9fc2d29ead vt(4): Fix keyboard allocation when kbdmux(4) isn't used
The problem was that only the kbdmux keyboard index was saved in
vd->vd_keyboard. This index is -1 when kbdmux isn't used. In this
case, the keyboard was correctly allocated, but the returned index was
discarded.

PR:		194718
MFC after:	1 week
2014-11-02 16:04:48 +00:00
Jean-Sébastien Pédron
da49f6bcc3 vt(4): Adjust the cursor position after changing the window size
A new terminal_set_cursor() is added: it wraps the existing
teken_set_cursor() function.

In vtbuf_grow(), the cursor position is adjusted at the end of the
function. In vt_change_font(), we call terminal_set_cursor() just after
terminal_set_winsize_blank(), while the terminal is mute.

This fixes a bug where, after loading a kernel video driver which
increases the terminal window size, the cursor remains at its old
position, in other words, in the middle of the display content.

PR:		194421
MFC after:	1 week
2014-11-01 17:05:15 +00:00
Jean-Sébastien Pédron
069f1c256a vt(4): Add PIO_VFONT_DEFAULT ioctl to restore the default builtin font
To restore the default font using vidcontrol(1), use the "-f" flag
without an argument:
    vidcontrol -f < /dev/ttyv0

PR:		193910
Differential Revision:	https://reviews.freebsd.org/D971
Submitted by:	Marcin Cieslak <saper@saper.info>
Reviewed by:	ray@, emaste@
Approved by:	ray@
MFC after:	1 week
2014-10-23 12:38:05 +00:00
Jean-Sébastien Pédron
2113857ae0 vt(4): Refuse to load a font if hw.vga.textmode is selected
Before, the font was loaded and the window size recalculated, giving an
unusable terminal, even if the actual font didn't change.

Reported by:	beeessdee@ruggedinbox.com
MFC after:	3 days
2014-10-20 14:25:23 +00:00
Ed Maste
0e53ac55b7 Do nothing in vt_upgrade if there is no vt driver
Previously, if no drivers attached at boot we would panic with
"vtbuf_fill_locked begin.tp_row 0 must be < screen height 0".

PR:		192248
Reviewed by:	ray
MFC after:	3 days
Sponsored by:	DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D954
2014-10-17 13:55:45 +00:00
Aleksandr Rybalko
c32f462f28 Allow vt(4) to disable terminal bell with sysctl kern.vt.bell_enable=0,
similar as syscons(4) do.

Submitted by:	Tiwei Bie <btw@mail.ustc.edu.cn>
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation
2014-10-07 18:47:53 +00:00
Jean-Sébastien Pédron
0d06446812 vt(4): Don't recalculate buffer size if we don't know screen size
When the screen size is unknown, it's set to 0x0. We can't use that as
the buffer size, otherwise, functions such as vtbuf_fill() will fail.

This fixes a panic on RaspberryPi, where there's no vt(4) backend
configured early in boot.

PR:		193981
Tested by:	danilo@
MFC after:	3 days
2014-10-04 18:40:40 +00:00
Jean-Sébastien Pédron
61220c0d64 vt(4): Save/restore keyboard mode & LED states when switching window
Add new functions to manipulate these mode & state, instead of calling
kbdd_ioctl() everyhere.

This fixes at least two bugs:

    1. The state of the Scroll Lock LED and the state of scroll mode
       could be out-of-sync. For instance, if one enables scroll mode on
       window #1 and switches to window #2, the LED would remain on, but
       the window wouldn't be in scroll mode.

       Similarily, when switching between a console and an X.Org
       session, the LED states could be inconsistent with the real
       state.

    2. When exiting from an X.Org session, the user could be unable to
       type anything. The workaround was to switch to another console
       window and come back.

Differential Revision:	https://reviews.freebsd.org/D821
Reviewed by:	ray@
Approved by:	ray@
Tested by:	kwm@
MFC after:	3 days
2014-10-02 16:36:37 +00:00
Bjoern A. Zeeb
a10068fdf5 Make gcc happy by initialising the variable only set in a couple of
case statements without a default.

MFC after:	2 days
X-MFC with:	r271871
2014-09-20 08:18:48 +00:00
Jean-Sébastien Pédron
09d058d153 vt(4): Remove superfluous word in comment
Submitted by:	brueffer@
MFC after:	3 days
MFC with:	271871
2014-09-19 12:38:43 +00:00
Jean-Sébastien Pédron
1454439c13 vt(4): Rewrite history scrolling
It's now possible to scroll up the 500 hard-coded lines of history, not
just a fraction of them. For instance, one can reach the top of the boot
process.

Sometimes, when scrolling or when changing the screen size (by changing
the font or loading a KMS driver for instance), one could see the
history cycling (old content appeared below latest lines). This is
fixed.

Now, when the resolution changes are more lines can be shown, the
displayed area is adjusted so that, if the screen was filled with
content before, it's filled with content after as well: more history
is visible, instead of having blank lines below the previously visible
content.

MFC after:	3 days
2014-09-19 12:20:43 +00:00
Jean-Sébastien Pédron
c3a05e5422 vt(4): Remove vt_buf->vb_dirtymask
This structure and the associated functions were unused since the
implementation of vd_bitblt_text_t callbacks.

MFC after:	3 days
2014-09-19 11:02:44 +00:00
Jean-Sébastien Pédron
18b21af2d2 vt(4): Use strncpy() to copy into a fixed-size buffer
CID:		1230007
MFC after:	3 days
2014-09-18 13:24:06 +00:00
Jean-Sébastien Pédron
46867de5dd vt(4): Fix out-of-bounds array access in VT_ACTIVATE ioctl handling
CID:		1229964
MFC after:	3 days
2014-09-18 12:20:19 +00:00
Jean-Sébastien Pédron
1365d0770d vt(4): Use vt_fb_drawrect() and vt_fb_setpixel() in all vt_fb-derivative
Review:		https://reviews.freebsd.org/D789
Reviewed by:	nwhitehorn
Approved by:	nwhitehorn
MFC after:	2 days
2014-09-16 18:02:24 +00:00
Jean-Sébastien Pédron
1952f0b519 vt(4): Fix a LOR which occurs during a call to vt_upgrade()
Reported by:	kib@
Review:		https://reviews.freebsd.org/D785
Reviewed by:	ray@
Approved by:	ray@
MFC after:	2 days
2014-09-16 17:42:37 +00:00
Jean-Sébastien Pédron
87684766b0 vt(4): Enclose vt_mouse_paste() prototype inside #ifndef SC_NO_CUTPASTE/#endif
This fixes the build with sparc64 LINT for instance.

Reported by:	bz@
MFC after:	3 days
2014-09-13 09:33:37 +00:00
Aleksandr Rybalko
673279c59b Fix 'function declaration isn't a prototype' warning.
Pointed by:	ian
MFC after:	1 week
2014-09-12 20:55:17 +00:00
Aleksandr Rybalko
44f751a21e Fix stray char on paste.
Tested by:	dumbbell and me
MFC after:	1 week
2014-09-12 14:17:09 +00:00
Aleksandr Rybalko
4f4b93ae98 Switch vt(4) to traditional behaviour with copy-paste same as syscons(4) do.
(forgetted in last commit)

Reviewed by:	dumbbell (as D755)
MFC after:	1 week
2014-09-12 14:16:10 +00:00