History log of /openbsd-current/sys/arch/macppc/pci/vgafb.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.65 13-Apr-2023 miod

Remove intentionally undocumented pci_{io,mem}_find and convert their last
few users to pci_mapreg_info().

ok jsg@


Revision tags: OPENBSD_7_3_BASE
# 1.64 31-Dec-2022 gkoehler

Look for the first 2 mem regions, ignore the rest

Some macppc nvidia graphics cards have a 3rd mem region, but nv(4)
wants to mmap the 1st and 2nd regions.

ok miod@


Revision tags: OPENBSD_7_2_BASE
# 1.63 15-Jul-2022 kettenis

Implement support for framebuffers that don't start on a page boundary.
This happens on the new 14" and 16" Macbook Pro where we deliberately use
a framebuffer that skips the first few lines to avoid "the notch".
The offset of the first pixel is added to struct wsdisplay_fbinfo. The
stride is added as well, mirroring the value returned by the
WSDISPLAYIO_LINEBYTES ioctl, such that we can retire that one in the
future. A compat ioctl is implemented to help the transition. The compat
code will be removed after OpenBSD 7.3 has been released.

ok miod@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.62 25-May-2020 jsg

change wsdisplay attribute type from long to uint32_t

miod explained it was initially a long as it was thought drivers may
need to allocate storage but in practice they don't need more than
32 bits for an attribute.

suggested and reviewed by miod@


# 1.61 25-May-2020 jsg

rename wsdisplay alloc_attr() to pack_attr()

Suggested by John Carmack. miod agrees a rename would make sense and
explained it was initially thought drivers may need to allocate storage
but in practice they don't need more than 32 bits for an attribute.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.60 28-Jul-2014 jsg

Limit the "aperture needed" printf to ramdisks via RAMDISK_HOOKS.
Originally with SMALL_KERNEL until sebastia@ pointed out that not
all ramdisks are built with SMALL_KERNEL.
ok deraadt@ kettenis@


# 1.59 22-Jul-2014 jsg

The aperture needed test should be in vgafb as well as vga@pci.
Problem noticed/fix tested by sebastia@ on macppc.
sparc64 problems in earlier diff pointed out by deraadt@
'looks good' kettenis@ 'commit' deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.58 21-Oct-2013 miod

Add load_font and list_font accessops to all rasops-based wsdisplay drivers.
Trivial except for tga(4) and gpx(4/vax) which need a bit more care setting
up a new font.


# 1.57 20-Oct-2013 miod

Use C99 named initializers for struct wsdisplay_accessops fields.
No functional change.


# 1.56 04-Sep-2013 mpi

Convert vgafb to use a proper softc.


# 1.55 28-Aug-2013 mpi

Move the early framebuffer initialization code outside of vgafb(4)
and introduce a function to get the cursor position an unmap the
stolen memory region when switching to the real framebuffer.

For the moment we still reuse the original region but this allows
me to move forward and it buys us the posibility to have an early
framebuffer without vgafb (i.e. radeondrm(4) only).


# 1.54 27-Aug-2013 mpi

Since we are no longer attaching radeondrm(4) to this driver there is
no reason to pretend being compatible with the MI vga layer. So stop
using the vga_pci_bar interface and reduce the differences with the
sparc64 driver.


# 1.53 23-Aug-2013 mpi

Move the openfirmware color selection code outside of vgafb(4) to
be able to configure an early console framebuffer without depending
on this driver


# 1.52 17-Aug-2013 mpi

Because vgafb(4) only match the console, no need for an additional check
when setting up multiple screens and don't clear the screen again at this
moment.


# 1.51 17-Aug-2013 mpi

Merge vgafb_init() into vgafb_cnattach() now that it is not used anywhere
else and pass the RI_FULLCLEAR flag to rasops_init() instead of clearing
the region directly. This also makes the console to be correctly restored
when exiting X. Previously a line at the bottom of the screen was never
cleared.


# 1.50 16-Aug-2013 kettenis

Use mapiodev instead of bus_space_map the do the initial mapping of the
frame buffer. This allows radeondrm(4) to bus_space_map it without panicking.

ok mpi@, jsg@


# 1.49 12-Aug-2013 mpi

Match the framebuffer device against its OpenFirmware node in order
to share the console detection logic with sparc64 in radeondrm(4).

ok miod@


Revision tags: OPENBSD_5_4_BASE
# 1.48 06-Jul-2013 mpi

Use the write-only rasops code to speed up the console framebuffer.

ok kettenis@


# 1.47 04-Jun-2013 mpi

Add support for virtual consoles, based on previous work done by kettenis@
for inteldrm(4).

ok miod@, kettenis@


# 1.46 04-Jun-2013 mpi

Remove unused includes, constify cfattach and other small cleanings.


# 1.45 04-Jun-2013 mpi

Move function declaration where they belong.


# 1.44 04-Jun-2013 mpi

Do not pretend mapping the MMIO region when in fact we don't and
clean some related code.


# 1.43 04-Jun-2013 mpi

Spacing.


# 1.42 03-Jun-2013 mpi

There's no reason to have a separate structure to hold and duplicate
the raster display data. Simplify this by using only one pointer to
a struct rasops_info, the one in vga_config.

While here remove unused fields from vga_config.


Revision tags: OPENBSD_5_3_BASE
# 1.41 30-Aug-2012 mpi

Determine the memory and mmio regions based on previously initialzed BAR
structures and add the necessary glue to attach drm(4).

ok kettenis@


Revision tags: OPENBSD_5_2_BASE
# 1.40 21-Jun-2012 mpi

Only allow the memory and mmio regions to be mmap()'ed at their real
addresses, remove the magic value to uniformize access to the mmio and
doesn't map the unused pseudo-vga registers.

While here simplify the console attachement logic and removed some
unused global variables. Tested by matthieu@ and myself on various
different G3 and G4 models.

ok kettenis@


Revision tags: OPENBSD_5_1_BASE
# 1.39 29-Jan-2012 mpi

Start cleaning vgafb(4) to be make it more like vga(4). Remove unused
function and move vgafb functions to there right place.

ok miod@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.38 27-Nov-2010 miod

Remove unused vgafb_cnprobe().


# 1.37 01-Sep-2010 miod

Fix typo in vgafb_mmap(), causing a comparison to always fail. ok kettenis@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 29-Mar-2009 sthen

make various strings ("can't map mem space" and similar) more consistent
between instances, saving space in the kernel. feedback from many (some
incorporated, some left for future work).

ok deraadt, kettenis, "why not" miod.


Revision tags: OPENBSD_4_5_BASE
# 1.35 23-Sep-2008 miod

Plug more uninitialized variables.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 23-Jan-2008 jsing

Cleanup cn_pri. Change constants to more meaningful names, rather than
the hp300 related ones currently in use. CN_NORMAL becomes CN_LOWPRI,
CN_INTERNAL becomes CN_MIDPRI and CN_REMOTE becomes CN_HIGHPRI.

ok miod@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.33 17-Dec-2006 miod

Remove unnecessary <dev/wscons/wscons_raster.h> inclusion.


# 1.32 29-Nov-2006 miod

Add a new member to struct wsemuldisplaydev_attach_args, for a frame buffer
driver to be able to tell how many wscons screens to attach to it,
instead of WSDISPLAY_DEFAULTSCREENS which is a global setting.


Revision tags: OPENBSD_4_0_BASE
# 1.31 30-May-2006 matthieu

The aperture that is needed in legacy vga space is even larger for
the mac mini's ATI graphics card. The full 0xa0000-0xfffff range is
used here.


# 1.30 02-May-2006 matthieu

The r128 driver also need the 0xb0000-0xc0000 address range. found by Jolan@.


# 1.29 28-Apr-2006 matthieu

