Commit Graph

251 Commits

Author SHA1 Message Date
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