History log of /openbsd-current/sys/dev/ic/sti.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.83 15-Jul-2022 deraadt

fix typos in previous


# 1.82 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_7_0_BASE OPENBSD_7_1_BASE
# 1.81 29-Apr-2021 kettenis

Replace uvm_km_alloc(9) calls with km_alloc(9) calls. Make the copied ROM
contents executable using pmap_kenter_pa(9) since uvm stops us from doing
so using higher-level interfaces (for good reasons).
Maintaining W^X of course!

ok mpi@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE
# 1.80 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.79 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_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.78 11-Jun-2017 deraadt

integer overflow for two range checks
fix from C Turt, ok miod


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.77 09-Sep-2015 deraadt

branches: 1.77.6; 1.77.8;
sizes for free(); ok sthen semarie


Revision tags: OPENBSD_5_8_BASE
# 1.76 05-Apr-2015 miod

Work-in-progress support for non-accelerated X11 on *some* sti(4) frame buffers;
based upon the old HP ngle X11 driver. Currently limited to CRX (720/735/750),
Timber (710, old 715), Artist (712, 715) and EG (B-series), however the
colormap isn't set up correctly on Timber and EG yet.

Joint work with Artem Falcon, now in good enough shape to be worked further
in the tree.


# 1.75 03-Apr-2015 miod

Fix unsigned vs signed comparison in for() loop condition causing an infinite
loop for WSDISPLAYIO_PUTCMAP ioctl with idx == 0; reported by Artem Falcon.

[according to my investigation, none of the other for() loops in the kernel
are affected by a similar issue]


Revision tags: OPENBSD_5_7_BASE
# 1.74 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.73 30-Aug-2014 miod

Fix format strings in STIDEBUG code.


Revision tags: OPENBSD_5_6_BASE
# 1.72 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.71 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


# 1.70 18-Mar-2014 miod

Retire hp300, mvme68k and mvme88k ports. These ports have no users, keeping
this hardware alive is becoming increasingly difficult, and I should heed the
message sent by the three disks which have died on me over the last few days.

Noone sane will mourn these ports anyway. So long, and thanks for the fish.


Revision tags: OPENBSD_5_5_BASE
# 1.69 20-Feb-2014 kettenis

revert previous commit; didn't intend to commit those bits


# 1.68 20-Feb-2014 kettenis

Avoid printing the "nvram corrupt" message for onboard 2200s found on Sun
hardware.

ok dlg@, jmatthew@


# 1.67 20-Oct-2013 miod

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


# 1.66 18-Oct-2013 miod

Make sure that, when a particular mapchar() can't find a proper glyph for the
requested character in the font it is using, it suggests a question mark
character, instead of a space, so that the existence of the non-representable
character becomes visible.

Note that this is consistent with pcdisplay which suggests a diamond for
missing glyphs.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.65 06-May-2012 mikeb

add support for the reverse video attribute in sti(4)
makes programs like less and mg look a wee bit prettier
ok miod


Revision tags: OPENBSD_5_1_BASE
# 1.64 19-Sep-2011 miod

Missing argument in STIDEBUG printf


# 1.63 18-Aug-2011 miod

So, it turns out that models 362 and 382 built-in frame buffer only shows up
in DIO-II space, as a fat device spanning four select codes (i.e. 16MB of
memory). This is way too much for an at-most 2 Mpixel 8bit frame buffer, and
it turns out that this is because the device provides both a regular DIO-II
frame buffer (spanning two select codes) and a regular STI frame buffer
(spanning the other two select codes).
This commit introduces a straightforward sti@dio attachment to get a working
sti(4) and wsdisplay(4) in a ridiculously small number of lines; however
the console code needs some changes to avoid duplicating globals.

While there, add sti@dio support for the bootblocks, and I couldn't help
myself but clean the most rotten parts of them, and try to have them reuse
various files in sys/arch/hp300/dev instead of rolling their outdated ones.

Tested on a real 382 with the low-resolution frame buffer:
sti0 at dio0 scode 132: rev 8.02;129, ID 0x27134CB440A00499
sti0: 382V, 2048x512 frame buffer, 640x480x8 display
sti0: 8x16 font type 1, 16 bpc, charset 0-255
wsdisplay0 at sti0 mux 1: console (std, vt100 emulation)

Boot blocks updates tested on DIO-II 425t (serial/glass console), SGC 425e
(serial/glass console) and 382 (serial/glass console). And will be tested
on SGC 425t soon as well.


Revision tags: OPENBSD_5_0_BASE
# 1.62 07-Apr-2011 miod

Do not use NULL in integer comparisons. No functional change.
ok matthew@ tedu@, also eyeballed by at least krw@ oga@ kettenis@ jsg@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.61 05-Sep-2009 miod

Change the wsdisplay_emulops return types from void to int; emulops will now
return zero on success and nonzero on failure.
This commit only performs mechanical changes for the existing emulops to
always return zero.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.60 06-Feb-2009 miod

Split sti structures into rom-related information and screen-related
information. This is preliminary work to help eventually supporting the
dual-head ELK model.

Also split the initialization code in several routines, this makes the
code easier to read, and makes it easier to release resources upon failure.

Finally, don't forget to clear the text planes on non-console displays
when initializing.


# 1.59 06-Feb-2009 miod

The new font selection logic would loop and consume all kmem on proms
with only one font (such as many 712 onboard graphics). Oops again (poukram).


# 1.58 29-Jan-2009 miod

Oops, correct logic when requested font index is out of bounds. Thankfully
it's a can't happen situation.


# 1.57 28-Jan-2009 miod

If the rom contains a monitor table, look for an entry matching our
display resolution, and if one is found, pick the built-in font it points
to, instead of the first font from the list. If the index is wrong and the
font list is shorter, revert to the previous behaviour of using the first
ROM font.

This fixes the font discrepency on my B132L (INTERNAL_EG_1280) where PDC
would use the 10x20 font, which is third in the list, and OpenBSD would
use the 8x16 font instead.

Tested on byte- and word- roms, gsc and pci cards.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.56 01-Oct-2007 krw

More easy bzero() -> M_ZERO. Use 'p = malloc(sizeof(*p) ...'.


Revision tags: OPENBSD_4_2_BASE
# 1.55 17-Jun-2007 miod

We can not consider the first sti region as always mapped, since on pci
cards it is no longer the rom image. This lets sti@pci work on non-dino
bridges.
Found by and ok kettenis@


# 1.54 17-Jun-2007 miod

Make sure to pass valid extended initialization structure pointers in
sti_init(), for recent sti proms require them. Also, return a meaningful
error value.
ok kettenis@ mickey@


Revision tags: OPENBSD_4_1_BASE
# 1.53 12-Jan-2007 miod

Keep the wsscreen_descr in the softc, to allow sti of different text
resolutions to attach without disturbing each other.


# 1.52 11-Jan-2007 miod

Add the ability for a sti backend to specify callbacks to disable and enable
access to the sti rom, as this seems to be necessary for sti@pci; hide this
with macros so that platforms which do not have pci support (i.e. hp300)
do not get bloated from this.

ok mickey@


# 1.51 11-Jan-2007 miod