In mapped mode, when allowaperture != 0,also allow mmapping of the
PC-style 0xa0000-0xb0000 region, as the nv X driver uses it.
Noticed and patch tested by xsa@ and aanriot@.


# 1.28 09-Apr-2006 matthieu

On macppc and sparc64, if allowaperture=0 only allow mmap()-ing of
the framebuffer memory in WSDISPLAYIO_MODE_DUMBFB mode.


Revision tags: OPENBSD_3_9_BASE
# 1.27 01-Jan-2006 miod

Let cons_init() and cons_init_bell() initialize the whole consdev structure,
thus removing the need for drivers to initialize cn_pri to CN_DEAD when
hardware probe fails.


# 1.26 26-Oct-2005 martin

Mach-macro wipeout

'do it' deraadt@


# 1.25 08-Oct-2005 drahn

Disable caching on vga buffer on 64bit machines. currently it causes
hangs.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.24 05-Jan-2005 miod

Let wsdisplay drivers return zero for WSDISPLAYIO_[GS]VIDEO ioctls - most
of the work is done in the upper layer, but they get to see the ioctl,
so don't always return an error.


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 17-Mar-2004 drahn

Better backlight detection on macppc, ok miod@ krw@ (a bit ago)


# 1.22 24-Oct-2003 drahn

If cons_backlight_available is not set, cons_brightness will not be valid,
return -1 to indicate so. same as WSDISPLAYIO_PARAM_BACKLIGHT.


# 1.21 15-Oct-2003 drahn

Further down the ANSI/KNF road, only binary difference is __LINE__.


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.20 09-Nov-2002 miod

Instead of relying on uvm_useracc(), get a false sense of security, and
do not check copyin() result, take care and properly handle copyin() failure.

This was not harmful, but a bit more correctness never harms.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 15-Sep-2002 deraadt

backout premature


# 1.18 15-Sep-2002 deraadt

KNF


# 1.17 06-Sep-2002 drahn

wscons display should have a console priority of INTERNAL, not REMOTE.
ok miod@


# 1.16 02-Aug-2002 millert

Do correct bounds checking in get/set/put cmap routines. A few of
these check were already OK but have been modified for consistency.
Problem found by Silvio Cesare.


# 1.15 21-Jul-2002 drahn

cleanup, mostly 'if 0'ed code removal.


# 1.14 27-Jun-2002 drahn

Do not muck with the color palette unless the console depth is 8 bit.
32 bit depth console and wsfb now work (If firmware is forced to that depth).


# 1.13 22-May-2002 miod

- in the OpenFirmware console initialisation, check if the console device
has support for backlight control (laptops do, and probably machines with
a built-in monitor do as well).
- provide a function to set the screen brightness as well.
- use both changes above to add a screen blanker to the vgafb driver
- let the screen brightness and backlight be controlled via wsconsctl
- clean dust, KNF, and more symbolic names in the vgafb driver to make it
better readable

Initial code by myself, with some hacks from drahn@ later.


# 1.12 18-May-2002 drahn

Workaround for color restoration on return from X. vgafb will not
reset the color palette to it's default colors when going back to text mode.
Would be better to fix this in the X server. ok matthieu@


# 1.11 29-Apr-2002 drahn

Better colors from rasops cmap, and enable all rasops features.
ok miod, mattheiu


# 1.10 29-Apr-2002 drahn

Change macppc vgafb from rcons to rasops, a faster color supporting virtual
terminal emulator for gfx console. tested by mattheiu, miod.


# 1.9 20-Apr-2002 matthieu

- the set-colors OF call takes a packed array of colors value,
remove the extra padding byte in the vgafb_color struct.
- store the initial colormap in vc->vc_cmap_{red,green,blue} so that
it can be fetched by a WSDISPLAYIO_GETCMAP ioctl
- fix the definition of the magenta color in the initial colormap.
Ok, drahn@


Revision tags: OPENBSD_3_1_BASE
# 1.8 05-Apr-2002 drahn

Use the OF set-colors operation instead of the color! operation, this
interface seems to work on more machines, also is more efficient
when XF4/wsfb is setting the palette. ok deraadt@


# 1.7 26-Mar-2002 drahn

Only allow valid device PAs to be mmapped.


# 1.6 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.5 14-Dec-2001 jason

branches: 1.5.2;
garbage collect some unused stuff.


# 1.4 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.3 17-Sep-2001 drahn

branches: 1.3.4;
The gfx display buffer should request that it be mapped cached (writethru).
Not used yet, but when the bus_space_map code and pmap are fixed,
this will speed up the console.


# 1.2 13-Sep-2001 drahn

The vgafb driver does not test memory, so no point mapping it during the probe.
Also, there is no point in mapping more than the 'visual' area for vga memory.
this will save kvm space on large memory display cards.


# 1.1 01-Sep-2001 drahn

The "powerpc" port which has supported the newer Apple Macintosh powerpc based
is being renamed to macppc. This is to allow sharing of common code
between different powerpc base platforms.

Most of the work involved in the renaming process was performed by miod@

Files moved from powerpc/pci to macppc/pci

The file pci_machdep.h was not moved in this conversion.
It needs to be check if it is correct that should be the only shared
powerpc/pci file. Or if that file too should be MD, or more files MI.


# 1.64 31-Dec-2022 gkoehler

Look for the first 2 mem regions, ignore the rest

Some macppc nvidia graphics cards have a 3rd mem region, but nv(4)
wants to mmap the 1st and 2nd regions.

ok miod@


Revision tags: OPENBSD_7_2_BASE
# 1.63 15-Jul-2022 kettenis

Implement support for framebuffers that don't start on a page boundary.
This happens on the new 14" and 16" Macbook Pro where we deliberately use
a framebuffer that skips the first few lines to avoid "the notch".
The offset of the first pixel is added to struct wsdisplay_fbinfo. The
stride is added as well, mirroring the value returned by the
WSDISPLAYIO_LINEBYTES ioctl, such that we can retire that one in the
future. A compat ioctl is implemented to help the transition. The compat
code will be removed after OpenBSD 7.3 has been released.

ok miod@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.62 25-May-2020 jsg

change wsdisplay attribute type from long to uint32_t

miod explained it was initially a long as it was thought drivers may
need to allocate storage but in practice they don't need more than
32 bits for an attribute.

suggested and reviewed by miod@


# 1.61 25-May-2020 jsg

rename wsdisplay alloc_attr() to pack_attr()

Suggested by John Carmack. miod agrees a rename would make sense and
explained it was initially thought drivers may need to allocate storage
but in practice they don't need more than 32 bits for an attribute.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.60 28-Jul-2014 jsg

Limit the "aperture needed" printf to ramdisks via RAMDISK_HOOKS.
Originally with SMALL_KERNEL until sebastia@ pointed out that not
all ramdisks are built with SMALL_KERNEL.
ok deraadt@ kettenis@


# 1.59 22-Jul-2014 jsg

The aperture needed test should be in vgafb as well as vga@pci.
Problem noticed/fix tested by sebastia@ on macppc.
sparc64 problems in earlier diff pointed out by deraadt@
'looks good' kettenis@ 'commit' deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.58 21-Oct-2013 miod

Add load_font and list_font accessops to all rasops-based wsdisplay drivers.
Trivial except for tga(4) and gpx(4/vax) which need a bit more care setting
up a new font.


# 1.57 20-Oct-2013 miod

Use C99 named initializers for struct wsdisplay_accessops fields.
No functional change.


# 1.56 04-Sep-2013 mpi

Convert vgafb to use a proper softc.


# 1.55 28-Aug-2013 mpi

Move the early framebuffer initialization code outside of vgafb(4)
and introduce a function to get the cursor position an unmap the
stolen memory region when switching to the real framebuffer.

