History log of /freebsd-current/sys/dev/vt/hw/ofwfb/ofwfb.c
Revision Date Author Comments
# fdafd315 24-Nov-2023 Warner Losh <imp@FreeBSD.org>

sys: Automated cleanup of cdefs and other formatting

Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by: Netflix


# 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


# b9f3b63a 25-Nov-2021 Leandro Lupori <luporl@FreeBSD.org>

vt: export RGB offsets with FBIO_GETRGBOFFS

Add a new ioctl to vt to make it possible to export RGB offsets
set by vt drivers. This is needed to fix colors on X and Mesa
on some machines, especially on modern PowerPC64 BE ones.

With the appropriate changes in SCFB, to use this ioctl to find
out the correct RGB offsets, this fixes wrong colors on Talos II
and Blackbird, when used with their built-in video cards.

Reviewed by: alfredo
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D29000


# b042d10c 03-Nov-2021 Alfredo Dal'Ava Junior <alfredo@FreeBSD.org>

ofwfb: fix vga/hdmi console with ASMEDIA during boot on powerpc64(le)

On recent OpenBMC firmware, the onboard ASMEDIA video card framebuffer
address was removed from device tree for security purposes (value is set
to zero to avoid leaking the address).

This patch works around the problem by taking framebuffer base address
from the "ranges" property of a parent node.

Reviewed by: luporl, jhibbits (on IRC)
MFC after: 2 weeks
Sponsored by: Instituto de Pesquisas Eldorado (eldorado.org.br)
Differential Revision: https://reviews.freebsd.org/D30626


# 043577b7 08-Mar-2021 Leandro Lupori <luporl@FreeBSD.org>

ofwfb: fix boot on LE

Some framebuffer properties obtained from the device tree were not being
properly converted to host endian.
Replace OF_getprop calls by OF_getencprop where needed to fix this.

This fixes boot on PowerPC64 LE, when using ofwfb as the system console.

Reviewed by: bdragon
Sponsored by: Eldorado Research Institute (eldorado.org.br)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D27475


# 50b7c1f5 18-Feb-2021 Alfredo Dal'Ava Junior <alfredo@FreeBSD.org>

ofwfb: fix incorrect colors on powerpc* and add new tunable parameters

- Implements little-endian support (powerpc64le)
- Adds 'hw.ofwfb.physaddr' kernel parameter so user can manually
provide correct address if it's not detected correctly
- Adds 'hw.ofwfb.argb32_pixel' so user can set it manually if
colors are inverted due to incorrect pixel format (default = 1)
- Automatically selects RGBA32 pixel format if NVidia graphic adapter
is detected (sets hw.ofwfb.argb32_pixel=0)

Machines equipped with NVidia graphic adapters tend to use RGBA32
pixel format. By default ARGB32 pixel format is used, proved to work
on machines equipped with ATI graphic adapter and the onboard adapter
used on Talos II and Blackbird machines from Raptor Computing Systems.

Original patch developed by bdragon

Reviewed by: bdragon, luporl
MFC after: 3 days
Relnotes: yes
Differential Revision: https://reviews.freebsd.org/D28604


# d276d86e 01-Sep-2020 Mateusz Guzik <mjg@FreeBSD.org>

vt: clean up empty lines in .c and .h files


# a7435285 03-Feb-2020 Warner Losh <imp@FreeBSD.org>

Fix a stray 'e'from my last commit.


# 58aa35d4 03-Feb-2020 Warner Losh <imp@FreeBSD.org>

Remove sparc64 kernel support

Remove all sparc64 specific files
Remove all sparc64 ifdefs
Removee indireeect sparc64 ifdefs


# 35f29427 09-Dec-2019 Leandro Lupori <luporl@FreeBSD.org>

Enable use of ofwcons for early debug

This change enables the use of OpenFirmware Console (ofwcons), even when VGA is
available, allowing early kernel messages to be seen, that is important in case
of crashes before VGA console initialization.

This is specially useful in virtualized environments, where the user/developer
doesn't have full control of the virtualization engine (e.g. OpenStack).

The old behavior is preserved by default and, in order to use ofwcons, a few
tunables that have been introduced need to be set:
- hw.ofwfb.disable=1 - disable OFW FrameBuffer device
- machdep.ofw.mtx_spin=1 - change PPC OFW mutex to SPIN type, to match kernel
console's mutex type
- debug.quiesce_ofw=0 - don't call OFW quiesce, needed to keep ofwcons I/O
working