Allow sti_attach_common() to return an error code, and do not fall into
sti_end_attach() if an error has occured.

ok mickey@


# 1.50 18-Dec-2006 miod

Read word-mode rom regions with bus_space_read_raw_region instead of
bus_space_region, for they might lie on a bus with a different endianness than
the cpu.

ok mickey@


# 1.49 18-Dec-2006 miod

Change sti attachment to pass an array of base addresses for the sti regions,
instead of using the rom mapping for region #0 and the device mapping for
region #1. This will allow sti devices on which regions may be relative to
different origins to attach (to be used very soon).

ok mickey@


# 1.48 16-Dec-2006 miod

Better sti_mapchar() implementation, matches Latin char indexes to HP Roman
font indicies whenever possible.


# 1.47 29-Nov-2006 miod

Add an unpack_attr function to struct wsdisplay_emulops, to match the
existing alloc_attr function. This allows rasops_unpack_attr to be kept
private to rasops, yet available to the screen drivers.


# 1.46 29-Nov-2006 miod

Use uvm_km_alloc() instead of uvm_km_alloc1(), so that the latter can
change within uvm without breaking code. From art@


# 1.45 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.44 22-Aug-2006 miod

Clear sti display on console attach, now that the bootloader leaves us
with scribbles around; ok mickey@


# 1.43 16-Apr-2006 miod

Introduce sti_rom_size() which will compute the size of a card's rom, and
use it instead of duplicating the same logic in 3 places.

ok mickey@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.42 27-Feb-2005 miod

Split sti softc in two structures, one device-related for regular device
attachment and interface, one screen-attached for the real work.

The attachment code is now required to decide whether sti_end_attach() is
run immediately, or as a startuphook.

This allows hp300 to initialize sti early, and use it as a console; hppa
is functionally unchanged, as it uses the PROM console until the root device
is mounted.


# 1.41 24-Jan-2005 miod

sti colormap fixes:
- correct bounds checking in colormap ioctls.
- force the scment() pointer to NULL on < 8.04 revisions; 8.02 provide a
non-NULL pointer, but it does not point to any meaningful piece of code.


# 1.40 23-Jan-2005 miod

bus_space_map() sti regions with BUS_SPACE_MAP_CACHEABLE if they have the
cache bit set in the region descriptor. Halves sti processing time on hp300.

ok mickey@


# 1.39 23-Jan-2005 miod

Two sti(4) changes necessary for hp300:
- specify which microcode bank (pa or m68k) to use at attachment time.
- compensate for broken 8.02 m68k code which reports wrong frame buffer
offset.

ok mickey@


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


# 1.37 03-Nov-2004 mickey

oops missed to set devtype here rather than in sti_sgc.c:1.23


# 1.36 14-Sep-2004 mickey

allocate ext-cfg memory if was requestd in dd_stimemreq


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.35 16-Dec-2003 mickey

only map the rom and do not touch the hpa space getting rid of memsize define that was not really true; plus tested by otto@ and miod@


# 1.34 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


Revision tags: OPENBSD_3_4_BASE
# 1.33 21-Aug-2003 mickey

fix the offsets in decoding byte rom dd (verified per manual); miod@ ok


# 1.32 19-Aug-2003 mickey

give better depth and cmsize


# 1.31 19-Aug-2003 mickey

implement WSDISPLAYIO_{GET,PUT}CMAP; untested


# 1.30 19-Aug-2003 mickey

inquire ext config and dump it in debugging and also fix other debugging prints


# 1.29 17-Aug-2003 mickey

implement WSDISPLAYIO_{S,G}MODE


# 1.28 17-Aug-2003 mickey

print out the graphics id


# 1.27 11-Aug-2003 mickey

free code memory should change permissions fail


# 1.26 02-Jun-2003 mickey

kill the caluses three and four on some of my code


# 1.25 24-May-2003 miod

Disable off-screen font loading. We still need to use the pdc console routines
before we switch to wsdisplay, and this can clobber the font image in some
cases, especially lower (<= 1024x768) resolutions.


Revision tags: UBC_SYNC_A
# 1.24 03-Apr-2003 mickey

adjust protection on the allocated memory through the uvm same as it was allocated w/o cutting short onto the pmap layer


Revision tags: OPENBSD_3_3_BASE
# 1.23 18-Feb-2003 miod

branches: 1.23.2;
Whenever possible, store the prom font data in off-screen frame buffer
memory, and use block move operations in putchar, rather than keeping a copy
of the prom font in memory and using memory to frame buffer transfers.

Recommended by the sti docs. No visible performance improvement though.

Tested on both kind of sti devices by mickey@ and myself.


# 1.22 17-Feb-2003 mickey

can use the same bus_space_read_region_4() to copy both type1 and type4 prom; tested on type4 by me and miod on type1


# 1.21 17-Feb-2003 mickey

oops


# 1.20 11-Feb-2003 miod

As hil devices can only attach after interrupts are enabled, delay
the attachment of wsdisplay to sti as well.
This allows us to have a working console for boot -a, and still attach
a full-blown wscons console as soon as possible.

ok mickey@


# 1.19 11-Feb-2003 miod

Byte-prom font loading support.
ok mickey@


# 1.18 05-Feb-2003 mickey

implement a few wsdisplay ioctls. comment on the putchar implementation


# 1.17 31-Jan-2003 miod

Working wscons attachment and block move operations; joint debug by mickey
and myself.
wsdisplay at sti will be enabled as soon as byte-size rom font loading is done.


# 1.16 31-Jan-2003 mickey

fetch the font and use it, some cleanup and knf


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.15 19-Jul-2002 mickey

a few more comments and debugs, other cosmetic stuff


Revision tags: OPENBSD_3_1_BASE
# 1.14 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 04-Mar-2002 mickey

do not attach wsdisplay if there is none configured


# 1.11 01-Feb-2002 mickey

clean the hppa leftover, from netbsd


# 1.10 25-Jan-2002 mickey

tell wsdisplay if we are a console


Revision tags: UBC_BASE
# 1.9 08-Dec-2001 art

branches: 1.9.2;
Sprinkle pmap_update calls where relevant and some other
misc pmap usage fixes.


# 1.8 02-Dec-2001 mickey

bzero the waa and not ready yet for the console


# 1.7 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.6 19-Sep-2001 mickey

merge vm/vm_kern.h into uvm/uvm_extern.h; art@ ok


Revision tags: OPENBSD_2_9_BASE
# 1.5 20-Mar-2001 mickey

branches: 1.5.4;
better default screen init


# 1.4 16-Feb-2001 mickey

sti_mmap() proper return type


# 1.3 11-Jan-2001 mickey

fix a few types and alignment problems


Revision tags: OPENBSD_2_8_BASE
# 1.2 03-Sep-2000 mickey

fix revision parsing, print local revision


# 1.1 30-May-2000 mickey

sti hp graphics, available in pci and hp-prop sgc bus form factors.
attach point for wsdisplay.
a few problems may exist w/ certain prom versions.
tested in byte- and word-wide modes.
no support yet for multiple resolutions and fonts.
pci not tested (obviously).


# 1.81 29-Apr-2021 kettenis