For the moment we still reuse the original region but this allows
me to move forward and it buys us the posibility to have an early
framebuffer without vgafb (i.e. radeondrm(4) only).


# 1.54 27-Aug-2013 mpi

Since we are no longer attaching radeondrm(4) to this driver there is
no reason to pretend being compatible with the MI vga layer. So stop
using the vga_pci_bar interface and reduce the differences with the
sparc64 driver.


# 1.53 23-Aug-2013 mpi

Move the openfirmware color selection code outside of vgafb(4) to
be able to configure an early console framebuffer without depending
on this driver


# 1.52 17-Aug-2013 mpi

Because vgafb(4) only match the console, no need for an additional check
when setting up multiple screens and don't clear the screen again at this
moment.


# 1.51 17-Aug-2013 mpi

Merge vgafb_init() into vgafb_cnattach() now that it is not used anywhere
else and pass the RI_FULLCLEAR flag to rasops_init() instead of clearing
the region directly. This also makes the console to be correctly restored
when exiting X. Previously a line at the bottom of the screen was never
cleared.


# 1.50 16-Aug-2013 kettenis

Use mapiodev instead of bus_space_map the do the initial mapping of the
frame buffer. This allows radeondrm(4) to bus_space_map it without panicking.

ok mpi@, jsg@


# 1.49 12-Aug-2013 mpi

Match the framebuffer device against its OpenFirmware node in order
to share the console detection logic with sparc64 in radeondrm(4).

ok miod@


Revision tags: OPENBSD_5_4_BASE
# 1.48 06-Jul-2013 mpi

Use the write-only rasops code to speed up the console framebuffer.

ok kettenis@


# 1.47 04-Jun-2013 mpi

Add support for virtual consoles, based on previous work done by kettenis@
for inteldrm(4).

ok miod@, kettenis@


# 1.46 04-Jun-2013 mpi

Remove unused includes, constify cfattach and other small cleanings.


# 1.45 04-Jun-2013 mpi

Move function declaration where they belong.


# 1.44 04-Jun-2013 mpi

Do not pretend mapping the MMIO region when in fact we don't and
clean some related code.


# 1.43 04-Jun-2013 mpi

Spacing.


# 1.42 03-Jun-2013 mpi

There's no reason to have a separate structure to hold and duplicate
the raster display data. Simplify this by using only one pointer to
a struct rasops_info, the one in vga_config.

While here remove unused fields from vga_config.


Revision tags: OPENBSD_5_3_BASE
# 1.41 30-Aug-2012 mpi

Determine the memory and mmio regions based on previously initialzed BAR
structures and add the necessary glue to attach drm(4).

ok kettenis@


Revision tags: OPENBSD_5_2_BASE
# 1.40 21-Jun-2012 mpi

Only allow the memory and mmio regions to be mmap()'ed at their real
addresses, remove the magic value to uniformize access to the mmio and
doesn't map the unused pseudo-vga registers.

While here simplify the console attachement logic and removed some
unused global variables. Tested by matthieu@ and myself on various
different G3 and G4 models.

ok kettenis@


Revision tags: OPENBSD_5_1_BASE
# 1.39 29-Jan-2012 mpi

Start cleaning vgafb(4) to be make it more like vga(4). Remove unused
function and move vgafb functions to there right place.

ok miod@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.38 27-Nov-2010 miod

Remove unused vgafb_cnprobe().


# 1.37 01-Sep-2010 miod

Fix typo in vgafb_mmap(), causing a comparison to always fail. ok kettenis@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 29-Mar-2009 sthen

make various strings ("can't map mem space" and similar) more consistent
between instances, saving space in the kernel. feedback from many (some
incorporated, some left for future work).

ok deraadt, kettenis, "why not" miod.


Revision tags: OPENBSD_4_5_BASE
# 1.35 23-Sep-2008 miod

Plug more uninitialized variables.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 23-Jan-2008 jsing

Cleanup cn_pri. Change constants to more meaningful names, rather than
the hp300 related ones currently in use. CN_NORMAL becomes CN_LOWPRI,
CN_INTERNAL becomes CN_MIDPRI and CN_REMOTE becomes CN_HIGHPRI.

ok miod@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.33 17-Dec-2006 miod

Remove unnecessary <dev/wscons/wscons_raster.h> inclusion.


# 1.32 29-Nov-2006 miod

Add a new member to struct wsemuldisplaydev_attach_args, for a frame buffer
driver to be able to tell how many wscons screens to attach to it,
instead of WSDISPLAY_DEFAULTSCREENS which is a global setting.


Revision tags: OPENBSD_4_0_BASE
# 1.31 30-May-2006 matthieu

The aperture that is needed in legacy vga space is even larger for
the mac mini's ATI graphics card. The full 0xa0000-0xfffff range is
used here.


# 1.30 02-May-2006 matthieu

The r128 driver also need the 0xb0000-0xc0000 address range. found by Jolan@.


# 1.29 28-Apr-2006 matthieu

In mapped mode, when allowaperture != 0,also allow mmapping of the
PC-style 0xa0000-0xb0000 region, as the nv X driver uses it.
Noticed and patch tested by xsa@ and aanriot@.


# 1.28 09-Apr-2006 matthieu

On macppc and sparc64, if allowaperture=0 only allow mmap()-ing of
the framebuffer memory in WSDISPLAYIO_MODE_DUMBFB mode.


Revision tags: OPENBSD_3_9_BASE
# 1.27 01-Jan-2006 miod

Let cons_init() and cons_init_bell() initialize the whole consdev structure,
thus removing the need for drivers to initialize cn_pri to CN_DEAD when
hardware probe fails.


# 1.26 26-Oct-2005 martin

Mach-macro wipeout

'do it' deraadt@


# 1.25 08-Oct-2005 drahn

Disable caching on vga buffer on 64bit machines. currently it causes
hangs.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.24 05-Jan-2005 miod

Let wsdisplay drivers return zero for WSDISPLAYIO_[GS]VIDEO ioctls - most
of the work is done in the upper layer, but they get to see the ioctl,
so don't always return an error.


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 17-Mar-2004 drahn

Better backlight detection on macppc, ok miod@ krw@ (a bit ago)


# 1.22 24-Oct-2003 drahn

If cons_backlight_available is not set, cons_brightness will not be valid,
return -1 to indicate so. same as WSDISPLAYIO_PARAM_BACKLIGHT.


# 1.21 15-Oct-2003 drahn

Further down the ANSI/KNF road, only binary difference is __LINE__.


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.20 09-Nov-2002 miod

Instead of relying on uvm_useracc(), get a false sense of security, and
do not check copyin() result, take care and properly handle copyin() failure.

This was not harmful, but a bit more correctness never harms.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 15-Sep-2002 deraadt

backout premature


# 1.18 15-Sep-2002 deraadt

KNF


# 1.17 06-Sep-2002 drahn

wscons display should have a console priority of INTERNAL, not REMOTE.
ok miod@


# 1.16 02-Aug-2002 millert

Do correct bounds checking in get/set/put cmap routines. A few of
these check were already OK but have been modified for consistency.
Problem found by Silvio Cesare.


# 1.15 21-Jul-2002 drahn

cleanup, mostly 'if 0'ed code removal.


# 1.14 27-Jun-2002 drahn

Do not muck with the color palette unless the console depth is 8 bit.
32 bit depth console and wsfb now work (If firmware is forced to that depth).


# 1.13 22-May-2002 miod

- in the OpenFirmware console initialisation, check if the console device
has support for backlight control (laptops do, and probably machines with
a built-in monitor do as well).
- provide a function to set the screen brightness as well.
- use both changes above to add a screen blanker to the vgafb driver
- let the screen brightness and backlight be controlled via wsconsctl
- clean dust, KNF, and more symbolic names in the vgafb driver to make it
better readable

