Home | History | Annotate | only in /src/sys/arch/luna68k/dev
History log of /src/sys/arch/luna68k/dev
RevisionDateAuthorComments
 1.9 30-Jun-2019  tsutsui Pull OpenBSD/luna88k board.h to define SX9100 board device addresses.

Also replace magic addresses with macro where appropriate.
 1.8 30-Jun-2019  tsutsui Misc KNF.
 1.7 23-Sep-2013  tsutsui branches: 1.7.30;
Tab/space cleanup.
 1.6 19-Jan-2010  pooka branches: 1.6.12; 1.6.22; 1.6.26;
Redefine bpf linkage through an always present op vector, i.e.
#if NBPFILTER is no longer required in the client. This change
doesn't yet add support for loading bpf as a module, since drivers
can register before bpf is attached. However, callers of bpf can
now be modularized.

Dynamically loadable bpf could probably be done fairly easily with
coordination from the stub driver and the real driver by registering
attachments in the stub before the real driver is loaded and doing
a handoff. ... and I'm not going to ponder the depths of unload
here.

Tested with i386/MONOLITHIC, modified MONOLITHIC without bpf and rump.
 1.5 04-Apr-2008  tsutsui branches: 1.5.4;
Split device_t/softc for le(4) and variants and misc cosmetic changes.
 1.4 11-Dec-2005  christos branches: 1.4.74;
merge ktrace-lwp.
 1.3 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.2 02-Oct-2002  thorpej branches: 1.2.6;
Use CFATTACH_DECL().
 1.1 05-Jan-2000  nisimura branches: 1.1.6; 1.1.10; 1.1.14;
Introduce NetBSD/luna68k port into CVS repository.
 1.1.14.1 18-Oct-2002  nathanw Catch up to -current.
 1.1.10.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 05-Jan-2000  bouyer file if_le.c was added on branch thorpej_scsipi on 2000-11-20 20:10:25 +0000
 1.2.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.6.1 03-Aug-2004  skrll Sync with HEAD
 1.4.74.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.4.1 11-Mar-2010  yamt sync with head
 1.6.26.1 18-May-2014  rmind sync with head
 1.6.22.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.12.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.7.30.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.13 15-Jan-2023  tsutsui TAB/space/indent cleanup.
 1.12 29-Dec-2020  tsutsui Make local functions static.
 1.11 30-Jun-2019  tsutsui branches: 1.11.10;
Pull OpenBSD/luna88k board.h to define SX9100 board device addresses.

Also replace magic addresses with macro where appropriate.
 1.10 30-Jun-2019  tsutsui Misc KNF.
 1.9 08-Mar-2018  mrg branches: 1.9.2;
fix various gcc6 m68k issues:
- bad indentation. next68k en.c and mvme68k le_poll.c fixes real issues
in error handling, the rest are NFCI.
- pass 68030 flags as appropriate for mvme68k.
- next68k nextrom.c has -Warray-bounds ignored for an odd expression
that appears to run before relocation, and needs manual offsets
added which trips bounds array checking.

with this all m68k ports build with GCC 6.
 1.8 09-Mar-2017  tsutsui branches: 1.8.12;
Add a driver for LUNA's front panel LCD. Ported from OpenBSD/luna88k.

Reviewed by enami@. Tested by Naruaki Etomi and me.

A 68k LUNA with this driver will be demonstrated at AsiaBSDCon NetBSD booth
by Etomi-san, with LUNA-88K2 running OpenBSD/luna88k by Kenji Aoyama.
 1.7 12-Nov-2011  tsutsui branches: 1.7.10; 1.7.28; 1.7.32; 1.7.36;
Finally complete LUNA-II support, after almost 12 years since
initial import of NetBSD/luna68k.

Note a working LUNA-II machine was found and provided by OMRON guys
after LUNA demonstration at Open Source Conference 2011 Kansai @ Kyoto:
http://mail-index.NetBSD.org/source-changes/2011/07/16/msg024675.html
and this resurrected LUNA-II which runs NetBSD/luna68k -current with Xserver
was also demonstrated on the NetBSD booth at Kansai Open Source 2011:
http://www.NetBSD.org/gallery/events.html#kansai-os-jp-2011

It's really pleasure to meet many OMRON LUNA developers and LUNA users
at the NetBSD booth. Thank you everyone!


Changes details:

luna68k/luna68k/locore.s
- don't use 68030 specific pflusha instruction in 68040 initialization path
- use TBIA() to invalidate TLB instead of 68030's pflusha
after MMU is turned on (as hp300 does)
(these two bugs are fatal at early bootstrap)
- pull loadustp() fixes from hp300/locore.s rev 1.82
(more flush ops are required in it otherwise causes random coredumps)
- specify correct %tt1 mask value
(the mask value means actually bit mask, not transparent range)

luna68k/luna68k/machdep.c
- use proper delay_divisor for 68040 25MHz LUNA-II

luna68k/luna68k/mainbus.c
- prepare and use per-model mainbus device lists for mainbus_attach_args

luna68k/conf/GENERIC
luna68k/conf/INSTALL
- enable options M68040 and FPSP
- enable secondary spc(4) on LUNA-II

luna68k/conf/Makefile.luna68k
- include arch/m68k/fpsp/Makefile.inc for FPSP

luna68k/dev/lcd.c
- promote LUNA-II model on LCD

XXX: old and slow SCSI-1 drives like Hitachi DK312 seems to have
XXX: some problem with spc(4) driver, even on the original LUNA
 1.6 18-Mar-2009  cegger branches: 1.6.12;
Ansify function definitions w/o arguments. Generated with sed.
 1.5 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.4 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.3 28-Apr-2008  martin branches: 1.3.8; 1.3.14;
Remove clause 3 and 4 from TNF licenses
 1.2 07-Jan-2000  nisimura branches: 1.2.6; 1.2.132; 1.2.134; 1.2.136;
- Make SCSI work; by kludges of machine/bus.h. TEAC streamer tape drive
found to be tweaked. Need extensive verifications.
- Add wsmouse node under ws; not useful this moment.
 1.1 05-Jan-2000  nisimura Introduce NetBSD/luna68k port into CVS repository.
 1.2.136.2 04-May-2009  yamt sync with head.
 1.2.136.1 16-May-2008  yamt sync with head.
 1.2.134.1 18-May-2008  yamt sync with head.
 1.2.132.1 02-Jun-2008  mjf Sync with HEAD.
 1.2.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.2.6.1 07-Jan-2000  bouyer file lcd.c was added on branch thorpej_scsipi on 2000-11-20 20:10:25 +0000
 1.3.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.6.12.1 17-Apr-2012  yamt sync with head
 1.7.36.1 21-Apr-2017  bouyer Sync with HEAD
 1.7.32.1 20-Mar-2017  pgoyette Sync with HEAD
 1.7.28.1 28-Aug-2017  skrll Sync with HEAD
 1.7.10.1 03-Dec-2017  jdolecek update from HEAD
 1.8.12.1 15-Mar-2018  pgoyette Synch with HEAD
 1.9.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.11.10.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.49 03-Oct-2022  tsutsui Remove global hwplanecount and use ri_depth in struct rasops instead.

No functional change.
 1.48 01-Oct-2022  tsutsui Set an actual framebuffer depth (bpp) to rasops ri_depth.

The previous value was derived from OpenBSD/luna88k but
it has not been referenced even via ioctl(2).
 1.47 25-Sep-2022  isaki lunafb: Improve drawing performance using VRAM ROP features.
- Drawing a character on 4bpp normally needs 4 times writes, but by using
VRAM ROP actively, it can be reduced to write only once.
The same goes for copyrows. If the whole row consists of only two colors
(one foreground and one background), it can be copied by reading once and
writing once, regardless of the number of planes. Only if the row consists
of more than two colors, it will be copied plane by plane.
- On 8bpp board, it acts as 4bpp (16 colors).
- On 4bpp board on the real LUNA-I(68030/20MHz), monochrome scroll is about
4 times faster even without asm. Using asm improves it by additional 5%
(asm is enabled by default).
- By tsutsui@-san's report, even color scroll is about about 2 times faster
on his 8bpp board on the real LUNA-II(68040).
This was first developped by Y.Sugahara back in late 2019, and was modified
a lot by me in 2022.
http://mail-index.netbsd.org/port-luna68k/2022/09/23/msg000072.html
 1.46 14-Jul-2022  tsutsui Misc KNF and cosmetics.
 1.45 14-Jul-2022  tsutsui Fix pasto.
 1.44 03-Jul-2022  andvar fix various typos in comments, mainly s/pallete/palette/.
 1.43 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.42 24-Apr-2021  thorpej branches: 1.42.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.41 22-Sep-2019  rin branches: 1.41.10;
Correct size of framebuffer; page offset appears only once,
not every color depths.

Pointed out by Araki Ken. Thanks!
 1.40 23-Jul-2019  rin branches: 1.40.2;
For drivers whose framebuffer is located not page-aligned, permit
offset of mmap up to (length of framebuffer) + (page offset of base
address of framebuffer). This is necessary in order to map the
highest page of framebuffer correctly, see,
http://cvsweb.netbsd.org/bsdweb.cgi/xsrc/external/mit/xf86-video-wsfb/dist/src/wsfb_driver.c#rev1.35
 1.39 30-Jun-2019  tsutsui Pull OpenBSD/luna88k board.h to define SX9100 board device addresses.

Also replace magic addresses with macro where appropriate.
 1.38 30-Jun-2019  tsutsui Misc KNF.
 1.37 24-Jan-2018  riastradh branches: 1.37.4;
Fix integer overflows noted by Silvio Cesare of InfoSect.

Someone^TM should name these idioms so we can eliminate this class of
copypasta bug.
 1.36 04-Oct-2014  tsutsui Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.

http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
>> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
>> It makes 4bpp wscons putchar ~20% faster.

This Makes 4bpp wscons putchar ~30% on LUNA-II.

Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.

Tested on all 1bpp/4bpp/8bpp framebuffers.
 1.35 25-Jul-2014  tsutsui branches: 1.35.2;
Implement WSDISPLAYIO_SMODE ioctl for proper mmap and colormap handling.

- allow mmap framebuffer memories only in WSDISPLAYIO_DUMBFB
- initialize palette for ANSI text colors on back to WSDISPLAYIO_MODE_EMUL

Tested on LUNA with 4bpp framebuffer.
 1.34 24-Jul-2014  tsutsui Add consistent prefix to a softc member name.
 1.33 18-Jul-2014  tsutsui Use kmem(9) instead of malloc(9).
 1.32 18-Jul-2014  tsutsui Use C99 struct initialization for wsdisplay_accessops.
 1.31 13-Jul-2014  tsutsui Setup Bt458 color palette to support ANSI color text on 8bpp framebuffer.

Mostly taken from OpenBSD/luna88k. Also sync some comments.
Tested on LUNA-II, and mlterm-fb with 8bpp wallpaper also works fine.

Thanks to Kenji Aoyama (OpenBSD/luna88k maintainer) for providing
his spare 8bpp board.
 1.30 30-Dec-2013  tsutsui branches: 1.30.2;
Pull a fix of Bt458 (8bpp framebuffer) initialization from OpenBSD/luna88k.

http://marc.info/?l=openbsd-cvs&m=138838884202196
>> Correct initialization of Bt458, used in LUNA's 8bpp frame buffer.
>>
>> According to the manual, the address register does not automatically
>> increment when we access to the control registers. Also we disable
>> overlay planes, because we do not use them.
 1.29 28-Dec-2013  tsutsui Add preleminary support of 4bpp LUNA framebuffer.

Changes details:
- prepare and switch 4bpp rasops functions that read/write all 4 planes
and also handle both fg and bg colors
- make 1bpp ops use first plane on write rather than common bitmap plane
(which is prepared for multiple plane write with raster ops)
- prepare 4bpp allocattr function to handle ANSI 16 color text
- split omrasops_init() function for each bpp
- move struct hwcmap from softc to hwdevconfig to sync palette values
on initialization
- allow mmap(2) against all available planes

Now we can use ANSI 16 color text console and also can
demonstrate mlterm-fb with color sixel graphics and wallpaper.
XXX: Xserver needs much more work.
 1.28 14-Dec-2013  tsutsui Initialize capabilities in struct wsscreen_descr per omrasops settings.

Now REVERSE characters are drawn properly.
 1.27 19-Jul-2013  tsutsui Properly initialize the palette for while on black even on 1bpp framebuffer.
Preparing for demonstration in Open Source Conference 2013 Kyoto.
 1.26 20-Jul-2012  tsutsui branches: 1.26.2; 1.26.4; 1.26.10;
Switch luna68k wscons framebuffer driver to using rasops(9) APIs instead of
deprecated rcons(4). This allows "options FONT_foo" in kernel config files.
Mostly taken from OpenBSD/luna88k, but unnecessary MI rasops(9) stuff is
omitted since omrasops.c has own raster wsdisplay_emulops functions.
Tested on LUNA with 4bpp fb and LUNA-II with 1bpp fb.
 1.25 27-Jul-2011  tsutsui branches: 1.25.2; 1.25.8;
KNF, use uintNN_t, tab/space cosmetics etc.
 1.24 27-Jul-2011  tsutsui - split device_t/softc and use device_t and cfdata_t etc.
- use aprint_normal(9)
- include "ioconf.h" for struct cfdriver decls
No crash on LUNA.
 1.23 21-Jul-2011  tsutsui Add and return WSKBD_TYPE_LUNA and WSDISPLAY_TYPE_LUNA on WS*_GTYPE ioctls.

XXX: should we still sync <sys/dev/wsconsio.h> and src/sbin/wsconsctl/util.c?
 1.22 21-Jul-2011  tsutsui Changes put for luna68k X.Org mono server demo at OSC 2011 Kansai @ Kyoto:
- sprinkle volatile around register access
- initialize pallete for WHITE on BLACK text
- add WSDISPLAYIO_LINEBYTES ioctl(2)
- fix index count in omsetcmap()
- make omfbmmap() return cookie for OMFB_FB_RADDR to make
X.Org wsfb driver work on 1bpp framebuffer memory
(XXX: should revisit later)
- make WSDISPLAYIO_GINFO always return 1bpp to avoid pallete mangled
by X.Org server initialization
(XXX: should revisit later)
 1.21 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.20 16-Mar-2009  dsl ANSIfy functions with function-pointer arguments
 1.19 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.18 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.17 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.16 28-Apr-2008  martin branches: 1.16.8; 1.16.14;
Remove clause 3 and 4 from TNF licenses
 1.15 04-Mar-2007  christos branches: 1.15.40; 1.15.42; 1.15.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.14 12-Apr-2006  jmmv branches: 1.14.14;
Add an extra cookie to the ioctl and mmap wsdisplay accessops that points
to the screen on which they are being called. The driver cannot guess
this by itself but it is needed to implement, at least, the getwschar and
putwschar functions in the correct place. There are no functional changes
yet.

Tested on i386 (vga, vga_raster, machfb, vesafb), macppc and sparc64.
Suggested and reviewed by macallan@.
 1.13 11-Dec-2005  christos branches: 1.13.4; 1.13.6; 1.13.8; 1.13.10; 1.13.12;
merge ktrace-lwp.
 1.12 13-Nov-2003  chs branches: 1.12.16;
eliminate uvm_useracc() in favor of checking the return value of
copyin() or copyout().

uvm_useracc() tells us whether the mapping permissions allow access to
the desired part of an address space, and many callers assume that
this is the same as knowing whether an attempt to access that part of
the address space will succeed. however, access to user space can
fail for reasons other than insufficient permission, most notably that
paging in any non-resident data can fail due to i/o errors. most of
the callers of uvm_useracc() make the above incorrect assumption. the
rest are all misguided optimizations, which optimize for the case
where an operation will fail. we'd rather optimize for operations
succeeding, in which case we should just attempt the access and handle
failures due to insufficient permissions the same way we handle i/o
errors. since there appear to be no good uses of uvm_useracc(), we'll
just remove it.
 1.11 02-Apr-2003  thorpej branches: 1.11.2;
Use PAGE_SIZE rather than NBPG.
 1.10 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.9 06-Aug-2002  itojun integer overflow. from silvio@qualys.com
 1.8 04-Jul-2002  junyoung alloc_attr -> allocattr

Approved by Matthias Drochner.
 1.7 17-Mar-2002  atatat branches: 1.7.4; 1.7.6;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.6 29-Jun-2000  mrg branches: 1.6.2; 1.6.6; 1.6.10;
remove include of <vm/vm.h>. <vm/vm.h> -> <uvm/uvm_extern.h>
 1.5 26-Jun-2000  simonb Change the kernel mmap interface so that the offset to map is an
"off_t" and the return value is a "paddr_t" to allow mappings
at offsets past 2^31 bytes. Somewhat inspired by FreeBSD, which
only changed the offset to a "vm_offset_t".

Includes updates for the i386, pc532 and sh3 mmmmap from Jason Thorpe.
 1.4 12-Jan-2000  nisimura branches: 1.4.4;
- Fix an error in clearing entire screen.
- Add 3 byte long mouse event parsing.
- Fix errors in comments.
 1.3 08-Jan-2000  nisimura Kludge to avoid a panic in badaddr() when no framebuffer is installed.
 1.2 06-Jan-2000  nisimura Fix a typo of screen size; pointed by tsubai.
 1.1 05-Jan-2000  nisimura Introduce NetBSD/luna68k port into CVS repository.
 1.4.4.2 04-Sep-2002  itojun pullup (itojun)