Replace uvm_km_alloc(9) calls with km_alloc(9) calls. Make the copied ROM
contents executable using pmap_kenter_pa(9) since uvm stops us from doing
so using higher-level interfaces (for good reasons).
Maintaining W^X of course!

ok mpi@


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE
# 1.80 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.79 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_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.78 11-Jun-2017 deraadt

integer overflow for two range checks
fix from C Turt, ok miod


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.77 09-Sep-2015 deraadt

branches: 1.77.6; 1.77.8;
sizes for free(); ok sthen semarie


Revision tags: OPENBSD_5_8_BASE
# 1.76 05-Apr-2015 miod

Work-in-progress support for non-accelerated X11 on *some* sti(4) frame buffers;
based upon the old HP ngle X11 driver. Currently limited to CRX (720/735/750),
Timber (710, old 715), Artist (712, 715) and EG (B-series), however the
colormap isn't set up correctly on Timber and EG yet.

Joint work with Artem Falcon, now in good enough shape to be worked further
in the tree.


# 1.75 03-Apr-2015 miod

Fix unsigned vs signed comparison in for() loop condition causing an infinite
loop for WSDISPLAYIO_PUTCMAP ioctl with idx == 0; reported by Artem Falcon.

[according to my investigation, none of the other for() loops in the kernel
are affected by a similar issue]


Revision tags: OPENBSD_5_7_BASE
# 1.74 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.73 30-Aug-2014 miod

Fix format strings in STIDEBUG code.


Revision tags: OPENBSD_5_6_BASE
# 1.72 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.71 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


# 1.70 18-Mar-2014 miod

Retire hp300, mvme68k and mvme88k ports. These ports have no users, keeping
this hardware alive is becoming increasingly difficult, and I should heed the
message sent by the three disks which have died on me over the last few days.

Noone sane will mourn these ports anyway. So long, and thanks for the fish.


Revision tags: OPENBSD_5_5_BASE
# 1.69 20-Feb-2014 kettenis

revert previous commit; didn't intend to commit those bits


# 1.68 20-Feb-2014 kettenis

Avoid printing the "nvram corrupt" message for onboard 2200s found on Sun
hardware.

ok dlg@, jmatthew@


# 1.67 20-Oct-2013 miod

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


# 1.66 18-Oct-2013 miod

Make sure that, when a particular mapchar() can't find a proper glyph for the
requested character in the font it is using, it suggests a question mark
character, instead of a space, so that the existence of the non-representable
character becomes visible.

Note that this is consistent with pcdisplay which suggests a diamond for
missing glyphs.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.65 06-May-2012 mikeb

add support for the reverse video attribute in sti(4)
makes programs like less and mg look a wee bit prettier
ok miod


Revision tags: OPENBSD_5_1_BASE
# 1.64 19-Sep-2011 miod

Missing argument in STIDEBUG printf


# 1.63 18-Aug-2011 miod

So, it turns out that models 362 and 382 built-in frame buffer only shows up
in DIO-II space, as a fat device spanning four select codes (i.e. 16MB of
memory). This is way too much for an at-most 2 Mpixel 8bit frame buffer, and
it turns out that this is because the device provides both a regular DIO-II
frame buffer (spanning two select codes) and a regular STI frame buffer
(spanning the other two select codes).
This commit introduces a straightforward sti@dio attachment to get a working
sti(4) and wsdisplay(4) in a ridiculously small number of lines; however
the console code needs some changes to avoid duplicating globals.

While there, add sti@dio support for the bootblocks, and I couldn't help
myself but clean the most rotten parts of them, and try to have them reuse
various files in sys/arch/hp300/dev instead of rolling their outdated ones.

Tested on a real 382 with the low-resolution frame buffer:
sti0 at dio0 scode 132: rev 8.02;129, ID 0x27134CB440A00499
sti0: 382V, 2048x512 frame buffer, 640x480x8 display
sti0: 8x16 font type 1, 16 bpc, charset 0-255
wsdisplay0 at sti0 mux 1: console (std, vt100 emulation)

Boot blocks updates tested on DIO-II 425t (serial/glass console), SGC 425e
(serial/glass console) and 382 (serial/glass console). And will be tested
on SGC 425t soon as well.


Revision tags: OPENBSD_5_0_BASE
# 1.62 07-Apr-2011 miod

Do not use NULL in integer comparisons. No functional change.
ok matthew@ tedu@, also eyeballed by at least krw@ oga@ kettenis@ jsg@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.61 05-Sep-2009 miod

Change the wsdisplay_emulops return types from void to int; emulops will now
return zero on success and nonzero on failure.
This commit only performs mechanical changes for the existing emulops to
always return zero.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.60 06-Feb-2009 miod

Split sti structures into rom-related information and screen-related
information. This is preliminary work to help eventually supporting the
dual-head ELK model.

Also split the initialization code in several routines, this makes the
code easier to read, and makes it easier to release resources upon failure.

Finally, don't forget to clear the text planes on non-console displays
when initializing.


# 1.59 06-Feb-2009 miod

The new font selection logic would loop and consume all kmem on proms
with only one font (such as many 712 onboard graphics). Oops again (poukram).


# 1.58 29-Jan-2009 miod

Oops, correct logic when requested font index is out of bounds. Thankfully
it's a can't happen situation.


# 1.57 28-Jan-2009 miod

If the rom contains a monitor table, look for an entry matching our
display resolution, and if one is found, pick the built-in font it points
to, instead of the first font from the list. If the index is wrong and the
font list is shorter, revert to the previous behaviour of using the first
ROM font.

This fixes the font discrepency on my B132L (INTERNAL_EG_1280) where PDC
would use the 10x20 font, which is third in the list, and OpenBSD would
use the 8x16 font instead.

Tested on byte- and word- roms, gsc and pci cards.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.56 01-Oct-2007 krw

More easy bzero() -> M_ZERO. Use 'p = malloc(sizeof(*p) ...'.


Revision tags: OPENBSD_4_2_BASE
# 1.55 17-Jun-2007 miod

We can not consider the first sti region as always mapped, since on pci
cards it is no longer the rom image. This lets sti@pci work on non-dino
bridges.
Found by and ok kettenis@


# 1.54 17-Jun-2007 miod

Make sure to pass valid extended initialization structure pointers in
sti_init(), for recent sti proms require them. Also, return a meaningful
error value.
ok kettenis@ mickey@


Revision tags: OPENBSD_4_1_BASE
# 1.53 12-Jan-2007 miod

Keep the wsscreen_descr in the softc, to allow sti of different text
resolutions to attach without disturbing each other.


# 1.52 11-Jan-2007 miod

Add the ability for a sti backend to specify callbacks to disable and enable
access to the sti rom, as this seems to be necessary for sti@pci; hide this
with macros so that platforms which do not have pci support (i.e. hp300)
do not get bloated from this.

ok mickey@


# 1.51 11-Jan-2007 miod

Allow sti_attach_common() to return an error code, and do not fall into
sti_end_attach() if an error has occured.

ok mickey@


# 1.50 18-Dec-2006 miod

Read word-mode rom regions with bus_space_read_raw_region instead of
bus_space_region, for they might lie on a bus with a different endianness than
the cpu.

ok mickey@


# 1.49 18-Dec-2006 miod