Initial code by myself, with some hacks from drahn@ later.


# 1.12 18-May-2002 drahn

Workaround for color restoration on return from X. vgafb will not
reset the color palette to it's default colors when going back to text mode.
Would be better to fix this in the X server. ok matthieu@


# 1.11 29-Apr-2002 drahn

Better colors from rasops cmap, and enable all rasops features.
ok miod, mattheiu


# 1.10 29-Apr-2002 drahn

Change macppc vgafb from rcons to rasops, a faster color supporting virtual
terminal emulator for gfx console. tested by mattheiu, miod.


# 1.9 20-Apr-2002 matthieu

- the set-colors OF call takes a packed array of colors value,
remove the extra padding byte in the vgafb_color struct.
- store the initial colormap in vc->vc_cmap_{red,green,blue} so that
it can be fetched by a WSDISPLAYIO_GETCMAP ioctl
- fix the definition of the magenta color in the initial colormap.
Ok, drahn@


Revision tags: OPENBSD_3_1_BASE
# 1.8 05-Apr-2002 drahn

Use the OF set-colors operation instead of the color! operation, this
interface seems to work on more machines, also is more efficient
when XF4/wsfb is setting the palette. ok deraadt@


# 1.7 26-Mar-2002 drahn

Only allow valid device PAs to be mmapped.


# 1.6 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.5 14-Dec-2001 jason

branches: 1.5.2;
garbage collect some unused stuff.


# 1.4 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.3 17-Sep-2001 drahn

branches: 1.3.4;
The gfx display buffer should request that it be mapped cached (writethru).
Not used yet, but when the bus_space_map code and pmap are fixed,
this will speed up the console.


# 1.2 13-Sep-2001 drahn

The vgafb driver does not test memory, so no point mapping it during the probe.
Also, there is no point in mapping more than the 'visual' area for vga memory.
this will save kvm space on large memory display cards.


# 1.1 01-Sep-2001 drahn

The "powerpc" port which has supported the newer Apple Macintosh powerpc based
is being renamed to macppc. This is to allow sharing of common code
between different powerpc base platforms.

Most of the work involved in the renaming process was performed by miod@

Files moved from powerpc/pci to macppc/pci

The file pci_machdep.h was not moved in this conversion.
It needs to be check if it is correct that should be the only shared
powerpc/pci file. Or if that file too should be MD, or more files MI.


# 1.63 15-Jul-2022 kettenis

Implement support for framebuffers that don't start on a page boundary.
This happens on the new 14" and 16" Macbook Pro where we deliberately use
a framebuffer that skips the first few lines to avoid "the notch".
The offset of the first pixel is added to struct wsdisplay_fbinfo. The
stride is added as well, mirroring the value returned by the
WSDISPLAYIO_LINEBYTES ioctl, such that we can retire that one in the
future. A compat ioctl is implemented to help the transition. The compat
code will be removed after OpenBSD 7.3 has been released.

ok miod@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.62 25-May-2020 jsg

change wsdisplay attribute type from long to uint32_t

miod explained it was initially a long as it was thought drivers may
need to allocate storage but in practice they don't need more than
32 bits for an attribute.

suggested and reviewed by miod@


# 1.61 25-May-2020 jsg

rename wsdisplay alloc_attr() to pack_attr()

Suggested by John Carmack. miod agrees a rename would make sense and
explained it was initially thought drivers may need to allocate storage
but in practice they don't need more than 32 bits for an attribute.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.60 28-Jul-2014 jsg

Limit the "aperture needed" printf to ramdisks via RAMDISK_HOOKS.
Originally with SMALL_KERNEL until sebastia@ pointed out that not
all ramdisks are built with SMALL_KERNEL.
ok deraadt@ kettenis@


# 1.59 22-Jul-2014 jsg

The aperture needed test should be in vgafb as well as vga@pci.
Problem noticed/fix tested by sebastia@ on macppc.
sparc64 problems in earlier diff pointed out by deraadt@
'looks good' kettenis@ 'commit' deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.58 21-Oct-2013 miod

Add load_font and list_font accessops to all rasops-based wsdisplay drivers.
Trivial except for tga(4) and gpx(4/vax) which need a bit more care setting
up a new font.


# 1.57 20-Oct-2013 miod

Use C99 named initializers for struct wsdisplay_accessops fields.
No functional change.


# 1.56 04-Sep-2013 mpi

Convert vgafb to use a proper softc.


# 1.55 28-Aug-2013 mpi

Move the early framebuffer initialization code outside of vgafb(4)
and introduce a function to get the cursor position an unmap the
stolen memory region when switching to the real framebuffer.

For the moment we still reuse the original region but this allows
me to move forward and it buys us the posibility to have an early
framebuffer without vgafb (i.e. radeondrm(4) only).


# 1.54 27-Aug-2013 mpi

Since we are no longer attaching radeondrm(4) to this driver there is
no reason to pretend being compatible with the MI vga layer. So stop
using the vga_pci_bar interface and reduce the differences with the
sparc64 driver.


# 1.53 23-Aug-2013 mpi

Move the openfirmware color selection code outside of vgafb(4) to
be able to configure an early console framebuffer without depending
on this driver


# 1.52 17-Aug-2013 mpi

Because vgafb(4) only match the console, no need for an additional check
when setting up multiple screens and don't clear the screen again at this
moment.


# 1.51 17-Aug-2013 mpi

Merge vgafb_init() into vgafb_cnattach() now that it is not used anywhere
else and pass the RI_FULLCLEAR flag to rasops_init() instead of clearing
the region directly. This also makes the console to be correctly restored
when exiting X. Previously a line at the bottom of the screen was never
cleared.


# 1.50 16-Aug-2013 kettenis

Use mapiodev instead of bus_space_map the do the initial mapping of the
frame buffer. This allows radeondrm(4) to bus_space_map it without panicking.

ok mpi@, jsg@


# 1.49 12-Aug-2013 mpi

Match the framebuffer device against its OpenFirmware node in order
to share the console detection logic with sparc64 in radeondrm(4).

ok miod@


Revision tags: OPENBSD_5_4_BASE
# 1.48 06-Jul-2013 mpi

Use the write-only rasops code to speed up the console framebuffer.

ok kettenis@


# 1.47 04-Jun-2013 mpi

Add support for virtual consoles, based on previous work done by kettenis@
for inteldrm(4).

ok miod@, kettenis@


# 1.46 04-Jun-2013 mpi

Remove unused includes, constify cfattach and other small cleanings.


# 1.45 04-Jun-2013 mpi

Move function declaration where they belong.


# 1.44 04-Jun-2013 mpi

Do not pretend mapping the MMIO region when in fact we don't and
clean some related code.


# 1.43 04-Jun-2013 mpi

Spacing.


# 1.42 03-Jun-2013 mpi

There's no reason to have a separate structure to hold and duplicate
the raster display data. Simplify this by using only one pointer to
a struct rasops_info, the one in vga_config.

While here remove unused fields from vga_config.


Revision tags: OPENBSD_5_3_BASE
# 1.41 30-Aug-2012 mpi

Determine the memory and mmio regions based on previously initialzed BAR
structures and add the necessary glue to attach drm(4).

ok kettenis@


Revision tags: OPENBSD_5_2_BASE
# 1.40 21-Jun-2012 mpi

Only allow the memory and mmio regions to be mmap()'ed at their real
addresses, remove the magic value to uniformize access to the mmio and
doesn't map the unused pseudo-vga registers.

While here simplify the console attachement logic and removed some
unused global variables. Tested by matthieu@ and myself on various
different G3 and G4 models.

ok kettenis@