More details can be found at differential revision D20640.

Reviewed by: jhibbits
Differential Revision: https://reviews.freebsd.org/D20640


# 529f0e6c 20-Jul-2018 Justin Hibbits <jhibbits@FreeBSD.org>

vt/ofwfb: Fix brain-o from r336514, use the correct form of /chosen/stdout-path

/chosen/stdout-path is a string, not ihandle. Treat it as such.

With this, ofwfb now starts correctly on a POWER9 system when launched from
the local console (not serial).


# 2cc27fc0 20-Jul-2018 Justin Hibbits <jhibbits@FreeBSD.org>

vt/ofwfb: Check that /chosen/stdout is valid before using it in initialization

The FDT implementation of OF_instance_to_package() backend checks the
cross-reference to get the node. On failure, this returns the input handle
unchanged. In the case of ofwfb attachment, if /chosen/stdout property does not
exist, sc->sc_handle is either garbage or 0, which then gets propagated to node.
This will prevent "screen" from being used, resulting in not properly attaching.
Correct this by matching the code in ofwfb_probe().


# 1dbd2e8c 19-Jul-2018 Justin Hibbits <jhibbits@FreeBSD.org>

ofwfb: Check for /chosen/stdout-path in addition to /chosen/stdout

Some platforms use /chosen/stdout-path as the property containing the path to
the stdout node, not /chosen/stdout.


# 452a74bf 29-May-2018 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

If linebytes property is missing from the graphics device, assume no
overscan and synthesize it from the display depth and screen width.
This may not be right, but it sometimes right and is better than
returning CN_DEAD.


# 4f75b930 19-May-2018 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Avoid writing to the frame buffer in early boot on PowerPC if the CPU's
MMU is disabled.

This expands some earlier logic and avoids a number of potential problems:
1. The CPU may not be able to access the framebuffer in real mode (real
mode does not necessarily encompass all available memory, especially
under a hypervisor).
2. Real mode accesses generally assume cacheability, so it might not
even have worked.
3. The difference in cacheability between real mode and later (and
potentially earlier) points in the boot with the MMU on may cause
ERAT parity problems, resulting in a machine check.

This fixes real-mode (usefdt=1) early boot on the G5 iMac, which was
previously broken as a result of issue #3. Late boot will require some
other fixups.


# c9a1264c 16-May-2018 Ed Maste <emaste@FreeBSD.org>

Clean up vt source whitespace issues


# f9edb09d 07-Mar-2018 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

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


# 223d42a4 30-Dec-2017 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

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


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


# 45fd1862 16-Feb-2016 Andrew Turner <andrew@FreeBSD.org>

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


# bb0455d7 09-Jan-2016 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

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


# 25023a8a 10-Mar-2015 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Let unchangeable 8-bit frame buffers have vaguely correct colors.

MFC after: 2 weeks


# 2204db86 12-Sep-2014 Aleksandr Rybalko <ray@FreeBSD.org>

Remove stray whitespaces.


# 84d623c6 27-Aug-2014 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

vt(4): Fix mouse cursor handling in vt_fb/creator_vt/ofwfb

There were two issues:
1. The area given to vt_is_cursor_in_area() was adding the drawable
area offset, something already handled by this function.
2. The cursor was shifted on the screen by the offset of this area
and thus was misplaced or not erased. Furthermore, when reaching
the bottom or right borders, the cursor was either totally
removed or not erased correctly.

MFC after: 1 week


# 83fbb296 25-Aug-2014 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

vt(4): Store a rectangle for the drawable area, not just the top-left corner

This allows backends to verify they do not draw outside of this area.
This fixes a bug in vt_vga where the text was happily drawn over the
right and bottom margins, when using the Gallant font.

MFC after: 1 week


# 631bb572 23-Aug-2014 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

vt(4): Add vd_bitblt_bmp_t callback

The code was already there in all backends, we just expose it. This is
used to display the splash screen.

MFC after: 1 week


# 5a7d2743 23-Aug-2014 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

ofwfb: Implement vd_bitblt_text_t

MFC after: 1 week