Change sti attachment to pass an array of base addresses for the sti regions,
instead of using the rom mapping for region #0 and the device mapping for
region #1. This will allow sti devices on which regions may be relative to
different origins to attach (to be used very soon).

ok mickey@


# 1.48 16-Dec-2006 miod

Better sti_mapchar() implementation, matches Latin char indexes to HP Roman
font indicies whenever possible.


# 1.47 29-Nov-2006 miod

Add an unpack_attr function to struct wsdisplay_emulops, to match the
existing alloc_attr function. This allows rasops_unpack_attr to be kept
private to rasops, yet available to the screen drivers.


# 1.46 29-Nov-2006 miod

Use uvm_km_alloc() instead of uvm_km_alloc1(), so that the latter can
change within uvm without breaking code. From art@


# 1.45 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.44 22-Aug-2006 miod

Clear sti display on console attach, now that the bootloader leaves us
with scribbles around; ok mickey@


# 1.43 16-Apr-2006 miod

Introduce sti_rom_size() which will compute the size of a card's rom, and
use it instead of duplicating the same logic in 3 places.

ok mickey@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.42 27-Feb-2005 miod

Split sti softc in two structures, one device-related for regular device
attachment and interface, one screen-attached for the real work.

The attachment code is now required to decide whether sti_end_attach() is
run immediately, or as a startuphook.

This allows hp300 to initialize sti early, and use it as a console; hppa
is functionally unchanged, as it uses the PROM console until the root device
is mounted.


# 1.41 24-Jan-2005 miod

sti colormap fixes:
- correct bounds checking in colormap ioctls.
- force the scment() pointer to NULL on < 8.04 revisions; 8.02 provide a
non-NULL pointer, but it does not point to any meaningful piece of code.


# 1.40 23-Jan-2005 miod

bus_space_map() sti regions with BUS_SPACE_MAP_CACHEABLE if they have the
cache bit set in the region descriptor. Halves sti processing time on hp300.

ok mickey@


# 1.39 23-Jan-2005 miod

Two sti(4) changes necessary for hp300:
- specify which microcode bank (pa or m68k) to use at attachment time.
- compensate for broken 8.02 m68k code which reports wrong frame buffer
offset.

ok mickey@


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


# 1.37 03-Nov-2004 mickey

oops missed to set devtype here rather than in sti_sgc.c:1.23


# 1.36 14-Sep-2004 mickey

allocate ext-cfg memory if was requestd in dd_stimemreq


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.35 16-Dec-2003 mickey

only map the rom and do not touch the hpa space getting rid of memsize define that was not really true; plus tested by otto@ and miod@


# 1.34 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


Revision tags: OPENBSD_3_4_BASE
# 1.33 21-Aug-2003 mickey

fix the offsets in decoding byte rom dd (verified per manual); miod@ ok


# 1.32 19-Aug-2003 mickey

give better depth and cmsize


# 1.31 19-Aug-2003 mickey

implement WSDISPLAYIO_{GET,PUT}CMAP; untested


# 1.30 19-Aug-2003 mickey

inquire ext config and dump it in debugging and also fix other debugging prints


# 1.29 17-Aug-2003 mickey

implement WSDISPLAYIO_{S,G}MODE


# 1.28 17-Aug-2003 mickey

print out the graphics id


# 1.27 11-Aug-2003 mickey

free code memory should change permissions fail


# 1.26 02-Jun-2003 mickey

kill the caluses three and four on some of my code


# 1.25 24-May-2003 miod

Disable off-screen font loading. We still need to use the pdc console routines
before we switch to wsdisplay, and this can clobber the font image in some
cases, especially lower (<= 1024x768) resolutions.


Revision tags: UBC_SYNC_A
# 1.24 03-Apr-2003 mickey

adjust protection on the allocated memory through the uvm same as it was allocated w/o cutting short onto the pmap layer


Revision tags: OPENBSD_3_3_BASE
# 1.23 18-Feb-2003 miod

branches: 1.23.2;
Whenever possible, store the prom font data in off-screen frame buffer
memory, and use block move operations in putchar, rather than keeping a copy
of the prom font in memory and using memory to frame buffer transfers.

Recommended by the sti docs. No visible performance improvement though.

Tested on both kind of sti devices by mickey@ and myself.


# 1.22 17-Feb-2003 mickey

can use the same bus_space_read_region_4() to copy both type1 and type4 prom; tested on type4 by me and miod on type1


# 1.21 17-Feb-2003 mickey

oops


# 1.20 11-Feb-2003 miod

As hil devices can only attach after interrupts are enabled, delay
the attachment of wsdisplay to sti as well.
This allows us to have a working console for boot -a, and still attach
a full-blown wscons console as soon as possible.

ok mickey@


# 1.19 11-Feb-2003 miod

Byte-prom font loading support.
ok mickey@


# 1.18 05-Feb-2003 mickey

implement a few wsdisplay ioctls. comment on the putchar implementation


# 1.17 31-Jan-2003 miod

Working wscons attachment and block move operations; joint debug by mickey
and myself.
wsdisplay at sti will be enabled as soon as byte-size rom font loading is done.


# 1.16 31-Jan-2003 mickey

fetch the font and use it, some cleanup and knf


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.15 19-Jul-2002 mickey

a few more comments and debugs, other cosmetic stuff


Revision tags: OPENBSD_3_1_BASE
# 1.14 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 04-Mar-2002 mickey

do not attach wsdisplay if there is none configured


# 1.11 01-Feb-2002 mickey

clean the hppa leftover, from netbsd


# 1.10 25-Jan-2002 mickey

tell wsdisplay if we are a console


Revision tags: UBC_BASE
# 1.9 08-Dec-2001 art

branches: 1.9.2;
Sprinkle pmap_update calls where relevant and some other
misc pmap usage fixes.


# 1.8 02-Dec-2001 mickey

bzero the waa and not ready yet for the console


# 1.7 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.6 19-Sep-2001 mickey

merge vm/vm_kern.h into uvm/uvm_extern.h; art@ ok


Revision tags: OPENBSD_2_9_BASE
# 1.5 20-Mar-2001 mickey

branches: 1.5.4;
better default screen init


# 1.4 16-Feb-2001 mickey

sti_mmap() proper return type


# 1.3 11-Jan-2001 mickey

fix a few types and alignment problems


Revision tags: OPENBSD_2_8_BASE
# 1.2 03-Sep-2000 mickey

fix revision parsing, print local revision


# 1.1 30-May-2000 mickey

sti hp graphics, available in pci and hp-prop sgc bus form factors.
attach point for wsdisplay.
a few problems may exist w/ certain prom versions.
tested in byte- and word-wide modes.
no support yet for multiple resolutions and fonts.
pci not tested (obviously).


# 1.80 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.79 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_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.78 11-Jun-2017 deraadt

integer overflow for two range checks
fix from C Turt, ok miod


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.77 09-Sep-2015 deraadt

branches: 1.77.6; 1.77.8;
sizes for free(); ok sthen semarie


Revision tags: OPENBSD_5_8_BASE
# 1.76 05-Apr-2015 miod