Revision tags: OPENBSD_5_1_BASE
# 1.39 29-Jan-2012 mpi

Start cleaning vgafb(4) to be make it more like vga(4). Remove unused
function and move vgafb functions to there right place.

ok miod@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.38 27-Nov-2010 miod

Remove unused vgafb_cnprobe().


# 1.37 01-Sep-2010 miod

Fix typo in vgafb_mmap(), causing a comparison to always fail. ok kettenis@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 29-Mar-2009 sthen

make various strings ("can't map mem space" and similar) more consistent
between instances, saving space in the kernel. feedback from many (some
incorporated, some left for future work).

ok deraadt, kettenis, "why not" miod.


Revision tags: OPENBSD_4_5_BASE
# 1.35 23-Sep-2008 miod

Plug more uninitialized variables.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 23-Jan-2008 jsing

Cleanup cn_pri. Change constants to more meaningful names, rather than
the hp300 related ones currently in use. CN_NORMAL becomes CN_LOWPRI,
CN_INTERNAL becomes CN_MIDPRI and CN_REMOTE becomes CN_HIGHPRI.

ok miod@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.33 17-Dec-2006 miod

Remove unnecessary <dev/wscons/wscons_raster.h> inclusion.


# 1.32 29-Nov-2006 miod

Add a new member to struct wsemuldisplaydev_attach_args, for a frame buffer
driver to be able to tell how many wscons screens to attach to it,
instead of WSDISPLAY_DEFAULTSCREENS which is a global setting.


Revision tags: OPENBSD_4_0_BASE
# 1.31 30-May-2006 matthieu

The aperture that is needed in legacy vga space is even larger for
the mac mini's ATI graphics card. The full 0xa0000-0xfffff range is
used here.


# 1.30 02-May-2006 matthieu

The r128 driver also need the 0xb0000-0xc0000 address range. found by Jolan@.


# 1.29 28-Apr-2006 matthieu

In mapped mode, when allowaperture != 0,also allow mmapping of the
PC-style 0xa0000-0xb0000 region, as the nv X driver uses it.
Noticed and patch tested by xsa@ and aanriot@.


# 1.28 09-Apr-2006 matthieu

On macppc and sparc64, if allowaperture=0 only allow mmap()-ing of
the framebuffer memory in WSDISPLAYIO_MODE_DUMBFB mode.


Revision tags: OPENBSD_3_9_BASE
# 1.27 01-Jan-2006 miod

Let cons_init() and cons_init_bell() initialize the whole consdev structure,
thus removing the need for drivers to initialize cn_pri to CN_DEAD when
hardware probe fails.


# 1.26 26-Oct-2005 martin

Mach-macro wipeout

'do it' deraadt@


# 1.25 08-Oct-2005 drahn

Disable caching on vga buffer on 64bit machines. currently it causes
hangs.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.24 05-Jan-2005 miod

Let wsdisplay drivers return zero for WSDISPLAYIO_[GS]VIDEO ioctls - most
of the work is done in the upper layer, but they get to see the ioctl,
so don't always return an error.


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 17-Mar-2004 drahn

Better backlight detection on macppc, ok miod@ krw@ (a bit ago)


# 1.22 24-Oct-2003 drahn

If cons_backlight_available is not set, cons_brightness will not be valid,
return -1 to indicate so. same as WSDISPLAYIO_PARAM_BACKLIGHT.


# 1.21 15-Oct-2003 drahn

Further down the ANSI/KNF road, only binary difference is __LINE__.


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.20 09-Nov-2002 miod

Instead of relying on uvm_useracc(), get a false sense of security, and
do not check copyin() result, take care and properly handle copyin() failure.

This was not harmful, but a bit more correctness never harms.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 15-Sep-2002 deraadt

backout premature


# 1.18 15-Sep-2002 deraadt

KNF


# 1.17 06-Sep-2002 drahn

wscons display should have a console priority of INTERNAL, not REMOTE.
ok miod@


# 1.16 02-Aug-2002 millert

Do correct bounds checking in get/set/put cmap routines. A few of
these check were already OK but have been modified for consistency.
Problem found by Silvio Cesare.


# 1.15 21-Jul-2002 drahn

cleanup, mostly 'if 0'ed code removal.


# 1.14 27-Jun-2002 drahn

Do not muck with the color palette unless the console depth is 8 bit.
32 bit depth console and wsfb now work (If firmware is forced to that depth).


# 1.13 22-May-2002 miod

- in the OpenFirmware console initialisation, check if the console device
has support for backlight control (laptops do, and probably machines with
a built-in monitor do as well).
- provide a function to set the screen brightness as well.
- use both changes above to add a screen blanker to the vgafb driver
- let the screen brightness and backlight be controlled via wsconsctl
- clean dust, KNF, and more symbolic names in the vgafb driver to make it
better readable

Initial code by myself, with some hacks from drahn@ later.


# 1.12 18-May-2002 drahn

Workaround for color restoration on return from X. vgafb will not
reset the color palette to it's default colors when going back to text mode.
Would be better to fix this in the X server. ok matthieu@


# 1.11 29-Apr-2002 drahn

Better colors from rasops cmap, and enable all rasops features.
ok miod, mattheiu


# 1.10 29-Apr-2002 drahn

Change macppc vgafb from rcons to rasops, a faster color supporting virtual
terminal emulator for gfx console. tested by mattheiu, miod.


# 1.9 20-Apr-2002 matthieu

- the set-colors OF call takes a packed array of colors value,
remove the extra padding byte in the vgafb_color struct.
- store the initial colormap in vc->vc_cmap_{red,green,blue} so that
it can be fetched by a WSDISPLAYIO_GETCMAP ioctl
- fix the definition of the magenta color in the initial colormap.
Ok, drahn@


Revision tags: OPENBSD_3_1_BASE
# 1.8 05-Apr-2002 drahn

Use the OF set-colors operation instead of the color! operation, this
interface seems to work on more machines, also is more efficient
when XF4/wsfb is setting the palette. ok deraadt@


# 1.7 26-Mar-2002 drahn

Only allow valid device PAs to be mmapped.


# 1.6 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.5 14-Dec-2001 jason

branches: 1.5.2;
garbage collect some unused stuff.


# 1.4 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.3 17-Sep-2001 drahn

branches: 1.3.4;
The gfx display buffer should request that it be mapped cached (writethru).
Not used yet, but when the bus_space_map code and pmap are fixed,
this will speed up the console.


# 1.2 13-Sep-2001 drahn

The vgafb driver does not test memory, so no point mapping it during the probe.
Also, there is no point in mapping more than the 'visual' area for vga memory.
this will save kvm space on large memory display cards.


# 1.1 01-Sep-2001 drahn

The "powerpc" port which has supported the newer Apple Macintosh powerpc based
is being renamed to macppc. This is to allow sharing of common code
between different powerpc base platforms.

Most of the work involved in the renaming process was performed by miod@

Files moved from powerpc/pci to macppc/pci

The file pci_machdep.h was not moved in this conversion.
It needs to be check if it is correct that should be the only shared
powerpc/pci file. Or if that file too should be MD, or more files MI.


# 1.62 25-May-2020 jsg

change wsdisplay attribute type from long to uint32_t

miod explained it was initially a long as it was thought drivers may
need to allocate storage but in practice they don't need more than
32 bits for an attribute.

suggested and reviewed by miod@


# 1.61 25-May-2020 jsg

rename wsdisplay alloc_attr() to pack_attr()

Suggested by John Carmack. miod agrees a rename would make sense and
explained it was initially thought drivers may need to allocate storage
but in practice they don't need more than 32 bits for an attribute.

ok mpi@


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.60 28-Jul-2014 jsg