# 19e2ce2d 10-Aug-2014 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>

vt(4): Colors are indexed against a console palette, not a VGA palette

Rename vt_generate_vga_palette() to vt_generate_cons_palette() and
change it to build a palette where the color index is the same than in
terminal escape codes, not the VGA index. That's what TCHAR_CREATE()
uses and passes to vt(4).

The main differences between both orders are:
o Blue and red are swapped (1 <-> 4)
o Yellow and cyan are swapped (3 <-> 6)

The problem remained unnoticed, because the RGB bit indexes passed to
vt_generate_vga_palette() were reversed. This inversion was cancelled
by the colors inversions in the generated palette. For instance, red
(0xff0000) and blue (0x0000ff) have bytes in opposite order, but were
swapped in the palette. But after changing the value of blue (see last
paragraph), the modified color was in fact the red one.

This commit includes a fix to creator_vt.c, submitted by Nathan
Whitehorn: fb_cmsize is set to 16. Before this, the generated palette
would be overwritte. This fixes colors on sparc64 with a Creator3D
adapter.

While here, tune the palette to better match console colors and improve
the readability (especially the dark blue).

Submitted by: nwhitehorn (fix to creator_vt.c)
MFC after: 1 week


# 0f3ec4da 07-Aug-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Retire vd_maskbitbltchr. The same functionality can be obtained by testing
for mask != NULL in vd_bitbltchr, which all implementations of vd_bitbltchr()
were doing anyway.


# f051baa0 06-Aug-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Set fb_pbase properly on PowerPC in the case where we have to guess at
the right register bank for the framebuffer. Disable the assigned-addresses
path on SPARC since it is just a hack for IBM PPC systems and was neither
relevant for nor worked on SPARC anyway.


# 9ed297c8 05-Aug-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Retire various intertwined bits of fbd(4) and vt_fb, in particular the
pixel modification indirection. No actual drivers use it and those that
might (e.g. creatorfb) use custom implementations of vd_bitbltchr().


# 232490c6 29-Jul-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Make mmap() of the console device when using ofwfb work like other supported
framebuffer drivers. This lets ofwfb work with xf86-video-scfb and makes
the driver much more generic and less PCI-centric. This changes some
user-visible behavior and will require updates to the xorg-server port
on PowerPC when using ATI graphics cards.


# 00cf40b0 06-Jul-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Use common vt_fb parts in ofwfb as far as we are able without sacrificing
performance.

MFC after: 2 weeks


# 0ee4b22d 10-May-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Port over mmap routine from syscons. This lets X11 work on PowerPC with vt.
The last obstacle to switching PowerPC entirely to vt is that the Playstation 3
framebuffer driver needs to be ported over. This only applies for powerpc64,
however.


# 015ac42e 10-May-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Make ofwfb not be painfully slow. This reduces the time for a verbose boot
on my G4 iBook by more than half. Still 10% slower than syscons, but that's
much better than a factor of 2.

The slowness had to do with pathological write performance on 8-bit
framebuffers, which are almost universally used on Open Firmware systems.
Writing 1 byte at a time, potentially nonconsecutively, resulted in many
extra PCI write cycles. This patch, in the common case where it's writing
one or several characters in an 8x8 font, gangs the writes together into
a set of 32-bit writes. This is a port of r143830 to vt(4).

The EFI framebuffer is also extremely slow, probably for the same reason,
and the same patch will likely help there.


# bdf49e39 10-May-2014 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Make ofwfb actually work again. Apparently the API it was written against
still exists but is now silently ignored by the VT core. At least xboxfb
needs similar changes.


# ac7073a9 05-May-2014 Aleksandr Rybalko <ray@FreeBSD.org>

Add vt(4) driver name for ofwfb driver.

Sponsored by: The FreeBSD Foundation


# 17661cc7 29-Jan-2014 Justin Hibbits <jhibbits@FreeBSD.org>

Micro-optimize 8-bit blanking. This is the same as in ofw_syscons.

Reviewed by: ray
MFC after: 1 week


# 27cf7d04 05-Dec-2013 Aleksandr Rybalko <ray@FreeBSD.org>

Merge VT(9) project (a.k.a. newcons).

Reviewed by: nwhitehorn
MFC_to_10_after: re approval

Sponsored by: The FreeBSD Foundation