Work-in-progress support for non-accelerated X11 on *some* sti(4) frame buffers;
based upon the old HP ngle X11 driver. Currently limited to CRX (720/735/750),
Timber (710, old 715), Artist (712, 715) and EG (B-series), however the
colormap isn't set up correctly on Timber and EG yet.

Joint work with Artem Falcon, now in good enough shape to be worked further
in the tree.


# 1.75 03-Apr-2015 miod

Fix unsigned vs signed comparison in for() loop condition causing an infinite
loop for WSDISPLAYIO_PUTCMAP ioctl with idx == 0; reported by Artem Falcon.

[according to my investigation, none of the other for() loops in the kernel
are affected by a similar issue]


Revision tags: OPENBSD_5_7_BASE
# 1.74 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.73 30-Aug-2014 miod

Fix format strings in STIDEBUG code.


Revision tags: OPENBSD_5_6_BASE
# 1.72 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.71 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


# 1.70 18-Mar-2014 miod

Retire hp300, mvme68k and mvme88k ports. These ports have no users, keeping
this hardware alive is becoming increasingly difficult, and I should heed the
message sent by the three disks which have died on me over the last few days.

Noone sane will mourn these ports anyway. So long, and thanks for the fish.


Revision tags: OPENBSD_5_5_BASE
# 1.69 20-Feb-2014 kettenis

revert previous commit; didn't intend to commit those bits


# 1.68 20-Feb-2014 kettenis

Avoid printing the "nvram corrupt" message for onboard 2200s found on Sun
hardware.

ok dlg@, jmatthew@


# 1.67 20-Oct-2013 miod

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


# 1.66 18-Oct-2013 miod

Make sure that, when a particular mapchar() can't find a proper glyph for the
requested character in the font it is using, it suggests a question mark
character, instead of a space, so that the existence of the non-representable
character becomes visible.

Note that this is consistent with pcdisplay which suggests a diamond for
missing glyphs.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.65 06-May-2012 mikeb

add support for the reverse video attribute in sti(4)
makes programs like less and mg look a wee bit prettier
ok miod


Revision tags: OPENBSD_5_1_BASE
# 1.64 19-Sep-2011 miod

Missing argument in STIDEBUG printf


# 1.63 18-Aug-2011 miod

So, it turns out that models 362 and 382 built-in frame buffer only shows up
in DIO-II space, as a fat device spanning four select codes (i.e. 16MB of
memory). This is way too much for an at-most 2 Mpixel 8bit frame buffer, and
it turns out that this is because the device provides both a regular DIO-II
frame buffer (spanning two select codes) and a regular STI frame buffer
(spanning the other two select codes).
This commit introduces a straightforward sti@dio attachment to get a working
sti(4) and wsdisplay(4) in a ridiculously small number of lines; however
the console code needs some changes to avoid duplicating globals.

While there, add sti@dio support for the bootblocks, and I couldn't help
myself but clean the most rotten parts of them, and try to have them reuse
various files in sys/arch/hp300/dev instead of rolling their outdated ones.

Tested on a real 382 with the low-resolution frame buffer:
sti0 at dio0 scode 132: rev 8.02;129, ID 0x27134CB440A00499
sti0: 382V, 2048x512 frame buffer, 640x480x8 display
sti0: 8x16 font type 1, 16 bpc, charset 0-255
wsdisplay0 at sti0 mux 1: console (std, vt100 emulation)

Boot blocks updates tested on DIO-II 425t (serial/glass console), SGC 425e
(serial/glass console) and 382 (serial/glass console). And will be tested
on SGC 425t soon as well.


Revision tags: OPENBSD_5_0_BASE
# 1.62 07-Apr-2011 miod

Do not use NULL in integer comparisons. No functional change.
ok matthew@ tedu@, also eyeballed by at least krw@ oga@ kettenis@ jsg@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.61 05-Sep-2009 miod

Change the wsdisplay_emulops return types from void to int; emulops will now
return zero on success and nonzero on failure.
This commit only performs mechanical changes for the existing emulops to
always return zero.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.60 06-Feb-2009 miod

Split sti structures into rom-related information and screen-related
information. This is preliminary work to help eventually supporting the
dual-head ELK model.

Also split the initialization code in several routines, this makes the
code easier to read, and makes it easier to release resources upon failure.

Finally, don't forget to clear the text planes on non-console displays
when initializing.


# 1.59 06-Feb-2009 miod

The new font selection logic would loop and consume all kmem on proms
with only one font (such as many 712 onboard graphics). Oops again (poukram).


# 1.58 29-Jan-2009 miod

Oops, correct logic when requested font index is out of bounds. Thankfully
it's a can't happen situation.


# 1.57 28-Jan-2009 miod

If the rom contains a monitor table, look for an entry matching our
display resolution, and if one is found, pick the built-in font it points
to, instead of the first font from the list. If the index is wrong and the
font list is shorter, revert to the previous behaviour of using the first
ROM font.

This fixes the font discrepency on my B132L (INTERNAL_EG_1280) where PDC
would use the 10x20 font, which is third in the list, and OpenBSD would
use the 8x16 font instead.

Tested on byte- and word- roms, gsc and pci cards.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.56 01-Oct-2007 krw

More easy bzero() -> M_ZERO. Use 'p = malloc(sizeof(*p) ...'.


Revision tags: OPENBSD_4_2_BASE
# 1.55 17-Jun-2007 miod

We can not consider the first sti region as always mapped, since on pci
cards it is no longer the rom image. This lets sti@pci work on non-dino
bridges.
Found by and ok kettenis@


# 1.54 17-Jun-2007 miod

Make sure to pass valid extended initialization structure pointers in
sti_init(), for recent sti proms require them. Also, return a meaningful
error value.
ok kettenis@ mickey@


Revision tags: OPENBSD_4_1_BASE
# 1.53 12-Jan-2007 miod

Keep the wsscreen_descr in the softc, to allow sti of different text
resolutions to attach without disturbing each other.


# 1.52 11-Jan-2007 miod

Add the ability for a sti backend to specify callbacks to disable and enable
access to the sti rom, as this seems to be necessary for sti@pci; hide this
with macros so that platforms which do not have pci support (i.e. hp300)
do not get bloated from this.

ok mickey@


# 1.51 11-Jan-2007 miod

Allow sti_attach_common() to return an error code, and do not fall into
sti_end_attach() if an error has occured.

ok mickey@


# 1.50 18-Dec-2006 miod

Read word-mode rom regions with bus_space_read_raw_region instead of
bus_space_region, for they might lie on a bus with a different endianness than
the cpu.

ok mickey@


# 1.49 18-Dec-2006 miod

Change sti attachment to pass an array of base addresses for the sti regions,
instead of using the rom mapping for region #0 and the device mapping for
region #1. This will allow sti devices on which regions may be relative to
different origins to attach (to be used very soon).

ok mickey@


# 1.48 16-Dec-2006 miod

Better sti_mapchar() implementation, matches Latin char indexes to HP Roman
font indicies whenever possible.


# 1.47 29-Nov-2006 miod

Add an unpack_attr function to struct wsdisplay_emulops, to match the
existing alloc_attr function. This allows rasops_unpack_attr to be kept
private to rasops, yet available to the screen drivers.