Limit the "aperture needed" printf to ramdisks via RAMDISK_HOOKS.
Originally with SMALL_KERNEL until sebastia@ pointed out that not
all ramdisks are built with SMALL_KERNEL.
ok deraadt@ kettenis@


# 1.59 22-Jul-2014 jsg

The aperture needed test should be in vgafb as well as vga@pci.
Problem noticed/fix tested by sebastia@ on macppc.
sparc64 problems in earlier diff pointed out by deraadt@
'looks good' kettenis@ 'commit' deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.58 21-Oct-2013 miod

Add load_font and list_font accessops to all rasops-based wsdisplay drivers.
Trivial except for tga(4) and gpx(4/vax) which need a bit more care setting
up a new font.


# 1.57 20-Oct-2013 miod

Use C99 named initializers for struct wsdisplay_accessops fields.
No functional change.


# 1.56 04-Sep-2013 mpi

Convert vgafb to use a proper softc.


# 1.55 28-Aug-2013 mpi

Move the early framebuffer initialization code outside of vgafb(4)
and introduce a function to get the cursor position an unmap the
stolen memory region when switching to the real framebuffer.

For the moment we still reuse the original region but this allows
me to move forward and it buys us the posibility to have an early
framebuffer without vgafb (i.e. radeondrm(4) only).


# 1.54 27-Aug-2013 mpi

Since we are no longer attaching radeondrm(4) to this driver there is
no reason to pretend being compatible with the MI vga layer. So stop
using the vga_pci_bar interface and reduce the differences with the
sparc64 driver.


# 1.53 23-Aug-2013 mpi

Move the openfirmware color selection code outside of vgafb(4) to
be able to configure an early console framebuffer without depending
on this driver


# 1.52 17-Aug-2013 mpi

Because vgafb(4) only match the console, no need for an additional check
when setting up multiple screens and don't clear the screen again at this
moment.


# 1.51 17-Aug-2013 mpi

Merge vgafb_init() into vgafb_cnattach() now that it is not used anywhere
else and pass the RI_FULLCLEAR flag to rasops_init() instead of clearing
the region directly. This also makes the console to be correctly restored
when exiting X. Previously a line at the bottom of the screen was never
cleared.


# 1.50 16-Aug-2013 kettenis

Use mapiodev instead of bus_space_map the do the initial mapping of the
frame buffer. This allows radeondrm(4) to bus_space_map it without panicking.

ok mpi@, jsg@


# 1.49 12-Aug-2013 mpi

Match the framebuffer device against its OpenFirmware node in order
to share the console detection logic with sparc64 in radeondrm(4).

ok miod@


Revision tags: OPENBSD_5_4_BASE
# 1.48 06-Jul-2013 mpi

Use the write-only rasops code to speed up the console framebuffer.

ok kettenis@


# 1.47 04-Jun-2013 mpi

Add support for virtual consoles, based on previous work done by kettenis@
for inteldrm(4).

ok miod@, kettenis@


# 1.46 04-Jun-2013 mpi

Remove unused includes, constify cfattach and other small cleanings.


# 1.45 04-Jun-2013 mpi

Move function declaration where they belong.


# 1.44 04-Jun-2013 mpi

Do not pretend mapping the MMIO region when in fact we don't and
clean some related code.


# 1.43 04-Jun-2013 mpi

Spacing.


# 1.42 03-Jun-2013 mpi

There's no reason to have a separate structure to hold and duplicate
the raster display data. Simplify this by using only one pointer to
a struct rasops_info, the one in vga_config.

While here remove unused fields from vga_config.


Revision tags: OPENBSD_5_3_BASE
# 1.41 30-Aug-2012 mpi

Determine the memory and mmio regions based on previously initialzed BAR
structures and add the necessary glue to attach drm(4).

ok kettenis@


Revision tags: OPENBSD_5_2_BASE
# 1.40 21-Jun-2012 mpi

Only allow the memory and mmio regions to be mmap()'ed at their real
addresses, remove the magic value to uniformize access to the mmio and
doesn't map the unused pseudo-vga registers.

While here simplify the console attachement logic and removed some
unused global variables. Tested by matthieu@ and myself on various
different G3 and G4 models.

ok kettenis@


Revision tags: OPENBSD_5_1_BASE
# 1.39 29-Jan-2012 mpi

Start cleaning vgafb(4) to be make it more like vga(4). Remove unused
function and move vgafb functions to there right place.

ok miod@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.38 27-Nov-2010 miod

Remove unused vgafb_cnprobe().


# 1.37 01-Sep-2010 miod

Fix typo in vgafb_mmap(), causing a comparison to always fail. ok kettenis@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 29-Mar-2009 sthen

make various strings ("can't map mem space" and similar) more consistent
between instances, saving space in the kernel. feedback from many (some
incorporated, some left for future work).

ok deraadt, kettenis, "why not" miod.


Revision tags: OPENBSD_4_5_BASE
# 1.35 23-Sep-2008 miod

Plug more uninitialized variables.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 23-Jan-2008 jsing

Cleanup cn_pri. Change constants to more meaningful names, rather than
the hp300 related ones currently in use. CN_NORMAL becomes CN_LOWPRI,
CN_INTERNAL becomes CN_MIDPRI and CN_REMOTE becomes CN_HIGHPRI.

ok miod@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.33 17-Dec-2006 miod

Remove unnecessary <dev/wscons/wscons_raster.h> inclusion.


# 1.32 29-Nov-2006 miod

Add a new member to struct wsemuldisplaydev_attach_args, for a frame buffer
driver to be able to tell how many wscons screens to attach to it,
instead of WSDISPLAY_DEFAULTSCREENS which is a global setting.


Revision tags: OPENBSD_4_0_BASE
# 1.31 30-May-2006 matthieu

The aperture that is needed in legacy vga space is even larger for
the mac mini's ATI graphics card. The full 0xa0000-0xfffff range is
used here.


# 1.30 02-May-2006 matthieu

The r128 driver also need the 0xb0000-0xc0000 address range. found by Jolan@.


# 1.29 28-Apr-2006 matthieu

In mapped mode, when allowaperture != 0,also allow mmapping of the
PC-style 0xa0000-0xb0000 region, as the nv X driver uses it.
Noticed and patch tested by xsa@ and aanriot@.


# 1.28 09-Apr-2006 matthieu

On macppc and sparc64, if allowaperture=0 only allow mmap()-ing of
the framebuffer memory in WSDISPLAYIO_MODE_DUMBFB mode.


Revision tags: OPENBSD_3_9_BASE
# 1.27 01-Jan-2006 miod

Let cons_init() and cons_init_bell() initialize the whole consdev structure,
thus removing the need for drivers to initialize cn_pri to CN_DEAD when
hardware probe fails.


# 1.26 26-Oct-2005 martin

Mach-macro wipeout

'do it' deraadt@


# 1.25 08-Oct-2005 drahn

Disable caching on vga buffer on 64bit machines. currently it causes
hangs.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.24 05-Jan-2005 miod

Let wsdisplay drivers return zero for WSDISPLAYIO_[GS]VIDEO ioctls - most
of the work is done in the upper layer, but they get to see the ioctl,
so don't always return an error.


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 17-Mar-2004 drahn

Better backlight detection on macppc, ok miod@ krw@ (a bit ago)


# 1.22 24-Oct-2003 drahn

If cons_backlight_available is not set, cons_brightness will not be valid,
return -1 to indicate so. same as WSDISPLAYIO_PARAM_BACKLIGHT.


# 1.21 15-Oct-2003 drahn

Further down the ANSI/KNF road, only binary difference is __LINE__.


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.20 09-Nov-2002 miod

Instead of relying on uvm_useracc(), get a false sense of security, and
do not check copyin() result, take care and properly handle copyin() failure.