sys/arch/amiga/dev/grf_cv3d.c 1.11
sys/arch/hpcmips/dev/mq200.c 1.21
sys/arch/i386/i386/sys_machdep.c 1.64
sys/arch/luna68k/dev/lunafb.c 1.9
sys/arch/sparc/dev/bt_subr.c via patch
sys/arch/sparc64/dev/bt_subr.c via patch
sys/arch/sun3/dev/bt_subr.c via patch
sys/compat/ibcs2/ibcs2_stat.c 1.21-1.23
sys/dev/sun/bt_subr.c 1.3
sys/dev/tc/cfb.c 1.34
sys/dev/tc/sfb.c 1.53
sys/dev/tc/xcfb.c 1.29
integer overflow. reported by silvio@qualys.com
 1.4.4.1 30-Jun-2000  simonb Pull up mmap paddr_t/off_t changes from trunk.
 1.6.10.4 18-Oct-2002  nathanw Catch up to -current.
 1.6.10.3 13-Aug-2002  nathanw Catch up to -current.
 1.6.10.2 01-Aug-2002  nathanw Catch up to -current.
 1.6.10.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.6.6.3 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.6.6.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.6.6.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.6.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.2.1 29-Jun-2000  bouyer file lunafb.c was added on branch thorpej_scsipi on 2000-11-20 20:10:25 +0000
 1.7.6.1 07-Aug-2002  lukem Pull up revision 1.9 (requested by itojun in ticket #616):
integer overflow. from silvio@qualys.com
 1.7.4.2 31-Aug-2002  gehenna catch up with -current.
 1.7.4.1 16-Jul-2002  gehenna catch up with -current.
 1.11.2.4 25-Jan-2005  skrll Adapt to branch.
 1.11.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.11.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.11.2.1 03-Aug-2004  skrll Sync with HEAD
 1.12.16.2 03-Sep-2007  yamt sync with head.
 1.12.16.1 21-Jun-2006  yamt sync with head.
 1.13.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.13.10.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.13.8.1 24-May-2006  yamt sync with head.
 1.13.6.1 22-Apr-2006  simonb Sync with head.
 1.13.4.1 09-Sep-2006  rpaulo sync with head
 1.14.14.1 12-Mar-2007  rmind Sync with HEAD.
 1.15.44.2 04-May-2009  yamt sync with head.
 1.15.44.1 16-May-2008  yamt sync with head.
 1.15.42.1 18-May-2008  yamt sync with head.
 1.15.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.16.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.16.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.25.8.3 09-Nov-2014  msaitoh Pull up following revision(s) (requested by tsutsui in ticket #1182):
sys/arch/luna68k/conf/files.luna68k: revision 1.24
sys/arch/luna68k/conf/GENERIC: revision 1.113 via patch
sys/arch/luna68k/dev/omrasops.c: revision 1.17-1.19
sys/arch/luna68k/dev/lunaws.c: revision 1.30
sys/arch/luna68k/dev/omkbdmap.c: revision 1.1-1.2
sys/arch/luna68k/dev/omkbdmap.h: revision 1.1
sys/arch/luna68k/dev/lunafb.c: revision 1.31-1.36
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.3
- Setup Bt458 color palette to support ANSI color text on 8bpp framebuffer.
Mostly taken from OpenBSD/luna88k. Also sync some comments.
Tested on LUNA-II, and mlterm-fb with 8bpp wallpaper also works fine.
Thanks to Kenji Aoyama (OpenBSD/luna88k maintainer) for providing
his spare 8bpp board.
- Use C99 struct initialization for wsdisplay_accessops.
- Use kmem(9) instead of malloc(9).
- Pull LUNA's keyboard driver changes from OpenBSD/luna88k. Now LUNA's
keyboard works on Xorg server without tweaks by xmodmap(1) etc.
- split keyboard mapping definitions to new files, omkbdmap.[ch]
- add WSDISPLAY_COMPAT_RAWKBD support
(actually the name is wrong; it doesn't emit raw keycode but
converts MD code into PS/2 one as "raw keycode on x86" for Xorg server)
- allow to enter into ddb by CTRL+ALT(zenmen)+ESC
- remove unnecessary return values
- Add consistent prefix to a softc member name.
- Implement WSDISPLAYIO_SMODE ioctl for proper mmap and colormap handling.
Tested on LUNA with 4bpp framebuffer.
- allow mmap framebuffer memories only in WSDISPLAYIO_DUMBFB
- initialize palette for ANSI text colors on back to WSDISPLAYIO_MODE_EMUL
- Pull readability changes from OpenBSD/luna88k.
Tested on LUNA-II with 8bpp framebuffer.
- prepare and use unpack_attr() function to get fg and bg from attribute
- use proper variable names to clarify meanings
- Put dumb optimizations to avoid conditionals in putchar drawing loops.
~10% improvements of time cat results on LUNA-II 8bpp framebuffer.
- Fix unintended RCS Id substitution.
- Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.
This Makes 4bpp wscons putchar ~30% on LUNA-II.
http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
> It makes 4bpp wscons putchar ~20% faster.
Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.
Tested on all 1bpp/4bpp/8bpp framebuffers.
- Add options WSDISPLAY_COMPAT_RAWKBD for Xorg server.
 1.25.8.2 12-Jan-2014  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1005):
sys/arch/luna68k/dev/omrasops.c: revision 1.15
sys/arch/luna68k/dev/omrasops.c: revision 1.16
sys/arch/luna68k/dev/lunafb.c: revision 1.27
sys/arch/luna68k/dev/lunafb.c: revision 1.28
sys/arch/luna68k/dev/lunafb.c: revision 1.29
sys/arch/luna68k/dev/lunafb.c: revision 1.30
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.2
sys/arch/luna68k/dev/omrasops.c: revision 1.14
Properly initialize the palette for while on black even on 1bpp framebuffer.
Preparing for demonstration in Open Source Conference 2013 Kyoto.
Fix off by one in copyrows() backward case.
Make omrasops copycols() op work even if columns are not 32 bit aligned.
This means command line editing works properly in any cases.
The bitcopy strategies for 1bpp copycols() op are taken from
recently fixed MI sys/dev/rasops/rasops_bitops.h.
GETBITS() and PUTBITS() m68k asm macro are taken from hp300.
Tested on both 1bpp (on LUNA-II) and 4bpp (on LUNA) framebuffers.
Initialize capabilities in struct wsscreen_descr per omrasops settings.
Now REVERSE characters are drawn properly.
Add preleminary support of 4bpp LUNA framebuffer.
Changes details:
- prepare and switch 4bpp rasops functions that read/write all 4 planes
and also handle both fg and bg colors
- make 1bpp ops use first plane on write rather than common bitmap plane
(which is prepared for multiple plane write with raster ops)
- prepare 4bpp allocattr function to handle ANSI 16 color text
- split omrasops_init() function for each bpp
- move struct hwcmap from softc to hwdevconfig to sync palette values
on initialization
- allow mmap(2) against all available planes
Now we can use ANSI 16 color text console and also can
demonstrate mlterm-fb with color sixel graphics and wallpaper.
XXX: Xserver needs much more work.
Pull a fix of Bt458 (8bpp framebuffer) initialization from OpenBSD/luna88k.
http://marc.info/?l=openbsd-cvs&m=138838884202196
> Correct initialization of Bt458, used in LUNA's 8bpp frame buffer.
>
> According to the manual, the address register does not automatically
> increment when we access to the control registers. Also we disable
> overlay planes, because we do not use them.
 1.25.8.1 25-Jul-2012  martin Pull up following revision(s) (requested by tsutsui in ticket #444):
sys/arch/luna68k/conf/GENERIC: revision 1.99
sys/arch/luna68k/dev/lunafb.c: revision 1.26
sys/arch/luna68k/luna68k/locore.s: revision 1.48
sys/arch/luna68k/dev/lunaws.c: revision 1.24
sys/arch/luna68k/dev/omron_rfont.h: file removal
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.1
sys/arch/luna68k/dev/omrasops.c: revision 1.12
sys/arch/luna68k/dev/omrasops.c: revision 1.13
sys/arch/luna68k/conf/INSTALL: revision 1.6
Use & not && to mask bits. From OpenBSD/luna88k
Fix typo in comment. From OpenBSD/luna88k.
Switch luna68k wscons framebuffer driver to using rasops(9) APIs instead of
deprecated rcons(4). This allows "options FONT_foo" in kernel config files.
Mostly taken from OpenBSD/luna88k, but unnecessary MI rasops(9) stuff is
omitted since omrasops.c has own raster wsdisplay_emulops functions.
Tested on LUNA with 4bpp fb and LUNA-II with 1bpp fb.
Make reboot(2) actually work (don't access %sp after MMU is turned off).
Also cleanup spaces and #if 0'ed code. Tested on both LUNA and LUNA-II.
Should be pulled up to netbsd-6.
 1.25.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.25.2.1 30-Oct-2012  yamt sync with head
 1.26.10.1 23-Jul-2013  riastradh sync with HEAD
 1.26.4.2 18-May-2014  rmind sync with head
 1.26.4.1 28-Aug-2013  rmind sync with head
 1.26.2.2 03-Dec-2017  jdolecek update from HEAD
 1.26.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.30.2.1 10-Aug-2014  tls Rebase.
 1.35.2.1 05-Oct-2014  martin Pull up following revision(s) (requested by tsutsui in ticket #130):
sys/arch/luna68k/dev/omrasops.c: revision 1.17
sys/arch/luna68k/dev/omrasops.c: revision 1.18
sys/arch/luna68k/dev/omrasops.c: revision 1.19
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.3
sys/arch/luna68k/dev/lunafb.c: revision 1.36
Pull readability changes from OpenBSD/luna88k.
- prepare and use unpack_attr() function to get fg and bg from attribute
- use proper variable names to clarify meanings
Tested on LUNA-II with 8bpp framebuffer.
Put dumb optimizations to avoid conditionals in putchar drawing loops.
~10% improvements of time cat results on LUNA-II 8bpp framebuffer.
Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.
http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
> It makes 4bpp wscons putchar ~20% faster.
This Makes 4bpp wscons putchar ~30% on LUNA-II.
Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.
Tested on all 1bpp/4bpp/8bpp framebuffers.
 1.37.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.40.2.1 03-Oct-2019  martin Pull up following revision(s) (requested by rin in ticket #271):

sys/arch/luna68k/dev/lunafb.c: revision 1.41

Correct size of framebuffer; page offset appears only once,
not every color depths.

Pointed out by Araki Ken. Thanks!
 1.41.10.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.42.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.42 15-Jan-2023  tsutsui TAB/space/indent cleanup.
 1.41 25-Jun-2022  tsutsui Add rnd(9) entropy source from keyboard and mouse.
 1.40 09-Oct-2021  tsutsui Handle wskbd(9) .set_leds op in cngetc(9) using wskbd_cnattach(9) cookie.

XXX1: LUNA's keyboards emulate "mechanical lock" for CAP and Kana keys,
i.e. it sends "DOWN" code only when CAP/Kana LEDs are turned on
and send "UP" code only when the LEDs are turned off.
The MD omkbd_input() via wskbd_input(9) for the normal wskbd(4)
(i.e. ttyE0) devices handles this quirk, but MI wskbd_cngetc()
in sys/dev/wscons/wskbd.c can do nothing for this.

XXX2: I wonder if we should have an independent .set_leds op for cons(9)
as cnbell(9), rather than referring a device specific softc stuff
during .set_leds op in struct wskbd_accessop (registered during
autoconf(9) via struct wskbddev_attach_args passed to config_found(9))
even for wskbd cngetc(9) op in struct wskbd_consops (registered
via early wskbd_cnattach(9)).
 1.39 25-Sep-2021  tsutsui Refactor and cleanup sio (uPD7201) drivers.

- remove confusing syscn*() functions (and its header) and prepare
explicit siottycninit(), siottycnget() and siottycnput() functions
- use exported struct consdev and cn_tab to initialize siotty console
- enable and handle E/S interrupts to make BREAK signal detected properly
- make CSR (status regsiters) access functions inline static
- make single byte read/write (i.e. cnputc() and cngetc()) functions
static inline and take struct sio_register rather than sio channel
- use proper integer type (uint16_t) for getsiocsr() as siotty.c
- handle channel dependent CR2A and CR2B registers properly
- use more explicit definitions for RR_* macro used by getsiocsr()
- define and use proper RR0 (read register) values
(there is no isStatusReg(r) macro used on 4.4BSD/luna68k)

Tested on LUNA with both wscons console and serial console.
 1.38 20-Sep-2021  tsutsui Add a comment that .set_leds function won't work correctly on cngetc(9).

I'm afraid all other keyboard drivers that have .set_leds function
(like sgimips/dev/zs_kbd.c) have the same issue.
Maybe we needs 'polled' flag in .set_leds function, or an independent
.set_leds accessop in struct wskbd_consops for cons(9).
 1.37 19-Sep-2021  tsutsui Use more C99 designated initializer.
 1.36 19-Sep-2021  tsutsui Handle CAP and Kana modifier key specification quirk of LUNA's keyboard.

LUNA's keyboard doesn't send any keycode when these modifier keys are
released. Instead, it sends a pressed or released code per how each
modifier LED status will be changed when the modifier keys are pressed.
To handle this quirk in MI wskbd(4) layer, we have to send a faked
"pressed and released" sequence on passing keycodes to wskbd_input(9).

Tested on LUNA both on ttyE0 and WSKBD_RAW mode (on Xorg server).
 1.35 18-Sep-2021  tsutsui Implement transmitting keyboard LED and buzzer control commands.

- enable TX on uPD7201 for keyboard port
- prepare TX queue and handle it in hardware interrupt and softint(9)
- send proper LED commands on WSKBDIO_SETLEDS
(XXX: KANA LED is not handled in wscons)
- return current LED settings on WSKBDIO_GETLEDS
- implement WSKBDIO_COMPLEXBELL by parsing struct wskbd_bell_data and
send proper buzzer commands
- handle pitch, period, and volume in cnbell(9)
(XXX: no description in cnbell(9) man pages)
- use proper queued TX function for omms_enable() and omms_disable()
- add DPRINTF()s for debug
- use C99 designated initializer and misc cosmetics

Tested on LUNA and its keyboard (3W4SD-098NDT).
 1.34 04-Sep-2021  tsutsui Ignore mouse packets properly even if wsmouse(4) isn't configured.

The internal state of wskbd(4) could be mangled if mouse (which was
connected behind keyboard) was enabled by unexpected keyboard reset.
This could happen on the INSTALL kernel (no wsmouse(4) on it).

Based on a patch from moveccr, with several tweaks by me.
 1.33 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.32 24-Apr-2021  thorpej branches: 1.32.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.31 21-Aug-2015  christos branches: 1.31.32;
- move prototypes to common header file
- rename function to avoid confusion with pseudo-device attach
 1.30 20-Jul-2014  tsutsui branches: 1.30.4;
Pull LUNA's keyboard driver changes from OpenBSD/luna88k.

- split keyboard mapping definitions to new files, omkbdmap.[ch]
- add WSDISPLAY_COMPAT_RAWKBD support
(actually the name is wrong; it doesn't emit raw keycode but
converts MD code into PS/2 one as "raw keycode on x86" for Xorg server)
- allow to enter into ddb by CTRL+ALT(zenmen)+ESC
- remove unnecessary return values

Now LUNA's keyboard works on Xorg server without tweaks by xmodmap(1) etc.
 1.29 18-Jul-2014  tsutsui Minor KNF. No binary changes.
 1.28 02-Feb-2014  tsutsui branches: 1.28.2;
Misc cleanup of sio drivers.

- register softc of child devices as an argument of the sio interrupt
handler to avoid device_lookup_private() calls on every interrupt
- change type of sc_reg from (void *) to (struct sioreg *)
to avoid weird address offset calculations with redundant casts
- rename struct sio_softc members for consistency
- use a channel number passed via sio_attach_args in lunaws_attach()

No functional chnages. Tested on LUNA.
 1.27 23-Sep-2013  tsutsui Tab/space cleanup.
 1.26 14-May-2013  tsutsui branches: 1.26.2;
Use softint(9) to pass received data into wskbd(9) and wsmouse(9) layers.
It might be problematic to call them from an interrupt handler at IPL_SERIAL.
 1.25 13-Oct-2012  tsutsui struct device * -> device_t, use device_xname() (from chs@)
 1.24 16-Jul-2012  tsutsui branches: 1.24.2;
Use & not && to mask bits. From OpenBSD/luna88k
 1.23 27-Jul-2011  tsutsui branches: 1.23.2; 1.23.8;
KNF, use uintNN_t, tab/space cosmetics etc.
 1.22 27-Jul-2011  tsutsui - split device_t/softc and use device_t and cfdata_t etc.
- use aprint_normal(9)
- include "ioconf.h" for struct cfdriver decls
No crash on LUNA.
 1.21 21-Jul-2011  tsutsui Add and return WSKBD_TYPE_LUNA and WSDISPLAY_TYPE_LUNA on WS*_GTYPE ioctls.

XXX: should we still sync <sys/dev/wsconsio.h> and src/sbin/wsconsctl/util.c?
 1.20 26-Oct-2009  cegger kill extra whitespaces
reviewed by tsutsui@
 1.19 18-Mar-2009  cegger bcopy -> memcpy
 1.18 18-Mar-2009  cegger Ansify function definitions w/o arguments. Generated with sed.
 1.17 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.16 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.15 13-Jun-2008  cegger branches: 1.15.4; 1.15.10;
use device_lookup_private to get softc
 1.14 28-Apr-2008  martin branches: 1.14.2; 1.14.4;
Remove clause 3 and 4 from TNF licenses
 1.13 04-Mar-2007  christos branches: 1.13.40; 1.13.42; 1.13.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.12 12-Nov-2006  plunky branches: 1.12.4;
Tidy away wsmouse_input() abstractions and update
documentation to include the W direction.
 1.11 11-Dec-2005  christos branches: 1.11.20; 1.11.22;
merge ktrace-lwp.
 1.10 28-Jun-2005  drochner branches: 1.10.2;
convert remaining autoconf bus "submatch" functions to use the new
signature (passing locators), and remove some which obviously don't
serve any purpose
(untested, sorry)
 1.9 02-Oct-2002  thorpej branches: 1.9.6;
Use CFATTACH_DECL().
 1.8 27-Sep-2002  thorpej Introduce a new routine, config_match(), which invokes the
cfattach->ca_match function in behalf of the caller. Use it
rather than invoking cfattach->ca_match directly.
 1.7 27-Sep-2002  thorpej Rather than referencing the cfdriver directly in the cfdata entries,
instead use a string naming the driver. The cfdriver is then looked
up in a list which is built at run-time.
 1.6 17-Mar-2002  atatat Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.5 19-Oct-2000  nisimura branches: 1.5.2; 1.5.6; 1.5.10;
Fix errors in mouse event handling;
- convert LMR bit pattern into RML since wsevent counts 0 for the leftmost
mouse button.
- found hardware reports mouse button state in negated.
 1.4 14-Jan-2000  nisimura Fix an argument error of wsmouse_input() call.
 1.3 12-Jan-2000  nisimura - Fix an error in clearing entire screen.
- Add 3 byte long mouse event parsing.
- Fix errors in comments.
 1.2 07-Jan-2000  nisimura - Make SCSI work; by kludges of machine/bus.h. TEAC streamer tape drive
found to be tweaked. Need extensive verifications.
- Add wsmouse node under ws; not useful this moment.
 1.1 05-Jan-2000  nisimura Introduce NetBSD/luna68k port into CVS repository.
 1.5.10.2 18-Oct-2002  nathanw Catch up to -current.
 1.5.10.1 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.5.6.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.5.6.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.5.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.5.2.1 19-Oct-2000  bouyer file lunaws.c was added on branch thorpej_scsipi on 2000-11-20 20:10:26 +0000
 1.9.6.2 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.9.6.1 25-Jan-2005  skrll Adapt to branch.
 1.10.2.3 03-Sep-2007  yamt sync with head.
 1.10.2.2 30-Dec-2006  yamt sync with head.
 1.10.2.1 21-Jun-2006  yamt sync with head.
 1.11.22.1 10-Dec-2006  yamt sync with head.
 1.11.20.1 18-Nov-2006  ad Sync with head.
 1.12.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.13.44.3 11-Mar-2010  yamt sync with head
 1.13.44.2 04-May-2009  yamt sync with head.
 1.13.44.1 16-May-2008  yamt sync with head.
 1.13.42.2 17-Jun-2008  yamt sync with head.
 1.13.42.1 18-May-2008  yamt sync with head.
 1.13.40.2 29-Jun-2008  mjf Sync with HEAD.
 1.13.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.14.4.1 18-Jun-2008  simonb Sync with head.
 1.14.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.15.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.15.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.23.8.3 09-Nov-2014  msaitoh Pull up following revision(s) (requested by tsutsui in ticket #1182):
sys/arch/luna68k/conf/files.luna68k: revision 1.24
sys/arch/luna68k/conf/GENERIC: revision 1.113 via patch
sys/arch/luna68k/dev/omrasops.c: revision 1.17-1.19
sys/arch/luna68k/dev/lunaws.c: revision 1.30
sys/arch/luna68k/dev/omkbdmap.c: revision 1.1-1.2
sys/arch/luna68k/dev/omkbdmap.h: revision 1.1
sys/arch/luna68k/dev/lunafb.c: revision 1.31-1.36
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.3
- Setup Bt458 color palette to support ANSI color text on 8bpp framebuffer.
Mostly taken from OpenBSD/luna88k. Also sync some comments.
Tested on LUNA-II, and mlterm-fb with 8bpp wallpaper also works fine.
Thanks to Kenji Aoyama (OpenBSD/luna88k maintainer) for providing
his spare 8bpp board.
- Use C99 struct initialization for wsdisplay_accessops.
- Use kmem(9) instead of malloc(9).
- Pull LUNA's keyboard driver changes from OpenBSD/luna88k. Now LUNA's
keyboard works on Xorg server without tweaks by xmodmap(1) etc.
- split keyboard mapping definitions to new files, omkbdmap.[ch]
- add WSDISPLAY_COMPAT_RAWKBD support
(actually the name is wrong; it doesn't emit raw keycode but
converts MD code into PS/2 one as "raw keycode on x86" for Xorg server)
- allow to enter into ddb by CTRL+ALT(zenmen)+ESC
- remove unnecessary return values
- Add consistent prefix to a softc member name.
- Implement WSDISPLAYIO_SMODE ioctl for proper mmap and colormap handling.
Tested on LUNA with 4bpp framebuffer.
- allow mmap framebuffer memories only in WSDISPLAYIO_DUMBFB
- initialize palette for ANSI text colors on back to WSDISPLAYIO_MODE_EMUL
- Pull readability changes from OpenBSD/luna88k.
Tested on LUNA-II with 8bpp framebuffer.
- prepare and use unpack_attr() function to get fg and bg from attribute
- use proper variable names to clarify meanings
- Put dumb optimizations to avoid conditionals in putchar drawing loops.
~10% improvements of time cat results on LUNA-II 8bpp framebuffer.
- Fix unintended RCS Id substitution.
- Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.
This Makes 4bpp wscons putchar ~30% on LUNA-II.
http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
> It makes 4bpp wscons putchar ~20% faster.
Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.
Tested on all 1bpp/4bpp/8bpp framebuffers.
- Add options WSDISPLAY_COMPAT_RAWKBD for Xorg server.
 1.23.8.2 12-Jan-2014  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1004):
sys/arch/luna68k/dev/siotty.c: revision 1.35
sys/arch/luna68k/dev/siotty.c: revision 1.36
sys/arch/luna68k/dev/siotty.c: revision 1.37
sys/arch/luna68k/dev/siotty.c: revision 1.38
sys/arch/luna68k/dev/lunaws.c: revision 1.25
sys/arch/luna68k/dev/lunaws.c: revision 1.26
sys/arch/luna68k/dev/lunaws.c: revision 1.27
sys/arch/luna68k/dev/siovar.h: revision 1.7
sys/arch/luna68k/dev/siotty.c: revision 1.34
struct device * -> device_t, use device_xname() (from chs@)
Whitespace cleanup.
Use softint(9) to pass received data into wskbd(9) and wsmouse(9) layers.
It might be problematic to call them from an interrupt handler at IPL_SERIAL.
Tab/space cleanup.
Use softint(9) properly to process TX/RX data between tty(4) layer.
It could cause possible locking issue to call tty(4) layer functions
from IPL_SERIAL interrupt handlers.
Changes details (mostly similar to com(4) and z8530tty(4)):
- allocate RX buffer and put data and status into it in the interrupt handler
- call t_linesw->l_rint from the software interrupt handler
- set the only first byte in siottystart() and use t_outq buffer to send
multiple TX data
- call the next t_linesw->l_start on TX complete in the software interrupt
handler
Also put more changes:
- handle cnmagic(9) properly (now entering ddb(4) by console BREAK works)
- allocate tty in the attach function as other drivers rather than first open
- use proper variable types
Remove initialization of unused t_softc in struct tty (to make pullup easier).
 1.23.8.1 25-Jul-2012  martin Pull up following revision(s) (requested by tsutsui in ticket #444):
sys/arch/luna68k/conf/GENERIC: revision 1.99
sys/arch/luna68k/dev/lunafb.c: revision 1.26
sys/arch/luna68k/luna68k/locore.s: revision 1.48
sys/arch/luna68k/dev/lunaws.c: revision 1.24
sys/arch/luna68k/dev/omron_rfont.h: file removal
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.1
sys/arch/luna68k/dev/omrasops.c: revision 1.12
sys/arch/luna68k/dev/omrasops.c: revision 1.13
sys/arch/luna68k/conf/INSTALL: revision 1.6
Use & not && to mask bits. From OpenBSD/luna88k
Fix typo in comment. From OpenBSD/luna88k.
Switch luna68k wscons framebuffer driver to using rasops(9) APIs instead of
deprecated rcons(4). This allows "options FONT_foo" in kernel config files.
Mostly taken from OpenBSD/luna88k, but unnecessary MI rasops(9) stuff is
omitted since omrasops.c has own raster wsdisplay_emulops functions.
Tested on LUNA with 4bpp fb and LUNA-II with 1bpp fb.
Make reboot(2) actually work (don't access %sp after MMU is turned off).
Also cleanup spaces and #if 0'ed code. Tested on both LUNA and LUNA-II.
Should be pulled up to netbsd-6.
 1.23.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.23.2.1 30-Oct-2012  yamt sync with head
 1.24.2.4 03-Dec-2017  jdolecek update from HEAD
 1.24.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.24.2.2 23-Jun-2013  tls resync from head
 1.24.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.26.2.1 18-May-2014  rmind sync with head
 1.28.2.1 10-Aug-2014  tls Rebase.
 1.30.4.1 22-Sep-2015  skrll Sync with HEAD
 1.31.32.1 02-Apr-2021  thorpej config_found_ia() -> config_found() w/ CFARG_IATTR.
 1.32.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.2 21-Jan-2002  jdolecek Switch to MI dev/md_root.c for archs which don't have any special
memory disk hooks (i.e. everything except atari).
 1.1 05-Jan-2000  nisimura branches: 1.1.6; 1.1.10; 1.1.14;
Introduce NetBSD/luna68k port into CVS repository.
 1.1.14.1 28-Feb-2002  nathanw Catch up to -current.
 1.1.10.1 11-Feb-2002  jdolecek Sync w/ -current.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 05-Jan-2000  bouyer file md_root.c was added on branch thorpej_scsipi on 2000-11-20 20:10:26 +0000
 1.3 15-Jan-2023  tsutsui TAB/space/indent cleanup.
 1.2 04-Oct-2014  tsutsui branches: 1.2.2;
Fix unintended RCS Id substitution.
 1.1 20-Jul-2014  tsutsui branches: 1.1.2; 1.1.6;
Pull LUNA's keyboard driver changes from OpenBSD/luna88k.

- split keyboard mapping definitions to new files, omkbdmap.[ch]
- add WSDISPLAY_COMPAT_RAWKBD support
(actually the name is wrong; it doesn't emit raw keycode but
converts MD code into PS/2 one as "raw keycode on x86" for Xorg server)
- allow to enter into ddb by CTRL+ALT(zenmen)+ESC
- remove unnecessary return values

Now LUNA's keyboard works on Xorg server without tweaks by xmodmap(1) etc.
 1.1.6.3 03-Dec-2017  jdolecek update from HEAD
 1.1.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.6.1 20-Jul-2014  tls file omkbdmap.c was added on branch tls-maxphys on 2014-08-20 00:03:10 +0000
 1.1.2.2 10-Aug-2014  tls Rebase.
 1.1.2.1 20-Jul-2014  tls file omkbdmap.c was added on branch tls-earlyentropy on 2014-08-10 06:54:00 +0000
 1.2.2.2 09-Nov-2014  msaitoh Pull up following revision(s) (requested by tsutsui in ticket #1182):
sys/arch/luna68k/conf/files.luna68k: revision 1.24
sys/arch/luna68k/conf/GENERIC: revision 1.113 via patch
sys/arch/luna68k/dev/omrasops.c: revision 1.17-1.19
sys/arch/luna68k/dev/lunaws.c: revision 1.30
sys/arch/luna68k/dev/omkbdmap.c: revision 1.1-1.2
sys/arch/luna68k/dev/omkbdmap.h: revision 1.1
sys/arch/luna68k/dev/lunafb.c: revision 1.31-1.36
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.3
- Setup Bt458 color palette to support ANSI color text on 8bpp framebuffer.
Mostly taken from OpenBSD/luna88k. Also sync some comments.
Tested on LUNA-II, and mlterm-fb with 8bpp wallpaper also works fine.
Thanks to Kenji Aoyama (OpenBSD/luna88k maintainer) for providing
his spare 8bpp board.
- Use C99 struct initialization for wsdisplay_accessops.
- Use kmem(9) instead of malloc(9).
- Pull LUNA's keyboard driver changes from OpenBSD/luna88k. Now LUNA's
keyboard works on Xorg server without tweaks by xmodmap(1) etc.
- split keyboard mapping definitions to new files, omkbdmap.[ch]
- add WSDISPLAY_COMPAT_RAWKBD support
(actually the name is wrong; it doesn't emit raw keycode but
converts MD code into PS/2 one as "raw keycode on x86" for Xorg server)
- allow to enter into ddb by CTRL+ALT(zenmen)+ESC
- remove unnecessary return values
- Add consistent prefix to a softc member name.
- Implement WSDISPLAYIO_SMODE ioctl for proper mmap and colormap handling.
Tested on LUNA with 4bpp framebuffer.
- allow mmap framebuffer memories only in WSDISPLAYIO_DUMBFB
- initialize palette for ANSI text colors on back to WSDISPLAYIO_MODE_EMUL
- Pull readability changes from OpenBSD/luna88k.
Tested on LUNA-II with 8bpp framebuffer.
- prepare and use unpack_attr() function to get fg and bg from attribute
- use proper variable names to clarify meanings
- Put dumb optimizations to avoid conditionals in putchar drawing loops.
~10% improvements of time cat results on LUNA-II 8bpp framebuffer.
- Fix unintended RCS Id substitution.
- Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.
This Makes 4bpp wscons putchar ~30% on LUNA-II.
http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
> It makes 4bpp wscons putchar ~20% faster.
Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.
Tested on all 1bpp/4bpp/8bpp framebuffers.
- Add options WSDISPLAY_COMPAT_RAWKBD for Xorg server.
 1.2.2.1 04-Oct-2014  msaitoh file omkbdmap.c was added on branch netbsd-6 on 2014-11-09 07:34:12 +0000
 1.1 20-Jul-2014  tsutsui branches: 1.1.2; 1.1.6; 1.1.8;
Pull LUNA's keyboard driver changes from OpenBSD/luna88k.

- split keyboard mapping definitions to new files, omkbdmap.[ch]
- add WSDISPLAY_COMPAT_RAWKBD support
(actually the name is wrong; it doesn't emit raw keycode but
converts MD code into PS/2 one as "raw keycode on x86" for Xorg server)
- allow to enter into ddb by CTRL+ALT(zenmen)+ESC
- remove unnecessary return values

Now LUNA's keyboard works on Xorg server without tweaks by xmodmap(1) etc.
 1.1.8.2 09-Nov-2014  msaitoh Pull up following revision(s) (requested by tsutsui in ticket #1182):
sys/arch/luna68k/conf/files.luna68k: revision 1.24
sys/arch/luna68k/conf/GENERIC: revision 1.113 via patch
sys/arch/luna68k/dev/omrasops.c: revision 1.17-1.19
sys/arch/luna68k/dev/lunaws.c: revision 1.30
sys/arch/luna68k/dev/omkbdmap.c: revision 1.1-1.2
sys/arch/luna68k/dev/omkbdmap.h: revision 1.1
sys/arch/luna68k/dev/lunafb.c: revision 1.31-1.36
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.3
- Setup Bt458 color palette to support ANSI color text on 8bpp framebuffer.
Mostly taken from OpenBSD/luna88k. Also sync some comments.
Tested on LUNA-II, and mlterm-fb with 8bpp wallpaper also works fine.
Thanks to Kenji Aoyama (OpenBSD/luna88k maintainer) for providing
his spare 8bpp board.
- Use C99 struct initialization for wsdisplay_accessops.
- Use kmem(9) instead of malloc(9).
- Pull LUNA's keyboard driver changes from OpenBSD/luna88k. Now LUNA's
keyboard works on Xorg server without tweaks by xmodmap(1) etc.
- split keyboard mapping definitions to new files, omkbdmap.[ch]
- add WSDISPLAY_COMPAT_RAWKBD support
(actually the name is wrong; it doesn't emit raw keycode but
converts MD code into PS/2 one as "raw keycode on x86" for Xorg server)
- allow to enter into ddb by CTRL+ALT(zenmen)+ESC
- remove unnecessary return values
- Add consistent prefix to a softc member name.
- Implement WSDISPLAYIO_SMODE ioctl for proper mmap and colormap handling.
Tested on LUNA with 4bpp framebuffer.
- allow mmap framebuffer memories only in WSDISPLAYIO_DUMBFB
- initialize palette for ANSI text colors on back to WSDISPLAYIO_MODE_EMUL
- Pull readability changes from OpenBSD/luna88k.
Tested on LUNA-II with 8bpp framebuffer.
- prepare and use unpack_attr() function to get fg and bg from attribute
- use proper variable names to clarify meanings
- Put dumb optimizations to avoid conditionals in putchar drawing loops.
~10% improvements of time cat results on LUNA-II 8bpp framebuffer.
- Fix unintended RCS Id substitution.
- Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.
This Makes 4bpp wscons putchar ~30% on LUNA-II.
http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
> It makes 4bpp wscons putchar ~20% faster.
Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.
Tested on all 1bpp/4bpp/8bpp framebuffers.
- Add options WSDISPLAY_COMPAT_RAWKBD for Xorg server.
 1.1.8.1 20-Jul-2014  msaitoh file omkbdmap.h was added on branch netbsd-6 on 2014-11-09 07:34:12 +0000
 1.1.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.6.1 20-Jul-2014  tls file omkbdmap.h was added on branch tls-maxphys on 2014-08-20 00:03:10 +0000
 1.1.2.2 10-Aug-2014  tls Rebase.
 1.1.2.1 20-Jul-2014  tls file omkbdmap.h was added on branch tls-earlyentropy on 2014-08-10 06:54:00 +0000
 1.27 20-Sep-2024  isaki s/speficically/specifically/ in comment. (Sync with OpenBSD/luna88k)
 1.26 15-Jan-2023  tsutsui branches: 1.26.6;
TAB/space/indent cleanup.
 1.25 03-Oct-2022  tsutsui Remove global hwplanecount and use ri_depth in struct rasops instead.

No functional change.
 1.24 01-Oct-2022  tsutsui Explicitly limit a number of rasops rows per size of rowattr[].
 1.23 25-Sep-2022  isaki lunafb: Improve drawing performance using VRAM ROP features.
- Drawing a character on 4bpp normally needs 4 times writes, but by using
VRAM ROP actively, it can be reduced to write only once.
The same goes for copyrows. If the whole row consists of only two colors
(one foreground and one background), it can be copied by reading once and
writing once, regardless of the number of planes. Only if the row consists
of more than two colors, it will be copied plane by plane.
- On 8bpp board, it acts as 4bpp (16 colors).
- On 4bpp board on the real LUNA-I(68030/20MHz), monochrome scroll is about
4 times faster even without asm. Using asm improves it by additional 5%
(asm is enabled by default).
- By tsutsui@-san's report, even color scroll is about about 2 times faster
on his 8bpp board on the real LUNA-II(68040).
This was first developped by Y.Sugahara back in late 2019, and was modified
a lot by me in 2022.
http://mail-index.netbsd.org/port-luna68k/2022/09/23/msg000072.html
 1.22 25-Sep-2022  isaki Cosmetic changes. Fix a typo in comment.
 1.21 31-Jul-2019  rin G/C ri_delta.

XXX
Bump kernel version after other changes for struct rasops_info.
 1.20 06-Jun-2018  maya branches: 1.20.2; 1.20.6;
Remove duplicate ;
 1.19 04-Oct-2014  tsutsui branches: 1.19.18;
Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.

http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
>> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
>> It makes 4bpp wscons putchar ~20% faster.

This Makes 4bpp wscons putchar ~30% on LUNA-II.

Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.

Tested on all 1bpp/4bpp/8bpp framebuffers.
 1.18 28-Sep-2014  tsutsui Put dumb optimizations to avoid conditionals in putchar drawing loops.

~10% improvements of time cat results on LUNA-II 8bpp framebuffer.
 1.17 28-Sep-2014  tsutsui Pull readability changes from OpenBSD/luna88k.

- prepare and use unpack_attr() function to get fg and bg from attribute
- use proper variable names to clarify meanings

Tested on LUNA-II with 8bpp framebuffer.
 1.16 28-Dec-2013  tsutsui branches: 1.16.4;
Add preleminary support of 4bpp LUNA framebuffer.

Changes details:
- prepare and switch 4bpp rasops functions that read/write all 4 planes
and also handle both fg and bg colors
- make 1bpp ops use first plane on write rather than common bitmap plane
(which is prepared for multiple plane write with raster ops)
- prepare 4bpp allocattr function to handle ANSI 16 color text
- split omrasops_init() function for each bpp
- move struct hwcmap from softc to hwdevconfig to sync palette values
on initialization
- allow mmap(2) against all available planes

Now we can use ANSI 16 color text console and also can
demonstrate mlterm-fb with color sixel graphics and wallpaper.
XXX: Xserver needs much more work.
 1.15 14-Dec-2013  tsutsui Make omrasops copycols() op work even if columns are not 32 bit aligned.

This means command line editing works properly in any cases.

The bitcopy strategies for 1bpp copycols() op are taken from
recently fixed MI sys/dev/rasops/rasops_bitops.h.
GETBITS() and PUTBITS() m68k asm macro are taken from hp300.

Tested on both 1bpp (on LUNA-II) and 4bpp (on LUNA) framebuffers.
 1.14 02-Dec-2013  tsutsui Fix off by one in copyrows() backward case.
 1.13 20-Jul-2012  tsutsui branches: 1.13.2; 1.13.4;
Switch luna68k wscons framebuffer driver to using rasops(9) APIs instead of
deprecated rcons(4). This allows "options FONT_foo" in kernel config files.
Mostly taken from OpenBSD/luna88k, but unnecessary MI rasops(9) stuff is
omitted since omrasops.c has own raster wsdisplay_emulops functions.
Tested on LUNA with 4bpp fb and LUNA-II with 1bpp fb.
 1.12 16-Jul-2012  tsutsui Fix typo in comment. From OpenBSD/luna88k.
 1.11 27-Jul-2011  tsutsui branches: 1.11.2; 1.11.8;
KNF, use uintNN_t, tab/space cosmetics etc.
 1.10 16-Jul-2011  tsutsui Revive NetBSD/luna68k.

Even after almost a lost decade since NetBSD/luna68k was
switched to using ELF format by default back in 2001,
actually only one fix (bus.h) is required for a GENERIC kernel itself
to get multiuser login: prompt on a real hardware. Hurrahhh!!!

Demonstrated with a working Xorg mono server on the NetBSD booth
at Open Source Conference 2011 Kansai @ Kyoto:
http://www.ospn.jp/osc2011-kyoto/

"Very impressed," commented by Tomoko YOSHIDA,
Program Committee Chair of the Conference,
and some other OMRON guys.

Special Thanks to Tadashi Okamura, for providing
a working SX-9100/DT "LUNA" for this mission.


Changes details:

sys/arch/luna68k/include/bus.h
- handle stride properly even on multi and region ops for MI spc(4)
- also fix stride handling of (currently unused) 2 and 4 byte ops

sys/arch/luna68k/conf/Makefile.luna68k
sys/arch/luna68k/conf/kern.ldscript.head
sys/arch/luna68k/conf/kern.ldscript.tail
- build a faked a.out kernel using elf2aout(8) tool
and a linker script derived from cats and shark
for the LUNA firmware that loads a.out binary directly
via network or from a UNIOS partition on a local disk

sys/arch/luna68k/dev/omrasops.c
sys/arch/luna68k/dev/omron_rfont.h
- use the original OMRON font derived from 4.4BSD-Lite/luna68k
rather than gallant19 which is used on Sun workstations
(XXX omrasops.c should be rewritten to use generic wsfont(4))

distrib/luna68k/*
distrib/utils/sysinst/arch/luna68k/*
etc/etc.luna68k/MAKEDEV.conf
etc/etc.luna68k/Makefile.inc
sys/arch/luna68k/conf/INSTALL
- build a ramdisk based INSTALL kernel with sysinst(8) for luna68k
- also build an installation iso image for luna68k

sys/arch/luna68k/conf/GENERIC
- enable SYSVSHM (and other SYSV*) options for Xorg server

More Xorg changes (which need some more cleanup) and
isiboot.c fixes will come soon.
 1.9 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.8 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.7 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.6 28-Apr-2008  martin branches: 1.6.8; 1.6.14;
Remove clause 3 and 4 from TNF licenses
 1.5 04-Mar-2007  tsutsui branches: 1.5.40; 1.5.42; 1.5.44;
Use (uint8_t *) for framebuffer address.
 1.4 04-Mar-2007  christos Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.3 04-Jul-2002  junyoung branches: 1.3.22; 1.3.60;
alloc_attr -> allocattr

Approved by Matthias Drochner.
 1.2 30-May-2002  thorpej Statements must follow labels.
 1.1 05-Jan-2000  nisimura branches: 1.1.6; 1.1.10; 1.1.14; 1.1.22;
Introduce NetBSD/luna68k port into CVS repository.
 1.1.22.2 16-Jul-2002  gehenna catch up with -current.
 1.1.22.1 14-Jul-2002  gehenna catch up with -current.
 1.1.14.2 01-Aug-2002  nathanw Catch up to -current.
 1.1.14.1 20-Jun-2002  nathanw Catch up to -current.
 1.1.10.2 06-Sep-2002  jdolecek sync kqueue branch with HEAD
 1.1.10.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 05-Jan-2000  bouyer file omrasops.c was added on branch thorpej_scsipi on 2000-11-20 20:10:26 +0000
 1.3.60.1 12-Mar-2007  rmind Sync with HEAD.
 1.3.22.1 03-Sep-2007  yamt sync with head.
 1.5.44.2 04-May-2009  yamt sync with head.
 1.5.44.1 16-May-2008  yamt sync with head.
 1.5.42.1 18-May-2008  yamt sync with head.
 1.5.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.6.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.6.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.11.8.3 09-Nov-2014  msaitoh Pull up following revision(s) (requested by tsutsui in ticket #1182):
sys/arch/luna68k/conf/files.luna68k: revision 1.24
sys/arch/luna68k/conf/GENERIC: revision 1.113 via patch
sys/arch/luna68k/dev/omrasops.c: revision 1.17-1.19
sys/arch/luna68k/dev/lunaws.c: revision 1.30
sys/arch/luna68k/dev/omkbdmap.c: revision 1.1-1.2
sys/arch/luna68k/dev/omkbdmap.h: revision 1.1
sys/arch/luna68k/dev/lunafb.c: revision 1.31-1.36
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.3
- Setup Bt458 color palette to support ANSI color text on 8bpp framebuffer.
Mostly taken from OpenBSD/luna88k. Also sync some comments.
Tested on LUNA-II, and mlterm-fb with 8bpp wallpaper also works fine.
Thanks to Kenji Aoyama (OpenBSD/luna88k maintainer) for providing
his spare 8bpp board.
- Use C99 struct initialization for wsdisplay_accessops.
- Use kmem(9) instead of malloc(9).
- Pull LUNA's keyboard driver changes from OpenBSD/luna88k. Now LUNA's
keyboard works on Xorg server without tweaks by xmodmap(1) etc.
- split keyboard mapping definitions to new files, omkbdmap.[ch]
- add WSDISPLAY_COMPAT_RAWKBD support
(actually the name is wrong; it doesn't emit raw keycode but
converts MD code into PS/2 one as "raw keycode on x86" for Xorg server)
- allow to enter into ddb by CTRL+ALT(zenmen)+ESC
- remove unnecessary return values
- Add consistent prefix to a softc member name.
- Implement WSDISPLAYIO_SMODE ioctl for proper mmap and colormap handling.
Tested on LUNA with 4bpp framebuffer.
- allow mmap framebuffer memories only in WSDISPLAYIO_DUMBFB
- initialize palette for ANSI text colors on back to WSDISPLAYIO_MODE_EMUL
- Pull readability changes from OpenBSD/luna88k.
Tested on LUNA-II with 8bpp framebuffer.
- prepare and use unpack_attr() function to get fg and bg from attribute
- use proper variable names to clarify meanings
- Put dumb optimizations to avoid conditionals in putchar drawing loops.
~10% improvements of time cat results on LUNA-II 8bpp framebuffer.
- Fix unintended RCS Id substitution.
- Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.
This Makes 4bpp wscons putchar ~30% on LUNA-II.
http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
> It makes 4bpp wscons putchar ~20% faster.
Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.
Tested on all 1bpp/4bpp/8bpp framebuffers.
- Add options WSDISPLAY_COMPAT_RAWKBD for Xorg server.
 1.11.8.2 12-Jan-2014  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1005):
sys/arch/luna68k/dev/omrasops.c: revision 1.15
sys/arch/luna68k/dev/omrasops.c: revision 1.16
sys/arch/luna68k/dev/lunafb.c: revision 1.27
sys/arch/luna68k/dev/lunafb.c: revision 1.28
sys/arch/luna68k/dev/lunafb.c: revision 1.29
sys/arch/luna68k/dev/lunafb.c: revision 1.30
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.2
sys/arch/luna68k/dev/omrasops.c: revision 1.14
Properly initialize the palette for while on black even on 1bpp framebuffer.
Preparing for demonstration in Open Source Conference 2013 Kyoto.
Fix off by one in copyrows() backward case.
Make omrasops copycols() op work even if columns are not 32 bit aligned.
This means command line editing works properly in any cases.
The bitcopy strategies for 1bpp copycols() op are taken from
recently fixed MI sys/dev/rasops/rasops_bitops.h.
GETBITS() and PUTBITS() m68k asm macro are taken from hp300.
Tested on both 1bpp (on LUNA-II) and 4bpp (on LUNA) framebuffers.
Initialize capabilities in struct wsscreen_descr per omrasops settings.
Now REVERSE characters are drawn properly.
Add preleminary support of 4bpp LUNA framebuffer.
Changes details:
- prepare and switch 4bpp rasops functions that read/write all 4 planes
and also handle both fg and bg colors
- make 1bpp ops use first plane on write rather than common bitmap plane
(which is prepared for multiple plane write with raster ops)
- prepare 4bpp allocattr function to handle ANSI 16 color text
- split omrasops_init() function for each bpp
- move struct hwcmap from softc to hwdevconfig to sync palette values
on initialization
- allow mmap(2) against all available planes
Now we can use ANSI 16 color text console and also can
demonstrate mlterm-fb with color sixel graphics and wallpaper.
XXX: Xserver needs much more work.
Pull a fix of Bt458 (8bpp framebuffer) initialization from OpenBSD/luna88k.
http://marc.info/?l=openbsd-cvs&m=138838884202196
> Correct initialization of Bt458, used in LUNA's 8bpp frame buffer.
>
> According to the manual, the address register does not automatically
> increment when we access to the control registers. Also we disable
> overlay planes, because we do not use them.
 1.11.8.1 25-Jul-2012  martin Pull up following revision(s) (requested by tsutsui in ticket #444):
sys/arch/luna68k/conf/GENERIC: revision 1.99
sys/arch/luna68k/dev/lunafb.c: revision 1.26
sys/arch/luna68k/luna68k/locore.s: revision 1.48
sys/arch/luna68k/dev/lunaws.c: revision 1.24
sys/arch/luna68k/dev/omron_rfont.h: file removal
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.1
sys/arch/luna68k/dev/omrasops.c: revision 1.12
sys/arch/luna68k/dev/omrasops.c: revision 1.13
sys/arch/luna68k/conf/INSTALL: revision 1.6
Use & not && to mask bits. From OpenBSD/luna88k
Fix typo in comment. From OpenBSD/luna88k.
Switch luna68k wscons framebuffer driver to using rasops(9) APIs instead of
deprecated rcons(4). This allows "options FONT_foo" in kernel config files.
Mostly taken from OpenBSD/luna88k, but unnecessary MI rasops(9) stuff is
omitted since omrasops.c has own raster wsdisplay_emulops functions.
Tested on LUNA with 4bpp fb and LUNA-II with 1bpp fb.
Make reboot(2) actually work (don't access %sp after MMU is turned off).
Also cleanup spaces and #if 0'ed code. Tested on both LUNA and LUNA-II.
Should be pulled up to netbsd-6.
 1.11.2.2 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.11.2.1 30-Oct-2012  yamt sync with head
 1.13.4.1 18-May-2014  rmind sync with head
 1.13.2.2 03-Dec-2017  jdolecek update from HEAD
 1.13.2.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.16.4.1 05-Oct-2014  martin Pull up following revision(s) (requested by tsutsui in ticket #130):
sys/arch/luna68k/dev/omrasops.c: revision 1.17
sys/arch/luna68k/dev/omrasops.c: revision 1.18
sys/arch/luna68k/dev/omrasops.c: revision 1.19
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.3
sys/arch/luna68k/dev/lunafb.c: revision 1.36
Pull readability changes from OpenBSD/luna88k.
- prepare and use unpack_attr() function to get fg and bg from attribute
- use proper variable names to clarify meanings
Tested on LUNA-II with 8bpp framebuffer.
Put dumb optimizations to avoid conditionals in putchar drawing loops.
~10% improvements of time cat results on LUNA-II 8bpp framebuffer.
Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.
http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
> It makes 4bpp wscons putchar ~20% faster.
This Makes 4bpp wscons putchar ~30% on LUNA-II.
Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.
Tested on all 1bpp/4bpp/8bpp framebuffers.
 1.19.18.1 25-Jun-2018  pgoyette Sync with HEAD
 1.20.6.1 15-Aug-2019  martin Pull up following revision(s) (requested by rin in ticket #56):

sys/dev/rasops/rasops.c: revision 1.120
sys/dev/rasops/rasops.h: revision 1.40
sys/dev/rasops/rasops.c: revision 1.121
sys/dev/rasops/rasops.h: revision 1.41
sys/dev/rasops/rasops.c: revision 1.122
sys/dev/rasops/rasops.h: revision 1.42
sys/dev/rasops/rasops.h: revision 1.43
sys/dev/rasops/rasops.h: revision 1.44
sys/dev/rasops/rasops.h: revision 1.45
sys/dev/rasops/rasops.h: revision 1.46
sys/dev/rasops/rasops.h: revision 1.47
sys/dev/rasops/rasops.h: revision 1.48
sys/dev/rasops/rasops32.c: revision 1.40
sys/dev/rasops/rasops32.c: revision 1.41
sys/dev/rasops/rasops32.c: revision 1.42
sys/dev/rasops/rasops32.c: revision 1.43
sys/dev/rasops/rasops32.c: revision 1.44
sys/dev/rasops/rasops32.c: revision 1.45
sys/dev/rasops/rasops32.c: revision 1.46
sys/dev/rasops/rasops1-4_putchar.h: revision 1.1
sys/dev/rasops/rasops1-4_putchar.h: revision 1.2
sys/dev/rasops/rasops1-4_putchar.h: revision 1.3
sys/dev/rasops/rasops1_putchar_width.h: revision 1.3
sys/dev/rasops/rasops1_putchar_width.h: revision 1.4
sys/dev/rasops/rasops1_putchar_width.h: revision 1.5
sys/dev/rasops/rasops1_putchar_width.h: revision 1.6
sys/dev/rasops/README: revision 1.7
sys/dev/rasops/rasops_putchar_aa.h: revision 1.5
sys/dev/rasops/rasops_putchar_aa.h: revision 1.6
sys/dev/rasops/rasops8.c: revision 1.45
sys/dev/rasops/rasops8.c: revision 1.46
sys/dev/rasops/rasops8.c: revision 1.47
sys/dev/rasops/rasops24.c: revision 1.40
sys/dev/rasops/rasops8.c: revision 1.48
sys/dev/rasops/rasops24.c: revision 1.41
sys/dev/rasops/rasops8.c: revision 1.49
sys/dev/rasops/rasops24.c: revision 1.42
sys/dev/rasops/rasops24.c: revision 1.43
sys/dev/rasops/rasops24.c: revision 1.44
sys/dev/rasops/rasops_masks.c: revision 1.10
doc/CHANGES: revision 1.2566
sys/dev/rasops/rasops24.c: revision 1.45
doc/CHANGES: revision 1.2567
sys/dev/rasops/rasops24.c: revision 1.46
sys/dev/rasops/rasops24.c: revision 1.47
sys/dev/rasops/rasops24.c: revision 1.48
sys/dev/rasops/rasops24.c: revision 1.49
sys/dev/rasops/rasops_bitops.h: revision 1.19
sys/dev/rasops/rasops_putchar_aa.h: file removal
sys/dev/wscons/wsdisplay_vcons.c: revision 1.40
sys/dev/rasops/rasops8.c: revision 1.50
sys/dev/rasops/rasops8.c: revision 1.51
sys/dev/rasops/rasops24.c: revision 1.50
sys/arch/luna68k/dev/omrasops.c: revision 1.21
sys/dev/rasops/rasops_bitops.h: revision 1.20
sys/dev/wsfb/genfb.c: revision 1.68
sys/dev/rasops/rasops_bitops.h: revision 1.21
sys/dev/wsfb/genfb.c: revision 1.69
sys/dev/rasops/rasops_putchar_width.h: revision 1.10
sys/dev/rasops/rasops_bitops.h: revision 1.22
sys/dev/rasops/rasops_putchar_width.h: revision 1.11
sys/dev/rasops/rasops_bitops.h: revision 1.23
sys/dev/rasops/rasops_putchar_width.h: revision 1.12
sys/dev/rasops/rasops_bitops.h: revision 1.24
sys/dev/rasops/rasops_putchar_width.h: revision 1.13
sys/dev/rasops/rasops_bitops.h: revision 1.25
sys/dev/rasops/rasops_putchar_width.h: revision 1.14
sys/dev/rasops/rasops_putchar_width.h: revision 1.15
sys/dev/rasops/rasops1.c: revision 1.32
sys/dev/rasops/rasops1.c: revision 1.33
sys/dev/rasops/rasops1.c: revision 1.34
sys/dev/rasops/rasops1.c: revision 1.35
sys/dev/rasops/rasops1.c: revision 1.36
sys/dev/rasops/rasops1.c: revision 1.37
sys/dev/rasops/rasops4.c: revision 1.21
sys/dev/rasops/rasops4.c: revision 1.22
sys/dev/rasops/rasops4.c: revision 1.23
sys/dev/rasops/rasops4.c: revision 1.24
sys/dev/rasops/rasops4.c: revision 1.25
sys/dev/rasops/rasops4.c: revision 1.26
sys/dev/rasops/rasops4.c: revision 1.27
sys/dev/rasops/rasops4.c: revision 1.28
sys/dev/wsfb/genfb.c: revision 1.70
sys/dev/rasops/rasops2.c: revision 1.27
sys/dev/rasops/rasops2.c: revision 1.28
share/man/man9/rasops.9: revision 1.18
sys/dev/rasops/rasops.c: revision 1.102
sys/dev/rasops/rasops2.c: revision 1.29
share/man/man9/rasops.9: revision 1.19
sys/dev/rasops/rasops.c: revision 1.103
sys/dev/rasops/rasops.c: revision 1.104
sys/dev/rasops/rasops.c: revision 1.105
sys/dev/rasops/rasops.c: revision 1.106
sys/dev/rasops/rasops.c: revision 1.107
sys/dev/rasops/rasops_putchar.h: revision 1.6
sys/dev/rasops/rasops.c: revision 1.108
sys/dev/rasops/rasops_putchar.h: revision 1.7
sys/dev/rasops/rasops.c: revision 1.109
sys/dev/rasops/rasops_putchar.h: revision 1.8
sys/dev/rasops/rasops2.c: revision 1.30
sys/dev/rasops/rasops2.c: revision 1.31
sys/dev/rasops/rasops15.c: revision 1.32
sys/dev/rasops/rasops2.c: revision 1.32
sys/dev/rasops/rasops15.c: revision 1.33
sys/dev/rasops/rasops2.c: revision 1.33
sys/dev/rasops/rasops15.c: revision 1.34
sys/dev/rasops/rasops15.c: revision 1.35
sys/dev/rasops/rasops15.c: revision 1.36
sys/dev/rasops/rasops.c: revision 1.110
sys/dev/rasops/rasops15.c: revision 1.37
sys/dev/rasops/rasops.c: revision 1.111
sys/dev/rasops/rasops15.c: revision 1.38
sys/dev/rasops/rasops.c: revision 1.112
sys/dev/rasops/rasops15.c: revision 1.39
sys/dev/rasops/rasops.c: revision 1.113
sys/dev/rasops/rasops.c: revision 1.114
sys/dev/rasops/rasops.c: revision 1.115
sys/dev/rasops/rasops_masks.h: revision 1.9
sys/dev/rasops/rasops.c: revision 1.116
sys/dev/rasops/rasops.c: revision 1.117
sys/dev/rasops/rasops.c: revision 1.118
sys/dev/rasops/rasops.c: revision 1.119
sys/dev/rasops/rasops.h: revision 1.39

Misc clean-up's:
- protect private stuff in rasops.h by _RASOPS_PRIVATE
- staticify rasops_copycols() and rasops_isgray[]
- G/C unused extern int cold
Switch to per-device stamp, and retire stamp_mutex.

Provide buffer capable of single-row pixels in order to make things simpler.

Factor out copy-paste. No functional changes.
When font is switched, not only putchar, but also other ri_ops can be
changed by backend driver, e.g., see rasops1.c:
https://nxr.netbsd.org/xref/src/sys/dev/rasops/rasops1.c#58
4 is 1 << 2, not 1 << 3...

Fix erasecols and do_cursor for font width >= 32 bits.
Also, some cosmetic clean-up's.

Oops, for rasops_copycols(), we cannot use memmove even if src == dst.
On the other hand, memmove is safe for rasops_copyrows().
Fix unaligned writes to buffer, that are introduced in 1.105:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/rasops/rasops.c#rev1.105

Support font width 32 on monochrome screen.

Remove duplicate substitution. Style. No functional changes.

Correct copy count. This affects ``left-to-right'' copy for region
including word boundary.

Fix a bug in shadow fb support for copycols on 1, 2, and 4bpp screen,
which was introduced in 1.18:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/rasops/rasops_bitops.h#rev1.18

Add general putchar functions for 2 and 4bpp.
Note that 1bpp continues to use its local version in rasops1.c,
which is much faster and simpler.

Cosmetic changes. No functional changes.

Reflect reality.

Notify size of shadow framebuffer if enabled.

Fix unaligned word write's to buffer, introduced in rev 1.42:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/rasops/rasops24.c#rev1.42

Real fix for 24-bpp color:
- When centering screen, locate effective base address of framebuffer to
both word and 24-bit color boundary.
- Consistently convert ri_devcmap to ``big endian'' if not RI_BSWAP.

Also, fix possible bug for 15/16-bpp with RI_BSWAP (not tested).

Protect rasops_copy{rows,cols}() by _RASOPS_PRIVATE.

Use _KERNEL_OPT.

Simplify calculation for 12-byte alignment.
No functional changes.

Fix black color-attribution for depths 2 and 4.

Depth 2 is monochrome.
IMO, it is impossible to support ANSI colors on 2-bpp display; fore-
and background can be same value even if they are different colors
logically.

Fix a critical bug for rasops_copyrows() introduced in rev. 1.90:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/rasops/rasops.c#rev1.90
When src < dst, we have to copy backward.

Simplify rasops_do_cursor():
- Use static masks similar to that used in rasops_bitops.h,
rather than generating them on the fly.
- Use pointer for proper type to avoid unnecessary casts.

Use "hp" instead of "hrp" consistently with other files.
No functional changes.

Stop allocating ri_buf and ri_stamp dynamically. As commented in
rasops.h, it is not safe to use kmem_alloc(9) in rasops_init();
rasops routines can be used for early putchar, which means that
UVM is not fully initialized.

Should fix a problem reported by macallan:
http://mail-index.netbsd.org/tech-kern/2019/08/02/msg025327.html

Instead of using ri_buf, inline function rasops_memcpy32() is
introduced to fill 32bit data efficiently.

Instead of using ri_stamp (per device stamp), stamp_ri is
introduced to distinguish for which device stamp is calculated.

Oops, revert an unintentional change for now.

If RI_CLEAR is set, do not forget to clear real framebuffer.

Modify struct rasops_info again (ride 9.99.4 bump).
- remove ri_buf and friends.
- remove ri_stamp and frieds.
- introduce ri_ul, which will be used for scaling underline with font.

Also add hack for ri_ul; adjust its size to obsoleted member, ri_delta,
which was only used rasops routines internally. Now, size and offsets of
all members of struct rasops_info become same with netbsd-9, -8, and -7,
again. So we can safelly pull up fixes to any release branches!

Scaling dimensions of underline by font height.

Currently,
- offset of underline is fixed to 1-row from bottom of characters, and
- height of underline is fixed to 1.
Both are good for standard 8x16 fonts. However, it is too thin for
larger fonts, especially when used on display of high resolution.
Also, 1-row offset of underline is ugly for small fonts, e.g.,
spleen5x8.
Therefore, adjust offset and height as,
- no changes for standard 16-height fonts.
- scaling by font height for larger fonts.
- set offset to zero for fonts of height smaller than 16.

Merge rasops_putchar_aa.h into rasops_putchar.h.

Support scaling underline dimensions by font height.

Separate general putchar for 1-4bpp from rasops_bitops:
- Support anti-aliasing for 2bpp, which works perfectly!
- Support scaling underline dimensions with font height.

We support anti-aliasing for depth 2.
Use switch appropriately.
- Stop showing struct rasops_info; readers can read the header itself.
- Correct description for optimized font widths.
- Remove strange blank line.

Try to improve formatting and naration.

Make rasops_erase{rows,cols}() public again; hp300/diofb uses them.
Pointed out by martin.

When legacy Apple 4-bpp color palette is used, make green dark so that
kernel messages are printed nicely on white background.

Fix color range overflow; we cannot make bright colors more brighter.

Correctly check whether character is in font in rasops_mapchar().
Also, make sure that in putchar functions for completeness.

Fix bug introduced in rev. 1.69:
http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/dev/wsfb/genfb.c#rev1.69
is_bgr should be initialized to false. Otherwise, color becomes strange
for depths 24 and 32 unless backend explicitly set "is_bgr" property.

Set 4-bpp devcmap in a similar manner to non-RGB case of 8-bpp.
No functional changes since this is not in use (4-bpp is monochrome).

Misc style clean up's.
- Introduce and use proper macros.
- Use not ambiguous variable names.
- Unify similar functions as possible as I can.
- G/C unused headers.
- Use #include <dev/rasops/foo.h> instead of "foo.h"

No particular functional changes intended.

My work for rasops(9) was finished (hopefully).

I will send pull-up request for netbsd-9, if there are no new failures
reported within few days.

Fix format in order not to confuse changes2html script.
Minor improvements of wording for my entry.

When using stamp, drop attributions other than back and foreground
colors so that stamp is not updated unnecessarily.
 1.20.2.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.26.6.1 02-Aug-2025  perseant Sync with HEAD
 1.8 03-Oct-2022  tsutsui Remove global hwplanecount and use ri_depth in struct rasops instead.

No functional change.
 1.7 01-Oct-2022  tsutsui Remove trailing whitespaces.
 1.6 25-Sep-2022  isaki lunafb: Improve drawing performance using VRAM ROP features.
- Drawing a character on 4bpp normally needs 4 times writes, but by using
VRAM ROP actively, it can be reduced to write only once.
The same goes for copyrows. If the whole row consists of only two colors
(one foreground and one background), it can be copied by reading once and
writing once, regardless of the number of planes. Only if the row consists
of more than two colors, it will be copied plane by plane.
- On 8bpp board, it acts as 4bpp (16 colors).
- On 4bpp board on the real LUNA-I(68030/20MHz), monochrome scroll is about
4 times faster even without asm. Using asm improves it by additional 5%
(asm is enabled by default).
- By tsutsui@-san's report, even color scroll is about about 2 times faster
on his 8bpp board on the real LUNA-II(68040).
This was first developped by Y.Sugahara back in late 2019, and was modified
a lot by me in 2022.
http://mail-index.netbsd.org/port-luna68k/2022/09/23/msg000072.html
 1.5 22-Sep-2019  rin Spell out "Hitachi" correctly in comment.
No binary changes.
 1.4 30-Jun-2019  tsutsui Pull OpenBSD/luna88k board.h to define SX9100 board device addresses.

Also replace magic addresses with macro where appropriate.
 1.3 04-Oct-2014  tsutsui branches: 1.3.20;
Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.

http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
>> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
>> It makes 4bpp wscons putchar ~20% faster.

This Makes 4bpp wscons putchar ~30% on LUNA-II.

Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.

Tested on all 1bpp/4bpp/8bpp framebuffers.
 1.2 28-Dec-2013  tsutsui branches: 1.2.4;
Add preleminary support of 4bpp LUNA framebuffer.

Changes details:
- prepare and switch 4bpp rasops functions that read/write all 4 planes
and also handle both fg and bg colors
- make 1bpp ops use first plane on write rather than common bitmap plane
(which is prepared for multiple plane write with raster ops)
- prepare 4bpp allocattr function to handle ANSI 16 color text
- split omrasops_init() function for each bpp
- move struct hwcmap from softc to hwdevconfig to sync palette values
on initialization
- allow mmap(2) against all available planes

Now we can use ANSI 16 color text console and also can
demonstrate mlterm-fb with color sixel graphics and wallpaper.
XXX: Xserver needs much more work.
 1.1 20-Jul-2012  tsutsui branches: 1.1.2; 1.1.4; 1.1.6; 1.1.8;
Switch luna68k wscons framebuffer driver to using rasops(9) APIs instead of
deprecated rcons(4). This allows "options FONT_foo" in kernel config files.
Mostly taken from OpenBSD/luna88k, but unnecessary MI rasops(9) stuff is
omitted since omrasops.c has own raster wsdisplay_emulops functions.
Tested on LUNA with 4bpp fb and LUNA-II with 1bpp fb.
 1.1.8.1 18-May-2014  rmind sync with head
 1.1.6.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.1.6.2 30-Oct-2012  yamt sync with head
 1.1.6.1 20-Jul-2012  yamt file omrasopsvar.h was added on branch yamt-pagecache on 2012-10-30 17:19:54 +0000
 1.1.4.2 03-Dec-2017  jdolecek update from HEAD
 1.1.4.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.1.2.4 09-Nov-2014  msaitoh Pull up following revision(s) (requested by tsutsui in ticket #1182):
sys/arch/luna68k/conf/files.luna68k: revision 1.24
sys/arch/luna68k/conf/GENERIC: revision 1.113 via patch
sys/arch/luna68k/dev/omrasops.c: revision 1.17-1.19
sys/arch/luna68k/dev/lunaws.c: revision 1.30
sys/arch/luna68k/dev/omkbdmap.c: revision 1.1-1.2
sys/arch/luna68k/dev/omkbdmap.h: revision 1.1
sys/arch/luna68k/dev/lunafb.c: revision 1.31-1.36
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.3
- Setup Bt458 color palette to support ANSI color text on 8bpp framebuffer.
Mostly taken from OpenBSD/luna88k. Also sync some comments.
Tested on LUNA-II, and mlterm-fb with 8bpp wallpaper also works fine.
Thanks to Kenji Aoyama (OpenBSD/luna88k maintainer) for providing
his spare 8bpp board.
- Use C99 struct initialization for wsdisplay_accessops.
- Use kmem(9) instead of malloc(9).
- Pull LUNA's keyboard driver changes from OpenBSD/luna88k. Now LUNA's
keyboard works on Xorg server without tweaks by xmodmap(1) etc.
- split keyboard mapping definitions to new files, omkbdmap.[ch]
- add WSDISPLAY_COMPAT_RAWKBD support
(actually the name is wrong; it doesn't emit raw keycode but
converts MD code into PS/2 one as "raw keycode on x86" for Xorg server)
- allow to enter into ddb by CTRL+ALT(zenmen)+ESC
- remove unnecessary return values
- Add consistent prefix to a softc member name.
- Implement WSDISPLAYIO_SMODE ioctl for proper mmap and colormap handling.
Tested on LUNA with 4bpp framebuffer.
- allow mmap framebuffer memories only in WSDISPLAYIO_DUMBFB
- initialize palette for ANSI text colors on back to WSDISPLAYIO_MODE_EMUL
- Pull readability changes from OpenBSD/luna88k.
Tested on LUNA-II with 8bpp framebuffer.
- prepare and use unpack_attr() function to get fg and bg from attribute
- use proper variable names to clarify meanings
- Put dumb optimizations to avoid conditionals in putchar drawing loops.
~10% improvements of time cat results on LUNA-II 8bpp framebuffer.
- Fix unintended RCS Id substitution.
- Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.
This Makes 4bpp wscons putchar ~30% on LUNA-II.
http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
> It makes 4bpp wscons putchar ~20% faster.
Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.
Tested on all 1bpp/4bpp/8bpp framebuffers.
- Add options WSDISPLAY_COMPAT_RAWKBD for Xorg server.
 1.1.2.3 12-Jan-2014  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1005):
sys/arch/luna68k/dev/omrasops.c: revision 1.15
sys/arch/luna68k/dev/omrasops.c: revision 1.16
sys/arch/luna68k/dev/lunafb.c: revision 1.27
sys/arch/luna68k/dev/lunafb.c: revision 1.28
sys/arch/luna68k/dev/lunafb.c: revision 1.29
sys/arch/luna68k/dev/lunafb.c: revision 1.30
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.2
sys/arch/luna68k/dev/omrasops.c: revision 1.14
Properly initialize the palette for while on black even on 1bpp framebuffer.
Preparing for demonstration in Open Source Conference 2013 Kyoto.
Fix off by one in copyrows() backward case.
Make omrasops copycols() op work even if columns are not 32 bit aligned.
This means command line editing works properly in any cases.
The bitcopy strategies for 1bpp copycols() op are taken from
recently fixed MI sys/dev/rasops/rasops_bitops.h.
GETBITS() and PUTBITS() m68k asm macro are taken from hp300.
Tested on both 1bpp (on LUNA-II) and 4bpp (on LUNA) framebuffers.
Initialize capabilities in struct wsscreen_descr per omrasops settings.
Now REVERSE characters are drawn properly.
Add preleminary support of 4bpp LUNA framebuffer.
Changes details:
- prepare and switch 4bpp rasops functions that read/write all 4 planes
and also handle both fg and bg colors
- make 1bpp ops use first plane on write rather than common bitmap plane
(which is prepared for multiple plane write with raster ops)
- prepare 4bpp allocattr function to handle ANSI 16 color text
- split omrasops_init() function for each bpp
- move struct hwcmap from softc to hwdevconfig to sync palette values
on initialization
- allow mmap(2) against all available planes
Now we can use ANSI 16 color text console and also can
demonstrate mlterm-fb with color sixel graphics and wallpaper.
XXX: Xserver needs much more work.
Pull a fix of Bt458 (8bpp framebuffer) initialization from OpenBSD/luna88k.
http://marc.info/?l=openbsd-cvs&m=138838884202196
> Correct initialization of Bt458, used in LUNA's 8bpp frame buffer.
>
> According to the manual, the address register does not automatically
> increment when we access to the control registers. Also we disable
> overlay planes, because we do not use them.
 1.1.2.2 25-Jul-2012  martin Pull up following revision(s) (requested by tsutsui in ticket #444):
sys/arch/luna68k/conf/GENERIC: revision 1.99
sys/arch/luna68k/dev/lunafb.c: revision 1.26
sys/arch/luna68k/luna68k/locore.s: revision 1.48
sys/arch/luna68k/dev/lunaws.c: revision 1.24
sys/arch/luna68k/dev/omron_rfont.h: file removal
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.1
sys/arch/luna68k/dev/omrasops.c: revision 1.12
sys/arch/luna68k/dev/omrasops.c: revision 1.13
sys/arch/luna68k/conf/INSTALL: revision 1.6
Use & not && to mask bits. From OpenBSD/luna88k
Fix typo in comment. From OpenBSD/luna88k.
Switch luna68k wscons framebuffer driver to using rasops(9) APIs instead of
deprecated rcons(4). This allows "options FONT_foo" in kernel config files.
Mostly taken from OpenBSD/luna88k, but unnecessary MI rasops(9) stuff is
omitted since omrasops.c has own raster wsdisplay_emulops functions.
Tested on LUNA with 4bpp fb and LUNA-II with 1bpp fb.
Make reboot(2) actually work (don't access %sp after MMU is turned off).
Also cleanup spaces and #if 0'ed code. Tested on both LUNA and LUNA-II.
Should be pulled up to netbsd-6.
 1.1.2.1 20-Jul-2012  martin file omrasopsvar.h was added on branch netbsd-6 on 2012-07-25 21:30:35 +0000
 1.2.4.1 05-Oct-2014  martin Pull up following revision(s) (requested by tsutsui in ticket #130):
sys/arch/luna68k/dev/omrasops.c: revision 1.17
sys/arch/luna68k/dev/omrasops.c: revision 1.18
sys/arch/luna68k/dev/omrasops.c: revision 1.19
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.3
sys/arch/luna68k/dev/lunafb.c: revision 1.36
Pull readability changes from OpenBSD/luna88k.
- prepare and use unpack_attr() function to get fg and bg from attribute
- use proper variable names to clarify meanings
Tested on LUNA-II with 8bpp framebuffer.
Put dumb optimizations to avoid conditionals in putchar drawing loops.
~10% improvements of time cat results on LUNA-II 8bpp framebuffer.
Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.
http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
> Use raster(logic) operation, or ROP, function on LUNA frame buffer.
> It makes 4bpp wscons putchar ~20% faster.
This Makes 4bpp wscons putchar ~30% on LUNA-II.
Also use the similar ROP in 1bpp putchar and cursor functions
and the 1bpp putchar is also ~5% faster.
While here, reduce diffs from OpenBSD a bit.
Tested on all 1bpp/4bpp/8bpp framebuffers.
 1.3.20.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.2 20-Jul-2012  tsutsui Switch luna68k wscons framebuffer driver to using rasops(9) APIs instead of
deprecated rcons(4). This allows "options FONT_foo" in kernel config files.
Mostly taken from OpenBSD/luna88k, but unnecessary MI rasops(9) stuff is
omitted since omrasops.c has own raster wsdisplay_emulops functions.
Tested on LUNA with 4bpp fb and LUNA-II with 1bpp fb.
 1.1 16-Jul-2011  tsutsui branches: 1.1.2; 1.1.8;
Revive NetBSD/luna68k.

Even after almost a lost decade since NetBSD/luna68k was
switched to using ELF format by default back in 2001,
actually only one fix (bus.h) is required for a GENERIC kernel itself
to get multiuser login: prompt on a real hardware. Hurrahhh!!!

Demonstrated with a working Xorg mono server on the NetBSD booth
at Open Source Conference 2011 Kansai @ Kyoto:
http://www.ospn.jp/osc2011-kyoto/

"Very impressed," commented by Tomoko YOSHIDA,
Program Committee Chair of the Conference,
and some other OMRON guys.

Special Thanks to Tadashi Okamura, for providing
a working SX-9100/DT "LUNA" for this mission.


Changes details:

sys/arch/luna68k/include/bus.h
- handle stride properly even on multi and region ops for MI spc(4)
- also fix stride handling of (currently unused) 2 and 4 byte ops

sys/arch/luna68k/conf/Makefile.luna68k
sys/arch/luna68k/conf/kern.ldscript.head
sys/arch/luna68k/conf/kern.ldscript.tail
- build a faked a.out kernel using elf2aout(8) tool
and a linker script derived from cats and shark
for the LUNA firmware that loads a.out binary directly
via network or from a UNIOS partition on a local disk

sys/arch/luna68k/dev/omrasops.c
sys/arch/luna68k/dev/omron_rfont.h
- use the original OMRON font derived from 4.4BSD-Lite/luna68k
rather than gallant19 which is used on Sun workstations
(XXX omrasops.c should be rewritten to use generic wsfont(4))

distrib/luna68k/*
distrib/utils/sysinst/arch/luna68k/*
etc/etc.luna68k/MAKEDEV.conf
etc/etc.luna68k/Makefile.inc
sys/arch/luna68k/conf/INSTALL
- build a ramdisk based INSTALL kernel with sysinst(8) for luna68k
- also build an installation iso image for luna68k

sys/arch/luna68k/conf/GENERIC
- enable SYSVSHM (and other SYSV*) options for Xorg server

More Xorg changes (which need some more cleanup) and
isiboot.c fixes will come soon.
 1.1.8.1 25-Jul-2012  martin Pull up following revision(s) (requested by tsutsui in ticket #444):
sys/arch/luna68k/conf/GENERIC: revision 1.99
sys/arch/luna68k/dev/lunafb.c: revision 1.26
sys/arch/luna68k/luna68k/locore.s: revision 1.48
sys/arch/luna68k/dev/lunaws.c: revision 1.24
sys/arch/luna68k/dev/omron_rfont.h: file removal
sys/arch/luna68k/dev/omrasopsvar.h: revision 1.1
sys/arch/luna68k/dev/omrasops.c: revision 1.12
sys/arch/luna68k/dev/omrasops.c: revision 1.13
sys/arch/luna68k/conf/INSTALL: revision 1.6
Use & not && to mask bits. From OpenBSD/luna88k
Fix typo in comment. From OpenBSD/luna88k.
Switch luna68k wscons framebuffer driver to using rasops(9) APIs instead of
deprecated rcons(4). This allows "options FONT_foo" in kernel config files.
Mostly taken from OpenBSD/luna88k, but unnecessary MI rasops(9) stuff is
omitted since omrasops.c has own raster wsdisplay_emulops functions.
Tested on LUNA with 4bpp fb and LUNA-II with 1bpp fb.
Make reboot(2) actually work (don't access %sp after MMU is turned off).
Also cleanup spaces and #if 0'ed code. Tested on both LUNA and LUNA-II.
Should be pulled up to netbsd-6.
 1.1.2.1 30-Oct-2012  yamt sync with head
 1.2 11-Jun-2022  tsutsui Match psgpam(4) only on LUNA-I. LUNA-II doesn't have YM2149 at XP.
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.3 15-Jan-2023  tsutsui TAB/space/indent cleanup.
 1.2 01-Oct-2022  tsutsui Remove trailing whitespaces.
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.16 25-Sep-2021  tsutsui Refactor and cleanup sio (uPD7201) drivers.

- remove confusing syscn*() functions (and its header) and prepare
explicit siottycninit(), siottycnget() and siottycnput() functions
- use exported struct consdev and cn_tab to initialize siotty console
- enable and handle E/S interrupts to make BREAK signal detected properly
- make CSR (status regsiters) access functions inline static
- make single byte read/write (i.e. cnputc() and cngetc()) functions
static inline and take struct sio_register rather than sio channel
- use proper integer type (uint16_t) for getsiocsr() as siotty.c
- handle channel dependent CR2A and CR2B registers properly
- use more explicit definitions for RR_* macro used by getsiocsr()
- define and use proper RR0 (read register) values
(there is no isStatusReg(r) macro used on 4.4BSD/luna68k)

Tested on LUNA with both wscons console and serial console.
 1.15 07-Aug-2021  thorpej Merge thorpej-cfargs2.
 1.14 24-Apr-2021  thorpej branches: 1.14.8;
Merge thorpej-cfargs branch:

Simplify and make extensible the config_search() / config_found() /
config_attach() interfaces: rather than having different variants for
which arguments you want pass along, just have a single call that
takes a variadic list of tag-value arguments.

Adjust all call sites:
- Simplify wherever possible; don't pass along arguments that aren't
actually needed.
- Don't be explicit about what interface attribute is attaching if
the device only has one. (More simplification.)
- Add a config_probe() function to be used in indirect configuiration
situations, making is visibly easier to see when indirect config is
in play, and allowing for future change in semantics. (As of now,
this is just a wrapper around config_match(), but that is an
implementation detail.)

Remove unnecessary or redundant interface attributes where they're not
needed.

There are currently 5 "cfargs" defined:
- CFARG_SUBMATCH (submatch function for direct config)
- CFARG_SEARCH (search function for indirect config)
- CFARG_IATTR (interface attribte)
- CFARG_LOCATORS (locators array)
- CFARG_DEVHANDLE (devhandle_t - wraps OFW, ACPI, etc. handles)

...and a sentinel value CFARG_EOL.

Add some extra sanity checking to ensure that interface attributes
aren't ambiguous.

Use CFARG_DEVHANDLE in MI FDT, OFW, and ACPI code, and macppc and shark
ports to associate those device handles with device_t instance. This
will trickle trough to more places over time (need back-end for pre-OFW
Sun OBP; any others?).
 1.13 02-Feb-2014  tsutsui branches: 1.13.44;
Misc cleanup of sio drivers.

- register softc of child devices as an argument of the sio interrupt
handler to avoid device_lookup_private() calls on every interrupt
- change type of sc_reg from (void *) to (struct sioreg *)
to avoid weird address offset calculations with redundant casts
- rename struct sio_softc members for consistency
- use a channel number passed via sio_attach_args in lunaws_attach()

No functional chnages. Tested on LUNA.
 1.12 23-Sep-2013  tsutsui Tab/space cleanup.
 1.11 28-Jul-2011  tsutsui branches: 1.11.2; 1.11.12; 1.11.16;
Explicitly print uPD7201A name, which is a Z80 SIO like serial chip
with 8086 I/O interfaces.
 1.10 27-Jul-2011  tsutsui KNF, use uintNN_t, tab/space cosmetics etc.
 1.9 27-Jul-2011  tsutsui - split device_t/softc and use device_t and cfdata_t etc.
- use aprint_normal(9)
- include "ioconf.h" for struct cfdriver decls
No crash on LUNA.
 1.8 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.7 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.6 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.5 28-Apr-2008  martin branches: 1.5.8; 1.5.14;
Remove clause 3 and 4 from TNF licenses
 1.4 04-Mar-2007  christos branches: 1.4.40; 1.4.42; 1.4.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.3 01-Jan-2003  thorpej branches: 1.3.18; 1.3.56;
Use aprint_normal() for cfprint routines.
 1.2 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.1 05-Jan-2000  nisimura branches: 1.1.6; 1.1.10; 1.1.14;
Introduce NetBSD/luna68k port into CVS repository.
 1.1.14.2 03-Jan-2003  thorpej Sync with HEAD.
 1.1.14.1 18-Oct-2002  nathanw Catch up to -current.
 1.1.10.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 05-Jan-2000  bouyer file sio.c was added on branch thorpej_scsipi on 2000-11-20 20:10:26 +0000
 1.3.56.1 12-Mar-2007  rmind Sync with HEAD.
 1.3.18.1 03-Sep-2007  yamt sync with head.
 1.4.44.2 04-May-2009  yamt sync with head.
 1.4.44.1 16-May-2008  yamt sync with head.
 1.4.42.1 18-May-2008  yamt sync with head.
 1.4.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.11.16.1 18-May-2014  rmind sync with head
 1.11.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.11.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.13.44.1 21-Mar-2021  thorpej Give config_found() the same variadic arguments treatment as
config_search(). This commit only adds the CFARG_EOL sentinel
to the existing config_found() calls. Conversion of config_found_sm_loc()
and config_found_ia() call sites will be in subsequent commits.
 1.14.8.1 04-Aug-2021  thorpej Adapt to CFARGS().
 1.6 28-Mar-2023  andvar s/interrput/interrupt/ and s/accesss/access/ in comments.
 1.5 25-Sep-2021  tsutsui Refactor and cleanup sio (uPD7201) drivers.

- remove confusing syscn*() functions (and its header) and prepare
explicit siottycninit(), siottycnget() and siottycnput() functions
- use exported struct consdev and cn_tab to initialize siotty console
- enable and handle E/S interrupts to make BREAK signal detected properly
- make CSR (status regsiters) access functions inline static
- make single byte read/write (i.e. cnputc() and cngetc()) functions
static inline and take struct sio_register rather than sio channel
- use proper integer type (uint16_t) for getsiocsr() as siotty.c
- handle channel dependent CR2A and CR2B registers properly
- use more explicit definitions for RR_* macro used by getsiocsr()
- define and use proper RR0 (read register) values
(there is no isStatusReg(r) macro used on 4.4BSD/luna68k)

Tested on LUNA with both wscons console and serial console.
 1.4 27-Jul-2011  tsutsui KNF, use uintNN_t, tab/space cosmetics etc.
 1.3 11-Dec-2005  christos merge ktrace-lwp.
 1.2 07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22364, verified by myself.
 1.1 05-Jan-2000  nisimura branches: 1.1.6; 1.1.30;
Introduce NetBSD/luna68k port into CVS repository.
 1.1.30.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.1.30.2 18-Sep-2004  skrll Sync with HEAD.
 1.1.30.1 03-Aug-2004  skrll Sync with HEAD
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 05-Jan-2000  bouyer file sioreg.h was added on branch thorpej_scsipi on 2000-11-20 20:10:26 +0000
 1.54 14-Sep-2025  andvar Fix various typos in comments and log message.
 1.53 15-Jan-2023  tsutsui TAB/space/indent cleanup.
 1.52 22-Nov-2022  tsutsui Use explicit struct to represent RX queue buffer data structure.

No binary change.

Maybe the similar change should be applied to MI com(4) and zsc(4)?
 1.51 25-Sep-2021  tsutsui Refactor and cleanup sio (uPD7201) drivers.

- remove confusing syscn*() functions (and its header) and prepare
explicit siottycninit(), siottycnget() and siottycnput() functions
- use exported struct consdev and cn_tab to initialize siotty console
- enable and handle E/S interrupts to make BREAK signal detected properly
- make CSR (status regsiters) access functions inline static
- make single byte read/write (i.e. cnputc() and cngetc()) functions
static inline and take struct sio_register rather than sio channel
- use proper integer type (uint16_t) for getsiocsr() as siotty.c
- handle channel dependent CR2A and CR2B registers properly
- use more explicit definitions for RR_* macro used by getsiocsr()
- define and use proper RR0 (read register) values
(there is no isStatusReg(r) macro used on 4.4BSD/luna68k)

Tested on LUNA with both wscons console and serial console.
 1.50 04-Sep-2021  tsutsui Fix several styles and formats.
 1.49 04-Sep-2021  tsutsui Use C99 designated initializer.
 1.48 04-Sep-2021  tsutsui Use proper macro for device register addresses.
 1.47 29-Dec-2020  tsutsui Make local functions static.
 1.46 01-Oct-2019  chs branches: 1.46.8;
in many device attach paths, allocate memory with KM_SLEEP instead of KM_NOSLEEP
and remove code to handle failures that can no longer happen.
 1.45 30-Jun-2019  tsutsui Misc KNF.
 1.44 21-Aug-2015  christos branches: 1.44.18;
- move prototypes to common header file
- rename function to avoid confusion with pseudo-device attach
 1.43 20-Aug-2015  christos include "ioconf.h" to get the 'void <driver>attach(int count);' prototype.
 1.42 25-Jul-2014  dholland branches: 1.42.4;
Add d_discard to all struct cdevsw instances I could find.

All have been set to "nodiscard"; some should get a real implementation.
 1.41 18-Jul-2014  tsutsui Minor KNF. No binary changes.
 1.40 16-Mar-2014  dholland branches: 1.40.2;
Change (mostly mechanically) every cdevsw/bdevsw I can find to use
designated initializers.

I have not built every extant kernel so I have probably broken at
least one build; however I've also found and fixed some wrong
cdevsw/bdevsw entries so even if so I think we come out ahead.
 1.39 02-Feb-2014  tsutsui Misc cleanup of sio drivers.

- register softc of child devices as an argument of the sio interrupt
handler to avoid device_lookup_private() calls on every interrupt
- change type of sc_reg from (void *) to (struct sioreg *)
to avoid weird address offset calculations with redundant casts
- rename struct sio_softc members for consistency
- use a channel number passed via sio_attach_args in lunaws_attach()

No functional chnages. Tested on LUNA.
 1.38 02-Jan-2014  tsutsui Remove initialization of unused t_softc in struct tty (to make pullup easier).
 1.37 31-Dec-2013  tsutsui Use softint(9) properly to process TX/RX data between tty(4) layer.

It could cause possible locking issue to call tty(4) layer functions
from IPL_SERIAL interrupt handlers.

Changes details (mostly similar to com(4) and z8530tty(4)):
- allocate RX buffer and put data and status into it in the interrupt handler
- call t_linesw->l_rint from the software interrupt handler
- set the only first byte in siottystart() and use t_outq buffer to send
multiple TX data
- call the next t_linesw->l_start on TX complete in the software interrupt
handler

Also put more changes:
- handle cnmagic(9) properly (now entering ddb(4) by console BREAK works)
- allocate tty in the attach function as other drivers rather than first open
- use proper variable types
 1.36 23-Sep-2013  tsutsui Tab/space cleanup.
 1.35 22-Jan-2013  tsutsui branches: 1.35.2;
Whitespace cleanup.
 1.34 13-Oct-2012  tsutsui struct device * -> device_t, use device_xname() (from chs@)
 1.33 26-Nov-2011  tsutsui branches: 1.33.4; 1.33.8;
Reorganize IPL for devices.
 1.32 27-Jul-2011  tsutsui branches: 1.32.2;
KNF, use uintNN_t, tab/space cosmetics etc.
 1.31 27-Jul-2011  tsutsui - split device_t/softc and use device_t and cfdata_t etc.
- use aprint_normal(9)
- include "ioconf.h" for struct cfdriver decls
No crash on LUNA.
 1.30 24-Apr-2011  rmind Rename ttymalloc() to tty_alloc(), and ttyfree() to tty_free() for
consistency. Remove some unnecessary malloc.h inclusions as well.
 1.29 23-Nov-2009  rmind branches: 1.29.4; 1.29.6;
Use lwp_getpcb() on m68k ports, clean from struct user usage.
 1.28 26-Oct-2009  cegger kill extra whitespaces
reviewed by tsutsui@
 1.27 18-Mar-2009  cegger bcopy -> memcpy
 1.26 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.25 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.24 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.23 13-Jun-2008  cegger branches: 1.23.4; 1.23.10;
use device_lookup_private to get softc
 1.22 28-Apr-2008  martin branches: 1.22.2; 1.22.4;
Remove clause 3 and 4 from TNF licenses
 1.21 19-Nov-2007  ad branches: 1.21.14; 1.21.16; 1.21.18;
- Factor out too many copies of the same bit of tty code.
- Fix another tty signalling/wakeup problem.
 1.20 04-Mar-2007  christos branches: 1.20.2; 1.20.18; 1.20.20; 1.20.24; 1.20.26;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.19 01-Oct-2006  elad branches: 1.19.4;
Adapt MD code to KAUTH_DEVICE_TTY_OPEN. Patch from Matt Fleming, thanks!
 1.18 23-Jul-2006  ad branches: 1.18.4; 1.18.6;
Use the LWP cached credentials where sane.
 1.17 14-May-2006  elad integrate kauth.
 1.16 11-Dec-2005  christos branches: 1.16.4; 1.16.6; 1.16.8; 1.16.10; 1.16.12;
merge ktrace-lwp.
 1.15 06-Sep-2005  kleink Change the driver open function's conditional for overriding exclusive tty
use from checking the proc's uid to suser(9), and account for the use of
privileges. Noted by David Holland in PR kern/31126.
 1.14 25-Apr-2004  matt branches: 1.14.12;
Constify the speedtab arrays
 1.13 28-Mar-2003  he branches: 1.13.2;
Initialize the two new members of consdev (cn_halt, cn_flush) to NULL so
that this compiles again.
 1.12 23-Oct-2002  jdolecek merge kqueue branch into -current

kqueue provides a stateful and efficient event notification framework
currently supported events include socket, file, directory, fifo,
pipe, tty and device changes, and monitoring of processes and signals

kqueue is supported by all writable filesystems in NetBSD tree
(with exception of Coda) and all device drivers supporting poll(2)

based on work done by Jonathan Lemon for FreeBSD
initial NetBSD port done by Luke Mewburn and Jason Thorpe
 1.11 02-Oct-2002  thorpej Use CFATTACH_DECL().
 1.10 06-Sep-2002  gehenna Merge the gehenna-devsw branch into the trunk.

This merge changes the device switch tables from static array to
dynamically generated by config(8).

- All device switches is defined as a constant structure in device drivers.

- The new grammer ``device-major'' is introduced to ``files''.

device-major <prefix> char <num> [block <num>] [<rules>]

- All device major numbers must be listed up in port dependent majors.<arch>
by using this grammer.

- Added the new naming convention.
The name of the device switch must be <prefix>_[bc]devsw for auto-generation
of device switch tables.

- The backward compatibility of loading block/character device
switch by LKM framework is broken. This is necessary to convert
from block/character device major to device name in runtime and vice versa.

- The restriction to assign device major by LKM is completely removed.
We don't need to reserve LKM entries for dynamic loading of device switch.

- In compile time, device major numbers list is packed into the kernel and
the LKM framework will refer it to assign device major number dynamically.
 1.9 17-Mar-2002  atatat branches: 1.9.4;
Convert ioctl code to use EPASSTHROUGH instead of -1 or ENOTTY for
indicating an unhandled "command". ERESTART is -1, which can lead to
confusion. ERESTART has been moved to -3 and EPASSTHROUGH has been
placed at -4. No ioctl code should now return -1 anywhere. The
ioctl() system call is now properly restartable.
 1.8 02-May-2001  scw branches: 1.8.2; 1.8.4; 1.8.8;
Add `l_poll' to `struct linesw' and provide an xxxpoll() entry point
in each tty driver to indirect through it.

This allows tty line-disciplines to handle poll(2) system calls.
 1.7 31-Mar-2001  enami Remove unnecessary test of tp->t_linesw against NULL; they are results
of confusion while correcting compilation error after t_line is
replaced with t_linesw.
 1.6 07-Nov-2000  nisimura branches: 1.6.2; 1.6.4;
Fix a minor typo in the previous change of tp->t_linesw introduction.
 1.5 02-Nov-2000  eeh Adapt to new line discipline scheme.
 1.4 06-Mar-2000  thorpej - Implement cnbell() -- ring the console bell. The cn_bell entrypoint
is optional.
- Add cn_bell to statically allocated consdevs as appropriate.
 1.3 12-Jan-2000  nisimura Put a comment about BREAK detection; DDB fails to resume. Need to clear
the condition before resume?
 1.2 07-Jan-2000  nisimura - Make SCSI work; by kludges of machine/bus.h. TEAC streamer tape drive
found to be tweaked. Need extensive verifications.
- Add wsmouse node under ws; not useful this moment.
 1.1 05-Jan-2000  nisimura Introduce NetBSD/luna68k port into CVS repository.
 1.6.4.2 21-Jun-2001  nathanw Catch up to -current.
 1.6.4.1 09-Apr-2001  nathanw Catch up with -current.
 1.6.2.4 21-Apr-2001  bouyer Sync with HEAD
 1.6.2.3 22-Nov-2000  bouyer Sync with HEAD.
 1.6.2.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.6.2.1 07-Nov-2000  bouyer file siotty.c was added on branch thorpej_scsipi on 2000-11-20 20:10:26 +0000
 1.8.8.5 11-Nov-2002  nathanw Catch up to -current
 1.8.8.4 18-Oct-2002  nathanw Catch up to -current.
 1.8.8.3 17-Sep-2002  nathanw Catch up to -current.
 1.8.8.2 01-Apr-2002  nathanw Catch up to -current.
(CVS: It's not just a program. It's an adventure!)
 1.8.8.1 02-May-2001  nathanw file siotty.c was added on branch nathanw_sa on 2002-04-01 07:40:45 +0000
 1.8.4.2 13-Oct-2001  fvdl Revert the t_dev -> t_devvp change in struct tty. The way that tty
structs are currently used (especially by console ttys) aren't
ready for it, and this will require quite a few changes.
 1.8.4.1 10-Oct-2001  fvdl Convert all remaining devices.
 1.8.2.2 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.8.2.1 23-Jun-2002  jdolecek catch up with -current on kqueue branch
 1.9.4.1 19-May-2002  gehenna Add device switch.
Replace the access to devsw table and the hard-coded majors with devsw API.
 1.13.2.5 10-Nov-2005  skrll Sync with HEAD. Here we go again...
 1.13.2.4 25-Jan-2005  skrll Adapt to branch.
 1.13.2.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.13.2.2 18-Sep-2004  skrll Sync with HEAD.
 1.13.2.1 03-Aug-2004  skrll Sync with HEAD
 1.14.12.4 07-Dec-2007  yamt sync with head
 1.14.12.3 03-Sep-2007  yamt sync with head.
 1.14.12.2 30-Dec-2006  yamt sync with head.
 1.14.12.1 21-Jun-2006  yamt sync with head.
 1.16.12.1 24-May-2006  tron Merge 2006-05-24 NetBSD-current into the "peter-altq" branch.
 1.16.10.3 13-May-2006  elad sprinkle some #include <sys/kauth.h> in files that use kauth kpi but
don't include it yet. hopefully this will prevent some fallout.
 1.16.10.2 10-Mar-2006  elad generic_authorize() -> kauth_authorize_generic().
 1.16.10.1 08-Mar-2006  elad Adapt to kernel authorization KPI.

I expect *some* lossage here...
 1.16.8.2 11-Aug-2006  yamt sync with head
 1.16.8.1 24-May-2006  yamt sync with head.
 1.16.6.1 01-Jun-2006  kardel Sync with head.
 1.16.4.1 09-Sep-2006  rpaulo sync with head
 1.18.6.1 22-Oct-2006  yamt sync with head
 1.18.4.1 18-Nov-2006  ad Sync with head.
 1.19.4.1 12-Mar-2007  rmind Sync with HEAD.
 1.20.26.1 08-Dec-2007  mjf Sync with HEAD.
 1.20.24.1 21-Nov-2007  bouyer Sync with HEAD
 1.20.20.1 09-Jan-2008  matt sync with HEAD
 1.20.18.1 21-Nov-2007  joerg Sync with HEAD.
 1.20.2.1 03-Dec-2007  ad Sync with HEAD.
 1.21.18.3 11-Mar-2010  yamt sync with head
 1.21.18.2 04-May-2009  yamt sync with head.
 1.21.18.1 16-May-2008  yamt sync with head.
 1.21.16.2 17-Jun-2008  yamt sync with head.
 1.21.16.1 18-May-2008  yamt sync with head.
 1.21.14.2 29-Jun-2008  mjf Sync with HEAD.
 1.21.14.1 02-Jun-2008  mjf Sync with HEAD.
 1.22.4.1 18-Jun-2008  simonb Sync with head.
 1.22.2.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.23.10.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.23.4.1 28-Apr-2009  skrll Sync with HEAD.
 1.29.6.1 06-Jun-2011  jruoho Sync with HEAD.
 1.29.4.1 31-May-2011  rmind sync with head
 1.32.2.3 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.32.2.2 30-Oct-2012  yamt sync with head
 1.32.2.1 17-Apr-2012  yamt sync with head
 1.33.8.4 03-Dec-2017  jdolecek update from HEAD
 1.33.8.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.33.8.2 25-Feb-2013  tls resync with head
 1.33.8.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.33.4.1 12-Jan-2014  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1004):
sys/arch/luna68k/dev/siotty.c: revision 1.35
sys/arch/luna68k/dev/siotty.c: revision 1.36
sys/arch/luna68k/dev/siotty.c: revision 1.37
sys/arch/luna68k/dev/siotty.c: revision 1.38
sys/arch/luna68k/dev/lunaws.c: revision 1.25
sys/arch/luna68k/dev/lunaws.c: revision 1.26
sys/arch/luna68k/dev/lunaws.c: revision 1.27
sys/arch/luna68k/dev/siovar.h: revision 1.7
sys/arch/luna68k/dev/siotty.c: revision 1.34
struct device * -> device_t, use device_xname() (from chs@)
Whitespace cleanup.
Use softint(9) to pass received data into wskbd(9) and wsmouse(9) layers.
It might be problematic to call them from an interrupt handler at IPL_SERIAL.
Tab/space cleanup.
Use softint(9) properly to process TX/RX data between tty(4) layer.
It could cause possible locking issue to call tty(4) layer functions
from IPL_SERIAL interrupt handlers.
Changes details (mostly similar to com(4) and z8530tty(4)):
- allocate RX buffer and put data and status into it in the interrupt handler
- call t_linesw->l_rint from the software interrupt handler
- set the only first byte in siottystart() and use t_outq buffer to send
multiple TX data
- call the next t_linesw->l_start on TX complete in the software interrupt
handler
Also put more changes:
- handle cnmagic(9) properly (now entering ddb(4) by console BREAK works)
- allocate tty in the attach function as other drivers rather than first open
- use proper variable types
Remove initialization of unused t_softc in struct tty (to make pullup easier).
 1.35.2.1 18-May-2014  rmind sync with head
 1.40.2.1 10-Aug-2014  tls Rebase.
 1.42.4.1 22-Sep-2015  skrll Sync with HEAD
 1.44.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.46.8.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.1 25-Sep-2021  tsutsui Refactor and cleanup sio (uPD7201) drivers.

- remove confusing syscn*() functions (and its header) and prepare
explicit siottycninit(), siottycnget() and siottycnput() functions
- use exported struct consdev and cn_tab to initialize siotty console
- enable and handle E/S interrupts to make BREAK signal detected properly
- make CSR (status regsiters) access functions inline static
- make single byte read/write (i.e. cnputc() and cngetc()) functions
static inline and take struct sio_register rather than sio channel
- use proper integer type (uint16_t) for getsiocsr() as siotty.c
- handle channel dependent CR2A and CR2B registers properly
- use more explicit definitions for RR_* macro used by getsiocsr()
- define and use proper RR0 (read register) values
(there is no isStatusReg(r) macro used on 4.4BSD/luna68k)

Tested on LUNA with both wscons console and serial console.
 1.9 25-Sep-2021  tsutsui Refactor and cleanup sio (uPD7201) drivers.

- remove confusing syscn*() functions (and its header) and prepare
explicit siottycninit(), siottycnget() and siottycnput() functions
- use exported struct consdev and cn_tab to initialize siotty console
- enable and handle E/S interrupts to make BREAK signal detected properly
- make CSR (status regsiters) access functions inline static
- make single byte read/write (i.e. cnputc() and cngetc()) functions
static inline and take struct sio_register rather than sio channel
- use proper integer type (uint16_t) for getsiocsr() as siotty.c
- handle channel dependent CR2A and CR2B registers properly
- use more explicit definitions for RR_* macro used by getsiocsr()
- define and use proper RR0 (read register) values
(there is no isStatusReg(r) macro used on 4.4BSD/luna68k)

Tested on LUNA with both wscons console and serial console.
 1.8 02-Feb-2014  tsutsui Misc cleanup of sio drivers.

- register softc of child devices as an argument of the sio interrupt
handler to avoid device_lookup_private() calls on every interrupt
- change type of sc_reg from (void *) to (struct sioreg *)
to avoid weird address offset calculations with redundant casts
- rename struct sio_softc members for consistency
- use a channel number passed via sio_attach_args in lunaws_attach()

No functional chnages. Tested on LUNA.
 1.7 31-Dec-2013  tsutsui Use softint(9) properly to process TX/RX data between tty(4) layer.

It could cause possible locking issue to call tty(4) layer functions
from IPL_SERIAL interrupt handlers.

Changes details (mostly similar to com(4) and z8530tty(4)):
- allocate RX buffer and put data and status into it in the interrupt handler
- call t_linesw->l_rint from the software interrupt handler
- set the only first byte in siottystart() and use t_outq buffer to send
multiple TX data
- call the next t_linesw->l_start on TX complete in the software interrupt
handler

Also put more changes:
- handle cnmagic(9) properly (now entering ddb(4) by console BREAK works)
- allocate tty in the attach function as other drivers rather than first open
- use proper variable types
 1.6 27-Jul-2011  tsutsui branches: 1.6.2; 1.6.8; 1.6.12; 1.6.16;
KNF, use uintNN_t, tab/space cosmetics etc.
 1.5 27-Jul-2011  tsutsui - split device_t/softc and use device_t and cfdata_t etc.
- use aprint_normal(9)
- include "ioconf.h" for struct cfdriver decls
No crash on LUNA.
 1.4 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.3 28-Apr-2008  martin branches: 1.3.8; 1.3.14;
Remove clause 3 and 4 from TNF licenses
 1.2 04-Mar-2007  christos branches: 1.2.40; 1.2.42; 1.2.44;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.1 05-Jan-2000  nisimura branches: 1.1.6; 1.1.46; 1.1.84;
Introduce NetBSD/luna68k port into CVS repository.
 1.1.84.1 12-Mar-2007  rmind Sync with HEAD.
 1.1.46.1 03-Sep-2007  yamt sync with head.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 05-Jan-2000  bouyer file siovar.h was added on branch thorpej_scsipi on 2000-11-20 20:10:26 +0000
 1.2.44.2 04-May-2009  yamt sync with head.
 1.2.44.1 16-May-2008  yamt sync with head.
 1.2.42.1 18-May-2008  yamt sync with head.
 1.2.40.1 02-Jun-2008  mjf Sync with HEAD.
 1.3.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.3.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.6.16.1 18-May-2014  rmind sync with head
 1.6.12.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.6.8.1 12-Jan-2014  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1004):
sys/arch/luna68k/dev/siotty.c: revision 1.35
sys/arch/luna68k/dev/siotty.c: revision 1.36
sys/arch/luna68k/dev/siotty.c: revision 1.37
sys/arch/luna68k/dev/siotty.c: revision 1.38
sys/arch/luna68k/dev/lunaws.c: revision 1.25
sys/arch/luna68k/dev/lunaws.c: revision 1.26
sys/arch/luna68k/dev/lunaws.c: revision 1.27
sys/arch/luna68k/dev/siovar.h: revision 1.7
sys/arch/luna68k/dev/siotty.c: revision 1.34
struct device * -> device_t, use device_xname() (from chs@)
Whitespace cleanup.
Use softint(9) to pass received data into wskbd(9) and wsmouse(9) layers.
It might be problematic to call them from an interrupt handler at IPL_SERIAL.
Tab/space cleanup.
Use softint(9) properly to process TX/RX data between tty(4) layer.
It could cause possible locking issue to call tty(4) layer functions
from IPL_SERIAL interrupt handlers.
Changes details (mostly similar to com(4) and z8530tty(4)):
- allocate RX buffer and put data and status into it in the interrupt handler
- call t_linesw->l_rint from the software interrupt handler
- set the only first byte in siottystart() and use t_outq buffer to send
multiple TX data
- call the next t_linesw->l_start on TX complete in the software interrupt
handler
Also put more changes:
- handle cnmagic(9) properly (now entering ddb(4) by console BREAK works)
- allocate tty in the attach function as other drivers rather than first open
- use proper variable types
Remove initialization of unused t_softc in struct tty (to make pullup easier).
 1.6.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.11 23-Apr-2023  tsutsui Explicitly check machine type (LUNA-II) on secondary spc(4) probe.

So that individual mainbus_attach_args for both LUNA and LUNA-II
are no longer necessary.
While here, use proper address macro in <machine/board.h>.

Tested on both LUNA and LUNA-II.
 1.10 22-Jan-2013  tsutsui Whitespace cleanup.
 1.9 27-Jul-2011  tsutsui branches: 1.9.2; 1.9.12;
KNF, use uintNN_t, tab/space cosmetics etc.
 1.8 28-Apr-2008  martin Remove clause 3 and 4 from TNF licenses
 1.7 31-Mar-2008  tsutsui branches: 1.7.2; 1.7.4;
Split softc/device_t for spc(4) and misc related cleanup.
 1.6 04-Mar-2007  christos branches: 1.6.40;
Kill caddr_t; there will be some MI fallout, but it will be fixed shortly.
 1.5 11-Dec-2005  christos branches: 1.5.26;
merge ktrace-lwp.
 1.4 05-Jul-2003  tsutsui branches: 1.4.16;
Rename some MI mb89352 functions for consistency:
spcintr() -> spc_intr()
spcattach() -> spc_attach()
 1.3 05-Jul-2003  tsutsui Rename functions to avoid namespace conflicts:
spc_match() -> spc_mainbus_match()
spc_attach() -> spc_mainbus_attach()
 1.2 02-Oct-2002  thorpej branches: 1.2.6;
Use CFATTACH_DECL().
 1.1 05-Jan-2000  nisimura branches: 1.1.6; 1.1.10; 1.1.14;
Introduce NetBSD/luna68k port into CVS repository.
 1.1.14.1 18-Oct-2002  nathanw Catch up to -current.
 1.1.10.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 05-Jan-2000  bouyer file spc.c was added on branch thorpej_scsipi on 2000-11-20 20:10:27 +0000
 1.2.6.3 21-Sep-2004  skrll Fix the sync with head I botched.
 1.2.6.2 18-Sep-2004  skrll Sync with HEAD.
 1.2.6.1 03-Aug-2004  skrll Sync with HEAD
 1.4.16.1 03-Sep-2007  yamt sync with head.
 1.5.26.1 12-Mar-2007  rmind Sync with HEAD.
 1.6.40.2 02-Jun-2008  mjf Sync with HEAD.
 1.6.40.1 03-Apr-2008  mjf Sync with HEAD.
 1.7.4.1 16-May-2008  yamt sync with head.
 1.7.2.1 18-May-2008  yamt sync with head.
 1.9.12.1 25-Feb-2013  tls resync with head
 1.9.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.2 25-Sep-2021  tsutsui Refactor and cleanup sio (uPD7201) drivers.

- remove confusing syscn*() functions (and its header) and prepare
explicit siottycninit(), siottycnget() and siottycnput() functions
- use exported struct consdev and cn_tab to initialize siotty console
- enable and handle E/S interrupts to make BREAK signal detected properly
- make CSR (status regsiters) access functions inline static
- make single byte read/write (i.e. cnputc() and cngetc()) functions
static inline and take struct sio_register rather than sio channel
- use proper integer type (uint16_t) for getsiocsr() as siotty.c
- handle channel dependent CR2A and CR2B registers properly
- use more explicit definitions for RR_* macro used by getsiocsr()
- define and use proper RR0 (read register) values
(there is no isStatusReg(r) macro used on 4.4BSD/luna68k)

Tested on LUNA with both wscons console and serial console.
 1.1 21-Aug-2015  christos branches: 1.1.2; 1.1.18;
- move prototypes to common header file
- rename function to avoid confusion with pseudo-device attach
 1.1.18.2 03-Dec-2017  jdolecek update from HEAD
 1.1.18.1 21-Aug-2015  jdolecek file syscn.h was added on branch tls-maxphys on 2017-12-03 11:36:23 +0000
 1.1.2.2 22-Sep-2015  skrll Sync with HEAD
 1.1.2.1 21-Aug-2015  skrll file syscn.h was added on branch nick-nhusb on 2015-09-22 12:05:45 +0000
 1.16 07-Sep-2025  thorpej Change todr_chip_handle::cookie -> todr_chip_handle::todr_dev, and
make it a device_t. Upcoming functional changes will require the
device_t associated with a TODR device.

Change todr_chip_handle::bus_cookie -> todr_chip_handle::todr_devaux.
Nothing was using the old field, but I decided to keep it around just
in cause something needs it in the future.

And with these largely mechanical yet semantically meaningful changes,
thus spake the Oracle: "Welcome to NetBSD 11.99.2."
 1.15 20-Nov-2014  christos use the inline bcdtobin and bintobcd directly instead through a macro.
 1.14 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.13 19-Jul-2013  tsutsui Add an initialization function of DS1287A RTC and call it during attach.

It looks the boot firmware doesn't initialize the control registers
of DS1287A (while it resets NVRAM settings) and RTC oscillator is not
started properly after replacement.

Now my LUNA-II can keep RTC properly even after reboot.
 1.12 26-Jan-2013  tsutsui branches: 1.12.2; 1.12.8;
Fix offset of DS1287A NVRAM address on LUNA-II.
 1.11 22-Jan-2013  tsutsui Whitespace cleanup.
 1.10 27-Jul-2011  tsutsui branches: 1.10.2; 1.10.8; 1.10.12;
KNF, use uintNN_t, tab/space cosmetics etc.
 1.9 27-Jul-2011  tsutsui - split device_t/softc and use device_t and cfdata_t etc.
- use aprint_normal(9)
- include "ioconf.h" for struct cfdriver decls
No crash on LUNA.
 1.8 14-Mar-2009  dsl ANSIfy another 1261 function definitions.
The only ones left in sys are beyond by sed script!
(or in sys/dist or sys/external)
Mostly they have function pointer parameters.
 1.7 14-Mar-2009  dsl Change about 4500 of the K&R function definitions to ANSI ones.
There are still about 1600 left, but they have ',' or /* ... */
in the actual variable definitions - which my awk script doesn't handle.
There are also many that need () -> (void).
(The script does handle misordered arguments.)
 1.6 14-Mar-2009  dsl Remove all the __P() from sys (excluding sys/dist)
Diff checked with grep and MK1 eyeball.
i386 and amd64 GENERIC and sys still build.
 1.5 28-Apr-2008  martin branches: 1.5.8; 1.5.14;
Remove clause 3 and 4 from TNF licenses
 1.4 14-Sep-2006  gdamore branches: 1.4.54; 1.4.56; 1.4.58;
Update luna68k to MI todr and timecounters.
 1.3 12-Mar-2006  he branches: 1.3.10;
Now that FROMBCD and TOBCD is in <sys/dev/clock_subr.h>, delete the
local definitions here.
 1.2 02-Oct-2002  thorpej branches: 1.2.22; 1.2.36; 1.2.38; 1.2.40; 1.2.42;
Use CFATTACH_DECL().
 1.1 05-Jan-2000  nisimura branches: 1.1.6; 1.1.10; 1.1.14;
Introduce NetBSD/luna68k port into CVS repository.
 1.1.14.1 18-Oct-2002  nathanw Catch up to -current.
 1.1.10.1 10-Oct-2002  jdolecek sync kqueue with -current; this includes merge of gehenna-devsw branch,
merge of i386 MP branch, and part of autoconf rototil work
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 05-Jan-2000  bouyer file timekeeper.c was added on branch thorpej_scsipi on 2000-11-20 20:10:27 +0000
 1.2.42.1 19-Apr-2006  elad sync with head - hopefully this will work
 1.2.40.1 13-Mar-2006  yamt sync with head.
 1.2.38.1 22-Apr-2006  simonb Sync with head.
 1.2.36.1 09-Sep-2006  rpaulo sync with head
 1.2.22.2 30-Dec-2006  yamt sync with head.
 1.2.22.1 21-Jun-2006  yamt sync with head.
 1.3.10.1 18-Nov-2006  ad Sync with head.
 1.4.58.2 04-May-2009  yamt sync with head.
 1.4.58.1 16-May-2008  yamt sync with head.
 1.4.56.1 18-May-2008  yamt sync with head.
 1.4.54.1 02-Jun-2008  mjf Sync with HEAD.
 1.5.14.1 13-May-2009  jym Sync with HEAD.

Commit is split, to avoid a "too many arguments" protocol error.
 1.5.8.1 28-Apr-2009  skrll Sync with HEAD.
 1.10.12.3 03-Dec-2017  jdolecek update from HEAD
 1.10.12.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.10.12.1 25-Feb-2013  tls resync with head
 1.10.8.1 12-Jan-2014  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1003):
sys/arch/luna68k/dev/timekeeper.h: revision 1.3
sys/arch/luna68k/dev/timekeeper.c: revision 1.11
sys/arch/luna68k/dev/timekeeper.c: revision 1.12
sys/arch/luna68k/dev/timekeeper.c: revision 1.13
Whitespace cleanup.
Fix offset of DS1287A NVRAM address on LUNA-II.
Add an initialization function of DS1287A RTC and call it during attach.
It looks the boot firmware doesn't initialize the control registers
of DS1287A (while it resets NVRAM settings) and RTC oscillator is not
started properly after replacement.
Now my LUNA-II can keep RTC properly even after reboot.
 1.10.2.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.12.8.1 23-Jul-2013  riastradh sync with HEAD
 1.12.2.1 28-Aug-2013  rmind sync with head
 1.4 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.3 19-Jul-2013  tsutsui Add an initialization function of DS1287A RTC and call it during attach.

It looks the boot firmware doesn't initialize the control registers
of DS1287A (while it resets NVRAM settings) and RTC oscillator is not
started properly after replacement.

Now my LUNA-II can keep RTC properly even after reboot.
 1.2 28-Apr-2008  martin branches: 1.2.34; 1.2.40; 1.2.44; 1.2.50; 1.2.58;
Remove clause 3 and 4 from TNF licenses
 1.1 05-Jan-2000  nisimura branches: 1.1.6; 1.1.132; 1.1.134; 1.1.136;
Introduce NetBSD/luna68k port into CVS repository.
 1.1.136.1 16-May-2008  yamt sync with head.
 1.1.134.1 18-May-2008  yamt sync with head.
 1.1.132.1 02-Jun-2008  mjf Sync with HEAD.
 1.1.6.2 20-Nov-2000  bouyer Update thorpej_scsipi to -current as of a month ago
A i386 GENERIC kernel compiles without the siop, ahc and bha drivers
(will be updated later). i386 IDE/ATAPI and ncr work, as well as
sparc/esp_sbus. alpha should work as well (untested yet).
siop, ahc and bha will be updated once I've updated the branch to current
-current, as well as machine-dependant code.
 1.1.6.1 05-Jan-2000  bouyer file timekeeper.h was added on branch thorpej_scsipi on 2000-11-20 20:10:27 +0000
 1.2.58.1 23-Jul-2013  riastradh sync with HEAD
 1.2.50.1 28-Aug-2013  rmind sync with head
 1.2.44.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.2.40.1 12-Jan-2014  bouyer Pull up following revision(s) (requested by tsutsui in ticket #1003):
sys/arch/luna68k/dev/timekeeper.h: revision 1.3
sys/arch/luna68k/dev/timekeeper.c: revision 1.11
sys/arch/luna68k/dev/timekeeper.c: revision 1.12
sys/arch/luna68k/dev/timekeeper.c: revision 1.13
Whitespace cleanup.
Fix offset of DS1287A NVRAM address on LUNA-II.
Add an initialization function of DS1287A RTC and call it during attach.
It looks the boot firmware doesn't initialize the control registers
of DS1287A (while it resets NVRAM settings) and RTC oscillator is not
started properly after replacement.
Now my LUNA-II can keep RTC properly even after reboot.
 1.2.34.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.8 15-Jan-2023  tsutsui TAB/space/indent cleanup.
 1.7 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.6 29-Dec-2020  tsutsui Make local functions static.
 1.5 30-Jun-2019  tsutsui branches: 1.5.10;
Pull OpenBSD/luna88k board.h to define SX9100 board device addresses.

Also replace magic addresses with macro where appropriate.
 1.4 01-Jun-2017  chs branches: 1.4.8; 1.4.12;
remove checks for failure after memory allocation calls that cannot fail:

kmem_alloc() with KM_SLEEP
kmem_zalloc() with KM_SLEEP
percpu_alloc()
pserialize_create()
psref_class_create()

all of these paths include an assertion that the allocation has not failed,
so callers should not assert that again.
 1.3 08-Jan-2017  tsutsui branches: 1.3.4;
Consistently use sc_shm_size initialized at device attach.
 1.2 08-Jan-2017  tsutsui Fix (mostly harmless) off-by-one size check in XPIOCDOWNLD ioctl.

Pointed out by Kenji Aoyama.
 1.1 03-Dec-2016  tsutsui branches: 1.1.2; 1.1.4; 1.1.6;
Preliminary support for LUNA's HD647180X I/O processor (a.k.a. XP).

Demonstrated as "PSG tunes / PCM wav player on LUNA"
(using Z80 PSG/PCM drivers ported from NEC PC-6001)
at OSC2016 Kyoto and OSC2016 Hiroshima:
http://mail-index.netbsd.org/netbsd-advocacy/2016/08/01/msg000712.html
http://mail-index.netbsd.org/netbsd-advocacy/2016/11/29/msg000724.html
 1.1.6.3 20-Mar-2017  pgoyette Sync with HEAD
 1.1.6.2 07-Jan-2017  pgoyette Sync with HEAD. (Note that most of these changes are simply $NetBSD$
tag issues.)
 1.1.6.1 03-Dec-2016  pgoyette file xp.c was added on branch pgoyette-localcount on 2017-01-07 08:56:20 +0000
 1.1.4.2 06-Dec-2016  snj Pull up following revision(s) (requested by tsutsui in ticket #1283):
distrib/sets/lists/comp/md.luna68k: revision 1.21
etc/etc.luna68k/MAKEDEV.conf: revision 1.9
sys/arch/luna68k/conf/GENERIC: revision 1.120
sys/arch/luna68k/conf/files.luna68k: revision 1.25
sys/arch/luna68k/conf/majors.luna68k: revision 1.21
sys/arch/luna68k/dev/xp.c: revision 1.1
sys/arch/luna68k/include/Makefile: revision 1.19
sys/arch/luna68k/include/xpio.h: revision 1.1
sys/arch/luna68k/luna68k/mainbus.c: revision 1.14
Preliminary support for LUNA's HD647180X I/O processor (a.k.a. XP).
Demonstrated as "PSG tunes / PCM wav player on LUNA"
(using Z80 PSG/PCM drivers ported from NEC PC-6001)
at OSC2016 Kyoto and OSC2016 Hiroshima:
http://mail-index.netbsd.org/netbsd-advocacy/2016/08/01/msg000712.html
http://mail-index.netbsd.org/netbsd-advocacy/2016/11/29/msg000724.html
 1.1.4.1 03-Dec-2016  snj file xp.c was added on branch netbsd-7 on 2016-12-06 06:50:23 +0000
 1.1.2.4 28-Aug-2017  skrll Sync with HEAD
 1.1.2.3 05-Feb-2017  skrll Sync with HEAD
 1.1.2.2 05-Dec-2016  skrll Sync with HEAD
 1.1.2.1 03-Dec-2016  skrll file xp.c was added on branch nick-nhusb on 2016-12-05 10:54:54 +0000
 1.3.4.2 18-Jan-2017  skrll Sync with netbsd-5
 1.3.4.1 08-Jan-2017  skrll file xp.c was added on branch netbsd-7-nhusb on 2017-01-18 08:46:25 +0000
 1.4.12.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.4.8.2 03-Dec-2017  jdolecek update from HEAD
 1.4.8.1 01-Jun-2017  jdolecek file xp.c was added on branch tls-maxphys on 2017-12-03 11:36:23 +0000
 1.5.10.1 03-Jan-2021  thorpej Sync w/ HEAD.
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.2 01-Oct-2022  tsutsui Remove trailing whitespaces.
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.2 13-Oct-2023  tsutsui Remove trailing spaces and TAB.
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!
 1.1 10-Jun-2022  tsutsui luna68k: add psgpam(4) audio for LUNA, using YM2149 PSG/SSG sound chip.

"PSG PAM" is a audio driver using "Pulse Amplitude Modulation" with the
YM2149 PSG/SSG chip connected to the I/O processor HD647180X on LUNA.
The driver plays up to 30 kHz PCM audio by manipulating PSG channel volumes
at extremely high speed with 6.144 MHz HD647180X, a Z80 compatible sub CPU.
https://www.youtube.com/watch?v=fR7PqaLpijQ
https://www.youtube.com/watch?v=kCDZCgkwgBA

Compatibilities with the existing XPIOCDOWNLD ioctl(2) to download and
exec user programs (PSG sound driver player ported from PC-6001 etc.)
on the HD647180X is still provided.
https://twitter.com/tsutsuii/status/1533247362965315584

This psgpam(4) driver for NetBSD/luna68k was written by @moveccr
during isaki-audio2 branch developments, and it was also demonstrated
at Open Source Conference 2018 Kyoto:
https://github.com/isaki68k/netbsd-src/tree/audio2
https://mail-index.netbsd.org/netbsd-advocacy/2018/08/07/msg000781.html
https://twitter.com/tsutsuii/status/1025504875625365505

Note specifications of interrupts from the HD647180X to the host LUNA
was confirmed by Kenji Aoyama on his LUNA-88K2 running OpenBSD/luna88k.

I would like to thank all people still working on ancient LUNA machines!

RSS XML Feed