# 1.46 29-Nov-2006 miod

Use uvm_km_alloc() instead of uvm_km_alloc1(), so that the latter can
change within uvm without breaking code. From art@


# 1.45 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.44 22-Aug-2006 miod

Clear sti display on console attach, now that the bootloader leaves us
with scribbles around; ok mickey@


# 1.43 16-Apr-2006 miod

Introduce sti_rom_size() which will compute the size of a card's rom, and
use it instead of duplicating the same logic in 3 places.

ok mickey@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.42 27-Feb-2005 miod

Split sti softc in two structures, one device-related for regular device
attachment and interface, one screen-attached for the real work.

The attachment code is now required to decide whether sti_end_attach() is
run immediately, or as a startuphook.

This allows hp300 to initialize sti early, and use it as a console; hppa
is functionally unchanged, as it uses the PROM console until the root device
is mounted.


# 1.41 24-Jan-2005 miod

sti colormap fixes:
- correct bounds checking in colormap ioctls.
- force the scment() pointer to NULL on < 8.04 revisions; 8.02 provide a
non-NULL pointer, but it does not point to any meaningful piece of code.


# 1.40 23-Jan-2005 miod

bus_space_map() sti regions with BUS_SPACE_MAP_CACHEABLE if they have the
cache bit set in the region descriptor. Halves sti processing time on hp300.

ok mickey@


# 1.39 23-Jan-2005 miod

Two sti(4) changes necessary for hp300:
- specify which microcode bank (pa or m68k) to use at attachment time.
- compensate for broken 8.02 m68k code which reports wrong frame buffer
offset.

ok mickey@


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


# 1.37 03-Nov-2004 mickey

oops missed to set devtype here rather than in sti_sgc.c:1.23


# 1.36 14-Sep-2004 mickey

allocate ext-cfg memory if was requestd in dd_stimemreq


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.35 16-Dec-2003 mickey

only map the rom and do not touch the hpa space getting rid of memsize define that was not really true; plus tested by otto@ and miod@


# 1.34 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


Revision tags: OPENBSD_3_4_BASE
# 1.33 21-Aug-2003 mickey

fix the offsets in decoding byte rom dd (verified per manual); miod@ ok


# 1.32 19-Aug-2003 mickey

give better depth and cmsize


# 1.31 19-Aug-2003 mickey

implement WSDISPLAYIO_{GET,PUT}CMAP; untested


# 1.30 19-Aug-2003 mickey

inquire ext config and dump it in debugging and also fix other debugging prints


# 1.29 17-Aug-2003 mickey

implement WSDISPLAYIO_{S,G}MODE


# 1.28 17-Aug-2003 mickey

print out the graphics id


# 1.27 11-Aug-2003 mickey

free code memory should change permissions fail


# 1.26 02-Jun-2003 mickey

kill the caluses three and four on some of my code


# 1.25 24-May-2003 miod

Disable off-screen font loading. We still need to use the pdc console routines
before we switch to wsdisplay, and this can clobber the font image in some
cases, especially lower (<= 1024x768) resolutions.


Revision tags: UBC_SYNC_A
# 1.24 03-Apr-2003 mickey

adjust protection on the allocated memory through the uvm same as it was allocated w/o cutting short onto the pmap layer


Revision tags: OPENBSD_3_3_BASE
# 1.23 18-Feb-2003 miod

branches: 1.23.2;
Whenever possible, store the prom font data in off-screen frame buffer
memory, and use block move operations in putchar, rather than keeping a copy
of the prom font in memory and using memory to frame buffer transfers.

Recommended by the sti docs. No visible performance improvement though.

Tested on both kind of sti devices by mickey@ and myself.


# 1.22 17-Feb-2003 mickey

can use the same bus_space_read_region_4() to copy both type1 and type4 prom; tested on type4 by me and miod on type1


# 1.21 17-Feb-2003 mickey

oops


# 1.20 11-Feb-2003 miod

As hil devices can only attach after interrupts are enabled, delay
the attachment of wsdisplay to sti as well.
This allows us to have a working console for boot -a, and still attach
a full-blown wscons console as soon as possible.

ok mickey@


# 1.19 11-Feb-2003 miod

Byte-prom font loading support.
ok mickey@


# 1.18 05-Feb-2003 mickey

implement a few wsdisplay ioctls. comment on the putchar implementation


# 1.17 31-Jan-2003 miod

Working wscons attachment and block move operations; joint debug by mickey
and myself.
wsdisplay at sti will be enabled as soon as byte-size rom font loading is done.


# 1.16 31-Jan-2003 mickey

fetch the font and use it, some cleanup and knf


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.15 19-Jul-2002 mickey

a few more comments and debugs, other cosmetic stuff


Revision tags: OPENBSD_3_1_BASE
# 1.14 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 04-Mar-2002 mickey

do not attach wsdisplay if there is none configured


# 1.11 01-Feb-2002 mickey

clean the hppa leftover, from netbsd


# 1.10 25-Jan-2002 mickey

tell wsdisplay if we are a console


Revision tags: UBC_BASE
# 1.9 08-Dec-2001 art

branches: 1.9.2;
Sprinkle pmap_update calls where relevant and some other
misc pmap usage fixes.


# 1.8 02-Dec-2001 mickey

bzero the waa and not ready yet for the console


# 1.7 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.6 19-Sep-2001 mickey

merge vm/vm_kern.h into uvm/uvm_extern.h; art@ ok


Revision tags: OPENBSD_2_9_BASE
# 1.5 20-Mar-2001 mickey

branches: 1.5.4;
better default screen init


# 1.4 16-Feb-2001 mickey

sti_mmap() proper return type


# 1.3 11-Jan-2001 mickey

fix a few types and alignment problems


Revision tags: OPENBSD_2_8_BASE
# 1.2 03-Sep-2000 mickey

fix revision parsing, print local revision


# 1.1 30-May-2000 mickey

sti hp graphics, available in pci and hp-prop sgc bus form factors.
attach point for wsdisplay.
a few problems may exist w/ certain prom versions.
tested in byte- and word-wide modes.
no support yet for multiple resolutions and fonts.
pci not tested (obviously).


Revision tags: OPENBSD_6_2_BASE
# 1.78 11-Jun-2017 deraadt

integer overflow for two range checks
fix from C Turt, ok miod


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE
# 1.77 09-Sep-2015 deraadt

branches: 1.77.6; 1.77.8;
sizes for free(); ok sthen semarie


Revision tags: OPENBSD_5_8_BASE
# 1.76 05-Apr-2015 miod

Work-in-progress support for non-accelerated X11 on *some* sti(4) frame buffers;
based upon the old HP ngle X11 driver. Currently limited to CRX (720/735/750),
Timber (710, old 715), Artist (712, 715) and EG (B-series), however the
colormap isn't set up correctly on Timber and EG yet.

Joint work with Artem Falcon, now in good enough shape to be worked further
in the tree.


# 1.75 03-Apr-2015 miod

Fix unsigned vs signed comparison in for() loop condition causing an infinite
loop for WSDISPLAYIO_PUTCMAP ioctl with idx == 0; reported by Artem Falcon.

[according to my investigation, none of the other for() loops in the kernel
are affected by a similar issue]