This was not harmful, but a bit more correctness never harms.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 15-Sep-2002 deraadt

backout premature


# 1.18 15-Sep-2002 deraadt

KNF


# 1.17 06-Sep-2002 drahn

wscons display should have a console priority of INTERNAL, not REMOTE.
ok miod@


# 1.16 02-Aug-2002 millert

Do correct bounds checking in get/set/put cmap routines. A few of
these check were already OK but have been modified for consistency.
Problem found by Silvio Cesare.


# 1.15 21-Jul-2002 drahn

cleanup, mostly 'if 0'ed code removal.


# 1.14 27-Jun-2002 drahn

Do not muck with the color palette unless the console depth is 8 bit.
32 bit depth console and wsfb now work (If firmware is forced to that depth).


# 1.13 22-May-2002 miod

- in the OpenFirmware console initialisation, check if the console device
has support for backlight control (laptops do, and probably machines with
a built-in monitor do as well).
- provide a function to set the screen brightness as well.
- use both changes above to add a screen blanker to the vgafb driver
- let the screen brightness and backlight be controlled via wsconsctl
- clean dust, KNF, and more symbolic names in the vgafb driver to make it
better readable

Initial code by myself, with some hacks from drahn@ later.


# 1.12 18-May-2002 drahn

Workaround for color restoration on return from X. vgafb will not
reset the color palette to it's default colors when going back to text mode.
Would be better to fix this in the X server. ok matthieu@


# 1.11 29-Apr-2002 drahn

Better colors from rasops cmap, and enable all rasops features.
ok miod, mattheiu


# 1.10 29-Apr-2002 drahn

Change macppc vgafb from rcons to rasops, a faster color supporting virtual
terminal emulator for gfx console. tested by mattheiu, miod.


# 1.9 20-Apr-2002 matthieu

- the set-colors OF call takes a packed array of colors value,
remove the extra padding byte in the vgafb_color struct.
- store the initial colormap in vc->vc_cmap_{red,green,blue} so that
it can be fetched by a WSDISPLAYIO_GETCMAP ioctl
- fix the definition of the magenta color in the initial colormap.
Ok, drahn@


Revision tags: OPENBSD_3_1_BASE
# 1.8 05-Apr-2002 drahn

Use the OF set-colors operation instead of the color! operation, this
interface seems to work on more machines, also is more efficient
when XF4/wsfb is setting the palette. ok deraadt@


# 1.7 26-Mar-2002 drahn

Only allow valid device PAs to be mmapped.


# 1.6 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.5 14-Dec-2001 jason

branches: 1.5.2;
garbage collect some unused stuff.


# 1.4 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.3 17-Sep-2001 drahn

branches: 1.3.4;
The gfx display buffer should request that it be mapped cached (writethru).
Not used yet, but when the bus_space_map code and pmap are fixed,
this will speed up the console.


# 1.2 13-Sep-2001 drahn

The vgafb driver does not test memory, so no point mapping it during the probe.
Also, there is no point in mapping more than the 'visual' area for vga memory.
this will save kvm space on large memory display cards.


# 1.1 01-Sep-2001 drahn

The "powerpc" port which has supported the newer Apple Macintosh powerpc based
is being renamed to macppc. This is to allow sharing of common code
between different powerpc base platforms.

Most of the work involved in the renaming process was performed by miod@

Files moved from powerpc/pci to macppc/pci

The file pci_machdep.h was not moved in this conversion.
It needs to be check if it is correct that should be the only shared
powerpc/pci file. Or if that file too should be MD, or more files MI.


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.60 28-Jul-2014 jsg

Limit the "aperture needed" printf to ramdisks via RAMDISK_HOOKS.
Originally with SMALL_KERNEL until sebastia@ pointed out that not
all ramdisks are built with SMALL_KERNEL.
ok deraadt@ kettenis@


# 1.59 22-Jul-2014 jsg

The aperture needed test should be in vgafb as well as vga@pci.
Problem noticed/fix tested by sebastia@ on macppc.
sparc64 problems in earlier diff pointed out by deraadt@
'looks good' kettenis@ 'commit' deraadt@


Revision tags: OPENBSD_5_5_BASE
# 1.58 21-Oct-2013 miod

Add load_font and list_font accessops to all rasops-based wsdisplay drivers.
Trivial except for tga(4) and gpx(4/vax) which need a bit more care setting
up a new font.


# 1.57 20-Oct-2013 miod

Use C99 named initializers for struct wsdisplay_accessops fields.
No functional change.


# 1.56 04-Sep-2013 mpi

Convert vgafb to use a proper softc.


# 1.55 28-Aug-2013 mpi

Move the early framebuffer initialization code outside of vgafb(4)
and introduce a function to get the cursor position an unmap the
stolen memory region when switching to the real framebuffer.

For the moment we still reuse the original region but this allows
me to move forward and it buys us the posibility to have an early
framebuffer without vgafb (i.e. radeondrm(4) only).


# 1.54 27-Aug-2013 mpi

Since we are no longer attaching radeondrm(4) to this driver there is
no reason to pretend being compatible with the MI vga layer. So stop
using the vga_pci_bar interface and reduce the differences with the
sparc64 driver.


# 1.53 23-Aug-2013 mpi

Move the openfirmware color selection code outside of vgafb(4) to
be able to configure an early console framebuffer without depending
on this driver


# 1.52 17-Aug-2013 mpi

Because vgafb(4) only match the console, no need for an additional check
when setting up multiple screens and don't clear the screen again at this
moment.


# 1.51 17-Aug-2013 mpi

Merge vgafb_init() into vgafb_cnattach() now that it is not used anywhere
else and pass the RI_FULLCLEAR flag to rasops_init() instead of clearing
the region directly. This also makes the console to be correctly restored
when exiting X. Previously a line at the bottom of the screen was never
cleared.


# 1.50 16-Aug-2013 kettenis

Use mapiodev instead of bus_space_map the do the initial mapping of the
frame buffer. This allows radeondrm(4) to bus_space_map it without panicking.

ok mpi@, jsg@


# 1.49 12-Aug-2013 mpi

Match the framebuffer device against its OpenFirmware node in order
to share the console detection logic with sparc64 in radeondrm(4).

ok miod@


Revision tags: OPENBSD_5_4_BASE
# 1.48 06-Jul-2013 mpi

Use the write-only rasops code to speed up the console framebuffer.

ok kettenis@


# 1.47 04-Jun-2013 mpi

Add support for virtual consoles, based on previous work done by kettenis@
for inteldrm(4).

ok miod@, kettenis@


# 1.46 04-Jun-2013 mpi

Remove unused includes, constify cfattach and other small cleanings.


# 1.45 04-Jun-2013 mpi

Move function declaration where they belong.


# 1.44 04-Jun-2013 mpi

Do not pretend mapping the MMIO region when in fact we don't and
clean some related code.


# 1.43 04-Jun-2013 mpi

Spacing.


# 1.42 03-Jun-2013 mpi

There's no reason to have a separate structure to hold and duplicate
the raster display data. Simplify this by using only one pointer to
a struct rasops_info, the one in vga_config.

While here remove unused fields from vga_config.


Revision tags: OPENBSD_5_3_BASE
# 1.41 30-Aug-2012 mpi

Determine the memory and mmio regions based on previously initialzed BAR
structures and add the necessary glue to attach drm(4).

ok kettenis@


Revision tags: OPENBSD_5_2_BASE
# 1.40 21-Jun-2012 mpi

Only allow the memory and mmio regions to be mmap()'ed at their real
addresses, remove the magic value to uniformize access to the mmio and
doesn't map the unused pseudo-vga registers.

While here simplify the console attachement logic and removed some
unused global variables. Tested by matthieu@ and myself on various
different G3 and G4 models.