Revision tags: OPENBSD_5_7_BASE
# 1.74 16-Nov-2014 deraadt

Replace a plethora of historical protection options with just
PROT_NONE, PROT_READ, PROT_WRITE, and PROT_EXEC from mman.h.
PROT_MASK is introduced as the one true way of extracting those bits.
Remove UVM_ADV_* wrapper, using the standard names.
ok doug guenther kettenis


# 1.73 30-Aug-2014 miod

Fix format strings in STIDEBUG code.


Revision tags: OPENBSD_5_6_BASE
# 1.72 12-Jul-2014 tedu

add a size argument to free. will be used soon, but for now default to 0.
after discussions with beck deraadt kettenis.


# 1.71 28-Mar-2014 mpi

Reduce uvm include madness. Use <uvm/uvm_extern.h> instead of
<uvm/uvm.h> if possible and remove double inclusions.

ok beck@, mlarkin@, deraadt@


# 1.70 18-Mar-2014 miod

Retire hp300, mvme68k and mvme88k ports. These ports have no users, keeping
this hardware alive is becoming increasingly difficult, and I should heed the
message sent by the three disks which have died on me over the last few days.

Noone sane will mourn these ports anyway. So long, and thanks for the fish.


Revision tags: OPENBSD_5_5_BASE
# 1.69 20-Feb-2014 kettenis

revert previous commit; didn't intend to commit those bits


# 1.68 20-Feb-2014 kettenis

Avoid printing the "nvram corrupt" message for onboard 2200s found on Sun
hardware.

ok dlg@, jmatthew@


# 1.67 20-Oct-2013 miod

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


# 1.66 18-Oct-2013 miod

Make sure that, when a particular mapchar() can't find a proper glyph for the
requested character in the font it is using, it suggests a question mark
character, instead of a space, so that the existence of the non-representable
character becomes visible.

Note that this is consistent with pcdisplay which suggests a diamond for
missing glyphs.


Revision tags: OPENBSD_5_2_BASE OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.65 06-May-2012 mikeb

add support for the reverse video attribute in sti(4)
makes programs like less and mg look a wee bit prettier
ok miod


Revision tags: OPENBSD_5_1_BASE
# 1.64 19-Sep-2011 miod

Missing argument in STIDEBUG printf


# 1.63 18-Aug-2011 miod

So, it turns out that models 362 and 382 built-in frame buffer only shows up
in DIO-II space, as a fat device spanning four select codes (i.e. 16MB of
memory). This is way too much for an at-most 2 Mpixel 8bit frame buffer, and
it turns out that this is because the device provides both a regular DIO-II
frame buffer (spanning two select codes) and a regular STI frame buffer
(spanning the other two select codes).
This commit introduces a straightforward sti@dio attachment to get a working
sti(4) and wsdisplay(4) in a ridiculously small number of lines; however
the console code needs some changes to avoid duplicating globals.

While there, add sti@dio support for the bootblocks, and I couldn't help
myself but clean the most rotten parts of them, and try to have them reuse
various files in sys/arch/hp300/dev instead of rolling their outdated ones.

Tested on a real 382 with the low-resolution frame buffer:
sti0 at dio0 scode 132: rev 8.02;129, ID 0x27134CB440A00499
sti0: 382V, 2048x512 frame buffer, 640x480x8 display
sti0: 8x16 font type 1, 16 bpc, charset 0-255
wsdisplay0 at sti0 mux 1: console (std, vt100 emulation)

Boot blocks updates tested on DIO-II 425t (serial/glass console), SGC 425e
(serial/glass console) and 382 (serial/glass console). And will be tested
on SGC 425t soon as well.


Revision tags: OPENBSD_5_0_BASE
# 1.62 07-Apr-2011 miod

Do not use NULL in integer comparisons. No functional change.
ok matthew@ tedu@, also eyeballed by at least krw@ oga@ kettenis@ jsg@


Revision tags: OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE
# 1.61 05-Sep-2009 miod

Change the wsdisplay_emulops return types from void to int; emulops will now
return zero on success and nonzero on failure.
This commit only performs mechanical changes for the existing emulops to
always return zero.


Revision tags: OPENBSD_4_5_BASE OPENBSD_4_6_BASE
# 1.60 06-Feb-2009 miod

Split sti structures into rom-related information and screen-related
information. This is preliminary work to help eventually supporting the
dual-head ELK model.

Also split the initialization code in several routines, this makes the
code easier to read, and makes it easier to release resources upon failure.

Finally, don't forget to clear the text planes on non-console displays
when initializing.


# 1.59 06-Feb-2009 miod

The new font selection logic would loop and consume all kmem on proms
with only one font (such as many 712 onboard graphics). Oops again (poukram).


# 1.58 29-Jan-2009 miod

Oops, correct logic when requested font index is out of bounds. Thankfully
it's a can't happen situation.


# 1.57 28-Jan-2009 miod

If the rom contains a monitor table, look for an entry matching our
display resolution, and if one is found, pick the built-in font it points
to, instead of the first font from the list. If the index is wrong and the
font list is shorter, revert to the previous behaviour of using the first
ROM font.

This fixes the font discrepency on my B132L (INTERNAL_EG_1280) where PDC
would use the 10x20 font, which is third in the list, and OpenBSD would
use the 8x16 font instead.

Tested on byte- and word- roms, gsc and pci cards.


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE
# 1.56 01-Oct-2007 krw

More easy bzero() -> M_ZERO. Use 'p = malloc(sizeof(*p) ...'.


Revision tags: OPENBSD_4_2_BASE
# 1.55 17-Jun-2007 miod

We can not consider the first sti region as always mapped, since on pci
cards it is no longer the rom image. This lets sti@pci work on non-dino
bridges.
Found by and ok kettenis@


# 1.54 17-Jun-2007 miod

Make sure to pass valid extended initialization structure pointers in
sti_init(), for recent sti proms require them. Also, return a meaningful
error value.
ok kettenis@ mickey@


Revision tags: OPENBSD_4_1_BASE
# 1.53 12-Jan-2007 miod

Keep the wsscreen_descr in the softc, to allow sti of different text
resolutions to attach without disturbing each other.


# 1.52 11-Jan-2007 miod

Add the ability for a sti backend to specify callbacks to disable and enable
access to the sti rom, as this seems to be necessary for sti@pci; hide this
with macros so that platforms which do not have pci support (i.e. hp300)
do not get bloated from this.

ok mickey@


# 1.51 11-Jan-2007 miod

Allow sti_attach_common() to return an error code, and do not fall into
sti_end_attach() if an error has occured.

ok mickey@


# 1.50 18-Dec-2006 miod

Read word-mode rom regions with bus_space_read_raw_region instead of
bus_space_region, for they might lie on a bus with a different endianness than
the cpu.

ok mickey@


# 1.49 18-Dec-2006 miod

Change sti attachment to pass an array of base addresses for the sti regions,
instead of using the rom mapping for region #0 and the device mapping for
region #1. This will allow sti devices on which regions may be relative to
different origins to attach (to be used very soon).

ok mickey@


# 1.48 16-Dec-2006 miod

Better sti_mapchar() implementation, matches Latin char indexes to HP Roman
font indicies whenever possible.