ok kettenis@


Revision tags: OPENBSD_5_1_BASE
# 1.39 29-Jan-2012 mpi

Start cleaning vgafb(4) to be make it more like vga(4). Remove unused
function and move vgafb functions to there right place.

ok miod@


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.38 27-Nov-2010 miod

Remove unused vgafb_cnprobe().


# 1.37 01-Sep-2010 miod

Fix typo in vgafb_mmap(), causing a comparison to always fail. ok kettenis@


Revision tags: OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE
# 1.36 29-Mar-2009 sthen

make various strings ("can't map mem space" and similar) more consistent
between instances, saving space in the kernel. feedback from many (some
incorporated, some left for future work).

ok deraadt, kettenis, "why not" miod.


Revision tags: OPENBSD_4_5_BASE
# 1.35 23-Sep-2008 miod

Plug more uninitialized variables.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.34 23-Jan-2008 jsing

Cleanup cn_pri. Change constants to more meaningful names, rather than
the hp300 related ones currently in use. CN_NORMAL becomes CN_LOWPRI,
CN_INTERNAL becomes CN_MIDPRI and CN_REMOTE becomes CN_HIGHPRI.

ok miod@


Revision tags: OPENBSD_4_1_BASE OPENBSD_4_2_BASE
# 1.33 17-Dec-2006 miod

Remove unnecessary <dev/wscons/wscons_raster.h> inclusion.


# 1.32 29-Nov-2006 miod

Add a new member to struct wsemuldisplaydev_attach_args, for a frame buffer
driver to be able to tell how many wscons screens to attach to it,
instead of WSDISPLAY_DEFAULTSCREENS which is a global setting.


Revision tags: OPENBSD_4_0_BASE
# 1.31 30-May-2006 matthieu

The aperture that is needed in legacy vga space is even larger for
the mac mini's ATI graphics card. The full 0xa0000-0xfffff range is
used here.


# 1.30 02-May-2006 matthieu

The r128 driver also need the 0xb0000-0xc0000 address range. found by Jolan@.


# 1.29 28-Apr-2006 matthieu

In mapped mode, when allowaperture != 0,also allow mmapping of the
PC-style 0xa0000-0xb0000 region, as the nv X driver uses it.
Noticed and patch tested by xsa@ and aanriot@.


# 1.28 09-Apr-2006 matthieu

On macppc and sparc64, if allowaperture=0 only allow mmap()-ing of
the framebuffer memory in WSDISPLAYIO_MODE_DUMBFB mode.


Revision tags: OPENBSD_3_9_BASE
# 1.27 01-Jan-2006 miod

Let cons_init() and cons_init_bell() initialize the whole consdev structure,
thus removing the need for drivers to initialize cn_pri to CN_DEAD when
hardware probe fails.


# 1.26 26-Oct-2005 martin

Mach-macro wipeout

'do it' deraadt@


# 1.25 08-Oct-2005 drahn

Disable caching on vga buffer on 64bit machines. currently it causes
hangs.


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE
# 1.24 05-Jan-2005 miod

Let wsdisplay drivers return zero for WSDISPLAYIO_[GS]VIDEO ioctls - most
of the work is done in the upper layer, but they get to see the ioctl,
so don't always return an error.


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.23 17-Mar-2004 drahn

Better backlight detection on macppc, ok miod@ krw@ (a bit ago)


# 1.22 24-Oct-2003 drahn

If cons_backlight_available is not set, cons_brightness will not be valid,
return -1 to indicate so. same as WSDISPLAYIO_PARAM_BACKLIGHT.


# 1.21 15-Oct-2003 drahn

Further down the ANSI/KNF road, only binary difference is __LINE__.


Revision tags: OPENBSD_3_3_BASE OPENBSD_3_4_BASE UBC_SYNC_A
# 1.20 09-Nov-2002 miod

Instead of relying on uvm_useracc(), get a false sense of security, and
do not check copyin() result, take care and properly handle copyin() failure.

This was not harmful, but a bit more correctness never harms.


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.19 15-Sep-2002 deraadt

backout premature


# 1.18 15-Sep-2002 deraadt

KNF


# 1.17 06-Sep-2002 drahn

wscons display should have a console priority of INTERNAL, not REMOTE.
ok miod@


# 1.16 02-Aug-2002 millert

Do correct bounds checking in get/set/put cmap routines. A few of
these check were already OK but have been modified for consistency.
Problem found by Silvio Cesare.


# 1.15 21-Jul-2002 drahn

cleanup, mostly 'if 0'ed code removal.


# 1.14 27-Jun-2002 drahn

Do not muck with the color palette unless the console depth is 8 bit.
32 bit depth console and wsfb now work (If firmware is forced to that depth).


# 1.13 22-May-2002 miod

- in the OpenFirmware console initialisation, check if the console device
has support for backlight control (laptops do, and probably machines with
a built-in monitor do as well).
- provide a function to set the screen brightness as well.
- use both changes above to add a screen blanker to the vgafb driver
- let the screen brightness and backlight be controlled via wsconsctl
- clean dust, KNF, and more symbolic names in the vgafb driver to make it
better readable

Initial code by myself, with some hacks from drahn@ later.


# 1.12 18-May-2002 drahn

Workaround for color restoration on return from X. vgafb will not
reset the color palette to it's default colors when going back to text mode.
Would be better to fix this in the X server. ok matthieu@


# 1.11 29-Apr-2002 drahn

Better colors from rasops cmap, and enable all rasops features.
ok miod, mattheiu


# 1.10 29-Apr-2002 drahn

Change macppc vgafb from rcons to rasops, a faster color supporting virtual
terminal emulator for gfx console. tested by mattheiu, miod.


# 1.9 20-Apr-2002 matthieu

- the set-colors OF call takes a packed array of colors value,
remove the extra padding byte in the vgafb_color struct.
- store the initial colormap in vc->vc_cmap_{red,green,blue} so that
it can be fetched by a WSDISPLAYIO_GETCMAP ioctl
- fix the definition of the magenta color in the initial colormap.
Ok, drahn@


Revision tags: OPENBSD_3_1_BASE
# 1.8 05-Apr-2002 drahn

Use the OF set-colors operation instead of the color! operation, this
interface seems to work on more machines, also is more efficient
when XF4/wsfb is setting the palette. ok deraadt@


# 1.7 26-Mar-2002 drahn

Only allow valid device PAs to be mmapped.


# 1.6 14-Mar-2002 millert

First round of __P removal in sys


Revision tags: UBC_BASE
# 1.5 14-Dec-2001 jason

branches: 1.5.2;
garbage collect some unused stuff.


# 1.4 06-Nov-2001 miod

Replace inclusion of <vm/foo.h> with the correct <uvm/bar.h> when necessary.
(Look ma, I might have broken the tree)


Revision tags: OPENBSD_3_0_BASE
# 1.3 17-Sep-2001 drahn

branches: 1.3.4;
The gfx display buffer should request that it be mapped cached (writethru).
Not used yet, but when the bus_space_map code and pmap are fixed,
this will speed up the console.


# 1.2 13-Sep-2001 drahn

The vgafb driver does not test memory, so no point mapping it during the probe.
Also, there is no point in mapping more than the 'visual' area for vga memory.
this will save kvm space on large memory display cards.


# 1.1 01-Sep-2001 drahn

The "powerpc" port which has supported the newer Apple Macintosh powerpc based
is being renamed to macppc. This is to allow sharing of common code
between different powerpc base platforms.

Most of the work involved in the renaming process was performed by miod@

Files moved from powerpc/pci to macppc/pci

The file pci_machdep.h was not moved in this conversion.
It needs to be check if it is correct that should be the only shared
powerpc/pci file. Or if that file too should be MD, or more files MI.