# 1.47 29-Nov-2006 miod

Add an unpack_attr function to struct wsdisplay_emulops, to match the
existing alloc_attr function. This allows rasops_unpack_attr to be kept
private to rasops, yet available to the screen drivers.


# 1.46 29-Nov-2006 miod

Use uvm_km_alloc() instead of uvm_km_alloc1(), so that the latter can
change within uvm without breaking code. From art@


# 1.45 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.44 22-Aug-2006 miod

Clear sti display on console attach, now that the bootloader leaves us
with scribbles around; ok mickey@


# 1.43 16-Apr-2006 miod

Introduce sti_rom_size() which will compute the size of a card's rom, and
use it instead of duplicating the same logic in 3 places.

ok mickey@


Revision tags: OPENBSD_3_7_BASE OPENBSD_3_8_BASE OPENBSD_3_9_BASE
# 1.42 27-Feb-2005 miod

Split sti softc in two structures, one device-related for regular device
attachment and interface, one screen-attached for the real work.

The attachment code is now required to decide whether sti_end_attach() is
run immediately, or as a startuphook.

This allows hp300 to initialize sti early, and use it as a console; hppa
is functionally unchanged, as it uses the PROM console until the root device
is mounted.


# 1.41 24-Jan-2005 miod

sti colormap fixes:
- correct bounds checking in colormap ioctls.
- force the scment() pointer to NULL on < 8.04 revisions; 8.02 provide a
non-NULL pointer, but it does not point to any meaningful piece of code.


# 1.40 23-Jan-2005 miod

bus_space_map() sti regions with BUS_SPACE_MAP_CACHEABLE if they have the
cache bit set in the region descriptor. Halves sti processing time on hp300.

ok mickey@


# 1.39 23-Jan-2005 miod

Two sti(4) changes necessary for hp300:
- specify which microcode bank (pa or m68k) to use at attachment time.
- compensate for broken 8.02 m68k code which reports wrong frame buffer
offset.

ok mickey@


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


# 1.37 03-Nov-2004 mickey

oops missed to set devtype here rather than in sti_sgc.c:1.23


# 1.36 14-Sep-2004 mickey

allocate ext-cfg memory if was requestd in dd_stimemreq


Revision tags: OPENBSD_3_5_BASE OPENBSD_3_6_BASE SMP_SYNC_A SMP_SYNC_B
# 1.35 16-Dec-2003 mickey

only map the rom and do not touch the hpa space getting rid of memsize define that was not really true; plus tested by otto@ and miod@


# 1.34 21-Oct-2003 jmc

typos from Tom Cosgrove;

Tom: I did not commit a couple of your changes.

i did not include some punctuation fixes (full stops, etc.)
mnemorable -> mnemonic: i decided memorable was probably better
instrunctions -> instruction: i kept the plural


Revision tags: OPENBSD_3_4_BASE
# 1.33 21-Aug-2003 mickey

fix the offsets in decoding byte rom dd (verified per manual); miod@ ok


# 1.32 19-Aug-2003 mickey

give better depth and cmsize


# 1.31 19-Aug-2003 mickey

implement WSDISPLAYIO_{GET,PUT}CMAP; untested


# 1.30 19-Aug-2003 mickey

inquire ext config and dump it in debugging and also fix other debugging prints


# 1.29 17-Aug-2003 mickey

implement WSDISPLAYIO_{S,G}MODE


# 1.28 17-Aug-2003 mickey

print out the graphics id


# 1.27 11-Aug-2003 mickey

free code memory should change permissions fail


# 1.26 02-Jun-2003 mickey

kill the caluses three and four on some of my code


# 1.25 24-May-2003 miod

Disable off-screen font loading. We still need to use the pdc console routines
before we switch to wsdisplay, and this can clobber the font image in some
cases, especially lower (<= 1024x768) resolutions.


Revision tags: UBC_SYNC_A
# 1.24 03-Apr-2003 mickey

adjust protection on the allocated memory through the uvm same as it was allocated w/o cutting short onto the pmap layer


Revision tags: OPENBSD_3_3_BASE
# 1.23 18-Feb-2003 miod

branches: 1.23.2;
Whenever possible, store the prom font data in off-screen frame buffer
memory, and use block move operations in putchar, rather than keeping a copy
of the prom font in memory and using memory to frame buffer transfers.

Recommended by the sti docs. No visible performance improvement though.

Tested on both kind of sti devices by mickey@ and myself.


# 1.22 17-Feb-2003 mickey

can use the same bus_space_read_region_4() to copy both type1 and type4 prom; tested on type4 by me and miod on type1


# 1.21 17-Feb-2003 mickey

oops


# 1.20 11-Feb-2003 miod

As hil devices can only attach after interrupts are enabled, delay
the attachment of wsdisplay to sti as well.
This allows us to have a working console for boot -a, and still attach
a full-blown wscons console as soon as possible.

ok mickey@


# 1.19 11-Feb-2003 miod

Byte-prom font loading support.
ok mickey@


# 1.18 05-Feb-2003 mickey

implement a few wsdisplay ioctls. comment on the putchar implementation


# 1.17 31-Jan-2003 miod

Working wscons attachment and block move operations; joint debug by mickey
and myself.
wsdisplay at sti will be enabled as soon as byte-size rom font loading is done.


# 1.16 31-Jan-2003 mickey

fetch the font and use it, some cleanup and knf


Revision tags: OPENBSD_3_2_BASE UBC_SYNC_B
# 1.15 19-Jul-2002 mickey

a few more comments and debugs, other cosmetic stuff


Revision tags: OPENBSD_3_1_BASE
# 1.14 14-Mar-2002 millert

Final __P removal plus some cosmetic fixups


# 1.13 14-Mar-2002 millert

First round of __P removal in sys


# 1.12 04-Mar-2002 mickey

do not attach wsdisplay if there is none configured


# 1.11 01-Feb-2002 mickey

clean the hppa leftover, from netbsd


# 1.10 25-Jan-2002 mickey

tell wsdisplay if we are a console


Revision tags: UBC_BASE
# 1.9 08-Dec-2001 art

branches: 1.9.2;
Sprinkle pmap_update calls where relevant and some other
misc pmap usage fixes.


# 1.8 02-Dec-2001 mickey

bzero the waa and not ready yet for the console


# 1.7 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.6 19-Sep-2001 mickey

merge vm/vm_kern.h into uvm/uvm_extern.h; art@ ok


Revision tags: OPENBSD_2_9_BASE
# 1.5 20-Mar-2001 mickey

branches: 1.5.4;
better default screen init


# 1.4 16-Feb-2001 mickey

sti_mmap() proper return type


# 1.3 11-Jan-2001 mickey

fix a few types and alignment problems


Revision tags: OPENBSD_2_8_BASE
# 1.2 03-Sep-2000 mickey

fix revision parsing, print local revision


# 1.1 30-May-2000 mickey

sti hp graphics, available in pci and hp-prop sgc bus form factors.
attach point for wsdisplay.
a few problems may exist w/ certain prom versions.
tested in byte- and word-wide modes.
no support yet for multiple resolutions and fonts.
pci not tested (obviously).