pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

import of svgalib64.



Module Name:	pkgsrc-wip
Committed By:	goon <goon.mage%yahoo.com@localhost>
Pushed By:	goon
Date:		Tue Feb 25 07:43:07 2025 +0100
Changeset:	0f8874a6b300dc07430356f5825beeebe7053456

Added Files:
	svgalib64/DESCR
	svgalib64/Makefile
	svgalib64/PLIST
	svgalib64/TODO
	svgalib64/buildlink3.mk
	svgalib64/distinfo
	svgalib64/patches/patch-aa
	svgalib64/patches/patch-ab
	svgalib64/patches/patch-ac
	svgalib64/patches/patch-ad
	svgalib64/patches/patch-ae
	svgalib64/patches/patch-af
	svgalib64/patches/patch-ag
	svgalib64/patches/patch-ah
	svgalib64/patches/patch-ai
	svgalib64/patches/patch-aj
	svgalib64/patches/patch-ak
	svgalib64/patches/patch-al
	svgalib64/patches/patch-am
	svgalib64/patches/patch-an
	svgalib64/patches/patch-ao
	svgalib64/patches/patch-ap
	svgalib64/patches/patch-aq
	svgalib64/patches/patch-ar
	svgalib64/patches/patch-as
	svgalib64/patches/patch-at
	svgalib64/patches/patch-au
	svgalib64/patches/patch-av
	svgalib64/patches/patch-aw
	svgalib64/patches/patch-ax
	svgalib64/patches/patch-ay
	svgalib64/patches/patch-az
	svgalib64/patches/patch-ba
	svgalib64/patches/patch-bb
	svgalib64/patches/patch-ca
	svgalib64/patches/patch-ca.0.1.1
	svgalib64/patches/patch-ca.0.1.2
	svgalib64/patches/patch-ca.0.1.3

Log Message:
import of svgalib64.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=0f8874a6b300dc07430356f5825beeebe7053456

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 svgalib64/DESCR                  |  11 +
 svgalib64/Makefile               |  36 +++
 svgalib64/PLIST                  | 264 +++++++++++++++
 svgalib64/TODO                   |  40 +++
 svgalib64/buildlink3.mk          |  12 +
 svgalib64/distinfo               |  33 ++
 svgalib64/patches/patch-aa       | 108 +++++++
 svgalib64/patches/patch-ab       |  43 +++
 svgalib64/patches/patch-ac       |  12 +
 svgalib64/patches/patch-ad       |  20 ++
 svgalib64/patches/patch-ae       |  22 ++
 svgalib64/patches/patch-af       |  13 +
 svgalib64/patches/patch-ag       |  13 +
 svgalib64/patches/patch-ah       |  84 +++++
 svgalib64/patches/patch-ai       |  28 ++
 svgalib64/patches/patch-aj       | 205 ++++++++++++
 svgalib64/patches/patch-ak       |  22 ++
 svgalib64/patches/patch-al       |  21 ++
 svgalib64/patches/patch-am       | 176 ++++++++++
 svgalib64/patches/patch-an       |  35 ++
 svgalib64/patches/patch-ao       |  12 +
 svgalib64/patches/patch-ap       |  13 +
 svgalib64/patches/patch-aq       |  12 +
 svgalib64/patches/patch-ar       |  13 +
 svgalib64/patches/patch-as       |  12 +
 svgalib64/patches/patch-at       |  13 +
 svgalib64/patches/patch-au       |  13 +
 svgalib64/patches/patch-av       | 435 +++++++++++++++++++++++++
 svgalib64/patches/patch-aw       |   6 +
 svgalib64/patches/patch-ax       |  53 +++
 svgalib64/patches/patch-ay       |  25 ++
 svgalib64/patches/patch-az       |  49 +++
 svgalib64/patches/patch-ba       | 476 +++++++++++++++++++++++++++
 svgalib64/patches/patch-bb       |  25 ++
 svgalib64/patches/patch-ca       | 679 +++++++++++++++++++++++++++++++++++++++
 svgalib64/patches/patch-ca.0.1.1 | 616 +++++++++++++++++++++++++++++++++++
 svgalib64/patches/patch-ca.0.1.2 | 660 +++++++++++++++++++++++++++++++++++++
 svgalib64/patches/patch-ca.0.1.3 | 679 +++++++++++++++++++++++++++++++++++++++
 38 files changed, 4989 insertions(+)

diffs:
diff --git a/svgalib64/DESCR b/svgalib64/DESCR
new file mode 100644
index 0000000000..682833d28e
--- /dev/null
+++ b/svgalib64/DESCR
@@ -0,0 +1,11 @@
+This is a low level console graphics library, originally based on VGAlib 1.2 by
+Tommy Frandsen. VGAlib supported  a number  of  standard  VGA graphics modes,
+as well high resolution/high color modes on many popular graphics adapters. As
+of now, support for  many  more  chipsets  has  been  added.
+
+It supports transparent virtual  console  switching,  that is,  you can switch
+consoles to and from text and graphics mode consoles using alt-[function key].
+Also, svgalib corrects  most  of  VGAlib's textmode corruption behaviour by
+catching SIGSEGV, SIGFPE, SIGILL, and other fatal  signals and  ensuring  that
+a program is running in the currently visible virtual console before setting a
+graphics mode.
diff --git a/svgalib64/Makefile b/svgalib64/Makefile
new file mode 100644
index 0000000000..cc030d7226
--- /dev/null
+++ b/svgalib64/Makefile
@@ -0,0 +1,36 @@
+# $NetBSD: Makefile,v 1.9 2012/10/07 16:23:18 asau Exp $
+
+DISTNAME=	svgalib-1.4.3
+CATEGORIES=	graphics devel
+MASTER_SITES=	http://www.svgalib.org/
+
+MAINTAINER=	indur9%yahoo.com@localhost ### old : collver1%comcast.net@localhost
+HOMEPAGE=	https://www.svgalib.org/
+COMMENT=	Low level console graphics library
+
+
+USE_TOOLS+=	gmake
+CFLAGS+=	-g -DUSE_LIBC_VM86
+MANCOMPRESSED=	yes
+
+BUILD_TARGET=	shared static
+
+#ONLY_FOR_ARCHS=	i386
+
+pre-patch:
+	for i in ${WRKSRC}/utils/gtf/*.h; do \
+		${TR} -d '\015' < $${i} > $${i}.new; \
+		${MV} $${i}.new $${i}; \
+	done
+	${MKDIR} ${WRKSRC}/include/linux
+	for i in ${WRKSRC}/utils/?*textmode ${WRKSRC}/demos/svidtune.c; do \
+		${CP} $${i} $${i}.orig; \
+		${SED} -e "s,/etc,${PREFIX}/etc,g" < $${i}.orig > $${i}; \
+	done
+
+post-install:
+	${INSTALL_DATA_DIR} ${PREFIX}/include/linux
+	cd ${WRKSRC}/include/linux && \
+		${INSTALL_DATA} keyboard.h kd.h ${PREFIX}/include/linux
+
+.include "../../mk/bsd.pkg.mk"
diff --git a/svgalib64/PLIST b/svgalib64/PLIST
new file mode 100644
index 0000000000..bbb23544c4
--- /dev/null
+++ b/svgalib64/PLIST
@@ -0,0 +1,264 @@
+@comment $NetBSD: PLIST,v 1.2 2009/10/11 10:45:19 thomasklausner Exp $
+bin/dumpreg
+bin/restorefont
+bin/restorepalette
+bin/restoretextmode
+bin/savetextmode
+bin/svgakeymap
+bin/textmode
+etc/vga/dvorak-us.keymap
+etc/vga/libvga.config
+etc/vga/libvga.et4000
+etc/vga/null.keymap
+include/linux/kd.h
+include/linux/keyboard.h
+include/vga.h
+include/vgagl.h
+include/vgajoystick.h
+include/vgakeyboard.h
+include/vgamouse.h
+lib/libvga.a
+lib/libvga.so
+lib/libvga.so.1
+lib/libvgagl.a
+lib/libvgagl.so
+lib/libvgagl.so.1
+man/man1/convfont.1
+man/man1/dumpreg.1
+man/man1/fix132x43.1
+man/man1/restorefont.1
+man/man1/restorepalette.1
+man/man1/restoretextmode.1
+man/man1/runx.1
+man/man1/savetextmode.1
+man/man1/setmclk.1
+man/man1/svgakeymap.1
+man/man1/textmode.1
+man/man3/currentcontext.3
+man/man3/gl_allocatecontext.3
+man/man3/gl_bcircle.3
+man/man3/gl_circle.3
+man/man3/gl_clearscreen.3
+man/man3/gl_colorfont.3
+man/man3/gl_compileboxmask.3
+man/man3/gl_compiledboxmasksize.3
+man/man3/gl_copybox.3
+man/man3/gl_copyboxfromcontext.3
+man/man3/gl_copyboxtocontext.3
+man/man3/gl_copyscreen.3
+man/man3/gl_disableclipping.3
+man/man3/gl_enableclipping.3
+man/man3/gl_enablepageflipping.3
+man/man3/gl_expandfont.3
+man/man3/gl_fillbox.3
+man/man3/gl_fillcircle.3
+man/man3/gl_font8x8.3
+man/man3/gl_freecontext.3
+man/man3/gl_getbox.3
+man/man3/gl_getcontext.3
+man/man3/gl_getpalette.3
+man/man3/gl_getpalettecolor.3
+man/man3/gl_getpalettecolors.3
+man/man3/gl_getpixel.3
+man/man3/gl_getpixelrgb.3
+man/man3/gl_hline.3
+man/man3/gl_line.3
+man/man3/gl_printf.3
+man/man3/gl_putbox.3
+man/man3/gl_putboxmask.3
+man/man3/gl_putboxmaskcompiled.3
+man/man3/gl_putboxpart.3
+man/man3/gl_rgbcolor.3
+man/man3/gl_scalebox.3
+man/man3/gl_setclippingwindow.3
+man/man3/gl_setcontext.3
+man/man3/gl_setcontextheight.3
+man/man3/gl_setcontextvga.3
+man/man3/gl_setcontextvgavirtual.3
+man/man3/gl_setcontextvirtual.3
+man/man3/gl_setcontextwidth.3
+man/man3/gl_setdisplaystart.3
+man/man3/gl_setfont.3
+man/man3/gl_setfontcolors.3
+man/man3/gl_setpalette.3
+man/man3/gl_setpalettecolor.3
+man/man3/gl_setpalettecolors.3
+man/man3/gl_setpixel.3
+man/man3/gl_setpixelrgb.3
+man/man3/gl_setrgbpalette.3
+man/man3/gl_setscreenoffset.3
+man/man3/gl_setwritemode.3
+man/man3/gl_striangle.3
+man/man3/gl_swtriangle.3
+man/man3/gl_triangle.3
+man/man3/gl_trigetcolorlookup.3
+man/man3/gl_trisetcolorlookup.3
+man/man3/gl_trisetdrawpoint.3
+man/man3/gl_write.3
+man/man3/gl_writen.3
+man/man3/gl_wtriangle.3
+man/man3/graph_mem.3
+man/man3/joystick_button1.3
+man/man3/joystick_button2.3
+man/man3/joystick_button3.3
+man/man3/joystick_button4.3
+man/man3/joystick_close.3
+man/man3/joystick_getaxis.3
+man/man3/joystick_getb1.3
+man/man3/joystick_getb2.3
+man/man3/joystick_getb3.3
+man/man3/joystick_getb4.3
+man/man3/joystick_getbutton.3
+man/man3/joystick_getnumaxes.3
+man/man3/joystick_getnumbuttons.3
+man/man3/joystick_getx.3
+man/man3/joystick_gety.3
+man/man3/joystick_getz.3
+man/man3/joystick_init.3
+man/man3/joystick_setdefaulthandler.3
+man/man3/joystick_sethandler.3
+man/man3/joystick_update.3
+man/man3/joystick_x.3
+man/man3/joystick_y.3
+man/man3/joystick_z.3
+man/man3/keyboard_clearstate.3
+man/man3/keyboard_close.3
+man/man3/keyboard_getstate.3
+man/man3/keyboard_init.3
+man/man3/keyboard_init_return_fd.3
+man/man3/keyboard_keypressed.3
+man/man3/keyboard_setdefaulteventhandler.3
+man/man3/keyboard_seteventhandler.3
+man/man3/keyboard_translatekeys.3
+man/man3/keyboard_update.3
+man/man3/keyboard_waitforupdate.3
+man/man3/mouse_close.3
+man/man3/mouse_getbutton.3
+man/man3/mouse_getcaps.3
+man/man3/mouse_getposition_6d.3
+man/man3/mouse_getx.3
+man/man3/mouse_gety.3
+man/man3/mouse_init.3
+man/man3/mouse_init_return_fd.3
+man/man3/mouse_setdefaulteventhandler.3
+man/man3/mouse_seteventhandler.3
+man/man3/mouse_setposition.3
+man/man3/mouse_setposition_6d.3
+man/man3/mouse_setrange_6d.3
+man/man3/mouse_setscale.3
+man/man3/mouse_setwrap.3
+man/man3/mouse_setxrange.3
+man/man3/mouse_setyrange.3
+man/man3/mouse_update.3
+man/man3/mouse_waitforupdate.3
+man/man3/vga_accel.3
+man/man3/vga_addmode.3
+man/man3/vga_addtiming.3
+man/man3/vga_bitblt.3
+man/man3/vga_blitwait.3
+man/man3/vga_changetiming.3
+man/man3/vga_claimvideomemory.3
+man/man3/vga_clear.3
+man/man3/vga_copytoplanar16.3
+man/man3/vga_copytoplanar256.3
+man/man3/vga_copytoplane.3
+man/man3/vga_disabledriverreport.3
+man/man3/vga_drawline.3
+man/man3/vga_drawpixel.3
+man/man3/vga_drawscanline.3
+man/man3/vga_drawscansegment.3
+man/man3/vga_dumpregs.3
+man/man3/vga_ext_set.3
+man/man3/vga_fillblt.3
+man/man3/vga_flip.3
+man/man3/vga_getch.3
+man/man3/vga_getcolors.3
+man/man3/vga_getcurrentchipset.3
+man/man3/vga_getcurrentmode.3
+man/man3/vga_getcurrenttiming.3
+man/man3/vga_getdefaultmode.3
+man/man3/vga_getgraphmem.3
+man/man3/vga_getkey.3
+man/man3/vga_getmodeinfo.3
+man/man3/vga_getmodename.3
+man/man3/vga_getmodenumber.3
+man/man3/vga_getmonitortype.3
+man/man3/vga_getmousetype.3
+man/man3/vga_getpalette.3
+man/man3/vga_getpalvec.3
+man/man3/vga_getpixel.3
+man/man3/vga_getscansegment.3
+man/man3/vga_gettextfont.3
+man/man3/vga_gettextmoderegs.3
+man/man3/vga_getxdim.3
+man/man3/vga_getydim.3
+man/man3/vga_guesstiming.3
+man/man3/vga_hasmode.3
+man/man3/vga_hlinelistblt.3
+man/man3/vga_imageblt.3
+man/man3/vga_init.3
+man/man3/vga_lastmodenumber.3
+man/man3/vga_lockvc.3
+man/man3/vga_oktowrite.3
+man/man3/vga_puttextfont.3
+man/man3/vga_runinbackground.3
+man/man3/vga_runinbackground_version.3
+man/man3/vga_safety_fork.3
+man/man3/vga_screenoff.3
+man/man3/vga_screenon.3
+man/man3/vga_setchipset.3
+man/man3/vga_setchipsetandfeatures.3
+man/man3/vga_setcolor.3
+man/man3/vga_setdisplaystart.3
+man/man3/vga_setegacolor.3
+man/man3/vga_setflipchar.3
+man/man3/vga_setlinearaddressing.3
+man/man3/vga_setlogicalwidth.3
+man/man3/vga_setmode.3
+man/man3/vga_setmodeX.3
+man/man3/vga_setmousesupport.3
+man/man3/vga_setpage.3
+man/man3/vga_setpalette.3
+man/man3/vga_setpalvec.3
+man/man3/vga_setreadpage.3
+man/man3/vga_setrgbcolor.3
+man/man3/vga_settextmoderegs.3
+man/man3/vga_setwritepage.3
+man/man3/vga_unlockvc.3
+man/man3/vga_waitevent.3
+man/man3/vga_waitretrace.3
+man/man3/vga_white.3
+man/man5/libvga.config.5
+man/man5/libvga.et4000.5
+man/man5/svgalibrc.5
+man/man6/accel.6
+man/man6/bg_test.6
+man/man6/eventtest.6
+man/man6/forktest.6
+man/man6/fun.6
+man/man6/joytest.6
+man/man6/keytest.6
+man/man6/lineart.6
+man/man6/mach32info.6
+man/man6/mjoytest.6
+man/man6/mousetest.6
+man/man6/plane.6
+man/man6/printftest.6
+man/man6/scrolltest.6
+man/man6/speedtest.6
+man/man6/spin.6
+man/man6/svidtune.6
+man/man6/testaccel.6
+man/man6/testgl.6
+man/man6/testlinear.6
+man/man6/threed.6
+man/man6/vgatest.6
+man/man6/wrapdemo.6
+man/man7/svgalib.7
+man/man7/svgalib.chips.7
+man/man7/svgalib.et4000.7
+man/man7/svgalib.faq.7
+man/man7/svgalib.mach32.7
+man/man7/threedkit.7
+man/man7/vgagl.7
+man/man8/mode3.8
diff --git a/svgalib64/TODO b/svgalib64/TODO
new file mode 100644
index 0000000000..9c6fd8a029
--- /dev/null
+++ b/svgalib64/TODO
@@ -0,0 +1,40 @@
+* add wsmouse glue
+* test more video drivers
+
+
+I have encountered problems where the console stops displaying.
+Sometimes I can switch to another console, and type in stuff
+but nothing displays.
+
+So it can be useful to have 2 consoles logged in as root ahead
+of time.  When the display gets munged, you can switch to the
+other console and blindly type some commands to recover the
+console.
+
+Before running a svgalib program, /usr/pkg/bin/savetextmode
+You only need to run this once.
+
+Also, do not run the svgalib program on the very first
+console.  If the first console gets hosed, it is hosed for
+good.
+
+Now, if your svgalib application is not displaying, and you
+cannot exit it, try switching to the other console.  You
+might still see nothing on the screen, but type
+/usr/pkg/bin/textmode
+
+Now you should see what you are typing.  But be warned, do
+not switch back to the svgalib application console.  It is
+still hosed, and you might get stuck permanently.
+
+Let's say the first console is console 0, and we avoided
+the first console and ran the svgalib application on
+console 1.
+
+wsconscfg -d -F 1
+wsconscfg -t 80x25 -e vt100 1
+pkill -f ttyE1
+
+This forcefully deletes console 1, then re-creates it, then
+kills the stale getty.  Now you can switch to console 1 and
+press enter a few times to get a login prompt.
diff --git a/svgalib64/buildlink3.mk b/svgalib64/buildlink3.mk
new file mode 100644
index 0000000000..b1f5f3c47d
--- /dev/null
+++ b/svgalib64/buildlink3.mk
@@ -0,0 +1,12 @@
+# $NetBSD: buildlink3.mk,v 1.4 2009/05/06 09:36:48 cheusov Exp $
+
+BUILDLINK_TREE+=	svgalib
+
+.if !defined(SVGALIB_BUILDLINK3_MK)
+SVGALIB_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.svgalib+=	svgalib>=1.4.2
+BUILDLINK_PKGSRCDIR.svgalib?=	../../wip/svgalib
+.endif # SVGALIB_BUILDLINK3_MK
+
+BUILDLINK_TREE+=	-svgalib
diff --git a/svgalib64/distinfo b/svgalib64/distinfo
new file mode 100644
index 0000000000..c4c4e723c2
--- /dev/null
+++ b/svgalib64/distinfo
@@ -0,0 +1,33 @@
+$NetBSD: distinfo,v 1.5 2005/09/28 06:41:42 rillig Exp $
+
+RMD160 (svgalib-1.4.3.tar.gz) = 611269f70ed378b6460f5e34f8c35d89646e92c5
+SHA512 (svgalib-1.4.3.tar.gz) = 05d0b2d860a3c0be0a5d10778665fe9f980a2f7304dcf2339f8ff2ca625072b190694ebd7ac9ed688fc6695f04541f663bb2c603c89064a0e7ad59c262d9efe8
+Size (svgalib-1.4.3.tar.gz) = 840282 bytes
+SHA1 (patch-aa) = 13314ed7507cd4fe06dc94124eebe797e18b5c52
+SHA1 (patch-ab) = c5e61ae5378e5d110ecc6c44897d1c42e73c75b8
+SHA1 (patch-ac) = fbcdde262d76a192610b0cf08e74145e9ea900bc
+SHA1 (patch-ad) = 54db5ec72e350f04182ad46e009baef716bba473
+SHA1 (patch-ae) = a18b5f9268a2721ed1f466ef0ee5566cffdd3f03
+SHA1 (patch-af) = ec5ae6101648e1e8609d8991e64e44b5fb466cdb
+SHA1 (patch-ag) = 03877bfd80f7d7240faf6ac80d79d0ce487d301e
+SHA1 (patch-ah) = 30833f96cc1118534c0c0231bfb5d6497af7b5db
+SHA1 (patch-ai) = 8fa4a76c24d138b199836fc2f492aeff4d609fdb
+SHA1 (patch-aj) = 9608dbfd81b896649c47019e9e3ef30174c1a15e
+SHA1 (patch-ak) = 494790dc29cfb41932e4a1520f853c838f14bf37
+SHA1 (patch-al) = 3d9192a0407f17b48b0d5a42743779318b93a8eb
+SHA1 (patch-am) = c0e49033e788d9377adabd8250989034c7ab80a1
+SHA1 (patch-an) = 4f4b7de4ccd0493e53ea357b877a876e04cb7d64
+SHA1 (patch-ao) = 9774108a174a67883d62ce1a0c42bdc1c980b6cf
+SHA1 (patch-ap) = 199e3976408c2470c65c3f0bb887a6f35209252e
+SHA1 (patch-aq) = 0517ec8602e160fc32f92da78c06ed40782f29f4
+SHA1 (patch-ar) = 066f70e4f9a9603c0ba24f284012e6032ff3982c
+SHA1 (patch-as) = 1125c23facea4fff2db3d1aa0770f7ef8affe301
+SHA1 (patch-at) = 2c4c86c4716e96f356d944a445cfec12032896ad
+SHA1 (patch-au) = 5406878e0cbf32fbd3d1e9e3d0fcafc77a24ff14
+SHA1 (patch-av) = ddd9492d620536c48e649ebcc3f7a70d6b94a5ad
+SHA1 (patch-aw) = c5b9de2342354f818c2af0e80ddb1f8deda03062
+SHA1 (patch-ax) = 5e00564cff2888608b337855fd338326aacd045b
+SHA1 (patch-ay) = 8fef73883a2fd06caf8b563ddfadef049488e781
+SHA1 (patch-az) = ce6a993e0c9e9ff4ff1e9208f891658bc035986f
+SHA1 (patch-ba) = b02085de0143e9204223c6e1fb87cbfe82031343
+SHA1 (patch-bb) = c0e9bb61c6fa5060ae54d18168a28846b517dd47
diff --git a/svgalib64/patches/patch-aa b/svgalib64/patches/patch-aa
new file mode 100644
index 0000000000..5faf4024e2
--- /dev/null
+++ b/svgalib64/patches/patch-aa
@@ -0,0 +1,108 @@
+$NetBSD: patch-aa,v 1.2 2003/07/31 15:12:39 bencollver Exp $
+
+--- Makefile.cfg.orig	Tue May 29 07:39:13 2001
++++ Makefile.cfg
+@@ -9,8 +9,8 @@
+ # to n means yes!
+ 
+ MAJOR_VER = 1
+-MINOR_VER = 4.3
+-VERSION = $(MAJOR_VER).$(MINOR_VER)
++MINOR_VER =
++VERSION = $(MAJOR_VER)
+ 
+ #----------------------------------------------------------------------
+ # Configuration Section
+@@ -24,8 +24,8 @@ confdir = $(srcdir)/src/config
+ 
+ # Common prefix for installation directories.
+ # NOTE: This directory must exist when you start the install.
+-TOPDIR=
+-prefix = $(TOPDIR)/usr/local
++TOPDIR= $(PREFIX)
++prefix = $(PREFIX)
+ exec_prefix = $(prefix)
+ 
+ # Directory where the shared stubs and static library will be installed.
+@@ -82,7 +82,7 @@ ROOT_VC_SHORTCUT = y
+ # BACKGROUND = y
+ 
+ # Uncomment this if you want to compile and install the static libs.
+-# INSTALLSTATICLIB = installstaticlib
++INSTALLSTATICLIB = installstaticlib
+ 
+ # Comment this out if you don't want to install the shared libs.
+ # If you do not install the shared nor the static libs, 'make static'
+@@ -94,7 +94,7 @@ INSTALLSHAREDLIB = installsharedlib
+ # a.out image is available install it in the first directory named something
+ # like *aout/ in /etc/ld.so.conf.
+ # If you want this, do not comment out the next line:
+-INSTALLAOUTLIB = installaoutcompat
++#INSTALLAOUTLIB = installaoutcompat
+ 
+ # Comment this out if you want to keep old shared images. Old header files,
+ # library stubs and static libraries CANNOT be kept in public locations
+@@ -126,15 +126,15 @@ INSTALLMAN = installman
+ INCLUDE_ET4000_DRIVER = y
+ INCLUDE_CIRRUS_DRIVER = y
+ INCLUDE_TVGA_DRIVER = y
+-#INCLUDE_OAK_DRIVER = y
+-#INCLUDE_EGA_DRIVER = y
++INCLUDE_OAK_DRIVER = y
++INCLUDE_EGA_DRIVER = y
+ INCLUDE_MACH32_DRIVER = y
+ INCLUDE_S3_DRIVER = y
+-#INCLUDE_ET3000_DRIVER = y
+-#INCLUDE_GVGA6400_DRIVER = y
+-#INCLUDE_ARK_DRIVER = y
+-#INCLUDE_ATI_DRIVER = y
+-#INCLUDE_ALI_DRIVER = y
++INCLUDE_ET3000_DRIVER = y
++INCLUDE_GVGA6400_DRIVER = y
++INCLUDE_ARK_DRIVER = y
++INCLUDE_ATI_DRIVER = y
++INCLUDE_ALI_DRIVER = y
+ INCLUDE_CHIPS_DRIVER = y
+ INCLUDE_APM_DRIVER = y
+ INCLUDE_NV3_DRIVER = y
+@@ -150,7 +150,7 @@ INCLUDE_LAGUNA_DRIVER = y
+ INCLUDE_NEO_DRIVER = y
+ INCLUDE_R128_DRIVER = y
+ INCLUDE_G400_DRIVER = y
+-INCLUDE_FBDEV_DRIVER = y
++#INCLUDE_FBDEV_DRIVER = y
+ INCLUDE_SAVAGE_DRIVER = y
+ #
+ # Comment out any adapter you don't want to autodetect.
+@@ -158,15 +158,15 @@ INCLUDE_SAVAGE_DRIVER = y
+ INCLUDE_ET4000_DRIVER_TEST = y
+ INCLUDE_CIRRUS_DRIVER_TEST = y
+ INCLUDE_TVGA_DRIVER_TEST = y
+-#INCLUDE_OAK_DRIVER_TEST = y
+-#INCLUDE_EGA_DRIVER_TEST = y
++INCLUDE_OAK_DRIVER_TEST = y
++INCLUDE_EGA_DRIVER_TEST = y
+ INCLUDE_MACH32_DRIVER_TEST = y
+-#INCLUDE_GVGA6400_DRIVER_TEST = y
++INCLUDE_GVGA6400_DRIVER_TEST = y
+ INCLUDE_S3_DRIVER_TEST = y
+-#INCLUDE_ET3000_DRIVER_TEST = y
+-#INCLUDE_ARK_DRIVER_TEST = y
+-#INCLUDE_ATI_DRIVER_TEST = y
+-#INCLUDE_ALI_DRIVER_TEST = y
++INCLUDE_ET3000_DRIVER_TEST = y
++INCLUDE_ARK_DRIVER_TEST = y
++INCLUDE_ATI_DRIVER_TEST = y
++INCLUDE_ALI_DRIVER_TEST = y
+ INCLUDE_CHIPS_DRIVER_TEST = y
+ INCLUDE_APM_DRIVER_TEST = y
+ INCLUDE_NV3_DRIVER_TEST = y
+@@ -185,7 +185,7 @@ INCLUDE_R128_DRIVER_TEST = y
+ INCLUDE_SAVAGE_DRIVER_TEST = y
+ 
+ #Might be too dangerous:
+-INCLUDE_VESA_DRIVER_TEST = y
++#INCLUDE_VESA_DRIVER_TEST = y
+ 
+ #
+ # Comment out any dac support that you don't want included in the library.
diff --git a/svgalib64/patches/patch-ab b/svgalib64/patches/patch-ab
new file mode 100644
index 0000000000..d6f799651d
--- /dev/null
+++ b/svgalib64/patches/patch-ab
@@ -0,0 +1,43 @@
+$NetBSD: patch-ab,v 1.2 2003/07/31 15:12:39 bencollver Exp $
+
+--- src/Makefile.orig	Tue May 29 07:36:53 2001
++++ src/Makefile
+@@ -14,7 +14,7 @@ VPATH     = $(srcdir)/src
+ # Compiler Section (overrides Makefile.cfg)
+ #----------------------------------------------------------------------
+ 
+-INCLUDES += -I$(srcdir)/src
++INCLUDES += -I$(srcdir)/src -I$(srcdir)/src/config
+ 
+ #----------------------------------------------------------------------
+ # Rules Section
+@@ -387,8 +387,9 @@ all:	libvga.so.$(VERSION)
+ 
+ # These rules are for ELF only.
+ libvga.so.$(VERSION): $(ALLOBJS)
+-	$(CC) -s -shared -Wl,-soname,libvga.so.$(MAJOR_VER) \
+-	  -o libvga.so.$(VERSION) $(ALLOBJS) -lm
++	$(CC) -shared -Wl,-soname,libvga.so.$(MAJOR_VER) \
++	  -o libvga.so.$(VERSION) $(ALLOBJS) -lm -li386
++	/bin/ln -sf libvga.so.$(VERSION) libvga.so
+ 
+ $(sharedlibdir)/libvga.so.$(VERSION): libvga.so.$(VERSION)
+ 	$(INSTALL_PROGRAM) $< $(sharedlibdir)/$<
+@@ -403,7 +404,7 @@ libvga.a: $(ALLOBJS)
+ 	$(AR) rcs libvga.a $(ALLOBJS)
+ 
+ libvgagl.a: FORCE
+-	make -f $(srcdir)/gl/Makefile $@ srcdir="$(srcdir)" DLLFLAGS="$(DLLFLAGS)"
++	$(MAKE) -f $(srcdir)/gl/Makefile $@ srcdir="$(srcdir)" DLLFLAGS="$(DLLFLAGS)"
+ 
+ vga.o: vga.c
+ 	$(CC) $(CFLAGS) $(VGA_DEFINES) -c -o $@ $<
+@@ -425,7 +426,7 @@ $(MODULES): .depend.src
+ 
+ dep:
+ 	rm -f .depend.src
+-	make .depend.src
++	$(MAKE) .depend.src
+ 
+ .depend.src:
+ 	echo '# Module dependencies' >>.depend.src
diff --git a/svgalib64/patches/patch-ac b/svgalib64/patches/patch-ac
new file mode 100644
index 0000000000..e38d4e4126
--- /dev/null
+++ b/svgalib64/patches/patch-ac
@@ -0,0 +1,12 @@
+$NetBSD: patch-ac,v 1.1.1.1 2003/07/27 06:03:36 bencollver Exp $
+
+--- gl/inlstring.h.orig	Fri Aug 25 05:11:26 2000
++++ gl/inlstring.h
+@@ -1,6 +1,6 @@
+ /* Based on functions in linux/string.h */
+ 
+-#include <linux/types.h>	/* for size_t */
++#include <sys/types.h>	/* for size_t */
+ 
+ #if defined(__alpha__) || defined (NO_ASSEMBLY)
+ 
diff --git a/svgalib64/patches/patch-ad b/svgalib64/patches/patch-ad
new file mode 100644
index 0000000000..6ada541059
--- /dev/null
+++ b/svgalib64/patches/patch-ad
@@ -0,0 +1,20 @@
+$NetBSD: patch-ad,v 1.1.1.1 2003/07/27 06:03:36 bencollver Exp $
+
+--- utils/gtf/scitech.h.orig	Sat Jul 26 10:31:25 2003
++++ utils/gtf/scitech.h
+@@ -236,6 +236,15 @@
+ #define __UNIX__
+ #endif
+ 
++/* 32-bit NetBSD compile environment */
++#elif	defined(__NetBSD__)
++#ifndef __32BIT__
++#define __32BIT__
++#endif
++#ifndef __UNIX__
++#define __UNIX__
++#endif
++
+ /* 32-bit BeOS compile environment */
+ #elif	defined(__BEOS__)
+ #ifndef	__32BIT__
diff --git a/svgalib64/patches/patch-ae b/svgalib64/patches/patch-ae
new file mode 100644
index 0000000000..d4db326957
--- /dev/null
+++ b/svgalib64/patches/patch-ae
@@ -0,0 +1,22 @@
+$NetBSD: patch-ae,v 1.2 2003/07/31 15:12:39 bencollver Exp $
+
+--- Makefile.orig	Wed Apr 18 10:35:51 2001
++++ Makefile
+@@ -187,7 +187,7 @@ installstaticlib: static
+ 	@$(INSTALL_DATA) staticlib/libvgagl.a $(libdir)/libvgagl.a
+ 	@chmod a+r $(libdir)/libvgagl.a
+ 
+-installutils: textutils lrmi
++installutils: textutils
+ 	@if [ ! -d $(bindir) ]; then \
+ 		echo No $(bindir) directory, creating it.; \
+ 		mkdir $(bindir); \
+@@ -213,8 +213,6 @@ installutils: textutils lrmi
+ 	@cp utils/textmode $(bindir)
+ 	@echo "savetextmode:     Script that saves textmode information used by 'textmode'."
+ 	@cp utils/savetextmode $(bindir)
+-	@echo "mode3:       Restore textmode by setting VESA mode 3."
+-	@cp lrmi-0.6m/mode3 $(bindir)
+ 	@echo "Installing keymap utilities in $(bindir):"
+ 	@echo "svgakeymap:       Perl script that generates scancode conversion maps."
+ 	@cp utils/svgakeymap $(bindir)
diff --git a/svgalib64/patches/patch-af b/svgalib64/patches/patch-af
new file mode 100644
index 0000000000..184fb02a3f
--- /dev/null
+++ b/svgalib64/patches/patch-af
@@ -0,0 +1,13 @@
+$NetBSD: patch-af,v 1.1.1.1 2003/07/27 06:03:36 bencollver Exp $
+
+--- src/et6000.c.orig	Fri Aug 25 04:39:39 2000
++++ src/et6000.c
+@@ -10,7 +10,7 @@
+ #include "vga.h"
+ #include "libvga.h"
+ #include "driver.h"
+-#include <linux/pci.h>
++/*#include <linux/pci.h>*/
+ #include "timing.h"
+ #include "interface.h"
+ #include "vgaregs.h"
diff --git a/svgalib64/patches/patch-ag b/svgalib64/patches/patch-ag
new file mode 100644
index 0000000000..3795507442
--- /dev/null
+++ b/svgalib64/patches/patch-ag
@@ -0,0 +1,13 @@
+$NetBSD: patch-ag,v 1.1.1.1 2003/07/27 06:03:36 bencollver Exp $
+
+--- src/joystick/joydev.h.orig	Fri Aug 25 04:39:39 2000
++++ src/joystick/joydev.h
+@@ -1,6 +1,6 @@
+-#include <linux/version.h>
++/*#include <linux/version.h>*/
+ 
+-#if ( LINUX_VESION_CODE >= 131584) 
++#if 0 /*( LINUX_VESION_CODE >= 131584) */
+ #include <linux/joystick.h>
+ #else
+ /* Joystick interface modeled after svgalibs keyboard and mouse interfaces 
diff --git a/svgalib64/patches/patch-ah b/svgalib64/patches/patch-ah
new file mode 100644
index 0000000000..e58bf0450e
--- /dev/null
+++ b/svgalib64/patches/patch-ah
@@ -0,0 +1,84 @@
+$NetBSD: patch-ah,v 1.2 2003/07/31 15:12:40 bencollver Exp $
+
+--- src/keyboard/keyboard.c.orig	Sun Oct  8 05:37:40 2000
++++ src/keyboard/keyboard.c
+@@ -28,12 +28,12 @@
+ #include <sys/ioctl.h>
+ #include <fcntl.h>
+ #include <termios.h>
+-#include <linux/kd.h>
+ /* linux/keyboard.h defines NR_KEYS and some scancode-like constants, so it */
+ /* should also be useful for svgalib programs using the keyboard. It misses */
+ /* a few KERNEL ifdefs around kernel data structures though. */
++#include <dev/wscons/wsconsio.h>
++#include <dev/wscons/wsdisplay_usl_io.h>
+ #include <linux/keyboard.h>
+-#include <sys/vt.h>
+ /* Needed to check uid of keymap files */
+ #include <sys/stat.h>
+ #include <unistd.h>
+@@ -46,7 +46,7 @@
+ void (*__svgalib_keyboard_eventhandler) (int, int);
+ 
+ static struct termios oldkbdtermios, newkbdtermios;
+-static int oldkbmode;
++static int oldkbmode, newkbmode;
+ /* vga.c needs to check that: */
+ int __svgalib_kbd_fd = -1; /* nowadays merely used as a flag */
+ static int c_state, ctrl_state, alt_state, functionkey_state, win_state;
+@@ -69,10 +69,11 @@ static char keynames[NR_KEYS][MAX_KEYNAM
+     "KP_4", "KP_5", "KP_6", "KP_Add",
+     "KP_1", "KP_2", "KP_3",
+     "KP_0", "KP_Period",
+-    "Last_Console", "", "less", "F11", "F12", "", "", "", "", "", "", "",
+-    "KP_Enter", "Control", "KP_Divide", "Control_backslash", "AltGr", "Break",
++    "Last_Console", "", "less", "F11", "F12",
++    "KP_Enter", "Control", "KP_Divide", "Control_backslash", "AltGr",
+     "Find", "Up", "Prior", "Left", "Right", "Select", "Down", "Next", "Insert",
+-    "Remove", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
++    "Remove", "Break", "", "", "", "", "", "",
++    "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""
+ };
+ static void default_handler(int, int);
+ static char *kbd_load_keymap(char *ptr);
+@@ -326,21 +327,27 @@ int keyboard_init_return_fd(void) {
+     __svgalib_open_devconsole();
+     __svgalib_kbd_fd = __svgalib_tty_fd; /* We are initialized. */
+ 
+-    if (ioctl(__svgalib_kbd_fd, KDGKBMODE, &oldkbmode)) {
++    if (ioctl(__svgalib_kbd_fd, WSKBDIO_GETMODE, &oldkbmode)) {
+ 	printf("svgalib: cannot get keyboard mode.\n");
+ 	return -1;
+     }
+     tcgetattr(__svgalib_kbd_fd, &oldkbdtermios);
+     newkbdtermios = oldkbdtermios;
+ 
++    cfmakeraw(&newkbdtermios);
+     newkbdtermios.c_lflag &= ~(ICANON | ECHO | ISIG);
+-    newkbdtermios.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
++    newkbdtermios.c_oflag = OPOST | ONLCR;
++    newkbdtermios.c_iflag = IGNPAR | IGNBRK;
++    newkbdtermios.c_cflag = CREAD | CS8;
+     newkbdtermios.c_cc[VMIN] = 0;	/* Making these 0 seems to have the */
+     newkbdtermios.c_cc[VTIME] = 0;	/* desired effect. */
++    cfsetispeed(&newkbdtermios, 9600);
++    cfsetospeed(&newkbdtermios, 9600);
+ 
+-    tcsetattr(__svgalib_kbd_fd, TCSAFLUSH, &newkbdtermios);
++    tcsetattr(__svgalib_kbd_fd, TCSANOW, &newkbdtermios);
+ 
+-    ioctl(__svgalib_kbd_fd, KDSKBMODE, K_MEDIUMRAW);
++    newkbmode = WSKBD_RAW;
++    ioctl(__svgalib_kbd_fd, WSKBDIO_SETMODE, &newkbmode);
+ 
+     keyboard_clearstate();
+ 
+@@ -379,7 +386,7 @@ void keyboard_close(void) {
+       fake_mouse_events = NULL;
+     }
+ 
+-    ioctl(__svgalib_kbd_fd, KDSKBMODE, oldkbmode);
++    ioctl(__svgalib_kbd_fd, WSKBDIO_SETMODE, &oldkbmode);
+     tcsetattr(__svgalib_kbd_fd, 0, &oldkbdtermios);
+ 
+     __svgalib_kbd_fd = -1;
diff --git a/svgalib64/patches/patch-ai b/svgalib64/patches/patch-ai
new file mode 100644
index 0000000000..e9d236660b
--- /dev/null
+++ b/svgalib64/patches/patch-ai
@@ -0,0 +1,28 @@
+$NetBSD: patch-ai,v 1.1.1.1 2003/07/27 06:03:36 bencollver Exp $
+
+--- src/libvga.h.orig	Thu Jul  6 09:08:11 2000
++++ src/libvga.h
+@@ -12,6 +12,14 @@
+ #include <sys/io.h>
+ #endif
+ 
++#ifdef __NetBSD__
++#include <sys/types.h>
++#include <machine/sysarch.h>
++#include <machine/pio.h>
++#define iopl(x) i386_iopl(x)
++extern int ioperm(unsigned long, unsigned long, int);
++#endif
++
+ /* --------------------- Macro definitions shared by library modules */
+ 
+ /* VGA index register ports */
+@@ -358,7 +366,7 @@ extern unsigned char *__svgalib_give_gra
+ 
+ #else
+ 
+-#define SVGALIB_ACQUIRE_SIG SIGUNUSED
++#define SVGALIB_ACQUIRE_SIG SIGUSR2
+ #define SVGALIB_RELEASE_SIG SIGPROF
+ 
+ #endif
diff --git a/svgalib64/patches/patch-aj b/svgalib64/patches/patch-aj
new file mode 100644
index 0000000000..a4549ecc93
--- /dev/null
+++ b/svgalib64/patches/patch-aj
@@ -0,0 +1,205 @@
+$NetBSD: patch-aj,v 1.1.1.1 2003/07/27 06:03:36 bencollver Exp $
+
+--- src/mach32.c.orig	Fri Aug 25 04:39:39 2000
++++ src/mach32.c
+@@ -2415,7 +2415,7 @@
+     return ptr;
+ }
+ 
+-static int isnumber(char *str)
++static int is_number(char *str)
+ {
+     if (str == NULL)
+ 	return 0;
+@@ -2607,11 +2607,11 @@
+ 	    goto ex_inv_mod;
+ 	}
+ 	if (*ptr == ':') {	/*No. of clock given */
+-	    if (!isnumber(ptr + 1))
++	    if (!is_number(ptr + 1))
+ 		goto inv_clk;
+ 	    i = atoi(ptr + 1);
+ 	} else {		/* search clock in table */
+-	    if (!isnumber(ptr))
++	    if (!is_number(ptr))
+ 		goto inv_clk;
+ 	    flag = atoi(ptr);
+ 	    for (i = 0; i < 32; i++)
+@@ -2627,45 +2627,45 @@
+ 	mptr->disp_cntl = 0x23;	/* Assume non interlaced */
+ 	/* The rest is straight forward: */
+ 	ptr = strtok(NULL, " ");
+-	if (!isnumber(ptr)) {
++	if (!is_number(ptr)) {
+ 	  inv_time:
+ 	    puts("mach32-config: Invalid define command, timing is invalid");
+ 	    goto ex_inv_mod;
+ 	}
+ 	mptr->h_disp = (atoi(ptr) >> 3) - 1;
+ 	ptr = strtok(NULL, " ");
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto inv_time;
+ 	i = atoi(ptr);
+ 	mptr->h_sync_strt = (i >> 3) - 1;
+ 	ptr = strtok(NULL, " ");
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto inv_time;
+ 	mptr->h_sync_wid = ((atoi(ptr) - i) >> 3);
+ 	if (mptr->h_sync_wid > 0x1f)
+ 	    mptr->h_sync_wid = 0x1f;
+ 	ptr = strtok(NULL, " ");
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto inv_time;
+ 	mptr->h_total = (atoi(ptr) >> 3) - 1;
+ 
+ 	ptr = strtok(NULL, " ");
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto inv_time;
+ 	mptr->v_disp = mach32_skip2(atoi(ptr) - 1);
+ 	ptr = strtok(NULL, " ");
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto inv_time;
+ 	i = atoi(ptr);
+ 	mptr->v_sync_strt = mach32_skip2(i - 1);
+ 	ptr = strtok(NULL, " ");
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto inv_time;
+ 	mptr->v_sync_wid = atoi(ptr) - i;
+ 	if (mptr->v_sync_wid > 0x1f)
+ 	    mptr->v_sync_wid = 0x1f;
+ 	ptr = strtok(NULL, " ");
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto inv_time;
+ 	mptr->v_total = mach32_skip2(atoi(ptr) - 1);
+ 	for (;;) {		/* Parse for additional goodies */
+@@ -2701,7 +2701,7 @@
+ 	return ptr;
+     case 3:
+ 	ptr = strtok(NULL, " ");
+-	if (!isnumber(ptr)) {
++	if (!is_number(ptr)) {
+ 	    puts("mach32-config: illegal setlinelength command.\n"
+ 		 "Usage: setlinelength integer modes...");
+ 	    return ptr;
+@@ -2719,7 +2719,7 @@
+ 	    puts("Don't use the maxclock's commands out of the environment variable.");
+ 	    return ptr;
+ 	}
+-	if (!isnumber(ptr)) {
++	if (!is_number(ptr)) {
+ 	  ilmaxclk:
+ 	    puts("mach32-config: illegal maxclock16 or maxclock24 command.\n"
+ 		 "Usage: maxclock16 integer or maxclock24 integer");
+@@ -2731,7 +2731,7 @@
+ 	ptr = strtok(NULL, " ");
+ 	if (!mode)
+ 	    goto maxclk_deny;
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto ilmaxclk;
+ 	mach32_maxclk24 = atoi(ptr);
+ 	break;
+@@ -2741,7 +2741,7 @@
+ 	for (i = 0; i < 16; i++) {
+ 	    ptr = strtok(NULL, " ");
+ 	    clocks_set = 1;
+-	    if (!isnumber(ptr)) {
++	    if (!is_number(ptr)) {
+ 		puts("mach32-config: illegal clocks command.\n"
+ 		     "Usage: clocks integer integer ...\n"
+ 		     "16 clocks have to be specified.\n"
+@@ -2776,7 +2776,7 @@
+ 	ptr = strtok(NULL, " ");
+ 	if (!mode)
+ 	    goto maxclk_deny;
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto ilmaxclk;
+ 	mach32_maxclk8 = atoi(ptr);
+ 	break;
+@@ -2784,7 +2784,7 @@
+ 	ptr = strtok(NULL, " ");
+ 	if (!mode)
+ 	    goto maxclk_deny;
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto ilmaxclk;
+ 	mach32_maxclk32 = atoi(ptr);
+ 	break;
+@@ -2803,7 +2803,7 @@
+ 	    puts("The vfifo, latch, blank commands are not allowed out of the environment.");
+ 	    return ptr;
+ 	}
+-	if (!isnumber(ptr)) {
++	if (!is_number(ptr)) {
+ 	  ilvfi:
+ 	    puts("Illegal vfifo command");
+ 	    return ptr;
+@@ -2814,7 +2814,7 @@
+ 	ptr = strtok(NULL, " ");
+ 	if (!mode)
+ 	    goto tweak_deny;
+-	if (!isnumber(ptr)) {
++	if (!is_number(ptr)) {
+ 	    puts("Illegal latch command");
+ 	    return ptr;
+ 	}
+@@ -2824,7 +2824,7 @@
+ 	ptr = strtok(NULL, " ");
+ 	if (!mode)
+ 	    goto tweak_deny;
+-	if (!isnumber(ptr)) {
++	if (!is_number(ptr)) {
+ 	    puts("Illegal blank command");
+ 	    return ptr;
+ 	}
+@@ -2834,7 +2834,7 @@
+ 	ptr = strtok(NULL, " ");
+ 	if (!mode)
+ 	    goto tweak_deny;
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto ilvfi;
+ 	vfifo16 = atoi(ptr) & 0xf;
+ 	break;
+@@ -2842,7 +2842,7 @@
+ 	ptr = strtok(NULL, " ");
+ 	if (!mode)
+ 	    goto tweak_deny;
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto ilvfi;
+ 	vfifo24 = atoi(ptr) & 0xf;
+ 	break;
+@@ -2850,13 +2850,13 @@
+ 	ptr = strtok(NULL, " ");
+ 	if (!mode)
+ 	    goto tweak_deny;
+-	if (!isnumber(ptr))
++	if (!is_number(ptr))
+ 	    goto ilvfi;
+ 	vfifo32 = atoi(ptr) & 0xf;
+ 	break;
+     case 20:
+ 	ptr = strtok(NULL, " ");
+-	if (!isnumber(ptr)) {
++	if (!is_number(ptr)) {
+ 	  ilsetupli:
+ 	    puts("Illegal setuplinear command.\n"
+ 		 "usage: setuplinear address size\n"
+@@ -2998,7 +2998,7 @@
+ 	else if (!strcasecmp(ptr, "keep"))
+ 	    svga_clock = (-1);
+ 	else {
+-	    if (!isnumber(ptr))
++	    if (!is_number(ptr))
+ 		goto invpar;
+ 	    i = atoi(ptr);
+ 	    if ((i < 0) || (i > 0x1f))
diff --git a/svgalib64/patches/patch-ak b/svgalib64/patches/patch-ak
new file mode 100644
index 0000000000..fbc62aa1bd
--- /dev/null
+++ b/svgalib64/patches/patch-ak
@@ -0,0 +1,22 @@
+$NetBSD: patch-ak,v 1.2 2003/07/31 15:12:40 bencollver Exp $
+
+--- src/mouse/ms.c.orig	Sun Aug 20 22:10:15 2000
++++ src/mouse/ms.c
+@@ -117,7 +117,7 @@ static void ms_setspeed(const int old, c
+     tty.c_iflag = IGNBRK | IGNPAR;
+     tty.c_oflag = 0;
+     tty.c_lflag = 0;
+-    tty.c_line  = 0;
++/*    tty.c_line  = 0;*/
+     tty.c_cc[VTIME] = 0;
+     tty.c_cc[VMIN]  = 1;
+ 
+@@ -511,7 +511,7 @@ static int ms_init(void)
+ 	tty.c_iflag = IGNBRK | IGNPAR;
+ 	tty.c_oflag = 0;
+ 	tty.c_lflag = 0;
+-	tty.c_line = 0;
++/*	tty.c_line = 0;*/
+ 	tty.c_cc[VTIME] = 0;
+ 	tty.c_cc[VMIN] = 1;
+ 	tty.c_cflag = cflag[m_type] | B1200;
diff --git a/svgalib64/patches/patch-al b/svgalib64/patches/patch-al
new file mode 100644
index 0000000000..d9cd0b7e00
--- /dev/null
+++ b/svgalib64/patches/patch-al
@@ -0,0 +1,21 @@
+$NetBSD: patch-al,v 1.2 2003/07/31 15:12:40 bencollver Exp $
+
+--- src/nv3.c.orig	Sat Mar 31 10:36:51 2001
++++ src/nv3.c
+@@ -17,6 +17,7 @@ there are still the following problems:
+ #include <stdlib.h>
+ #include <stdio.h>		/* for printf */
+ #include <string.h>		/* for memset */
++#include <sys/types.h>
+ #include <sys/mman.h>		
+ #include <fcntl.h>
+ #include <math.h>
+@@ -578,7 +579,7 @@ DriverSpecs __svgalib_nv3_driverspecs =
+ 
+ #define MapDevice(device,base) \
+   nv##device##Port=(unsigned*)(mmap(0, \
+-     	DEVICE_SIZE(device),PROT_WRITE,MAP_SHARED,__svgalib_mem_fd,\
++     	DEVICE_SIZE(device),PROT_WRITE|PROT_READ,MAP_SHARED,__svgalib_mem_fd,\
+         (MMIOBASE)+DEVICE_BASE(device)))
+ 
+ /* Initialize chipset (called after detection) */
diff --git a/svgalib64/patches/patch-am b/svgalib64/patches/patch-am
new file mode 100644
index 0000000000..ce33365f41
--- /dev/null
+++ b/svgalib64/patches/patch-am
@@ -0,0 +1,176 @@
+$NetBSD: patch-am,v 1.2 2003/07/31 15:12:40 bencollver Exp $
+
+--- src/vga.c.orig	Tue May 29 07:37:55 2001
++++ src/vga.c
+@@ -22,10 +22,10 @@
+ #include <unistd.h>
+ #include <stdarg.h>
+ #include <sys/mman.h>
+-#include <sys/kd.h>
+ #include <sys/ioctl.h>
+ #include <sys/stat.h>
+-#include <sys/vt.h>
++#include <dev/wscons/wsconsio.h>
++#include <dev/wscons/wsdisplay_usl_io.h>
+ #include <sys/wait.h>
+ #include <errno.h>
+ #include <ctype.h>
+@@ -38,6 +38,38 @@
+ #include "vgaregs.h"
+ #include "vgaversion.h"
+ 
++#ifdef __NetBSD__
++#define IOMAP_ELEMENTS 32
++#define IOMAP_ELEMENT_BITS 32
++int ioperm(unsigned long from, unsigned long num, int turn_on)
++{
++	int i;
++	int j = from + num;
++	int base;
++	int offset;
++	int retval;
++	unsigned long iomap[IOMAP_ELEMENTS];
++
++	if (j > 1024)
++		return EINVAL;
++
++	retval = i386_get_ioperm(iomap);
++	if (retval != 0)
++		return retval;
++
++	for (i = from; i < j; i++) {
++		base = i / IOMAP_ELEMENT_BITS;
++		offset = i - (base * IOMAP_ELEMENT_BITS);
++		if (turn_on)
++			iomap[base] &= ~(1 << offset);
++		else
++			iomap[base] |= 1 << offset;
++	}
++	retval = i386_set_ioperm(iomap);
++	return retval;
++}
++#endif
++
+ #ifdef BACKGROUND
+ #include "vgabg.h"
+ 
+@@ -772,7 +804,7 @@ static void set_graphtermio(void)
+     /* Leave keyboard alone when rawkeyboard is enabled! */
+     if (__svgalib_kbd_fd < 0) {
+ 	/* set graphics mode termio parameters */
+-	ioctl(0, TCSETSW, &graph_termio);
++	ioctl(0, TIOCSETAW, &graph_termio);
+     }
+ }
+ 
+@@ -782,7 +814,7 @@ static void set_texttermio(void)
+     /* Leave keyboard alone when rawkeyboard is enabled! */
+     if (__svgalib_kbd_fd < 0) {
+ 	/* restore text mode termio parameters */
+-	ioctl(0, TCSETSW, &text_termio);
++	ioctl(0, TIOCSETAW, &text_termio);
+     }
+ }
+ 
+@@ -793,9 +825,9 @@ static void disable_interrupt(void)
+ 
+     /* Well, one could argue that sigint is not enabled at all when in __svgalib_nosigint
+        but sometimes they *still* are enabled b4 graph_termio is set.. */
+-    ioctl(0, TCGETS, &cur_termio);
++    ioctl(0, TIOCGETA, &cur_termio);
+     cur_termio.c_lflag &= ~ISIG;
+-    ioctl(0, TCSETSW, &cur_termio);
++    ioctl(0, TIOCSETAW, &cur_termio);
+ }
+ 
+ 
+@@ -805,9 +837,9 @@ static void enable_interrupt(void)
+ 
+     if (__svgalib_nosigint) /* do not reenable, they are often reenabled by text_termio */
+ 	return; 
+-    ioctl(0, TCGETS, &cur_termio);
++    ioctl(0, TIOCGETA, &cur_termio);
+     cur_termio.c_lflag |= ISIG;
+-    ioctl(0, TCSETSW, &cur_termio);
++    ioctl(0, TIOCSETAW, &cur_termio);
+ }
+ 
+ /* The following is rather messy and inelegant. The only solution I can */
+@@ -882,7 +914,7 @@ static int check_owner(int vc)
+     if (!getuid())
+         return 1;               /* root can do it always */
+ #endif
+-    sprintf(fname, "/dev/tty%d", vc);
++    sprintf(fname, "/dev/ttyE%x", vc);
+     if ((stat(fname, &sbuf) >= 0) && (getuid() == sbuf.st_uid)) {
+         return 1;
+     }
+@@ -918,11 +950,9 @@ void __svgalib_open_devconsole(void)
+             continue;
+         if (ioctl(__svgalib_tty_fd, VT_GETMODE, &vtm) < 0)
+             continue;
+-        if ((sbuf.st_rdev & 0xff00) != 0x400)
+-            continue;
+-        if (!(sbuf.st_rdev & 0xff))
++        if (major(sbuf.st_rdev & 0xff00) != 47)
+             continue;
+-        svgalib_vc = sbuf.st_rdev & 0xff;
++        svgalib_vc = minor(sbuf.st_rdev) + 1;
+         return;                 /* perfect */
+     }
+ 
+@@ -934,7 +964,7 @@ void __svgalib_open_devconsole(void)
+         goto error;
+     if (svgalib_vc <= 0)
+         goto error;
+-    sprintf(fname, "/dev/tty%d", svgalib_vc);
++    sprintf(fname, "/dev/ttyE%x", svgalib_vc - 1);
+     close(__svgalib_tty_fd);
+     /* change our control terminal: */
+     setpgid(0,getppid());
+@@ -1271,7 +1301,7 @@ static char sig2catch[] =
+  SIGTRAP, SIGIOT, SIGBUS, SIGFPE,
+  SIGSEGV, SIGPIPE, SIGALRM, SIGTERM,
+  SIGXCPU, SIGXFSZ, SIGVTALRM,
+-/* SIGPROF ,*/ SIGPWR};
++/* SIGPROF ,*/ SIGUSR1};
+ static struct sigaction old_signal_handler[sizeof(sig2catch)];
+ 
+ struct vt_mode __svgalib_oldvtmode;
+@@ -1879,15 +1909,15 @@ static void initialize(void)
+ #endif
+ 
+     /* save text mode termio parameters */
+-    ioctl(0, TCGETS, &text_termio);
++    ioctl(0, TIOCGETA, &text_termio);
+ 
+     graph_termio = text_termio;
+ 
+     /* change termio parameters to allow our own I/O processing */
+-    graph_termio.c_iflag &= ~(BRKINT | PARMRK | INPCK | IUCLC | IXON | IXOFF);
++    graph_termio.c_iflag &= ~(BRKINT | PARMRK | INPCK | IXON | IXOFF);
+     graph_termio.c_iflag |= (IGNBRK | IGNPAR);
+ 
+-    graph_termio.c_oflag &= ~(ONOCR);
++/*    graph_termio.c_oflag &= ~(ONOCR);*/
+ 
+     graph_termio.c_lflag &= ~(ICANON | ECHO | ECHOE | ECHOK | ECHONL | NOFLSH);
+     if (__svgalib_nosigint)
+@@ -2096,7 +2126,7 @@ void vga_safety_fork(void (*shutdown_rou
+      *  If this didn't suffice we claim we are on an old system and just don't
+      *  need to restore it.
+      */
+-    ioctl(__svgalib_tty_fd, KDGKBMODE, &oldkbmode);
++    ioctl(__svgalib_tty_fd, WSKBDIO_GETMODE, &oldkbmode);
+ 
+     childpid = fork();
+     if (childpid < 0) {
+@@ -2113,7 +2143,7 @@ void vga_safety_fork(void (*shutdown_rou
+ 		shutdown_routine();
+ 
+ 	    vga_setmode(TEXT);	/* resets termios as well */
+-	    ioctl(__svgalib_tty_fd, KDSKBMODE, oldkbmode);
++	    ioctl(__svgalib_tty_fd, WSKBDIO_SETMODE, &oldkbmode);
+ 
+ 	    if (WIFEXITED(child_status))
+ 		exit(WEXITSTATUS(child_status));
diff --git a/svgalib64/patches/patch-an b/svgalib64/patches/patch-an
new file mode 100644
index 0000000000..48279ecd68
--- /dev/null
+++ b/svgalib64/patches/patch-an
@@ -0,0 +1,35 @@
+$NetBSD: patch-an,v 1.1.1.1 2003/07/27 06:03:38 bencollver Exp $
+
+--- src/vgamisc.c.orig	Tue Jul 27 09:36:19 1999
++++ src/vgamisc.c
+@@ -73,8 +73,9 @@ unsigned char *
+     return __svgalib_graph_mem;
+ }
+ 
+-#include <syscall.h>
+-#include <linux/kernel.h>
++#include <sys/types.h>
++#include <sys/param.h>
++#include <sys/sysctl.h>
+ 
+ int __svgalib_physmem(void)
+ {
+@@ -82,10 +83,14 @@ int __svgalib_physmem(void)
+     printf("__svgalib_physmem: are you sure you wanna do this??\n");
+     return -1;
+ #else
+-    struct sysinfo si;
+-    si.totalram = 0;
+-    syscall(SYS_sysinfo, &si);
+-    return si.totalram;
++    int mem;
++    int smem;
++    int mib[2];
++    mib[0] = CTL_HW;
++    mib[1] = HW_PHYSMEM;
++    smem = sizeof(mem);
++    sysctl(mib, 2, &mem, &smem, NULL, 0);
++    return mem;
+ #endif
+ }
+ 
diff --git a/svgalib64/patches/patch-ao b/svgalib64/patches/patch-ao
new file mode 100644
index 0000000000..66972e2ca6
--- /dev/null
+++ b/svgalib64/patches/patch-ao
@@ -0,0 +1,12 @@
+$NetBSD: patch-ao,v 1.1.1.1 2003/07/27 06:03:36 bencollver Exp $
+
+--- src/ark.c.orig	Fri Aug 25 05:03:06 2000
++++ src/ark.c
+@@ -25,6 +25,7 @@
+ #include <stdlib.h>
+ #include <stdio.h>
+ #include <string.h>
++#include <sys/types.h>
+ #include <sys/mman.h>
+ #include <signal.h>
+ #include "vga.h"
diff --git a/svgalib64/patches/patch-ap b/svgalib64/patches/patch-ap
new file mode 100644
index 0000000000..3bb5732760
--- /dev/null
+++ b/svgalib64/patches/patch-ap
@@ -0,0 +1,13 @@
+$NetBSD: patch-ap,v 1.3 2004/08/27 06:30:33 jlamwww Exp $
+
+--- utils/Makefile.orig	Wed Jul 21 09:41:18 1999
++++ utils/Makefile	Sun Jul 27 04:03:47 2003
+@@ -15,7 +15,7 @@
+ 
+ CFLAGS = $(WARN) $(OPTIMIZE) -I../include
+ #Use the next one for the Alpha/AXP if you need it
+-#LDFLAGS = -L../staticlib 
++LDFLAGS = -L../sharedlib $(COMPILER_RPATH_FLAG)$(PREFIX)/lib
+ LIBS = -lvga -lm
+ 
+ #----------------------------------------------------------------------
diff --git a/svgalib64/patches/patch-aq b/svgalib64/patches/patch-aq
new file mode 100644
index 0000000000..8c640a371a
--- /dev/null
+++ b/svgalib64/patches/patch-aq
@@ -0,0 +1,12 @@
+$NetBSD: patch-aq,v 1.1.1.1 2003/07/27 06:03:36 bencollver Exp $
+
+--- gl/Makefile.orig	Sun Jul 18 16:14:45 1999
++++ gl/Makefile
+@@ -31,6 +31,7 @@
+ libvgagl.so.$(VERSION): $(MODULES)
+ 	$(CC) -s -shared -Wl,-soname,libvgagl.so.$(MAJOR_VER) -o libvgagl.so.$(VERSION) \
+ 	  $(MODULES)
++	/bin/ln -sf libvgagl.so.$(MAJOR_VER) libvgagl.so
+ 
+ libvgagl.a: $(MODULES)
+ 	rm -f libvgagl.a
diff --git a/svgalib64/patches/patch-ar b/svgalib64/patches/patch-ar
new file mode 100644
index 0000000000..8bae479563
--- /dev/null
+++ b/svgalib64/patches/patch-ar
@@ -0,0 +1,13 @@
+$NetBSD: patch-ar,v 1.1.1.1 2003/07/27 06:03:36 bencollver Exp $
+
+--- demos/Makefile.orig	Fri Aug 25 06:09:33 2000
++++ demos/Makefile
+@@ -29,7 +29,7 @@
+ 
+ # Determine what library (static or shared) we will be linking programs with
+ ifdef INSTALLSHAREDLIB
+-  LIBS = -lvgagl -lvga
++  LIBS = -L../sharedlib -lvgagl -lvga
+ endif
+ ifndef LIBS
+   LIBS    = ../staticlib/libvgagl.a ../staticlib/libvga.a -lm
diff --git a/svgalib64/patches/patch-as b/svgalib64/patches/patch-as
new file mode 100644
index 0000000000..00c2b0d3e3
--- /dev/null
+++ b/svgalib64/patches/patch-as
@@ -0,0 +1,12 @@
+$NetBSD: patch-as,v 1.1.1.1 2003/07/27 06:03:36 bencollver Exp $
+
+--- demos/accel.c.orig	Fri Aug 25 06:13:16 2000
++++ demos/accel.c
+@@ -12,7 +12,6 @@
+ #include <unistd.h>
+ #include <time.h>
+ #include <math.h>
+-#include <alloca.h>
+ #include <string.h>
+ #include "vga.h"
+ #include "vgagl.h"
diff --git a/svgalib64/patches/patch-at b/svgalib64/patches/patch-at
new file mode 100644
index 0000000000..d53c545b84
--- /dev/null
+++ b/svgalib64/patches/patch-at
@@ -0,0 +1,13 @@
+$NetBSD: patch-at,v 1.1.1.1 2003/07/27 06:03:36 bencollver Exp $
+
+--- demos/forktest.c.orig	Fri Aug 25 06:13:58 2000
++++ demos/forktest.c
+@@ -18,7 +18,7 @@
+  SIGTRAP, SIGIOT, SIGBUS, SIGFPE,
+  SIGSEGV, SIGPIPE, SIGALRM, SIGTERM,
+  SIGXCPU, SIGXFSZ, SIGVTALRM,
+- SIGPROF, SIGPWR};
++ SIGPROF, SIGUSR1};
+ 
+ 
+ static int newcolor(void)
diff --git a/svgalib64/patches/patch-au b/svgalib64/patches/patch-au
new file mode 100644
index 0000000000..a9c7a7f5d8
--- /dev/null
+++ b/svgalib64/patches/patch-au
@@ -0,0 +1,13 @@
+$NetBSD: patch-au,v 1.1.1.1 2003/07/27 06:03:36 bencollver Exp $
+
+--- demos/linearfork.c.orig	Fri Aug 25 06:14:48 2000
++++ demos/linearfork.c
+@@ -18,7 +18,7 @@
+  SIGTRAP, SIGIOT, SIGBUS, SIGFPE,
+  SIGSEGV, SIGPIPE, SIGALRM, SIGTERM,
+  SIGXCPU, SIGXFSZ, SIGVTALRM,
+- SIGPROF, SIGPWR};
++ SIGPROF, SIGUSR1};
+ 
+ 
+ static int newcolor(void)
diff --git a/svgalib64/patches/patch-av b/svgalib64/patches/patch-av
new file mode 100644
index 0000000000..7238ddd13e
--- /dev/null
+++ b/svgalib64/patches/patch-av
@@ -0,0 +1,435 @@
+$NetBSD: patch-av,v 1.1.1.1 2003/07/27 06:03:38 bencollver Exp $
+
+--- include/linux/keyboard.h.orig	Sat Jul 26 11:39:30 2003
++++ include/linux/keyboard.h
+@@ -0,0 +1,430 @@
++#ifndef __LINUX_KEYBOARD_H
++#define __LINUX_KEYBOARD_H
++
++#define KG_SHIFT	0
++#define KG_CTRL		2
++#define KG_ALT		3
++#define KG_ALTGR	1
++#define KG_SHIFTL	4
++#define KG_SHIFTR	5
++#define KG_CTRLL	6
++#define KG_CTRLR	7
++#define KG_CAPSSHIFT	8
++
++#define NR_SHIFT	9
++
++#define NR_KEYS		WSKBDIO_MAXMAPLEN 	/* WAS: 128 */
++/* #define MAX_NR_KEYMAPS	NUM_STATES	/* WAS: 256 */
++/* This means 64Kb if all keymaps are allocated. Only the superuser
++	may increase the number of keymaps beyond MAX_NR_OF_USER_KEYMAPS. */
++#define MAX_NR_OF_USER_KEYMAPS 256 	/* should be at least 7 */
++
++#ifdef __KERNEL__
++extern const int NR_TYPES;
++extern const int max_vals[];
++/* extern unsigned short *key_maps[MAX_NR_KEYMAPS]; */
++extern unsigned short plain_map[NR_KEYS];
++extern struct wait_queue * keypress_wait;
++extern unsigned char keyboard_type;
++#endif
++
++#define MAX_NR_FUNC	256	/* max nr of strings assigned to keys */
++
++#define KT_LATIN	0	/* we depend on this being zero */
++#define KT_LETTER	11	/* symbol that can be acted upon by CapsLock */
++#define KT_FN		1
++#define KT_SPEC		2
++#define KT_PAD		3
++#define KT_DEAD		4
++#define KT_CONS		5
++#define KT_CUR		6
++#define KT_SHIFT	7
++#define KT_META		8
++#define KT_ASCII	9
++#define KT_LOCK		10
++#define KT_SLOCK	12
++
++#define K(t,v)		(((t)<<8)|(v))
++#define KTYP(x)		((x) >> 8)
++#define KVAL(x)		((x) & 0xff)
++
++#define K_F1		K(KT_FN,0)
++#define K_F2		K(KT_FN,1)
++#define K_F3		K(KT_FN,2)
++#define K_F4		K(KT_FN,3)
++#define K_F5		K(KT_FN,4)
++#define K_F6		K(KT_FN,5)
++#define K_F7		K(KT_FN,6)
++#define K_F8		K(KT_FN,7)
++#define K_F9		K(KT_FN,8)
++#define K_F10		K(KT_FN,9)
++#define K_F11		K(KT_FN,10)
++#define K_F12		K(KT_FN,11)
++#define K_F13		K(KT_FN,12)
++#define K_F14		K(KT_FN,13)
++#define K_F15		K(KT_FN,14)
++#define K_F16		K(KT_FN,15)
++#define K_F17		K(KT_FN,16)
++#define K_F18		K(KT_FN,17)
++#define K_F19		K(KT_FN,18)
++#define K_F20		K(KT_FN,19)
++#define K_FIND		K(KT_FN,20)
++#define K_INSERT	K(KT_FN,21)
++#define K_REMOVE	K(KT_FN,22)
++#define K_SELECT	K(KT_FN,23)
++#define K_PGUP		K(KT_FN,24) /* PGUP is a synonym for PRIOR */
++#define K_PGDN		K(KT_FN,25) /* PGDN is a synonym for NEXT */
++#define K_MACRO	 	K(KT_FN,26)
++#define K_HELP		K(KT_FN,27)
++#define K_DO		K(KT_FN,28)
++#define K_PAUSE	 	K(KT_FN,29)
++#define K_F21		K(KT_FN,30)
++#define K_F22		K(KT_FN,31)
++#define K_F23		K(KT_FN,32)
++#define K_F24		K(KT_FN,33)
++#define K_F25		K(KT_FN,34)
++#define K_F26		K(KT_FN,35)
++#define K_F27		K(KT_FN,36)
++#define K_F28		K(KT_FN,37)
++#define K_F29		K(KT_FN,38)
++#define K_F30		K(KT_FN,39)
++#define K_F31		K(KT_FN,40)
++#define K_F32		K(KT_FN,41)
++#define K_F33		K(KT_FN,42)
++#define K_F34		K(KT_FN,43)
++#define K_F35		K(KT_FN,44)
++#define K_F36		K(KT_FN,45)
++#define K_F37		K(KT_FN,46)
++#define K_F38		K(KT_FN,47)
++#define K_F39		K(KT_FN,48)
++#define K_F40		K(KT_FN,49)
++#define K_F41		K(KT_FN,50)
++#define K_F42		K(KT_FN,51)
++#define K_F43		K(KT_FN,52)
++#define K_F44		K(KT_FN,53)
++#define K_F45		K(KT_FN,54)
++#define K_F46		K(KT_FN,55)
++#define K_F47		K(KT_FN,56)
++#define K_F48		K(KT_FN,57)
++#define K_F49		K(KT_FN,58)
++#define K_F50		K(KT_FN,59)
++#define K_F51		K(KT_FN,60)
++#define K_F52		K(KT_FN,61)
++#define K_F53		K(KT_FN,62)
++#define K_F54		K(KT_FN,63)
++#define K_F55		K(KT_FN,64)
++#define K_F56		K(KT_FN,65)
++#define K_F57		K(KT_FN,66)
++#define K_F58		K(KT_FN,67)
++#define K_F59		K(KT_FN,68)
++#define K_F60		K(KT_FN,69)
++#define K_F61		K(KT_FN,70)
++#define K_F62		K(KT_FN,71)
++#define K_F63		K(KT_FN,72)
++#define K_F64		K(KT_FN,73)
++#define K_F65		K(KT_FN,74)
++#define K_F66		K(KT_FN,75)
++#define K_F67		K(KT_FN,76)
++#define K_F68		K(KT_FN,77)
++#define K_F69		K(KT_FN,78)
++#define K_F70		K(KT_FN,79)
++#define K_F71		K(KT_FN,80)
++#define K_F72		K(KT_FN,81)
++#define K_F73		K(KT_FN,82)
++#define K_F74		K(KT_FN,83)
++#define K_F75		K(KT_FN,84)
++#define K_F76		K(KT_FN,85)
++#define K_F77		K(KT_FN,86)
++#define K_F78		K(KT_FN,87)
++#define K_F79		K(KT_FN,88)
++#define K_F80		K(KT_FN,89)
++#define K_F81		K(KT_FN,90)
++#define K_F82		K(KT_FN,91)
++#define K_F83		K(KT_FN,92)
++#define K_F84		K(KT_FN,93)
++#define K_F85		K(KT_FN,94)
++#define K_F86		K(KT_FN,95)
++#define K_F87		K(KT_FN,96)
++#define K_F88		K(KT_FN,97)
++#define K_F89		K(KT_FN,98)
++#define K_F90		K(KT_FN,99)
++#define K_F91		K(KT_FN,100)
++#define K_F92		K(KT_FN,101)
++#define K_F93		K(KT_FN,102)
++#define K_F94		K(KT_FN,103)
++#define K_F95		K(KT_FN,104)
++#define K_F96		K(KT_FN,105)
++#define K_F97		K(KT_FN,106)
++#define K_F98		K(KT_FN,107)
++#define K_F99		K(KT_FN,108)
++#define K_F100		K(KT_FN,109)
++#define K_F101		K(KT_FN,110)
++#define K_F102		K(KT_FN,111)
++#define K_F103		K(KT_FN,112)
++#define K_F104		K(KT_FN,113)
++#define K_F105		K(KT_FN,114)
++#define K_F106		K(KT_FN,115)
++#define K_F107		K(KT_FN,116)
++#define K_F108		K(KT_FN,117)
++#define K_F109		K(KT_FN,118)
++#define K_F110		K(KT_FN,119)
++#define K_F111		K(KT_FN,120)
++#define K_F112		K(KT_FN,121)
++#define K_F113		K(KT_FN,122)
++#define K_F114		K(KT_FN,123)
++#define K_F115		K(KT_FN,124)
++#define K_F116		K(KT_FN,125)
++#define K_F117		K(KT_FN,126)
++#define K_F118		K(KT_FN,127)
++#define K_F119		K(KT_FN,128)
++#define K_F120		K(KT_FN,129)
++#define K_F121		K(KT_FN,130)
++#define K_F122		K(KT_FN,131)
++#define K_F123		K(KT_FN,132)
++#define K_F124		K(KT_FN,133)
++#define K_F125		K(KT_FN,134)
++#define K_F126		K(KT_FN,135)
++#define K_F127		K(KT_FN,136)
++#define K_F128		K(KT_FN,137)
++#define K_F129		K(KT_FN,138)
++#define K_F130		K(KT_FN,139)
++#define K_F131		K(KT_FN,140)
++#define K_F132		K(KT_FN,141)
++#define K_F133		K(KT_FN,142)
++#define K_F134		K(KT_FN,143)
++#define K_F135		K(KT_FN,144)
++#define K_F136		K(KT_FN,145)
++#define K_F137		K(KT_FN,146)
++#define K_F138		K(KT_FN,147)
++#define K_F139		K(KT_FN,148)
++#define K_F140		K(KT_FN,149)
++#define K_F141		K(KT_FN,150)
++#define K_F142		K(KT_FN,151)
++#define K_F143		K(KT_FN,152)
++#define K_F144		K(KT_FN,153)
++#define K_F145		K(KT_FN,154)
++#define K_F146		K(KT_FN,155)
++#define K_F147		K(KT_FN,156)
++#define K_F148		K(KT_FN,157)
++#define K_F149		K(KT_FN,158)
++#define K_F150		K(KT_FN,159)
++#define K_F151		K(KT_FN,160)
++#define K_F152		K(KT_FN,161)
++#define K_F153		K(KT_FN,162)
++#define K_F154		K(KT_FN,163)
++#define K_F155		K(KT_FN,164)
++#define K_F156		K(KT_FN,165)
++#define K_F157		K(KT_FN,166)
++#define K_F158		K(KT_FN,167)
++#define K_F159		K(KT_FN,168)
++#define K_F160		K(KT_FN,169)
++#define K_F161		K(KT_FN,170)
++#define K_F162		K(KT_FN,171)
++#define K_F163		K(KT_FN,172)
++#define K_F164		K(KT_FN,173)
++#define K_F165		K(KT_FN,174)
++#define K_F166		K(KT_FN,175)
++#define K_F167		K(KT_FN,176)
++#define K_F168		K(KT_FN,177)
++#define K_F169		K(KT_FN,178)
++#define K_F170		K(KT_FN,179)
++#define K_F171		K(KT_FN,180)
++#define K_F172		K(KT_FN,181)
++#define K_F173		K(KT_FN,182)
++#define K_F174		K(KT_FN,183)
++#define K_F175		K(KT_FN,184)
++#define K_F176		K(KT_FN,185)
++#define K_F177		K(KT_FN,186)
++#define K_F178		K(KT_FN,187)
++#define K_F179		K(KT_FN,188)
++#define K_F180		K(KT_FN,189)
++#define K_F181		K(KT_FN,190)
++#define K_F182		K(KT_FN,191)
++#define K_F183		K(KT_FN,192)
++#define K_F184		K(KT_FN,193)
++#define K_F185		K(KT_FN,194)
++#define K_F186		K(KT_FN,195)
++#define K_F187		K(KT_FN,196)
++#define K_F188		K(KT_FN,197)
++#define K_F189		K(KT_FN,198)
++#define K_F190		K(KT_FN,199)
++#define K_F191		K(KT_FN,200)
++#define K_F192		K(KT_FN,201)
++#define K_F193		K(KT_FN,202)
++#define K_F194		K(KT_FN,203)
++#define K_F195		K(KT_FN,204)
++#define K_F196		K(KT_FN,205)
++#define K_F197		K(KT_FN,206)
++#define K_F198		K(KT_FN,207)
++#define K_F199		K(KT_FN,208)
++#define K_F200		K(KT_FN,209)
++#define K_F201		K(KT_FN,210)
++#define K_F202		K(KT_FN,211)
++#define K_F203		K(KT_FN,212)
++#define K_F204		K(KT_FN,213)
++#define K_F205		K(KT_FN,214)
++#define K_F206		K(KT_FN,215)
++#define K_F207		K(KT_FN,216)
++#define K_F208		K(KT_FN,217)
++#define K_F209		K(KT_FN,218)
++#define K_F210		K(KT_FN,219)
++#define K_F211		K(KT_FN,220)
++#define K_F212		K(KT_FN,221)
++#define K_F213		K(KT_FN,222)
++#define K_F214		K(KT_FN,223)
++#define K_F215		K(KT_FN,224)
++#define K_F216		K(KT_FN,225)
++#define K_F217		K(KT_FN,226)
++#define K_F218		K(KT_FN,227)
++#define K_F219		K(KT_FN,228)
++#define K_F220		K(KT_FN,229)
++#define K_F221		K(KT_FN,230)
++#define K_F222		K(KT_FN,231)
++#define K_F223		K(KT_FN,232)
++#define K_F224		K(KT_FN,233)
++#define K_F225		K(KT_FN,234)
++#define K_F226		K(KT_FN,235)
++#define K_F227		K(KT_FN,236)
++#define K_F228		K(KT_FN,237)
++#define K_F229		K(KT_FN,238)
++#define K_F230		K(KT_FN,239)
++#define K_F231		K(KT_FN,240)
++#define K_F232		K(KT_FN,241)
++#define K_F233		K(KT_FN,242)
++#define K_F234		K(KT_FN,243)
++#define K_F235		K(KT_FN,244)
++#define K_F236		K(KT_FN,245)
++#define K_F237		K(KT_FN,246)
++#define K_F238		K(KT_FN,247)
++#define K_F239		K(KT_FN,248)
++#define K_F240		K(KT_FN,249)
++#define K_F241		K(KT_FN,250)
++#define K_F242		K(KT_FN,251)
++#define K_F243		K(KT_FN,252)
++#define K_F244		K(KT_FN,253)
++#define K_F245		K(KT_FN,254)
++#define K_UNDO		K(KT_FN,255)
++
++
++#define K_HOLE		K(KT_SPEC,0)
++#define K_ENTER		K(KT_SPEC,1)
++#define K_SH_REGS	K(KT_SPEC,2)
++#define K_SH_MEM	K(KT_SPEC,3)
++#define K_SH_STAT	K(KT_SPEC,4)
++#define K_BREAK		K(KT_SPEC,5)
++#define K_CONS		K(KT_SPEC,6)
++#define K_CAPS		K(KT_SPEC,7)
++#define K_NUM		K(KT_SPEC,8)
++#define K_HOLD		K(KT_SPEC,9)
++#define K_SCROLLFORW	K(KT_SPEC,10)
++#define K_SCROLLBACK	K(KT_SPEC,11)
++#define K_BOOT		K(KT_SPEC,12)
++#define K_CAPSON	K(KT_SPEC,13)
++#define K_COMPOSE	K(KT_SPEC,14)
++#define K_SAK		K(KT_SPEC,15)
++#define K_DECRCONSOLE	K(KT_SPEC,16)
++#define K_INCRCONSOLE	K(KT_SPEC,17)
++#define K_SPAWNCONSOLE	K(KT_SPEC,18)
++#define K_BARENUMLOCK	K(KT_SPEC,19)
++
++#define K_ALLOCATED	K(KT_SPEC,126) /* dynamically allocated keymap */
++#define K_NOSUCHMAP	K(KT_SPEC,127) /* returned by KDGKBENT */
++
++#define K_P0		K(KT_PAD,0)
++#define K_P1		K(KT_PAD,1)
++#define K_P2		K(KT_PAD,2)
++#define K_P3		K(KT_PAD,3)
++#define K_P4		K(KT_PAD,4)
++#define K_P5		K(KT_PAD,5)
++#define K_P6		K(KT_PAD,6)
++#define K_P7		K(KT_PAD,7)
++#define K_P8		K(KT_PAD,8)
++#define K_P9		K(KT_PAD,9)
++#define K_PPLUS		K(KT_PAD,10)	/* key-pad plus */
++#define K_PMINUS	K(KT_PAD,11)	/* key-pad minus */
++#define K_PSTAR		K(KT_PAD,12)	/* key-pad asterisk (star) */
++#define K_PSLASH	K(KT_PAD,13)	/* key-pad slash */
++#define K_PENTER	K(KT_PAD,14)	/* key-pad enter */
++#define K_PCOMMA	K(KT_PAD,15)	/* key-pad comma: kludge... */
++#define K_PDOT		K(KT_PAD,16)	/* key-pad dot (period): kludge... */
++#define K_PPLUSMINUS	K(KT_PAD,17)	/* key-pad plus/minus */
++#define K_PPARENL	K(KT_PAD,18)	/* key-pad left parenthesis */
++#define K_PPARENR	K(KT_PAD,19)	/* key-pad right parenthesis */
++
++#define NR_PAD		20
++
++#define K_DGRAVE	K(KT_DEAD,0)
++#define K_DACUTE	K(KT_DEAD,1)
++#define K_DCIRCM	K(KT_DEAD,2)
++#define K_DTILDE	K(KT_DEAD,3)
++#define K_DDIERE	K(KT_DEAD,4)
++#define K_DCEDIL	K(KT_DEAD,5)
++
++#define NR_DEAD		6
++
++#define K_DOWN		K(KT_CUR,0)
++#define K_LEFT		K(KT_CUR,1)
++#define K_RIGHT		K(KT_CUR,2)
++#define K_UP		K(KT_CUR,3)
++
++#define K_SHIFT		K(KT_SHIFT,KG_SHIFT)
++#define K_CTRL		K(KT_SHIFT,KG_CTRL)
++#define K_ALT		K(KT_SHIFT,KG_ALT)
++#define K_ALTGR		K(KT_SHIFT,KG_ALTGR)
++#define K_SHIFTL	K(KT_SHIFT,KG_SHIFTL)
++#define K_SHIFTR	K(KT_SHIFT,KG_SHIFTR)
++#define K_CTRLL	 	K(KT_SHIFT,KG_CTRLL)
++#define K_CTRLR	 	K(KT_SHIFT,KG_CTRLR)
++#define K_CAPSSHIFT	K(KT_SHIFT,KG_CAPSSHIFT)
++
++#define K_ASC0		K(KT_ASCII,0)
++#define K_ASC1		K(KT_ASCII,1)
++#define K_ASC2		K(KT_ASCII,2)
++#define K_ASC3		K(KT_ASCII,3)
++#define K_ASC4		K(KT_ASCII,4)
++#define K_ASC5		K(KT_ASCII,5)
++#define K_ASC6		K(KT_ASCII,6)
++#define K_ASC7		K(KT_ASCII,7)
++#define K_ASC8		K(KT_ASCII,8)
++#define K_ASC9		K(KT_ASCII,9)
++#define K_HEX0		K(KT_ASCII,10)
++#define K_HEX1		K(KT_ASCII,11)
++#define K_HEX2		K(KT_ASCII,12)
++#define K_HEX3		K(KT_ASCII,13)
++#define K_HEX4		K(KT_ASCII,14)
++#define K_HEX5		K(KT_ASCII,15)
++#define K_HEX6		K(KT_ASCII,16)
++#define K_HEX7		K(KT_ASCII,17)
++#define K_HEX8		K(KT_ASCII,18)
++#define K_HEX9		K(KT_ASCII,19)
++#define K_HEXa		K(KT_ASCII,20)
++#define K_HEXb		K(KT_ASCII,21)
++#define K_HEXc		K(KT_ASCII,22)
++#define K_HEXd		K(KT_ASCII,23)
++#define K_HEXe		K(KT_ASCII,24)
++#define K_HEXf		K(KT_ASCII,25)
++
++#define NR_ASCII	26
++
++#define K_SHIFTLOCK	K(KT_LOCK,KG_SHIFT)
++#define K_CTRLLOCK	K(KT_LOCK,KG_CTRL)
++#define K_ALTLOCK	K(KT_LOCK,KG_ALT)
++#define K_ALTGRLOCK	K(KT_LOCK,KG_ALTGR)
++#define K_SHIFTLLOCK	K(KT_LOCK,KG_SHIFTL)
++#define K_SHIFTRLOCK	K(KT_LOCK,KG_SHIFTR)
++#define K_CTRLLLOCK	K(KT_LOCK,KG_CTRLL)
++#define K_CTRLRLOCK	K(KT_LOCK,KG_CTRLR)
++
++#define K_SHIFT_SLOCK	K(KT_SLOCK,KG_SHIFT)
++#define K_CTRL_SLOCK	K(KT_SLOCK,KG_CTRL)
++#define K_ALT_SLOCK	K(KT_SLOCK,KG_ALT)
++#define K_ALTGR_SLOCK	K(KT_SLOCK,KG_ALTGR)
++#define K_SHIFTL_SLOCK	K(KT_SLOCK,KG_SHIFTL)
++#define K_SHIFTR_SLOCK	K(KT_SLOCK,KG_SHIFTR)
++#define K_CTRLL_SLOCK	K(KT_SLOCK,KG_CTRLL)
++#define K_CTRLR_SLOCK	K(KT_SLOCK,KG_CTRLR)
++
++#define NR_LOCK		8
++
++#define MAX_DIACR	256
++#endif
diff --git a/svgalib64/patches/patch-aw b/svgalib64/patches/patch-aw
new file mode 100644
index 0000000000..6d9eb86b66
--- /dev/null
+++ b/svgalib64/patches/patch-aw
@@ -0,0 +1,6 @@
+$NetBSD: patch-aw,v 1.1.1.1 2003/07/27 06:03:38 bencollver Exp $
+
+--- include/linux/kd.h.orig	Sat Jul 26 11:45:25 2003
++++ include/linux/kd.h
+@@ -0,0 +1 @@
++#include <dev/wscons/wsconsio.h>
diff --git a/svgalib64/patches/patch-ax b/svgalib64/patches/patch-ax
new file mode 100644
index 0000000000..d3745cf59c
--- /dev/null
+++ b/svgalib64/patches/patch-ax
@@ -0,0 +1,53 @@
+$NetBSD: patch-ax,v 1.1.1.1 2003/07/27 06:03:38 bencollver Exp $
+
+--- src/keyboard/vgakeyboard.h.orig	2000/08/30 16:11:47	1.1
++++ src/keyboard/vgakeyboard.h
+@@ -120,28 +120,28 @@
+ #define SCANCODE_F11			87
+ #define SCANCODE_F12			88
+ 
+-#define SCANCODE_KEYPADENTER		96
+-#define SCANCODE_RIGHTCONTROL		97
+-#define SCANCODE_CONTROL		97
+-#define SCANCODE_KEYPADDIVIDE		98
+-#define SCANCODE_PRINTSCREEN		99
+-#define SCANCODE_RIGHTALT		100
+-#define SCANCODE_BREAK			101	/* Beware: is 119     */
+-#define SCANCODE_BREAK_ALTERNATIVE	119	/* on some keyboards! */
++#define SCANCODE_KEYPADENTER		89
++#define SCANCODE_RIGHTCONTROL		90
++#define SCANCODE_CONTROL		107
++#define SCANCODE_KEYPADDIVIDE		91
++#define SCANCODE_PRINTSCREEN		92
++#define SCANCODE_RIGHTALT		93
++#define SCANCODE_BREAK			104	/* Beware: is 119     */
++#define SCANCODE_BREAK_ALTERNATIVE	104	/* on some keyboards! */
+ 
+-#define SCANCODE_HOME			102
+-#define SCANCODE_CURSORBLOCKUP		103	/* Cursor key block */
+-#define SCANCODE_PAGEUP			104
+-#define SCANCODE_CURSORBLOCKLEFT	105	/* Cursor key block */
+-#define SCANCODE_CURSORBLOCKRIGHT	106	/* Cursor key block */
+-#define SCANCODE_END			107
+-#define SCANCODE_CURSORBLOCKDOWN	108	/* Cursor key block */
+-#define SCANCODE_PAGEDOWN		109
+-#define SCANCODE_INSERT			110
+-#define SCANCODE_REMOVE			111
++#define SCANCODE_HOME			94
++#define SCANCODE_CURSORBLOCKUP		95	/* Cursor key block */
++#define SCANCODE_PAGEUP			96
++#define SCANCODE_CURSORBLOCKLEFT	97	/* Cursor key block */
++#define SCANCODE_CURSORBLOCKRIGHT	98	/* Cursor key block */
++#define SCANCODE_END			99
++#define SCANCODE_CURSORBLOCKDOWN	100	/* Cursor key block */
++#define SCANCODE_PAGEDOWN		101
++#define SCANCODE_INSERT			102
++#define SCANCODE_REMOVE			103
+ 
+-#define SCANCODE_RIGHTWIN		126
+-#define SCANCODE_LEFTWIN		125
++#define SCANCODE_RIGHTWIN		106
++#define SCANCODE_LEFTWIN		105
+ 
+ #define KEY_EVENTRELEASE 0
+ #define KEY_EVENTPRESS 1
diff --git a/svgalib64/patches/patch-ay b/svgalib64/patches/patch-ay
new file mode 100644
index 0000000000..2d6bcef1f1
--- /dev/null
+++ b/svgalib64/patches/patch-ay
@@ -0,0 +1,25 @@
+$NetBSD: patch-ay,v 1.2 2003/07/31 15:12:40 bencollver Exp $
+
+--- src/laguna.c.orig	Wed Oct 11 09:35:46 2000
++++ src/laguna.c
+@@ -445,9 +445,20 @@ static int laguna_test(void)
+ {
+     int found;
+     unsigned long buf[64];
++    int _ioperm=0;
+     
++    if (getenv("IOPERM") == NULL) {
++	_ioperm=1;
++        if (iopl(3) < 0) {
++          printf("svgalib: cannot get I/O permissions\n");
++          exit(1);
++        }
++    }
++
+     found=__svgalib_pci_find_vendor_vga(VENDOR_ID,buf,0);
+     
++    if (_ioperm) iopl(0);
++
+     if(!found&&
+         ((((buf[0]>>16)&0xffff)==0x00d0)||
+          (((buf[0]>>16)&0xffff)==0x00d4)||
diff --git a/svgalib64/patches/patch-az b/svgalib64/patches/patch-az
new file mode 100644
index 0000000000..3d6060eb4d
--- /dev/null
+++ b/svgalib64/patches/patch-az
@@ -0,0 +1,49 @@
+$NetBSD: patch-az,v 1.2 2003/07/31 15:12:40 bencollver Exp $
+
+--- src/r128.c.orig	Wed May 30 01:02:14 2001
++++ src/r128.c
+@@ -313,7 +313,7 @@ static void R128RestoreMode(R128SavePtr 
+     OUTREG(R128_AMCGPIO_MASK,     restore->amcgpio_mask);
+     OUTREG(R128_AMCGPIO_EN_REG,   restore->amcgpio_en_reg);
+     OUTREG(R128_CLOCK_CNTL_INDEX, restore->clock_cntl_index);
+-    OUTREG(R128_GEN_RESET_CNTL,   restore->gen_reset_cntl);
++//    OUTREG(R128_GEN_RESET_CNTL,   restore->gen_reset_cntl);
+     OUTREG(R128_DP_DATATYPE,      restore->dp_datatype);
+ 
+     R128RestoreCommonRegisters( restore);
+@@ -443,6 +443,10 @@ static void R128InitCommonRegisters(R128
+     save->mem_vga_wp_sel     = 0;
+     save->mem_vga_rp_sel     = 0;
+     save->bus_cntl           = BusCntl;
++
++    save->config_cntl        = INREG(R128_CONFIG_CNTL);
++    save->amcgpio_en_reg   = INREG(R128_AMCGPIO_EN_REG);
++    save->amcgpio_mask     = INREG(R128_AMCGPIO_MASK);
+     /*
+      * If bursts are enabled, turn on discards and aborts
+      */
+@@ -958,6 +962,15 @@ static int r128_test(void)
+ {
+     int found, id;
+     unsigned long buf[64];
++    int _ioperm=0;
++     
++    if (getenv("IOPERM") == NULL) {
++       _ioperm=1;
++        if (iopl(3) < 0) {
++          printf("svgalib: cannot get I/O permissions\n");
++          exit(1);
++        }
++    }
+     
+     found=__svgalib_pci_find_vendor_vga(VENDOR_ID,buf,0);
+ 
+@@ -966,6 +979,8 @@ static int r128_test(void)
+     if((id>=0x5350) || (id<=0x4fff)) return 0;
+     
+     r128_init(0,0,0);
++    if (_ioperm) iopl(0);
++
+     return 1;
+ }
+ 
diff --git a/svgalib64/patches/patch-ba b/svgalib64/patches/patch-ba
new file mode 100644
index 0000000000..eb4a1589dc
--- /dev/null
+++ b/svgalib64/patches/patch-ba
@@ -0,0 +1,476 @@
+$NetBSD: patch-ba,v 1.1 2003/07/31 15:13:39 bencollver Exp $
+
+--- src/lrmi.c.orig	Mon Aug  7 00:17:23 2000
++++ src/lrmi.c
+@@ -12,10 +12,14 @@ This software has NO WARRANTY.  Use it a
+ 
+ #include <stdio.h>
+ #include <string.h>
+-#include <asm/vm86.h>
+ 
+ #ifdef USE_LIBC_VM86
+-#include <sys/vm86.h>
++#include <sys/types.h>
++#include <signal.h>
++#include <machine/psl.h>
++#include <machine/segments.h>
++#include <machine/sysarch.h>
++#include <machine/vm86.h>
+ #endif
+ 
+ #include <sys/types.h>
+@@ -30,7 +34,7 @@ This software has NO WARRANTY.  Use it a
+ #define REAL_MEM_SIZE 	0x10000
+ #define REAL_MEM_BLOCKS 	0x100
+ 
+-int __svgalib_lrmi_cpu_type=CPU_386;
++int __svgalib_lrmi_cpu_type=VCPU_386;
+ 
+ struct mem_block
+ 	{
+@@ -171,7 +175,7 @@ LRMI_free_real(void *m)
+ 	}
+ 
+ 
+-#define DEFAULT_VM86_FLAGS 	(IF_MASK | IOPL_MASK)
++#define DEFAULT_VM86_FLAGS 	(PSL_I|PSL_IOPL)
+ #define DEFAULT_STACK_SIZE 	0x1000
+ #define RETURN_TO_32_INT 	255
+ 
+@@ -210,9 +214,9 @@ get_int_off(int i)
+ static inline void
+ pushw(unsigned short i)
+ 	{
+-	struct vm86_regs *r = &context.vm.regs;
+-	r->esp -= 2;
+-	*(unsigned short *)(((unsigned int)r->ss << 4) + r->esp) = i;
++	struct vm86_regs *r = &context.vm.substr.regs;
++	r->vmsc.sc_esp -= 2;
++	*(unsigned short *)(((unsigned int)r->vmsc.sc_ss << 4) + r->vmsc.sc_esp) = i;
+ 	}
+ 
+ 
+@@ -282,13 +286,13 @@ LRMI_init(void)
+ 
+ 	memset(&context.vm, 0, sizeof(context.vm));
+ 
+-	context.vm.cpu_type = __svgalib_lrmi_cpu_type;
++	context.vm.substr.ss_cpu_type = __svgalib_lrmi_cpu_type;
+ 
+ 	/*
+ 	 Enable kernel emulation of all ints except RETURN_TO_32_INT
+ 	*/
+-	memset(&context.vm.int_revectored, 0, sizeof(context.vm.int_revectored));
+-	set_bit(RETURN_TO_32_INT, &context.vm.int_revectored);
++	memset(&context.vm.int_byuser, 0, sizeof(context.vm.int_byuser));
++	set_bit(RETURN_TO_32_INT, &context.vm.int_byuser);
+ 
+ 	context.ready = 1;
+ 
+@@ -299,36 +303,36 @@ LRMI_init(void)
+ static void
+ set_regs(struct LRMI_regs *r)
+ 	{
+-	context.vm.regs.edi = r->edi;
+-	context.vm.regs.esi = r->esi;
+-	context.vm.regs.ebp = r->ebp;
+-	context.vm.regs.ebx = r->ebx;
+-	context.vm.regs.edx = r->edx;
+-	context.vm.regs.ecx = r->ecx;
+-	context.vm.regs.eax = r->eax;
+-	context.vm.regs.eflags = DEFAULT_VM86_FLAGS;
+-	context.vm.regs.es = r->es;
+-	context.vm.regs.ds = r->ds;
+-	context.vm.regs.fs = r->fs;
+-	context.vm.regs.gs = r->gs;
++	context.vm.substr.regs.vmsc.sc_edi = r->edi;
++	context.vm.substr.regs.vmsc.sc_esi = r->esi;
++	context.vm.substr.regs.vmsc.sc_ebp = r->ebp;
++	context.vm.substr.regs.vmsc.sc_ebx = r->ebx;
++	context.vm.substr.regs.vmsc.sc_edx = r->edx;
++	context.vm.substr.regs.vmsc.sc_ecx = r->ecx;
++	context.vm.substr.regs.vmsc.sc_eax = r->eax;
++	context.vm.substr.regs.vmsc.sc_eflags = DEFAULT_VM86_FLAGS;
++	context.vm.substr.regs.vmsc.sc_es = r->es;
++	context.vm.substr.regs.vmsc.sc_ds = r->ds;
++	context.vm.substr.regs.vmsc.sc_fs = r->fs;
++	context.vm.substr.regs.vmsc.sc_gs = r->gs;
+ 	}
+ 
+ 
+ static void
+ get_regs(struct LRMI_regs *r)
+ 	{
+-	r->edi = context.vm.regs.edi;
+-	r->esi = context.vm.regs.esi;
+-	r->ebp = context.vm.regs.ebp;
+-	r->ebx = context.vm.regs.ebx;
+-	r->edx = context.vm.regs.edx;
+-	r->ecx = context.vm.regs.ecx;
+-	r->eax = context.vm.regs.eax;
+-	r->flags = context.vm.regs.eflags;
+-	r->es = context.vm.regs.es;
+-	r->ds = context.vm.regs.ds;
+-	r->fs = context.vm.regs.fs;
+-	r->gs = context.vm.regs.gs;
++	r->edi = context.vm.substr.regs.vmsc.sc_edi;
++	r->esi = context.vm.substr.regs.vmsc.sc_esi;
++	r->ebp = context.vm.substr.regs.vmsc.sc_ebp;
++	r->ebx = context.vm.substr.regs.vmsc.sc_ebx;
++	r->edx = context.vm.substr.regs.vmsc.sc_edx;
++	r->ecx = context.vm.substr.regs.vmsc.sc_ecx;
++	r->eax = context.vm.substr.regs.vmsc.sc_eax;
++	r->flags = context.vm.substr.regs.vmsc.sc_eflags;
++	r->es = context.vm.substr.regs.vmsc.sc_es;
++	r->ds = context.vm.substr.regs.vmsc.sc_ds;
++	r->fs = context.vm.substr.regs.vmsc.sc_fs;
++	r->gs = context.vm.substr.regs.vmsc.sc_gs;
+ 	}
+ 
+ #define DIRECTION_FLAG 	(1 << 10)
+@@ -338,11 +342,11 @@ em_ins(int size)
+ 	{
+ 	unsigned int edx, edi;
+ 
+-	edx = context.vm.regs.edx & 0xffff;
+-	edi = context.vm.regs.edi & 0xffff;
+-	edi += (unsigned int)context.vm.regs.ds << 4;
++	edx = context.vm.substr.regs.vmsc.sc_edx & 0xffff;
++	edi = context.vm.substr.regs.vmsc.sc_edi & 0xffff;
++	edi += (unsigned int)context.vm.substr.regs.vmsc.sc_ds << 4;
+ 
+-	if (context.vm.regs.eflags & DIRECTION_FLAG)
++	if (context.vm.substr.regs.vmsc.sc_eflags & DIRECTION_FLAG)
+ 		{
+ 		if (size == 4)
+ 			asm volatile ("std; insl; cld"
+@@ -367,10 +371,10 @@ em_ins(int size)
+ 			 : "=D" (edi) : "d" (edx), "0" (edi));
+ 		}
+ 
+-	edi -= (unsigned int)context.vm.regs.ds << 4;
++	edi -= (unsigned int)context.vm.substr.regs.vmsc.sc_ds << 4;
+ 
+-	context.vm.regs.edi &= 0xffff0000;
+-	context.vm.regs.edi |= edi & 0xffff;
++	context.vm.substr.regs.vmsc.sc_edi &= 0xffff0000;
++	context.vm.substr.regs.vmsc.sc_edi |= edi & 0xffff;
+ 	}
+ 
+ static void
+@@ -378,12 +382,12 @@ em_rep_ins(int size)
+ 	{
+ 	unsigned int ecx, edx, edi;
+ 
+-	ecx = context.vm.regs.ecx & 0xffff;
+-	edx = context.vm.regs.edx & 0xffff;
+-	edi = context.vm.regs.edi & 0xffff;
+-	edi += (unsigned int)context.vm.regs.ds << 4;
++	ecx = context.vm.substr.regs.vmsc.sc_ecx & 0xffff;
++	edx = context.vm.substr.regs.vmsc.sc_edx & 0xffff;
++	edi = context.vm.substr.regs.vmsc.sc_edi & 0xffff;
++	edi += (unsigned int)context.vm.substr.regs.vmsc.sc_ds << 4;
+ 
+-	if (context.vm.regs.eflags & DIRECTION_FLAG)
++	if (context.vm.substr.regs.vmsc.sc_eflags & DIRECTION_FLAG)
+ 		{
+ 		if (size == 4)
+ 			asm volatile ("std; rep; insl; cld"
+@@ -414,13 +418,13 @@ em_rep_ins(int size)
+ 			 : "d" (edx), "0" (edi), "1" (ecx));
+ 		}
+ 
+-	edi -= (unsigned int)context.vm.regs.ds << 4;
++	edi -= (unsigned int)context.vm.substr.regs.vmsc.sc_ds << 4;
+ 
+-	context.vm.regs.edi &= 0xffff0000;
+-	context.vm.regs.edi |= edi & 0xffff;
++	context.vm.substr.regs.vmsc.sc_edi &= 0xffff0000;
++	context.vm.substr.regs.vmsc.sc_edi |= edi & 0xffff;
+ 
+-	context.vm.regs.ecx &= 0xffff0000;
+-	context.vm.regs.ecx |= ecx & 0xffff;
++	context.vm.substr.regs.vmsc.sc_ecx &= 0xffff0000;
++	context.vm.substr.regs.vmsc.sc_ecx |= ecx & 0xffff;
+ 	}
+ 
+ static void
+@@ -428,11 +432,11 @@ em_outs(int size)
+ 	{
+ 	unsigned int edx, esi;
+ 
+-	edx = context.vm.regs.edx & 0xffff;
+-	esi = context.vm.regs.esi & 0xffff;
+-	esi += (unsigned int)context.vm.regs.ds << 4;
++	edx = context.vm.substr.regs.vmsc.sc_edx & 0xffff;
++	esi = context.vm.substr.regs.vmsc.sc_esi & 0xffff;
++	esi += (unsigned int)context.vm.substr.regs.vmsc.sc_ds << 4;
+ 
+-	if (context.vm.regs.eflags & DIRECTION_FLAG)
++	if (context.vm.substr.regs.vmsc.sc_eflags & DIRECTION_FLAG)
+ 		{
+ 		if (size == 4)
+ 			asm volatile ("std; outsl; cld"
+@@ -457,10 +461,10 @@ em_outs(int size)
+ 			 : "=S" (esi) : "d" (edx), "0" (esi));
+ 		}
+ 
+-	esi -= (unsigned int)context.vm.regs.ds << 4;
++	esi -= (unsigned int)context.vm.substr.regs.vmsc.sc_ds << 4;
+ 
+-	context.vm.regs.esi &= 0xffff0000;
+-	context.vm.regs.esi |= esi & 0xffff;
++	context.vm.substr.regs.vmsc.sc_esi &= 0xffff0000;
++	context.vm.substr.regs.vmsc.sc_esi |= esi & 0xffff;
+ 	}
+ 
+ static void
+@@ -468,12 +472,12 @@ em_rep_outs(int size)
+ 	{
+ 	unsigned int ecx, edx, esi;
+ 
+-	ecx = context.vm.regs.ecx & 0xffff;
+-	edx = context.vm.regs.edx & 0xffff;
+-	esi = context.vm.regs.esi & 0xffff;
+-	esi += (unsigned int)context.vm.regs.ds << 4;
++	ecx = context.vm.substr.regs.vmsc.sc_ecx & 0xffff;
++	edx = context.vm.substr.regs.vmsc.sc_edx & 0xffff;
++	esi = context.vm.substr.regs.vmsc.sc_esi & 0xffff;
++	esi += (unsigned int)context.vm.substr.regs.vmsc.sc_ds << 4;
+ 
+-	if (context.vm.regs.eflags & DIRECTION_FLAG)
++	if (context.vm.substr.regs.vmsc.sc_eflags & DIRECTION_FLAG)
+ 		{
+ 		if (size == 4)
+ 			asm volatile ("std; rep; outsl; cld"
+@@ -504,61 +508,61 @@ em_rep_outs(int size)
+ 			 : "d" (edx), "0" (esi), "1" (ecx));
+ 		}
+ 
+-	esi -= (unsigned int)context.vm.regs.ds << 4;
++	esi -= (unsigned int)context.vm.substr.regs.vmsc.sc_ds << 4;
+ 
+-	context.vm.regs.esi &= 0xffff0000;
+-	context.vm.regs.esi |= esi & 0xffff;
++	context.vm.substr.regs.vmsc.sc_esi &= 0xffff0000;
++	context.vm.substr.regs.vmsc.sc_esi |= esi & 0xffff;
+ 
+-	context.vm.regs.ecx &= 0xffff0000;
+-	context.vm.regs.ecx |= ecx & 0xffff;
++	context.vm.substr.regs.vmsc.sc_ecx &= 0xffff0000;
++	context.vm.substr.regs.vmsc.sc_ecx |= ecx & 0xffff;
+ 	}
+ 
+ static void
+ em_inb(void)
+ 	{
+ 	asm volatile ("inb (%w1), %b0"
+-	 : "=a" (context.vm.regs.eax)
+-	 : "d" (context.vm.regs.edx), "0" (context.vm.regs.eax));
++	 : "=a" (context.vm.substr.regs.vmsc.sc_eax)
++	 : "d" (context.vm.substr.regs.vmsc.sc_edx), "0" (context.vm.substr.regs.vmsc.sc_eax));
+ 	}
+ 
+ static void
+ em_inw(void)
+ 	{
+ 	asm volatile ("inw (%w1), %w0"
+-	 : "=a" (context.vm.regs.eax)
+-	 : "d" (context.vm.regs.edx), "0" (context.vm.regs.eax));
++	 : "=a" (context.vm.substr.regs.vmsc.sc_eax)
++	 : "d" (context.vm.substr.regs.vmsc.sc_edx), "0" (context.vm.substr.regs.vmsc.sc_eax));
+ 	}
+ 
+ static void
+ em_inl(void)
+ 	{
+ 	asm volatile ("inl (%w1), %0"
+-	 : "=a" (context.vm.regs.eax)
+-	 : "d" (context.vm.regs.edx));
++	 : "=a" (context.vm.substr.regs.vmsc.sc_eax)
++	 : "d" (context.vm.substr.regs.vmsc.sc_edx));
+ 	}
+ 
+ static void
+ em_outb(void)
+ 	{
+ 	asm volatile ("outb %b0, (%w1)"
+-	 : : "a" (context.vm.regs.eax),
+-	 "d" (context.vm.regs.edx));
++	 : : "a" (context.vm.substr.regs.vmsc.sc_eax),
++	 "d" (context.vm.substr.regs.vmsc.sc_edx));
+ 	}
+ 
+ static void
+ em_outw(void)
+ 	{
+ 	asm volatile ("outw %w0, (%w1)"
+-	 : : "a" (context.vm.regs.eax),
+-	 "d" (context.vm.regs.edx));
++	 : : "a" (context.vm.substr.regs.vmsc.sc_eax),
++	 "d" (context.vm.substr.regs.vmsc.sc_edx));
+ 	}
+ 
+ static void
+ em_outl(void)
+ 	{
+ 	asm volatile ("outl %0, (%w1)"
+-	 : : "a" (context.vm.regs.eax),
+-	 "d" (context.vm.regs.edx));
++	 : : "a" (context.vm.substr.regs.vmsc.sc_eax),
++	 "d" (context.vm.substr.regs.vmsc.sc_edx));
+ 	}
+ 
+ static int
+@@ -572,8 +576,8 @@ emulate(void)
+ 		} prefix = { 0, 0 };
+ 	int i = 0;
+ 
+-	insn = (unsigned char *)((unsigned int)context.vm.regs.cs << 4);
+-	insn += context.vm.regs.eip;
++	insn = (unsigned char *)((unsigned int)context.vm.substr.regs.vmsc.sc_cs << 4);
++	insn += context.vm.substr.regs.vmsc.sc_eip;
+ 
+ 	while (1)
+ 		{
+@@ -687,7 +691,7 @@ emulate(void)
+ 			return 0;
+ 		}
+ 
+-	context.vm.regs.eip += i;
++	context.vm.substr.regs.vmsc.sc_eip += i;
+ 	return 1;
+ 	}
+ 
+@@ -723,7 +727,7 @@ lrmi_vm86(struct vm86_struct *vm)
+ 	return r;
+ 	}
+ #else
+-#define lrmi_vm86 vm86
++#define lrmi_vm86 i386_vm86
+ #endif
+ 
+ 
+@@ -735,26 +739,26 @@ debug_info(int vret)
+ 
+ 	fputs("vm86() failed\n", stderr);
+ 	fprintf(stderr, "return = 0x%x\n", vret);
+-	fprintf(stderr, "eax = 0x%08lx\n", context.vm.regs.eax);
+-	fprintf(stderr, "ebx = 0x%08lx\n", context.vm.regs.ebx);
+-	fprintf(stderr, "ecx = 0x%08lx\n", context.vm.regs.ecx);
+-	fprintf(stderr, "edx = 0x%08lx\n", context.vm.regs.edx);
+-	fprintf(stderr, "esi = 0x%08lx\n", context.vm.regs.esi);
+-	fprintf(stderr, "edi = 0x%08lx\n", context.vm.regs.edi);
+-	fprintf(stderr, "ebp = 0x%08lx\n", context.vm.regs.ebp);
+-	fprintf(stderr, "eip = 0x%08lx\n", context.vm.regs.eip);
+-	fprintf(stderr, "cs  = 0x%04x\n", context.vm.regs.cs);
+-	fprintf(stderr, "esp = 0x%08lx\n", context.vm.regs.esp);
+-	fprintf(stderr, "ss  = 0x%04x\n", context.vm.regs.ss);
+-	fprintf(stderr, "ds  = 0x%04x\n", context.vm.regs.ds);
+-	fprintf(stderr, "es  = 0x%04x\n", context.vm.regs.es);
+-	fprintf(stderr, "fs  = 0x%04x\n", context.vm.regs.fs);
+-	fprintf(stderr, "gs  = 0x%04x\n", context.vm.regs.gs);
+-	fprintf(stderr, "eflags  = 0x%08lx\n", context.vm.regs.eflags);
++	fprintf(stderr, "eax = 0x%08lx\n", context.vm.substr.regs.vmsc.sc_eax);
++	fprintf(stderr, "ebx = 0x%08lx\n", context.vm.substr.regs.vmsc.sc_ebx);
++	fprintf(stderr, "ecx = 0x%08lx\n", context.vm.substr.regs.vmsc.sc_ecx);
++	fprintf(stderr, "edx = 0x%08lx\n", context.vm.substr.regs.vmsc.sc_edx);
++	fprintf(stderr, "esi = 0x%08lx\n", context.vm.substr.regs.vmsc.sc_esi);
++	fprintf(stderr, "edi = 0x%08lx\n", context.vm.substr.regs.vmsc.sc_edi);
++	fprintf(stderr, "ebp = 0x%08lx\n", context.vm.substr.regs.vmsc.sc_ebp);
++	fprintf(stderr, "eip = 0x%08lx\n", context.vm.substr.regs.vmsc.sc_eip);
++	fprintf(stderr, "cs  = 0x%04x\n", context.vm.substr.regs.vmsc.sc_cs);
++	fprintf(stderr, "esp = 0x%08lx\n", context.vm.substr.regs.vmsc.sc_esp);
++	fprintf(stderr, "ss  = 0x%04x\n", context.vm.substr.regs.vmsc.sc_ss);
++	fprintf(stderr, "ds  = 0x%04x\n", context.vm.substr.regs.vmsc.sc_ds);
++	fprintf(stderr, "es  = 0x%04x\n", context.vm.substr.regs.vmsc.sc_es);
++	fprintf(stderr, "fs  = 0x%04x\n", context.vm.substr.regs.vmsc.sc_fs);
++	fprintf(stderr, "gs  = 0x%04x\n", context.vm.substr.regs.vmsc.sc_gs);
++	fprintf(stderr, "eflags  = 0x%08lx\n", context.vm.substr.regs.vmsc.sc_eflags);
+ 
+ 	fputs("cs:ip = [ ", stderr);
+ 
+-	p = (unsigned char *)((context.vm.regs.cs << 4) + (context.vm.regs.eip & 0xffff));
++	p = (unsigned char *)((context.vm.substr.regs.vmsc.sc_cs << 4) + (context.vm.substr.regs.vmsc.sc_eip & 0xffff));
+ 
+ 	for (i = 0; i < 16; ++i)
+ 		fprintf(stderr, "%02x ", (unsigned int)p[i]);
+@@ -779,13 +783,13 @@ run_vm86(void)
+ 			if (v == RETURN_TO_32_INT)
+ 				return 1;
+ 
+-			pushw(context.vm.regs.eflags);
+-			pushw(context.vm.regs.cs);
+-			pushw(context.vm.regs.eip);
+-
+-			context.vm.regs.cs = get_int_seg(v);
+-			context.vm.regs.eip = get_int_off(v);
+-			context.vm.regs.eflags &= ~(VIF_MASK | TF_MASK);
++			pushw(context.vm.substr.regs.vmsc.sc_eflags);
++			pushw(context.vm.substr.regs.vmsc.sc_cs);
++			pushw(context.vm.substr.regs.vmsc.sc_eip);
++
++			context.vm.substr.regs.vmsc.sc_cs = get_int_seg(v);
++			context.vm.substr.regs.vmsc.sc_eip = get_int_off(v);
++			context.vm.substr.regs.vmsc.sc_eflags &= ~(PSL_VIF | PSL_T);
+ 
+ 			continue;
+ 			}
+@@ -808,22 +812,20 @@ LRMI_call(struct LRMI_regs *r)
+ 	{
+ 	unsigned int vret;
+ 
+-	memset(&context.vm.regs, 0, sizeof(context.vm.regs));
+-
+ 	set_regs(r);
+ 
+-	context.vm.regs.cs = r->cs;
+-	context.vm.regs.eip = r->ip;
++	context.vm.substr.regs.vmsc.sc_cs = r->cs;
++	context.vm.substr.regs.vmsc.sc_eip = r->ip;
+ 
+ 	if (r->ss == 0 && r->sp == 0)
+ 		{
+-		context.vm.regs.ss = context.stack_seg;
+-		context.vm.regs.esp = context.stack_off;
++		context.vm.substr.regs.vmsc.sc_ss = context.stack_seg;
++		context.vm.substr.regs.vmsc.sc_esp = context.stack_off;
+ 		}
+ 	else
+ 		{
+-		context.vm.regs.ss = r->ss;
+-		context.vm.regs.esp = r->sp;
++		context.vm.substr.regs.vmsc.sc_ss = r->ss;
++		context.vm.substr.regs.vmsc.sc_esp = r->sp;
+ 		}
+ 
+ 	pushw(context.ret_seg);
+@@ -856,22 +858,20 @@ LRMI_int(int i, struct LRMI_regs *r)
+ 		return 0;
+ 		}
+ 
+-	memset(&context.vm.regs, 0, sizeof(context.vm.regs));
+-
+ 	set_regs(r);
+ 
+-	context.vm.regs.cs = seg;
+-	context.vm.regs.eip = off;
++	context.vm.substr.regs.vmsc.sc_cs = seg;
++	context.vm.substr.regs.vmsc.sc_eip = off;
+ 
+ 	if (r->ss == 0 && r->sp == 0)
+ 		{
+-		context.vm.regs.ss = context.stack_seg;
+-		context.vm.regs.esp = context.stack_off;
++		context.vm.substr.regs.vmsc.sc_ss = context.stack_seg;
++		context.vm.substr.regs.vmsc.sc_esp = context.stack_off;
+ 		}
+ 	else
+ 		{
+-		context.vm.regs.ss = r->ss;
+-		context.vm.regs.esp = r->sp;
++		context.vm.substr.regs.vmsc.sc_ss = r->ss;
++		context.vm.substr.regs.vmsc.sc_esp = r->sp;
+ 		}
+ 
+ 	pushw(DEFAULT_VM86_FLAGS);
diff --git a/svgalib64/patches/patch-bb b/svgalib64/patches/patch-bb
new file mode 100644
index 0000000000..0dedf1ab22
--- /dev/null
+++ b/svgalib64/patches/patch-bb
@@ -0,0 +1,25 @@
+$NetBSD: patch-bb,v 1.1 2003/07/31 15:13:39 bencollver Exp $
+
+--- src/g400.c.orig	Wed Jul 30 07:06:43 2003
++++ src/g400.c
+@@ -593,9 +593,20 @@ static int g400_test(void)
+ {
+     int found, id;
+     unsigned long buf[64];
++    int _ioperm=0;
++     
++    if (getenv("IOPERM") == NULL) {
++       _ioperm=1;
++        if (iopl(3) < 0) {
++          printf("svgalib: cannot get I/O permissions\n");
++          exit(1);
++        }
++    }
+     
+     found=__svgalib_pci_find_vendor_vga(VENDOR_ID,buf,0);
+     
++    if (_ioperm) iopl(0);
++
+     if(found) return 0;
+     
+     id=(buf[0]>>16)&0xffff;
diff --git a/svgalib64/patches/patch-ca b/svgalib64/patches/patch-ca
new file mode 100644
index 0000000000..3b3c8699e6
--- /dev/null
+++ b/svgalib64/patches/patch-ca
@@ -0,0 +1,679 @@
+diff -Naur svgalib-1.4.3.orig/HACKING svgalib-1.4.3-nbsd/HACKING
+--- svgalib-1.4.3.orig/HACKING	1970-01-01 01:00:00.000000000 +0100
++++ svgalib-1.4.3-nbsd/HACKING	2025-02-18 14:36:03.045132620 +0100
+@@ -0,0 +1,15 @@
++HACKING File 
++
++
++
++Of 18 Feb 2025 :
++----------------
++
++The work on the Intel HD Graphics (IHD) has started, we need it for an intel 
++Atom computer (smartpads) and more up-to-date hardware.
++
++The Atoms are mostly 11.6" screen diagonal and use 1366x768 as a resolution
++with WXGA as a screen. 
++
++See ihd.c in the src directory.
++
+diff -Naur svgalib-1.4.3.orig/Makefile.cfg svgalib-1.4.3-nbsd/Makefile.cfg
+--- svgalib-1.4.3.orig/Makefile.cfg	2025-02-18 10:23:12.209757756 +0100
++++ svgalib-1.4.3-nbsd/Makefile.cfg	2025-02-18 11:53:55.311140360 +0100
+@@ -140,6 +140,7 @@
+ INCLUDE_NV3_DRIVER = y
+ INCLUDE_ET6000_DRIVER = y
+ INCLUDE_VESA_DRIVER = y
++INCLUDE_IHD_DRIVER = y
+ INCLUDE_MX_DRIVER = y
+ INCLUDE_PARADISE_DRIVER = y
+ INCLUDE_RAGE_DRIVER = y
+@@ -171,6 +172,7 @@
+ INCLUDE_APM_DRIVER_TEST = y
+ INCLUDE_NV3_DRIVER_TEST = y
+ INCLUDE_ET6000_DRIVER_TEST = y
++INCLUDE_IHD_DRIVER_TEST = y
+ INCLUDE_MX_DRIVER_TEST = y
+ INCLUDE_PARADISE_DRIVER_TEST = y
+ INCLUDE_RAGE_DRIVER_TEST = y
+diff -Naur svgalib-1.4.3.orig/include/vga.h svgalib-1.4.3-nbsd/include/vga.h
+--- svgalib-1.4.3.orig/include/vga.h	2025-02-18 10:23:12.360150109 +0100
++++ svgalib-1.4.3-nbsd/include/vga.h	2025-02-18 14:11:27.468507143 +0100
+@@ -360,6 +360,7 @@
+ #define G400		29
+ #define R128		30
+ #define SAVAGE		31
++#define IHD		32
+ 
+     /* Hor. sync: */
+ #define MON640_60	0	/* 31.5 KHz (standard VGA) */
+diff -Naur svgalib-1.4.3.orig/src/Makefile svgalib-1.4.3-nbsd/src/Makefile
+--- svgalib-1.4.3.orig/src/Makefile	2025-02-18 10:23:12.364759064 +0100
++++ svgalib-1.4.3-nbsd/src/Makefile	2025-02-18 11:50:45.628448772 +0100
+@@ -187,6 +187,13 @@
+     VGA_DEFINES += -DINCLUDE_VESA_DRIVER_TEST
+   endif
+ endif
++ifdef INCLUDE_IHD_DRIVER
++  VGA_DEFINES +=-DINCLUDE_IHD_DRIVER
++  DRIVERS += ihd.o
++  ifdef INCLUDE_IHD_DRIVER_TEST
++    VGA_DEFINES += -DINCLUDE_IHD_DRIVER_TEST
++  endif
++endif
+ ifdef INCLUDE_NV3_DRIVER
+   VGA_DEFINES +=-DINCLUDE_NV3_DRIVER
+   DRIVERS += nv3.o
+diff -Naur svgalib-1.4.3.orig/src/_types.h svgalib-1.4.3-nbsd/src/_types.h
+--- svgalib-1.4.3.orig/src/_types.h	1970-01-01 01:00:00.000000000 +0100
++++ svgalib-1.4.3-nbsd/src/_types.h	2025-02-18 10:38:07.488947844 +0100
+@@ -0,0 +1,29 @@
++/* VGAlib version 1.4.3 - (c) 2025 Zanthia of Silverhawk Software  */
++/*                                                                 */
++/* This library is free software; you can redistribute it and/or   */
++/* modify it without any restrictions. This library is distributed */
++/* in the hope that it will be useful, but without any warranty.   */
++
++#ifndef __TYPES_H
++#define __TYPES_H
++
++/* byte and character */
++typedef unsigned char byte;
++typedef unsigned char u8;
++
++typedef unsigned char uint8;
++
++/* NOTE : redefine these for good measure */
++typedef unsigned short int u16;
++typedef unsigned int u32;
++typedef unsigned long int u64;
++
++typedef unsigned short int uint16;
++typedef unsigned int uint32;
++typedef unsigned long int uint64;
++
++/* optional */
++typedef void *id;
++typedef void *void_ptr;
++
++#endif
+diff -Naur svgalib-1.4.3.orig/src/driver.h svgalib-1.4.3-nbsd/src/driver.h
+--- svgalib-1.4.3.orig/src/driver.h	2025-02-18 10:23:12.371438290 +0100
++++ svgalib-1.4.3-nbsd/src/driver.h	2025-02-18 14:08:21.959799848 +0100
+@@ -82,6 +82,7 @@
+ extern DriverSpecs __svgalib_nv3_driverspecs;
+ extern DriverSpecs __svgalib_et6000_driverspecs;
+ extern DriverSpecs __svgalib_vesa_driverspecs;
++extern DriverSpecs __svgalib_ihd_driverspecs;
+ extern DriverSpecs __svgalib_mx_driverspecs;
+ extern DriverSpecs __svgalib_paradise_driverspecs;
+ extern DriverSpecs __svgalib_rage_driverspecs;
+diff -Naur svgalib-1.4.3.orig/src/drivers svgalib-1.4.3-nbsd/src/drivers
+--- svgalib-1.4.3.orig/src/drivers	2025-02-18 10:23:12.418179564 +0100
++++ svgalib-1.4.3-nbsd/src/drivers	2025-02-18 14:06:20.868420995 +0100
+@@ -18,6 +18,7 @@
+ s3.c		v	v
+ tvga8900.c	v	v
+ vesa.c		v	v
++ihd.c		v	
+ vgadrv.c	v	v
+ rage.c		v	v
+ sis.c		v	v
+diff -Naur svgalib-1.4.3.orig/src/ihd.c svgalib-1.4.3-nbsd/src/ihd.c
+--- svgalib-1.4.3.orig/src/ihd.c	1970-01-01 01:00:00.000000000 +0100
++++ svgalib-1.4.3-nbsd/src/ihd.c	2025-02-18 12:00:16.520229366 +0100
+@@ -0,0 +1,543 @@
++/* VGAlib version 1.4.3 - (c) 2025 Zanthia of Silverhawk Software  */
++/*                                                                 */
++/* This library is free software; you can redistribute it and/or   */
++/* modify it without any restrictions. This library is distributed */
++/* in the hope that it will be useful, but without any warranty.   */
++
++/*
++Intel HD driver (WIP)
++*/
++
++
++#include <stdlib.h>
++#include <stdio.h>		/* for printf */
++#include <string.h>		/* for memset */
++#include <unistd.h>
++#include "vga.h"
++#include "libvga.h"
++#include "driver.h"
++
++
++/* New style driver interface. */
++#include "timing.h"
++#include "vgaregs.h"
++#include "interface.h"
++#include "accel.h"
++#include "vgapci.h"
++
++#define IHDREG_SAVE(i) (VGA_TOTAL_REGS+i)
++#define IHD_TOTAL_REGS (VGA_TOTAL_REGS + 2 + 40)
++
++static int ihd_init(int, int, int);
++static void ihd_unlock(void);
++static void ihd_lock(void);
++
++void __svgalib_ihdaccel_init(AccelSpecs * accelspecs, int bpp, int width_in_pixels);
++
++static int ihd_memory,ihd_chiptype;
++static int ihd_is_linear, ihd_linear_base, ihd_io_base;
++
++static CardSpecs *cardspecs;
++
++static void ihd_setpage(int page)
++{
++   page<<=1;
++   outl(ihd_io_base+0x2c,(inl(ihd_io_base+0x2c)&0xfff00000)|(page)|(page<<10));
++}
++
++static int __svgalib_ihd_inlinearmode(void)
++{
++return ihd_is_linear;
++}
++
++/* Fill in chipset specific mode information */
++
++static void ihd_getmodeinfo(int mode, vga_modeinfo *modeinfo)
++{
++
++    if(modeinfo->colors==16)return;
++
++    modeinfo->maxpixels = ihd_memory*1024/modeinfo->bytesperpixel;
++    modeinfo->maxlogicalwidth = 4088;
++    modeinfo->startaddressrange = ihd_memory * 1024 - 1;
++    modeinfo->haveblit = 0;
++    modeinfo->flags &= ~HAVE_RWPAGE;
++
++    if (modeinfo->bytesperpixel >= 1) {
++	if(ihd_linear_base)modeinfo->flags |= CAPABLE_LINEAR;
++        if (__svgalib_ihd_inlinearmode())
++	    modeinfo->flags |= IS_LINEAR;
++    }
++}
++
++/* Read and save chipset-specific registers */
++
++typedef struct {
++   unsigned int pllCtrl0, pllCtrl1, dacMode, dacAddr,
++      		vidProcCfg, vidScreenSize, vgaInit0,
++                vgaInit1, vidDesktopStartAddr,vidDesktopOverlayStride;
++} *HWRecPtr;
++
++static int ihd_saveregs(unsigned char regs[])
++{ 
++  HWRecPtr save;
++
++  ihd_unlock();		/* May be locked again by other programs (e.g. X) */
++  
++  save=(HWRecPtr)(regs+62);
++  
++  regs[IHDREG_SAVE(0)]=__svgalib_inCR(0x1a);
++  regs[IHDREG_SAVE(1)]=__svgalib_inCR(0x1b);
++  save->pllCtrl0=inl(ihd_io_base+0x40);
++  save->pllCtrl1=inl(ihd_io_base+0x44);
++  save->dacMode=inl(ihd_io_base+0x4c);
++  save->dacAddr=inl(ihd_io_base+0x50);
++  save->vidProcCfg=inl(ihd_io_base+0x5c);
++  save->vidScreenSize=inl(ihd_io_base+0x98);
++  save->vgaInit0=inl(ihd_io_base+0x28);
++  save->vgaInit1=inl(ihd_io_base+0x2c);
++  save->vidDesktopStartAddr=inl(ihd_io_base+0xe4);
++  save->vidDesktopOverlayStride=inl(ihd_io_base+0xe8);
++  
++  return IHD_TOTAL_REGS - VGA_TOTAL_REGS;
++}
++
++/* Set chipset-specific registers */
++
++static void ihd_setregs(const unsigned char regs[], int mode)
++{  
++    HWRecPtr restore;
++
++    ihd_unlock();		/* May be locked again by other programs (eg. X) */
++  
++    restore=(HWRecPtr)(regs+62);
++  
++    __svgalib_outCR(0x1a,regs[IHDREG_SAVE(0)]);
++    __svgalib_outCR(0x1b,regs[IHDREG_SAVE(1)]);
++    outl(ihd_io_base+0x40,restore->pllCtrl0);
++    outl(ihd_io_base+0x44,restore->pllCtrl1);
++    outl(ihd_io_base+0x4c,restore->dacMode);
++    outl(ihd_io_base+0x50,restore->dacAddr);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg);
++    outl(ihd_io_base+0x98,restore->vidScreenSize);
++    outl(ihd_io_base+0x28,restore->vgaInit0);
++    outl(ihd_io_base+0x2c,restore->vgaInit1);
++    outl(ihd_io_base+0xe4,restore->vidDesktopStartAddr);
++    outl(ihd_io_base+0xe8,restore->vidDesktopOverlayStride);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg&0xfffffffe);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg|1);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg);
++
++}
++
++/* Return nonzero if mode is available */
++
++static int ihd_modeavailable(int mode)
++{
++    struct info *info;
++    ModeTiming *modetiming;
++    ModeInfo *modeinfo;
++
++    if ((mode < G640x480x256 )
++	|| mode == G720x348x2)
++	return __svgalib_vga_driverspecs.modeavailable(mode);
++
++    info = &__svgalib_infotable[mode];
++    if (ihd_memory * 1024 < info->ydim * info->xbytes)
++	return 0;
++
++    modeinfo = __svgalib_createModeInfoStructureForSvgalibMode(mode);
++
++    if((modeinfo->bitsPerPixel==16)&&(modeinfo->greenWeight==5)) {
++	free(modeinfo);
++        return 0;
++    }
++
++    modetiming = malloc(sizeof(ModeTiming));
++    if (__svgalib_getmodetiming(modetiming, modeinfo, cardspecs)) {
++	free(modetiming);
++	return 0;
++    }
++    free(modetiming);
++    free(modeinfo);
++
++    return SVGADRV;
++}
++
++static unsigned comp_lmn(int freq) ;
++/* Set a mode */
++
++/* Local, called by ihd_setmode(). */
++
++static void ihd_initializemode(unsigned char *moderegs,
++			    ModeTiming * modetiming, ModeInfo * modeinfo, int mode)
++{ /* long k; */
++
++    int vd,vt,vbs,vbe,ht,hd,hss,hse;
++
++    HWRecPtr ihd_regs;
++
++    ihd_regs=(HWRecPtr)(moderegs+62);
++   
++    ihd_saveregs(moderegs);
++
++    __svgalib_setup_VGA_registers(moderegs, modetiming, modeinfo);
++
++    hd = (modetiming->CrtcHDisplay>>3)-1;
++    hss = (modetiming->CrtcHSyncStart>>3);
++    hse = (modetiming->CrtcHSyncEnd>>3);
++    ht = (modetiming->CrtcHTotal>>3)-5;
++    moderegs[IHDREG_SAVE(0)]=((ht&0x100)>>8) |
++       			    ((hd&0x100)>>6) |
++                            ((hd&0x100)>>4) |
++                            ((ht&0x40)>>1) |
++                            ((hss&0x100)>>2) |
++                            ((hse&0x20)<<2) ; 
++
++    vd    = modetiming->CrtcVDisplay - 1;
++    vt = modetiming->CrtcVTotal - 2;
++    vbs  = modetiming->CrtcVSyncStart - 1;
++    vbe  = vt; 
++    moderegs[IHDREG_SAVE(1)]=((vt & 0x400)>>10) | 
++		            ((vd  & 0x400)>>8) |
++		            ((vbs & 0x400)>>6) |
++		            ((vbe & 0x400)>>4);
++/*
++    if (modetiming->flags & INTERLACED)
++	    moderegs[MXREG_SAVE(3)] |= 0x8;
++*/
++
++    ihd_regs->vidProcCfg&=0xf7e30000;
++    ihd_regs->vidProcCfg|=0x00000c81;
++
++    ihd_regs->vidScreenSize=modeinfo->width|(modeinfo->height<<12);
++
++    if (modetiming->flags & DOUBLESCAN)
++	    ihd_regs->vidProcCfg |= 0x10;
++
++    switch (modeinfo->bitsPerPixel)
++    {
++	    case 8: 
++               	    ihd_regs->vidProcCfg|=0<<18;
++		    break;
++	    case 15: 
++	    case 16:if(modeinfo->greenWeight==5){
++                        ihd_regs->vidProcCfg|=1<<18;
++                    } else ihd_regs->vidProcCfg|=1<<18;
++		    break;
++	    case 24: 
++               	    ihd_regs->vidProcCfg|=2<<18;
++		    break;
++	    case 32: 
++               	    ihd_regs->vidProcCfg|=3<<18;
++		    break;
++	    default: 
++		    break;
++    }
++    
++    ihd_regs->vgaInit0&=0xfffffffb;
++    if(modeinfo->bitsPerPixel!=8){
++        ihd_regs->vgaInit0|=4;
++    };
++
++    ihd_regs->pllCtrl0=comp_lmn(modetiming->pixelClock);
++    moderegs[VGA_MISCOUTPUT]|=0x0c;
++
++    ihd_regs->vidDesktopStartAddr=0;
++    ihd_regs->vidDesktopOverlayStride=modeinfo->lineWidth;    
++
++    ihd_regs->vgaInit0=0x1140;
++    ihd_regs->vgaInit1=0x00100000;
++
++    moderegs[41]=0;
++
++    if(modeinfo->bitsPerPixel==8){
++       moderegs[79]=0;
++    };
++
++    ihd_is_linear=0;
++
++return ;
++
++}
++
++static int ihd_setmode(int mode, int prv_mode)
++{
++    unsigned char *moderegs;
++    ModeTiming modetiming;
++    ModeInfo *modeinfo;
++
++    if ((mode < G640x480x256 /*&& mode != G320x200x256*/)
++	|| mode == G720x348x2) {
++
++	return __svgalib_vga_driverspecs.setmode(mode, prv_mode);
++    }
++    if (!ihd_modeavailable(mode))
++	return 1;
++
++    modeinfo = __svgalib_createModeInfoStructureForSvgalibMode(mode);
++
++    if (__svgalib_getmodetiming(&modetiming, modeinfo, cardspecs)) {
++	free(modeinfo);
++	return 1;
++    }
++
++    moderegs = malloc(IHD_TOTAL_REGS);
++
++    ihd_initializemode(moderegs, &modetiming, modeinfo, mode);
++
++    __svgalib_setregs(moderegs);	/* Set standard regs. */
++    ihd_setregs(moderegs, mode);		/* Set extended regs. */
++    free(moderegs);
++
++    __svgalib_InitializeAcceleratorInterface(modeinfo);
++
++    free(modeinfo);
++
++
++    return 0;
++}
++
++
++/* Unlock chipset-specific registers */
++
++static void ihd_unlock(void)
++{
++    int vgaIOBase, temp;
++
++    vgaIOBase = (inb(0x3CC) & 0x01) ? 0x3D0 : 0x3B0;
++    outb(vgaIOBase + 4, 0x11);
++    temp = inb(vgaIOBase + 5);
++    outb(vgaIOBase + 5, temp & 0x7F);
++    
++    outl(ihd_io_base+0x28,(inl(ihd_io_base+0x28)&0xffffffbf)|(1<<6));
++}
++
++static void ihd_lock(void)
++{
++    int vgaIOBase, temp;
++
++    vgaIOBase = (inb(0x3CC) & 0x01) ? 0x3D0 : 0x3B0;
++    outb(vgaIOBase + 4, 0x11);
++    temp = inb(vgaIOBase + 5);
++    outb(vgaIOBase + 5, temp & 0x7F);
++    
++    outl(ihd_io_base+0x28,(inl(ihd_io_base+0x28)&0xffffffbf));
++}
++
++
++/* Indentify chipset, initialize and return non-zero if detected */
++
++static int ihd_test(void)
++{
++   int found,_ioperm=0;
++   unsigned long buf[64];
++
++   if (getenv("IOPERM") == NULL) {
++      _ioperm=1;
++      if (iopl(3) < 0) {
++        printf("svgalib: ihd: cannot get I/O permissions\n");
++        exit(1);
++      }
++   }
++   found=(!__svgalib_pci_find_vendor_vga(0x121a,buf,0))&&
++          (((buf[0]>>16)==0x0003)||
++          ((buf[0]>>16)==0x0009)||
++          ((buf[0]>>16)==0x0005));
++    
++   if (_ioperm) iopl(0);
++
++   if(found)ihd_init(0,0,0); 
++   return found;
++}
++
++
++/* Set display start address (not for 16 color modes) */
++/* Cirrus supports any address in video memory (up to 2Mb) */
++
++static void ihd_setdisplaystart(int address)
++{ 
++  outw(CRT_IC, ((address>>2) & 0x00FF00) | 0x0C);
++  outw(CRT_IC, (((address>>2) & 0x00FF) << 8) | 0x0D);
++  outl(ihd_io_base+0xe4,address);
++
++}
++
++
++/* Set logical scanline length (usually multiple of 8) */
++
++static void ihd_setlogicalwidth(int width)
++{   
++    int offset = width >> 3;
++ 
++    __svgalib_outCR(0x13,offset&0xff);
++    outl(ihd_io_base+0xe8,width);
++}
++
++static int ihd_linear(int op, int param)
++{
++if (op==LINEAR_ENABLE || op==LINEAR_DISABLE){ ihd_is_linear=1-ihd_is_linear; return 0;}
++if (op==LINEAR_QUERY_BASE) return ihd_linear_base;
++if (op == LINEAR_QUERY_RANGE || op == LINEAR_QUERY_GRANULARITY) return 0;		/* No granularity or range. */
++    else return -1;		/* Unknown function. */
++}
++
++static int ihd_match_programmable_clock(int clock)
++{
++return clock ;
++}
++
++static int ihd_map_clock(int bpp, int clock)
++{
++return clock ;
++}
++
++static int ihd_map_horizontal_crtc(int bpp, int pixelclock, int htiming)
++{
++return htiming;
++}
++
++/* Function table (exported) */
++
++DriverSpecs __svgalib_ihd_driverspecs =
++{
++    ihd_saveregs,
++    ihd_setregs,
++    ihd_unlock,
++    ihd_lock,
++    ihd_test,
++    ihd_init,
++    ihd_setpage,
++    NULL,
++    NULL,
++    ihd_setmode,
++    ihd_modeavailable,
++    ihd_setdisplaystart,
++    ihd_setlogicalwidth,
++    ihd_getmodeinfo,
++    0,				/* old blit funcs */
++    0,
++    0,
++    0,
++    0,
++    0,				/* ext_set */
++    0,				/* accel */
++    ihd_linear,
++    0,				/* accelspecs, filled in during init. */
++    NULL,                       /* Emulation */
++};
++
++/* Initialize chipset (called after detection) */
++
++static int ihd_init(int force, int par1, int par2)
++{
++    unsigned long buf[64];
++    int found=0;
++    int _ioperm=0;
++
++    if (force) {
++	ihd_memory = par1;
++        ihd_chiptype = par2;
++    } else {
++
++    };
++    
++    if (getenv("IOPERM") == NULL) {
++      _ioperm=1;
++      if (iopl(3) < 0) {
++        printf("svgalib: ihd: cannot get I/O permissions\n");
++        exit(1);
++      }
++    }
++     
++    found=(!__svgalib_pci_find_vendor_vga(0x121a,buf,0))&&
++            (((buf[0]>>16)==0x0003)||
++            ((buf[0]>>16)==0x0009)||
++            ((buf[0]>>16)==0x0005));
++    
++/*     if (_ioperm) iopl(0);*/
++    if (found){
++       ihd_linear_base=buf[5]&0xffffff00;
++       ihd_io_base=buf[6]&0xff00;
++    };
++
++    if(ihd_memory==0) {
++       unsigned int draminit0,draminit1;
++       
++       draminit0=inl(ihd_io_base+0x18);
++       draminit1=inl(ihd_io_base+0x1c);
++       if(draminit1&0x40000000) {
++          /* SDRAM */
++          ihd_memory=16*1024;
++       } else {
++          /* SGRAM */
++          ihd_memory=1024*4*
++             (1+((draminit0>>27)&1))* /* SGRAM type - 8MBIT or 16MBIT */
++             (1+((draminit0>>26)&1)); /* Number of sgram chips (4 or 8) */
++       }
++    }
++    
++    ihd_unlock();
++    
++    if (__svgalib_driver_report) {
++	printf("Using Banshee / Voodoo3 driver, %iKB.\n",ihd_memory);
++    }
++    
++    cardspecs = malloc(sizeof(CardSpecs));
++    cardspecs->videoMemory = ihd_memory;
++    cardspecs->maxPixelClock4bpp = 270000;	
++    cardspecs->maxPixelClock8bpp = 270000;	
++    cardspecs->maxPixelClock16bpp = 270000;	
++    cardspecs->maxPixelClock24bpp = 270000;
++    cardspecs->maxPixelClock32bpp = 270000;
++    cardspecs->flags = INTERLACE_DIVIDE_VERT | CLOCK_PROGRAMMABLE;
++    cardspecs->maxHorizontalCrtc = 4088;
++    cardspecs->maxPixelClock4bpp = 0;
++    cardspecs->nClocks =0;
++    cardspecs->mapClock = ihd_map_clock;
++    cardspecs->mapHorizontalCrtc = ihd_map_horizontal_crtc;
++    cardspecs->matchProgrammableClock=ihd_match_programmable_clock;
++    __svgalib_driverspecs = &__svgalib_ihd_driverspecs;
++    __svgalib_banked_mem_base=0xa0000;
++    __svgalib_banked_mem_size=0x10000;
++    __svgalib_linear_mem_base=ihd_linear_base;
++    __svgalib_linear_mem_size=ihd_memory*0x400;
++    return 0;
++}
++
++#define REFFREQ 14318.18
++
++static unsigned
++comp_lmn(int freq)
++{
++  int m, n, k, best_m, best_n, best_k, f_cur, best_error;
++
++  best_error=freq;
++  best_n=best_m=best_k=0;
++  for (n=1; n<256; n++) {
++    f_cur=REFFREQ*(n+2);
++    if (f_cur<freq) {
++      f_cur=f_cur/3;
++      if (freq-f_cur<best_error) {
++        best_error=freq-f_cur;
++        best_n=n;
++        best_m=1;
++        best_k=0;
++        continue;
++      }
++    }
++    for (m=1; m<64; m++) {
++      for (k=0; k<4; k++) {
++        f_cur=REFFREQ*(n+2)/(m+2)/(1<<k);
++        if (abs(f_cur-freq)<best_error) {
++          best_error=abs(f_cur-freq);
++          best_n=n;
++          best_m=m;
++          best_k=k;
++	}
++      }
++    }
++  }
++  return (best_n << 8) | (best_m<<2) | best_k;
++}
++
+diff -Naur svgalib-1.4.3.orig/src/vga.h svgalib-1.4.3-nbsd/src/vga.h
+--- svgalib-1.4.3.orig/src/vga.h	2025-02-18 10:23:12.408464645 +0100
++++ svgalib-1.4.3-nbsd/src/vga.h	2025-02-18 14:11:27.468507143 +0100
+@@ -360,6 +360,7 @@
+ #define G400		29
+ #define R128		30
+ #define SAVAGE		31
++#define IHD		32
+ 
+     /* Hor. sync: */
+ #define MON640_60	0	/* 31.5 KHz (standard VGA) */
diff --git a/svgalib64/patches/patch-ca.0.1.1 b/svgalib64/patches/patch-ca.0.1.1
new file mode 100644
index 0000000000..40a10d0f1c
--- /dev/null
+++ b/svgalib64/patches/patch-ca.0.1.1
@@ -0,0 +1,616 @@
+diff -Naur svgalib-1.4.3.orig/Makefile.cfg svgalib-1.4.3-nbsd/Makefile.cfg
+--- svgalib-1.4.3.orig/Makefile.cfg	2025-02-18 10:23:12.209757756 +0100
++++ svgalib-1.4.3-nbsd/Makefile.cfg	2025-02-18 11:53:55.311140360 +0100
+@@ -140,6 +140,7 @@
+ INCLUDE_NV3_DRIVER = y
+ INCLUDE_ET6000_DRIVER = y
+ INCLUDE_VESA_DRIVER = y
++INCLUDE_IHD_DRIVER = y
+ INCLUDE_MX_DRIVER = y
+ INCLUDE_PARADISE_DRIVER = y
+ INCLUDE_RAGE_DRIVER = y
+@@ -171,6 +172,7 @@
+ INCLUDE_APM_DRIVER_TEST = y
+ INCLUDE_NV3_DRIVER_TEST = y
+ INCLUDE_ET6000_DRIVER_TEST = y
++INCLUDE_IHD_DRIVER_TEST = y
+ INCLUDE_MX_DRIVER_TEST = y
+ INCLUDE_PARADISE_DRIVER_TEST = y
+ INCLUDE_RAGE_DRIVER_TEST = y
+diff -Naur svgalib-1.4.3.orig/src/Makefile svgalib-1.4.3-nbsd/src/Makefile
+--- svgalib-1.4.3.orig/src/Makefile	2025-02-18 10:23:12.364759064 +0100
++++ svgalib-1.4.3-nbsd/src/Makefile	2025-02-18 11:50:45.628448772 +0100
+@@ -187,6 +187,13 @@
+     VGA_DEFINES += -DINCLUDE_VESA_DRIVER_TEST
+   endif
+ endif
++ifdef INCLUDE_IHD_DRIVER
++  VGA_DEFINES +=-DINCLUDE_IHD_DRIVER
++  DRIVERS += ihd.o
++  ifdef INCLUDE_IHD_DRIVER_TEST
++    VGA_DEFINES += -DINCLUDE_IHD_DRIVER_TEST
++  endif
++endif
+ ifdef INCLUDE_NV3_DRIVER
+   VGA_DEFINES +=-DINCLUDE_NV3_DRIVER
+   DRIVERS += nv3.o
+diff -Naur svgalib-1.4.3.orig/src/_types.h svgalib-1.4.3-nbsd/src/_types.h
+--- svgalib-1.4.3.orig/src/_types.h	1970-01-01 01:00:00.000000000 +0100
++++ svgalib-1.4.3-nbsd/src/_types.h	2025-02-18 10:38:07.488947844 +0100
+@@ -0,0 +1,29 @@
++/* VGAlib version 1.4.3 - (c) 2025 Zanthia of Silverhawk Software  */
++/*                                                                 */
++/* This library is free software; you can redistribute it and/or   */
++/* modify it without any restrictions. This library is distributed */
++/* in the hope that it will be useful, but without any warranty.   */
++
++#ifndef __TYPES_H
++#define __TYPES_H
++
++/* byte and character */
++typedef unsigned char byte;
++typedef unsigned char u8;
++
++typedef unsigned char uint8;
++
++/* NOTE : redefine these for good measure */
++typedef unsigned short int u16;
++typedef unsigned int u32;
++typedef unsigned long int u64;
++
++typedef unsigned short int uint16;
++typedef unsigned int uint32;
++typedef unsigned long int uint64;
++
++/* optional */
++typedef void *id;
++typedef void *void_ptr;
++
++#endif
+diff -Naur svgalib-1.4.3.orig/src/ihd.c svgalib-1.4.3-nbsd/src/ihd.c
+--- svgalib-1.4.3.orig/src/ihd.c	1970-01-01 01:00:00.000000000 +0100
++++ svgalib-1.4.3-nbsd/src/ihd.c	2025-02-18 12:00:16.520229366 +0100
+@@ -0,0 +1,543 @@
++/* VGAlib version 1.4.3 - (c) 2025 Zanthia of Silverhawk Software  */
++/*                                                                 */
++/* This library is free software; you can redistribute it and/or   */
++/* modify it without any restrictions. This library is distributed */
++/* in the hope that it will be useful, but without any warranty.   */
++
++/*
++Intel HD driver (WIP)
++*/
++
++
++#include <stdlib.h>
++#include <stdio.h>		/* for printf */
++#include <string.h>		/* for memset */
++#include <unistd.h>
++#include "vga.h"
++#include "libvga.h"
++#include "driver.h"
++
++
++/* New style driver interface. */
++#include "timing.h"
++#include "vgaregs.h"
++#include "interface.h"
++#include "accel.h"
++#include "vgapci.h"
++
++#define IHDREG_SAVE(i) (VGA_TOTAL_REGS+i)
++#define IHD_TOTAL_REGS (VGA_TOTAL_REGS + 2 + 40)
++
++static int ihd_init(int, int, int);
++static void ihd_unlock(void);
++static void ihd_lock(void);
++
++void __svgalib_ihdaccel_init(AccelSpecs * accelspecs, int bpp, int width_in_pixels);
++
++static int ihd_memory,ihd_chiptype;
++static int ihd_is_linear, ihd_linear_base, ihd_io_base;
++
++static CardSpecs *cardspecs;
++
++static void ihd_setpage(int page)
++{
++   page<<=1;
++   outl(ihd_io_base+0x2c,(inl(ihd_io_base+0x2c)&0xfff00000)|(page)|(page<<10));
++}
++
++static int __svgalib_ihd_inlinearmode(void)
++{
++return ihd_is_linear;
++}
++
++/* Fill in chipset specific mode information */
++
++static void ihd_getmodeinfo(int mode, vga_modeinfo *modeinfo)
++{
++
++    if(modeinfo->colors==16)return;
++
++    modeinfo->maxpixels = ihd_memory*1024/modeinfo->bytesperpixel;
++    modeinfo->maxlogicalwidth = 4088;
++    modeinfo->startaddressrange = ihd_memory * 1024 - 1;
++    modeinfo->haveblit = 0;
++    modeinfo->flags &= ~HAVE_RWPAGE;
++
++    if (modeinfo->bytesperpixel >= 1) {
++	if(ihd_linear_base)modeinfo->flags |= CAPABLE_LINEAR;
++        if (__svgalib_ihd_inlinearmode())
++	    modeinfo->flags |= IS_LINEAR;
++    }
++}
++
++/* Read and save chipset-specific registers */
++
++typedef struct {
++   unsigned int pllCtrl0, pllCtrl1, dacMode, dacAddr,
++      		vidProcCfg, vidScreenSize, vgaInit0,
++                vgaInit1, vidDesktopStartAddr,vidDesktopOverlayStride;
++} *HWRecPtr;
++
++static int ihd_saveregs(unsigned char regs[])
++{ 
++  HWRecPtr save;
++
++  ihd_unlock();		/* May be locked again by other programs (e.g. X) */
++  
++  save=(HWRecPtr)(regs+62);
++  
++  regs[IHDREG_SAVE(0)]=__svgalib_inCR(0x1a);
++  regs[IHDREG_SAVE(1)]=__svgalib_inCR(0x1b);
++  save->pllCtrl0=inl(ihd_io_base+0x40);
++  save->pllCtrl1=inl(ihd_io_base+0x44);
++  save->dacMode=inl(ihd_io_base+0x4c);
++  save->dacAddr=inl(ihd_io_base+0x50);
++  save->vidProcCfg=inl(ihd_io_base+0x5c);
++  save->vidScreenSize=inl(ihd_io_base+0x98);
++  save->vgaInit0=inl(ihd_io_base+0x28);
++  save->vgaInit1=inl(ihd_io_base+0x2c);
++  save->vidDesktopStartAddr=inl(ihd_io_base+0xe4);
++  save->vidDesktopOverlayStride=inl(ihd_io_base+0xe8);
++  
++  return IHD_TOTAL_REGS - VGA_TOTAL_REGS;
++}
++
++/* Set chipset-specific registers */
++
++static void ihd_setregs(const unsigned char regs[], int mode)
++{  
++    HWRecPtr restore;
++
++    ihd_unlock();		/* May be locked again by other programs (eg. X) */
++  
++    restore=(HWRecPtr)(regs+62);
++  
++    __svgalib_outCR(0x1a,regs[IHDREG_SAVE(0)]);
++    __svgalib_outCR(0x1b,regs[IHDREG_SAVE(1)]);
++    outl(ihd_io_base+0x40,restore->pllCtrl0);
++    outl(ihd_io_base+0x44,restore->pllCtrl1);
++    outl(ihd_io_base+0x4c,restore->dacMode);
++    outl(ihd_io_base+0x50,restore->dacAddr);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg);
++    outl(ihd_io_base+0x98,restore->vidScreenSize);
++    outl(ihd_io_base+0x28,restore->vgaInit0);
++    outl(ihd_io_base+0x2c,restore->vgaInit1);
++    outl(ihd_io_base+0xe4,restore->vidDesktopStartAddr);
++    outl(ihd_io_base+0xe8,restore->vidDesktopOverlayStride);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg&0xfffffffe);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg|1);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg);
++
++}
++
++/* Return nonzero if mode is available */
++
++static int ihd_modeavailable(int mode)
++{
++    struct info *info;
++    ModeTiming *modetiming;
++    ModeInfo *modeinfo;
++
++    if ((mode < G640x480x256 )
++	|| mode == G720x348x2)
++	return __svgalib_vga_driverspecs.modeavailable(mode);
++
++    info = &__svgalib_infotable[mode];
++    if (ihd_memory * 1024 < info->ydim * info->xbytes)
++	return 0;
++
++    modeinfo = __svgalib_createModeInfoStructureForSvgalibMode(mode);
++
++    if((modeinfo->bitsPerPixel==16)&&(modeinfo->greenWeight==5)) {
++	free(modeinfo);
++        return 0;
++    }
++
++    modetiming = malloc(sizeof(ModeTiming));
++    if (__svgalib_getmodetiming(modetiming, modeinfo, cardspecs)) {
++	free(modetiming);
++	return 0;
++    }
++    free(modetiming);
++    free(modeinfo);
++
++    return SVGADRV;
++}
++
++static unsigned comp_lmn(int freq) ;
++/* Set a mode */
++
++/* Local, called by ihd_setmode(). */
++
++static void ihd_initializemode(unsigned char *moderegs,
++			    ModeTiming * modetiming, ModeInfo * modeinfo, int mode)
++{ /* long k; */
++
++    int vd,vt,vbs,vbe,ht,hd,hss,hse;
++
++    HWRecPtr ihd_regs;
++
++    ihd_regs=(HWRecPtr)(moderegs+62);
++   
++    ihd_saveregs(moderegs);
++
++    __svgalib_setup_VGA_registers(moderegs, modetiming, modeinfo);
++
++    hd = (modetiming->CrtcHDisplay>>3)-1;
++    hss = (modetiming->CrtcHSyncStart>>3);
++    hse = (modetiming->CrtcHSyncEnd>>3);
++    ht = (modetiming->CrtcHTotal>>3)-5;
++    moderegs[IHDREG_SAVE(0)]=((ht&0x100)>>8) |
++       			    ((hd&0x100)>>6) |
++                            ((hd&0x100)>>4) |
++                            ((ht&0x40)>>1) |
++                            ((hss&0x100)>>2) |
++                            ((hse&0x20)<<2) ; 
++
++    vd    = modetiming->CrtcVDisplay - 1;
++    vt = modetiming->CrtcVTotal - 2;
++    vbs  = modetiming->CrtcVSyncStart - 1;
++    vbe  = vt; 
++    moderegs[IHDREG_SAVE(1)]=((vt & 0x400)>>10) | 
++		            ((vd  & 0x400)>>8) |
++		            ((vbs & 0x400)>>6) |
++		            ((vbe & 0x400)>>4);
++/*
++    if (modetiming->flags & INTERLACED)
++	    moderegs[MXREG_SAVE(3)] |= 0x8;
++*/
++
++    ihd_regs->vidProcCfg&=0xf7e30000;
++    ihd_regs->vidProcCfg|=0x00000c81;
++
++    ihd_regs->vidScreenSize=modeinfo->width|(modeinfo->height<<12);
++
++    if (modetiming->flags & DOUBLESCAN)
++	    ihd_regs->vidProcCfg |= 0x10;
++
++    switch (modeinfo->bitsPerPixel)
++    {
++	    case 8: 
++               	    ihd_regs->vidProcCfg|=0<<18;
++		    break;
++	    case 15: 
++	    case 16:if(modeinfo->greenWeight==5){
++                        ihd_regs->vidProcCfg|=1<<18;
++                    } else ihd_regs->vidProcCfg|=1<<18;
++		    break;
++	    case 24: 
++               	    ihd_regs->vidProcCfg|=2<<18;
++		    break;
++	    case 32: 
++               	    ihd_regs->vidProcCfg|=3<<18;
++		    break;
++	    default: 
++		    break;
++    }
++    
++    ihd_regs->vgaInit0&=0xfffffffb;
++    if(modeinfo->bitsPerPixel!=8){
++        ihd_regs->vgaInit0|=4;
++    };
++
++    ihd_regs->pllCtrl0=comp_lmn(modetiming->pixelClock);
++    moderegs[VGA_MISCOUTPUT]|=0x0c;
++
++    ihd_regs->vidDesktopStartAddr=0;
++    ihd_regs->vidDesktopOverlayStride=modeinfo->lineWidth;    
++
++    ihd_regs->vgaInit0=0x1140;
++    ihd_regs->vgaInit1=0x00100000;
++
++    moderegs[41]=0;
++
++    if(modeinfo->bitsPerPixel==8){
++       moderegs[79]=0;
++    };
++
++    ihd_is_linear=0;
++
++return ;
++
++}
++
++static int ihd_setmode(int mode, int prv_mode)
++{
++    unsigned char *moderegs;
++    ModeTiming modetiming;
++    ModeInfo *modeinfo;
++
++    if ((mode < G640x480x256 /*&& mode != G320x200x256*/)
++	|| mode == G720x348x2) {
++
++	return __svgalib_vga_driverspecs.setmode(mode, prv_mode);
++    }
++    if (!ihd_modeavailable(mode))
++	return 1;
++
++    modeinfo = __svgalib_createModeInfoStructureForSvgalibMode(mode);
++
++    if (__svgalib_getmodetiming(&modetiming, modeinfo, cardspecs)) {
++	free(modeinfo);
++	return 1;
++    }
++
++    moderegs = malloc(IHD_TOTAL_REGS);
++
++    ihd_initializemode(moderegs, &modetiming, modeinfo, mode);
++
++    __svgalib_setregs(moderegs);	/* Set standard regs. */
++    ihd_setregs(moderegs, mode);		/* Set extended regs. */
++    free(moderegs);
++
++    __svgalib_InitializeAcceleratorInterface(modeinfo);
++
++    free(modeinfo);
++
++
++    return 0;
++}
++
++
++/* Unlock chipset-specific registers */
++
++static void ihd_unlock(void)
++{
++    int vgaIOBase, temp;
++
++    vgaIOBase = (inb(0x3CC) & 0x01) ? 0x3D0 : 0x3B0;
++    outb(vgaIOBase + 4, 0x11);
++    temp = inb(vgaIOBase + 5);
++    outb(vgaIOBase + 5, temp & 0x7F);
++    
++    outl(ihd_io_base+0x28,(inl(ihd_io_base+0x28)&0xffffffbf)|(1<<6));
++}
++
++static void ihd_lock(void)
++{
++    int vgaIOBase, temp;
++
++    vgaIOBase = (inb(0x3CC) & 0x01) ? 0x3D0 : 0x3B0;
++    outb(vgaIOBase + 4, 0x11);
++    temp = inb(vgaIOBase + 5);
++    outb(vgaIOBase + 5, temp & 0x7F);
++    
++    outl(ihd_io_base+0x28,(inl(ihd_io_base+0x28)&0xffffffbf));
++}
++
++
++/* Indentify chipset, initialize and return non-zero if detected */
++
++static int ihd_test(void)
++{
++   int found,_ioperm=0;
++   unsigned long buf[64];
++
++   if (getenv("IOPERM") == NULL) {
++      _ioperm=1;
++      if (iopl(3) < 0) {
++        printf("svgalib: ihd: cannot get I/O permissions\n");
++        exit(1);
++      }
++   }
++   found=(!__svgalib_pci_find_vendor_vga(0x121a,buf,0))&&
++          (((buf[0]>>16)==0x0003)||
++          ((buf[0]>>16)==0x0009)||
++          ((buf[0]>>16)==0x0005));
++    
++   if (_ioperm) iopl(0);
++
++   if(found)ihd_init(0,0,0); 
++   return found;
++}
++
++
++/* Set display start address (not for 16 color modes) */
++/* Cirrus supports any address in video memory (up to 2Mb) */
++
++static void ihd_setdisplaystart(int address)
++{ 
++  outw(CRT_IC, ((address>>2) & 0x00FF00) | 0x0C);
++  outw(CRT_IC, (((address>>2) & 0x00FF) << 8) | 0x0D);
++  outl(ihd_io_base+0xe4,address);
++
++}
++
++
++/* Set logical scanline length (usually multiple of 8) */
++
++static void ihd_setlogicalwidth(int width)
++{   
++    int offset = width >> 3;
++ 
++    __svgalib_outCR(0x13,offset&0xff);
++    outl(ihd_io_base+0xe8,width);
++}
++
++static int ihd_linear(int op, int param)
++{
++if (op==LINEAR_ENABLE || op==LINEAR_DISABLE){ ihd_is_linear=1-ihd_is_linear; return 0;}
++if (op==LINEAR_QUERY_BASE) return ihd_linear_base;
++if (op == LINEAR_QUERY_RANGE || op == LINEAR_QUERY_GRANULARITY) return 0;		/* No granularity or range. */
++    else return -1;		/* Unknown function. */
++}
++
++static int ihd_match_programmable_clock(int clock)
++{
++return clock ;
++}
++
++static int ihd_map_clock(int bpp, int clock)
++{
++return clock ;
++}
++
++static int ihd_map_horizontal_crtc(int bpp, int pixelclock, int htiming)
++{
++return htiming;
++}
++
++/* Function table (exported) */
++
++DriverSpecs __svgalib_ihd_driverspecs =
++{
++    ihd_saveregs,
++    ihd_setregs,
++    ihd_unlock,
++    ihd_lock,
++    ihd_test,
++    ihd_init,
++    ihd_setpage,
++    NULL,
++    NULL,
++    ihd_setmode,
++    ihd_modeavailable,
++    ihd_setdisplaystart,
++    ihd_setlogicalwidth,
++    ihd_getmodeinfo,
++    0,				/* old blit funcs */
++    0,
++    0,
++    0,
++    0,
++    0,				/* ext_set */
++    0,				/* accel */
++    ihd_linear,
++    0,				/* accelspecs, filled in during init. */
++    NULL,                       /* Emulation */
++};
++
++/* Initialize chipset (called after detection) */
++
++static int ihd_init(int force, int par1, int par2)
++{
++    unsigned long buf[64];
++    int found=0;
++    int _ioperm=0;
++
++    if (force) {
++	ihd_memory = par1;
++        ihd_chiptype = par2;
++    } else {
++
++    };
++    
++    if (getenv("IOPERM") == NULL) {
++      _ioperm=1;
++      if (iopl(3) < 0) {
++        printf("svgalib: ihd: cannot get I/O permissions\n");
++        exit(1);
++      }
++    }
++     
++    found=(!__svgalib_pci_find_vendor_vga(0x121a,buf,0))&&
++            (((buf[0]>>16)==0x0003)||
++            ((buf[0]>>16)==0x0009)||
++            ((buf[0]>>16)==0x0005));
++    
++/*     if (_ioperm) iopl(0);*/
++    if (found){
++       ihd_linear_base=buf[5]&0xffffff00;
++       ihd_io_base=buf[6]&0xff00;
++    };
++
++    if(ihd_memory==0) {
++       unsigned int draminit0,draminit1;
++       
++       draminit0=inl(ihd_io_base+0x18);
++       draminit1=inl(ihd_io_base+0x1c);
++       if(draminit1&0x40000000) {
++          /* SDRAM */
++          ihd_memory=16*1024;
++       } else {
++          /* SGRAM */
++          ihd_memory=1024*4*
++             (1+((draminit0>>27)&1))* /* SGRAM type - 8MBIT or 16MBIT */
++             (1+((draminit0>>26)&1)); /* Number of sgram chips (4 or 8) */
++       }
++    }
++    
++    ihd_unlock();
++    
++    if (__svgalib_driver_report) {
++	printf("Using Banshee / Voodoo3 driver, %iKB.\n",ihd_memory);
++    }
++    
++    cardspecs = malloc(sizeof(CardSpecs));
++    cardspecs->videoMemory = ihd_memory;
++    cardspecs->maxPixelClock4bpp = 270000;	
++    cardspecs->maxPixelClock8bpp = 270000;	
++    cardspecs->maxPixelClock16bpp = 270000;	
++    cardspecs->maxPixelClock24bpp = 270000;
++    cardspecs->maxPixelClock32bpp = 270000;
++    cardspecs->flags = INTERLACE_DIVIDE_VERT | CLOCK_PROGRAMMABLE;
++    cardspecs->maxHorizontalCrtc = 4088;
++    cardspecs->maxPixelClock4bpp = 0;
++    cardspecs->nClocks =0;
++    cardspecs->mapClock = ihd_map_clock;
++    cardspecs->mapHorizontalCrtc = ihd_map_horizontal_crtc;
++    cardspecs->matchProgrammableClock=ihd_match_programmable_clock;
++    __svgalib_driverspecs = &__svgalib_ihd_driverspecs;
++    __svgalib_banked_mem_base=0xa0000;
++    __svgalib_banked_mem_size=0x10000;
++    __svgalib_linear_mem_base=ihd_linear_base;
++    __svgalib_linear_mem_size=ihd_memory*0x400;
++    return 0;
++}
++
++#define REFFREQ 14318.18
++
++static unsigned
++comp_lmn(int freq)
++{
++  int m, n, k, best_m, best_n, best_k, f_cur, best_error;
++
++  best_error=freq;
++  best_n=best_m=best_k=0;
++  for (n=1; n<256; n++) {
++    f_cur=REFFREQ*(n+2);
++    if (f_cur<freq) {
++      f_cur=f_cur/3;
++      if (freq-f_cur<best_error) {
++        best_error=freq-f_cur;
++        best_n=n;
++        best_m=1;
++        best_k=0;
++        continue;
++      }
++    }
++    for (m=1; m<64; m++) {
++      for (k=0; k<4; k++) {
++        f_cur=REFFREQ*(n+2)/(m+2)/(1<<k);
++        if (abs(f_cur-freq)<best_error) {
++          best_error=abs(f_cur-freq);
++          best_n=n;
++          best_m=m;
++          best_k=k;
++	}
++      }
++    }
++  }
++  return (best_n << 8) | (best_m<<2) | best_k;
++}
++
diff --git a/svgalib64/patches/patch-ca.0.1.2 b/svgalib64/patches/patch-ca.0.1.2
new file mode 100644
index 0000000000..957da92100
--- /dev/null
+++ b/svgalib64/patches/patch-ca.0.1.2
@@ -0,0 +1,660 @@
+diff -Naur svgalib-1.4.3.orig/Makefile.cfg svgalib-1.4.3-nbsd/Makefile.cfg
+--- svgalib-1.4.3.orig/Makefile.cfg	2025-02-18 10:23:12.209757756 +0100
++++ svgalib-1.4.3-nbsd/Makefile.cfg	2025-02-18 11:53:55.311140360 +0100
+@@ -140,6 +140,7 @@
+ INCLUDE_NV3_DRIVER = y
+ INCLUDE_ET6000_DRIVER = y
+ INCLUDE_VESA_DRIVER = y
++INCLUDE_IHD_DRIVER = y
+ INCLUDE_MX_DRIVER = y
+ INCLUDE_PARADISE_DRIVER = y
+ INCLUDE_RAGE_DRIVER = y
+@@ -171,6 +172,7 @@
+ INCLUDE_APM_DRIVER_TEST = y
+ INCLUDE_NV3_DRIVER_TEST = y
+ INCLUDE_ET6000_DRIVER_TEST = y
++INCLUDE_IHD_DRIVER_TEST = y
+ INCLUDE_MX_DRIVER_TEST = y
+ INCLUDE_PARADISE_DRIVER_TEST = y
+ INCLUDE_RAGE_DRIVER_TEST = y
+diff -Naur svgalib-1.4.3.orig/include/vga.h svgalib-1.4.3-nbsd/include/vga.h
+--- svgalib-1.4.3.orig/include/vga.h	2025-02-18 10:23:12.360150109 +0100
++++ svgalib-1.4.3-nbsd/include/vga.h	2025-02-18 14:11:27.468507143 +0100
+@@ -360,6 +360,7 @@
+ #define G400		29
+ #define R128		30
+ #define SAVAGE		31
++#define IHD		32
+ 
+     /* Hor. sync: */
+ #define MON640_60	0	/* 31.5 KHz (standard VGA) */
+diff -Naur svgalib-1.4.3.orig/src/Makefile svgalib-1.4.3-nbsd/src/Makefile
+--- svgalib-1.4.3.orig/src/Makefile	2025-02-18 10:23:12.364759064 +0100
++++ svgalib-1.4.3-nbsd/src/Makefile	2025-02-18 11:50:45.628448772 +0100
+@@ -187,6 +187,13 @@
+     VGA_DEFINES += -DINCLUDE_VESA_DRIVER_TEST
+   endif
+ endif
++ifdef INCLUDE_IHD_DRIVER
++  VGA_DEFINES +=-DINCLUDE_IHD_DRIVER
++  DRIVERS += ihd.o
++  ifdef INCLUDE_IHD_DRIVER_TEST
++    VGA_DEFINES += -DINCLUDE_IHD_DRIVER_TEST
++  endif
++endif
+ ifdef INCLUDE_NV3_DRIVER
+   VGA_DEFINES +=-DINCLUDE_NV3_DRIVER
+   DRIVERS += nv3.o
+diff -Naur svgalib-1.4.3.orig/src/_types.h svgalib-1.4.3-nbsd/src/_types.h
+--- svgalib-1.4.3.orig/src/_types.h	1970-01-01 01:00:00.000000000 +0100
++++ svgalib-1.4.3-nbsd/src/_types.h	2025-02-18 10:38:07.488947844 +0100
+@@ -0,0 +1,29 @@
++/* VGAlib version 1.4.3 - (c) 2025 Zanthia of Silverhawk Software  */
++/*                                                                 */
++/* This library is free software; you can redistribute it and/or   */
++/* modify it without any restrictions. This library is distributed */
++/* in the hope that it will be useful, but without any warranty.   */
++
++#ifndef __TYPES_H
++#define __TYPES_H
++
++/* byte and character */
++typedef unsigned char byte;
++typedef unsigned char u8;
++
++typedef unsigned char uint8;
++
++/* NOTE : redefine these for good measure */
++typedef unsigned short int u16;
++typedef unsigned int u32;
++typedef unsigned long int u64;
++
++typedef unsigned short int uint16;
++typedef unsigned int uint32;
++typedef unsigned long int uint64;
++
++/* optional */
++typedef void *id;
++typedef void *void_ptr;
++
++#endif
+diff -Naur svgalib-1.4.3.orig/src/driver.h svgalib-1.4.3-nbsd/src/driver.h
+--- svgalib-1.4.3.orig/src/driver.h	2025-02-18 10:23:12.371438290 +0100
++++ svgalib-1.4.3-nbsd/src/driver.h	2025-02-18 14:08:21.959799848 +0100
+@@ -82,6 +82,7 @@
+ extern DriverSpecs __svgalib_nv3_driverspecs;
+ extern DriverSpecs __svgalib_et6000_driverspecs;
+ extern DriverSpecs __svgalib_vesa_driverspecs;
++extern DriverSpecs __svgalib_ihd_driverspecs;
+ extern DriverSpecs __svgalib_mx_driverspecs;
+ extern DriverSpecs __svgalib_paradise_driverspecs;
+ extern DriverSpecs __svgalib_rage_driverspecs;
+diff -Naur svgalib-1.4.3.orig/src/drivers svgalib-1.4.3-nbsd/src/drivers
+--- svgalib-1.4.3.orig/src/drivers	2025-02-18 10:23:12.418179564 +0100
++++ svgalib-1.4.3-nbsd/src/drivers	2025-02-18 14:06:20.868420995 +0100
+@@ -18,6 +18,7 @@
+ s3.c		v	v
+ tvga8900.c	v	v
+ vesa.c		v	v
++ihd.c		v	
+ vgadrv.c	v	v
+ rage.c		v	v
+ sis.c		v	v
+diff -Naur svgalib-1.4.3.orig/src/ihd.c svgalib-1.4.3-nbsd/src/ihd.c
+--- svgalib-1.4.3.orig/src/ihd.c	1970-01-01 01:00:00.000000000 +0100
++++ svgalib-1.4.3-nbsd/src/ihd.c	2025-02-18 12:00:16.520229366 +0100
+@@ -0,0 +1,543 @@
++/* VGAlib version 1.4.3 - (c) 2025 Zanthia of Silverhawk Software  */
++/*                                                                 */
++/* This library is free software; you can redistribute it and/or   */
++/* modify it without any restrictions. This library is distributed */
++/* in the hope that it will be useful, but without any warranty.   */
++
++/*
++Intel HD driver (WIP)
++*/
++
++
++#include <stdlib.h>
++#include <stdio.h>		/* for printf */
++#include <string.h>		/* for memset */
++#include <unistd.h>
++#include "vga.h"
++#include "libvga.h"
++#include "driver.h"
++
++
++/* New style driver interface. */
++#include "timing.h"
++#include "vgaregs.h"
++#include "interface.h"
++#include "accel.h"
++#include "vgapci.h"
++
++#define IHDREG_SAVE(i) (VGA_TOTAL_REGS+i)
++#define IHD_TOTAL_REGS (VGA_TOTAL_REGS + 2 + 40)
++
++static int ihd_init(int, int, int);
++static void ihd_unlock(void);
++static void ihd_lock(void);
++
++void __svgalib_ihdaccel_init(AccelSpecs * accelspecs, int bpp, int width_in_pixels);
++
++static int ihd_memory,ihd_chiptype;
++static int ihd_is_linear, ihd_linear_base, ihd_io_base;
++
++static CardSpecs *cardspecs;
++
++static void ihd_setpage(int page)
++{
++   page<<=1;
++   outl(ihd_io_base+0x2c,(inl(ihd_io_base+0x2c)&0xfff00000)|(page)|(page<<10));
++}
++
++static int __svgalib_ihd_inlinearmode(void)
++{
++return ihd_is_linear;
++}
++
++/* Fill in chipset specific mode information */
++
++static void ihd_getmodeinfo(int mode, vga_modeinfo *modeinfo)
++{
++
++    if(modeinfo->colors==16)return;
++
++    modeinfo->maxpixels = ihd_memory*1024/modeinfo->bytesperpixel;
++    modeinfo->maxlogicalwidth = 4088;
++    modeinfo->startaddressrange = ihd_memory * 1024 - 1;
++    modeinfo->haveblit = 0;
++    modeinfo->flags &= ~HAVE_RWPAGE;
++
++    if (modeinfo->bytesperpixel >= 1) {
++	if(ihd_linear_base)modeinfo->flags |= CAPABLE_LINEAR;
++        if (__svgalib_ihd_inlinearmode())
++	    modeinfo->flags |= IS_LINEAR;
++    }
++}
++
++/* Read and save chipset-specific registers */
++
++typedef struct {
++   unsigned int pllCtrl0, pllCtrl1, dacMode, dacAddr,
++      		vidProcCfg, vidScreenSize, vgaInit0,
++                vgaInit1, vidDesktopStartAddr,vidDesktopOverlayStride;
++} *HWRecPtr;
++
++static int ihd_saveregs(unsigned char regs[])
++{ 
++  HWRecPtr save;
++
++  ihd_unlock();		/* May be locked again by other programs (e.g. X) */
++  
++  save=(HWRecPtr)(regs+62);
++  
++  regs[IHDREG_SAVE(0)]=__svgalib_inCR(0x1a);
++  regs[IHDREG_SAVE(1)]=__svgalib_inCR(0x1b);
++  save->pllCtrl0=inl(ihd_io_base+0x40);
++  save->pllCtrl1=inl(ihd_io_base+0x44);
++  save->dacMode=inl(ihd_io_base+0x4c);
++  save->dacAddr=inl(ihd_io_base+0x50);
++  save->vidProcCfg=inl(ihd_io_base+0x5c);
++  save->vidScreenSize=inl(ihd_io_base+0x98);
++  save->vgaInit0=inl(ihd_io_base+0x28);
++  save->vgaInit1=inl(ihd_io_base+0x2c);
++  save->vidDesktopStartAddr=inl(ihd_io_base+0xe4);
++  save->vidDesktopOverlayStride=inl(ihd_io_base+0xe8);
++  
++  return IHD_TOTAL_REGS - VGA_TOTAL_REGS;
++}
++
++/* Set chipset-specific registers */
++
++static void ihd_setregs(const unsigned char regs[], int mode)
++{  
++    HWRecPtr restore;
++
++    ihd_unlock();		/* May be locked again by other programs (eg. X) */
++  
++    restore=(HWRecPtr)(regs+62);
++  
++    __svgalib_outCR(0x1a,regs[IHDREG_SAVE(0)]);
++    __svgalib_outCR(0x1b,regs[IHDREG_SAVE(1)]);
++    outl(ihd_io_base+0x40,restore->pllCtrl0);
++    outl(ihd_io_base+0x44,restore->pllCtrl1);
++    outl(ihd_io_base+0x4c,restore->dacMode);
++    outl(ihd_io_base+0x50,restore->dacAddr);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg);
++    outl(ihd_io_base+0x98,restore->vidScreenSize);
++    outl(ihd_io_base+0x28,restore->vgaInit0);
++    outl(ihd_io_base+0x2c,restore->vgaInit1);
++    outl(ihd_io_base+0xe4,restore->vidDesktopStartAddr);
++    outl(ihd_io_base+0xe8,restore->vidDesktopOverlayStride);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg&0xfffffffe);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg|1);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg);
++
++}
++
++/* Return nonzero if mode is available */
++
++static int ihd_modeavailable(int mode)
++{
++    struct info *info;
++    ModeTiming *modetiming;
++    ModeInfo *modeinfo;
++
++    if ((mode < G640x480x256 )
++	|| mode == G720x348x2)
++	return __svgalib_vga_driverspecs.modeavailable(mode);
++
++    info = &__svgalib_infotable[mode];
++    if (ihd_memory * 1024 < info->ydim * info->xbytes)
++	return 0;
++
++    modeinfo = __svgalib_createModeInfoStructureForSvgalibMode(mode);
++
++    if((modeinfo->bitsPerPixel==16)&&(modeinfo->greenWeight==5)) {
++	free(modeinfo);
++        return 0;
++    }
++
++    modetiming = malloc(sizeof(ModeTiming));
++    if (__svgalib_getmodetiming(modetiming, modeinfo, cardspecs)) {
++	free(modetiming);
++	return 0;
++    }
++    free(modetiming);
++    free(modeinfo);
++
++    return SVGADRV;
++}
++
++static unsigned comp_lmn(int freq) ;
++/* Set a mode */
++
++/* Local, called by ihd_setmode(). */
++
++static void ihd_initializemode(unsigned char *moderegs,
++			    ModeTiming * modetiming, ModeInfo * modeinfo, int mode)
++{ /* long k; */
++
++    int vd,vt,vbs,vbe,ht,hd,hss,hse;
++
++    HWRecPtr ihd_regs;
++
++    ihd_regs=(HWRecPtr)(moderegs+62);
++   
++    ihd_saveregs(moderegs);
++
++    __svgalib_setup_VGA_registers(moderegs, modetiming, modeinfo);
++
++    hd = (modetiming->CrtcHDisplay>>3)-1;
++    hss = (modetiming->CrtcHSyncStart>>3);
++    hse = (modetiming->CrtcHSyncEnd>>3);
++    ht = (modetiming->CrtcHTotal>>3)-5;
++    moderegs[IHDREG_SAVE(0)]=((ht&0x100)>>8) |
++       			    ((hd&0x100)>>6) |
++                            ((hd&0x100)>>4) |
++                            ((ht&0x40)>>1) |
++                            ((hss&0x100)>>2) |
++                            ((hse&0x20)<<2) ; 
++
++    vd    = modetiming->CrtcVDisplay - 1;
++    vt = modetiming->CrtcVTotal - 2;
++    vbs  = modetiming->CrtcVSyncStart - 1;
++    vbe  = vt; 
++    moderegs[IHDREG_SAVE(1)]=((vt & 0x400)>>10) | 
++		            ((vd  & 0x400)>>8) |
++		            ((vbs & 0x400)>>6) |
++		            ((vbe & 0x400)>>4);
++/*
++    if (modetiming->flags & INTERLACED)
++	    moderegs[MXREG_SAVE(3)] |= 0x8;
++*/
++
++    ihd_regs->vidProcCfg&=0xf7e30000;
++    ihd_regs->vidProcCfg|=0x00000c81;
++
++    ihd_regs->vidScreenSize=modeinfo->width|(modeinfo->height<<12);
++
++    if (modetiming->flags & DOUBLESCAN)
++	    ihd_regs->vidProcCfg |= 0x10;
++
++    switch (modeinfo->bitsPerPixel)
++    {
++	    case 8: 
++               	    ihd_regs->vidProcCfg|=0<<18;
++		    break;
++	    case 15: 
++	    case 16:if(modeinfo->greenWeight==5){
++                        ihd_regs->vidProcCfg|=1<<18;
++                    } else ihd_regs->vidProcCfg|=1<<18;
++		    break;
++	    case 24: 
++               	    ihd_regs->vidProcCfg|=2<<18;
++		    break;
++	    case 32: 
++               	    ihd_regs->vidProcCfg|=3<<18;
++		    break;
++	    default: 
++		    break;
++    }
++    
++    ihd_regs->vgaInit0&=0xfffffffb;
++    if(modeinfo->bitsPerPixel!=8){
++        ihd_regs->vgaInit0|=4;
++    };
++
++    ihd_regs->pllCtrl0=comp_lmn(modetiming->pixelClock);
++    moderegs[VGA_MISCOUTPUT]|=0x0c;
++
++    ihd_regs->vidDesktopStartAddr=0;
++    ihd_regs->vidDesktopOverlayStride=modeinfo->lineWidth;    
++
++    ihd_regs->vgaInit0=0x1140;
++    ihd_regs->vgaInit1=0x00100000;
++
++    moderegs[41]=0;
++
++    if(modeinfo->bitsPerPixel==8){
++       moderegs[79]=0;
++    };
++
++    ihd_is_linear=0;
++
++return ;
++
++}
++
++static int ihd_setmode(int mode, int prv_mode)
++{
++    unsigned char *moderegs;
++    ModeTiming modetiming;
++    ModeInfo *modeinfo;
++
++    if ((mode < G640x480x256 /*&& mode != G320x200x256*/)
++	|| mode == G720x348x2) {
++
++	return __svgalib_vga_driverspecs.setmode(mode, prv_mode);
++    }
++    if (!ihd_modeavailable(mode))
++	return 1;
++
++    modeinfo = __svgalib_createModeInfoStructureForSvgalibMode(mode);
++
++    if (__svgalib_getmodetiming(&modetiming, modeinfo, cardspecs)) {
++	free(modeinfo);
++	return 1;
++    }
++
++    moderegs = malloc(IHD_TOTAL_REGS);
++
++    ihd_initializemode(moderegs, &modetiming, modeinfo, mode);
++
++    __svgalib_setregs(moderegs);	/* Set standard regs. */
++    ihd_setregs(moderegs, mode);		/* Set extended regs. */
++    free(moderegs);
++
++    __svgalib_InitializeAcceleratorInterface(modeinfo);
++
++    free(modeinfo);
++
++
++    return 0;
++}
++
++
++/* Unlock chipset-specific registers */
++
++static void ihd_unlock(void)
++{
++    int vgaIOBase, temp;
++
++    vgaIOBase = (inb(0x3CC) & 0x01) ? 0x3D0 : 0x3B0;
++    outb(vgaIOBase + 4, 0x11);
++    temp = inb(vgaIOBase + 5);
++    outb(vgaIOBase + 5, temp & 0x7F);
++    
++    outl(ihd_io_base+0x28,(inl(ihd_io_base+0x28)&0xffffffbf)|(1<<6));
++}
++
++static void ihd_lock(void)
++{
++    int vgaIOBase, temp;
++
++    vgaIOBase = (inb(0x3CC) & 0x01) ? 0x3D0 : 0x3B0;
++    outb(vgaIOBase + 4, 0x11);
++    temp = inb(vgaIOBase + 5);
++    outb(vgaIOBase + 5, temp & 0x7F);
++    
++    outl(ihd_io_base+0x28,(inl(ihd_io_base+0x28)&0xffffffbf));
++}
++
++
++/* Indentify chipset, initialize and return non-zero if detected */
++
++static int ihd_test(void)
++{
++   int found,_ioperm=0;
++   unsigned long buf[64];
++
++   if (getenv("IOPERM") == NULL) {
++      _ioperm=1;
++      if (iopl(3) < 0) {
++        printf("svgalib: ihd: cannot get I/O permissions\n");
++        exit(1);
++      }
++   }
++   found=(!__svgalib_pci_find_vendor_vga(0x121a,buf,0))&&
++          (((buf[0]>>16)==0x0003)||
++          ((buf[0]>>16)==0x0009)||
++          ((buf[0]>>16)==0x0005));
++    
++   if (_ioperm) iopl(0);
++
++   if(found)ihd_init(0,0,0); 
++   return found;
++}
++
++
++/* Set display start address (not for 16 color modes) */
++/* Cirrus supports any address in video memory (up to 2Mb) */
++
++static void ihd_setdisplaystart(int address)
++{ 
++  outw(CRT_IC, ((address>>2) & 0x00FF00) | 0x0C);
++  outw(CRT_IC, (((address>>2) & 0x00FF) << 8) | 0x0D);
++  outl(ihd_io_base+0xe4,address);
++
++}
++
++
++/* Set logical scanline length (usually multiple of 8) */
++
++static void ihd_setlogicalwidth(int width)
++{   
++    int offset = width >> 3;
++ 
++    __svgalib_outCR(0x13,offset&0xff);
++    outl(ihd_io_base+0xe8,width);
++}
++
++static int ihd_linear(int op, int param)
++{
++if (op==LINEAR_ENABLE || op==LINEAR_DISABLE){ ihd_is_linear=1-ihd_is_linear; return 0;}
++if (op==LINEAR_QUERY_BASE) return ihd_linear_base;
++if (op == LINEAR_QUERY_RANGE || op == LINEAR_QUERY_GRANULARITY) return 0;		/* No granularity or range. */
++    else return -1;		/* Unknown function. */
++}
++
++static int ihd_match_programmable_clock(int clock)
++{
++return clock ;
++}
++
++static int ihd_map_clock(int bpp, int clock)
++{
++return clock ;
++}
++
++static int ihd_map_horizontal_crtc(int bpp, int pixelclock, int htiming)
++{
++return htiming;
++}
++
++/* Function table (exported) */
++
++DriverSpecs __svgalib_ihd_driverspecs =
++{
++    ihd_saveregs,
++    ihd_setregs,
++    ihd_unlock,
++    ihd_lock,
++    ihd_test,
++    ihd_init,
++    ihd_setpage,
++    NULL,
++    NULL,
++    ihd_setmode,
++    ihd_modeavailable,
++    ihd_setdisplaystart,
++    ihd_setlogicalwidth,
++    ihd_getmodeinfo,
++    0,				/* old blit funcs */
++    0,
++    0,
++    0,
++    0,
++    0,				/* ext_set */
++    0,				/* accel */
++    ihd_linear,
++    0,				/* accelspecs, filled in during init. */
++    NULL,                       /* Emulation */
++};
++
++/* Initialize chipset (called after detection) */
++
++static int ihd_init(int force, int par1, int par2)
++{
++    unsigned long buf[64];
++    int found=0;
++    int _ioperm=0;
++
++    if (force) {
++	ihd_memory = par1;
++        ihd_chiptype = par2;
++    } else {
++
++    };
++    
++    if (getenv("IOPERM") == NULL) {
++      _ioperm=1;
++      if (iopl(3) < 0) {
++        printf("svgalib: ihd: cannot get I/O permissions\n");
++        exit(1);
++      }
++    }
++     
++    found=(!__svgalib_pci_find_vendor_vga(0x121a,buf,0))&&
++            (((buf[0]>>16)==0x0003)||
++            ((buf[0]>>16)==0x0009)||
++            ((buf[0]>>16)==0x0005));
++    
++/*     if (_ioperm) iopl(0);*/
++    if (found){
++       ihd_linear_base=buf[5]&0xffffff00;
++       ihd_io_base=buf[6]&0xff00;
++    };
++
++    if(ihd_memory==0) {
++       unsigned int draminit0,draminit1;
++       
++       draminit0=inl(ihd_io_base+0x18);
++       draminit1=inl(ihd_io_base+0x1c);
++       if(draminit1&0x40000000) {
++          /* SDRAM */
++          ihd_memory=16*1024;
++       } else {
++          /* SGRAM */
++          ihd_memory=1024*4*
++             (1+((draminit0>>27)&1))* /* SGRAM type - 8MBIT or 16MBIT */
++             (1+((draminit0>>26)&1)); /* Number of sgram chips (4 or 8) */
++       }
++    }
++    
++    ihd_unlock();
++    
++    if (__svgalib_driver_report) {
++	printf("Using Banshee / Voodoo3 driver, %iKB.\n",ihd_memory);
++    }
++    
++    cardspecs = malloc(sizeof(CardSpecs));
++    cardspecs->videoMemory = ihd_memory;
++    cardspecs->maxPixelClock4bpp = 270000;	
++    cardspecs->maxPixelClock8bpp = 270000;	
++    cardspecs->maxPixelClock16bpp = 270000;	
++    cardspecs->maxPixelClock24bpp = 270000;
++    cardspecs->maxPixelClock32bpp = 270000;
++    cardspecs->flags = INTERLACE_DIVIDE_VERT | CLOCK_PROGRAMMABLE;
++    cardspecs->maxHorizontalCrtc = 4088;
++    cardspecs->maxPixelClock4bpp = 0;
++    cardspecs->nClocks =0;
++    cardspecs->mapClock = ihd_map_clock;
++    cardspecs->mapHorizontalCrtc = ihd_map_horizontal_crtc;
++    cardspecs->matchProgrammableClock=ihd_match_programmable_clock;
++    __svgalib_driverspecs = &__svgalib_ihd_driverspecs;
++    __svgalib_banked_mem_base=0xa0000;
++    __svgalib_banked_mem_size=0x10000;
++    __svgalib_linear_mem_base=ihd_linear_base;
++    __svgalib_linear_mem_size=ihd_memory*0x400;
++    return 0;
++}
++
++#define REFFREQ 14318.18
++
++static unsigned
++comp_lmn(int freq)
++{
++  int m, n, k, best_m, best_n, best_k, f_cur, best_error;
++
++  best_error=freq;
++  best_n=best_m=best_k=0;
++  for (n=1; n<256; n++) {
++    f_cur=REFFREQ*(n+2);
++    if (f_cur<freq) {
++      f_cur=f_cur/3;
++      if (freq-f_cur<best_error) {
++        best_error=freq-f_cur;
++        best_n=n;
++        best_m=1;
++        best_k=0;
++        continue;
++      }
++    }
++    for (m=1; m<64; m++) {
++      for (k=0; k<4; k++) {
++        f_cur=REFFREQ*(n+2)/(m+2)/(1<<k);
++        if (abs(f_cur-freq)<best_error) {
++          best_error=abs(f_cur-freq);
++          best_n=n;
++          best_m=m;
++          best_k=k;
++	}
++      }
++    }
++  }
++  return (best_n << 8) | (best_m<<2) | best_k;
++}
++
+diff -Naur svgalib-1.4.3.orig/src/vga.h svgalib-1.4.3-nbsd/src/vga.h
+--- svgalib-1.4.3.orig/src/vga.h	2025-02-18 10:23:12.408464645 +0100
++++ svgalib-1.4.3-nbsd/src/vga.h	2025-02-18 14:11:27.468507143 +0100
+@@ -360,6 +360,7 @@
+ #define G400		29
+ #define R128		30
+ #define SAVAGE		31
++#define IHD		32
+ 
+     /* Hor. sync: */
+ #define MON640_60	0	/* 31.5 KHz (standard VGA) */
diff --git a/svgalib64/patches/patch-ca.0.1.3 b/svgalib64/patches/patch-ca.0.1.3
new file mode 100644
index 0000000000..3b3c8699e6
--- /dev/null
+++ b/svgalib64/patches/patch-ca.0.1.3
@@ -0,0 +1,679 @@
+diff -Naur svgalib-1.4.3.orig/HACKING svgalib-1.4.3-nbsd/HACKING
+--- svgalib-1.4.3.orig/HACKING	1970-01-01 01:00:00.000000000 +0100
++++ svgalib-1.4.3-nbsd/HACKING	2025-02-18 14:36:03.045132620 +0100
+@@ -0,0 +1,15 @@
++HACKING File 
++
++
++
++Of 18 Feb 2025 :
++----------------
++
++The work on the Intel HD Graphics (IHD) has started, we need it for an intel 
++Atom computer (smartpads) and more up-to-date hardware.
++
++The Atoms are mostly 11.6" screen diagonal and use 1366x768 as a resolution
++with WXGA as a screen. 
++
++See ihd.c in the src directory.
++
+diff -Naur svgalib-1.4.3.orig/Makefile.cfg svgalib-1.4.3-nbsd/Makefile.cfg
+--- svgalib-1.4.3.orig/Makefile.cfg	2025-02-18 10:23:12.209757756 +0100
++++ svgalib-1.4.3-nbsd/Makefile.cfg	2025-02-18 11:53:55.311140360 +0100
+@@ -140,6 +140,7 @@
+ INCLUDE_NV3_DRIVER = y
+ INCLUDE_ET6000_DRIVER = y
+ INCLUDE_VESA_DRIVER = y
++INCLUDE_IHD_DRIVER = y
+ INCLUDE_MX_DRIVER = y
+ INCLUDE_PARADISE_DRIVER = y
+ INCLUDE_RAGE_DRIVER = y
+@@ -171,6 +172,7 @@
+ INCLUDE_APM_DRIVER_TEST = y
+ INCLUDE_NV3_DRIVER_TEST = y
+ INCLUDE_ET6000_DRIVER_TEST = y
++INCLUDE_IHD_DRIVER_TEST = y
+ INCLUDE_MX_DRIVER_TEST = y
+ INCLUDE_PARADISE_DRIVER_TEST = y
+ INCLUDE_RAGE_DRIVER_TEST = y
+diff -Naur svgalib-1.4.3.orig/include/vga.h svgalib-1.4.3-nbsd/include/vga.h
+--- svgalib-1.4.3.orig/include/vga.h	2025-02-18 10:23:12.360150109 +0100
++++ svgalib-1.4.3-nbsd/include/vga.h	2025-02-18 14:11:27.468507143 +0100
+@@ -360,6 +360,7 @@
+ #define G400		29
+ #define R128		30
+ #define SAVAGE		31
++#define IHD		32
+ 
+     /* Hor. sync: */
+ #define MON640_60	0	/* 31.5 KHz (standard VGA) */
+diff -Naur svgalib-1.4.3.orig/src/Makefile svgalib-1.4.3-nbsd/src/Makefile
+--- svgalib-1.4.3.orig/src/Makefile	2025-02-18 10:23:12.364759064 +0100
++++ svgalib-1.4.3-nbsd/src/Makefile	2025-02-18 11:50:45.628448772 +0100
+@@ -187,6 +187,13 @@
+     VGA_DEFINES += -DINCLUDE_VESA_DRIVER_TEST
+   endif
+ endif
++ifdef INCLUDE_IHD_DRIVER
++  VGA_DEFINES +=-DINCLUDE_IHD_DRIVER
++  DRIVERS += ihd.o
++  ifdef INCLUDE_IHD_DRIVER_TEST
++    VGA_DEFINES += -DINCLUDE_IHD_DRIVER_TEST
++  endif
++endif
+ ifdef INCLUDE_NV3_DRIVER
+   VGA_DEFINES +=-DINCLUDE_NV3_DRIVER
+   DRIVERS += nv3.o
+diff -Naur svgalib-1.4.3.orig/src/_types.h svgalib-1.4.3-nbsd/src/_types.h
+--- svgalib-1.4.3.orig/src/_types.h	1970-01-01 01:00:00.000000000 +0100
++++ svgalib-1.4.3-nbsd/src/_types.h	2025-02-18 10:38:07.488947844 +0100
+@@ -0,0 +1,29 @@
++/* VGAlib version 1.4.3 - (c) 2025 Zanthia of Silverhawk Software  */
++/*                                                                 */
++/* This library is free software; you can redistribute it and/or   */
++/* modify it without any restrictions. This library is distributed */
++/* in the hope that it will be useful, but without any warranty.   */
++
++#ifndef __TYPES_H
++#define __TYPES_H
++
++/* byte and character */
++typedef unsigned char byte;
++typedef unsigned char u8;
++
++typedef unsigned char uint8;
++
++/* NOTE : redefine these for good measure */
++typedef unsigned short int u16;
++typedef unsigned int u32;
++typedef unsigned long int u64;
++
++typedef unsigned short int uint16;
++typedef unsigned int uint32;
++typedef unsigned long int uint64;
++
++/* optional */
++typedef void *id;
++typedef void *void_ptr;
++
++#endif
+diff -Naur svgalib-1.4.3.orig/src/driver.h svgalib-1.4.3-nbsd/src/driver.h
+--- svgalib-1.4.3.orig/src/driver.h	2025-02-18 10:23:12.371438290 +0100
++++ svgalib-1.4.3-nbsd/src/driver.h	2025-02-18 14:08:21.959799848 +0100
+@@ -82,6 +82,7 @@
+ extern DriverSpecs __svgalib_nv3_driverspecs;
+ extern DriverSpecs __svgalib_et6000_driverspecs;
+ extern DriverSpecs __svgalib_vesa_driverspecs;
++extern DriverSpecs __svgalib_ihd_driverspecs;
+ extern DriverSpecs __svgalib_mx_driverspecs;
+ extern DriverSpecs __svgalib_paradise_driverspecs;
+ extern DriverSpecs __svgalib_rage_driverspecs;
+diff -Naur svgalib-1.4.3.orig/src/drivers svgalib-1.4.3-nbsd/src/drivers
+--- svgalib-1.4.3.orig/src/drivers	2025-02-18 10:23:12.418179564 +0100
++++ svgalib-1.4.3-nbsd/src/drivers	2025-02-18 14:06:20.868420995 +0100
+@@ -18,6 +18,7 @@
+ s3.c		v	v
+ tvga8900.c	v	v
+ vesa.c		v	v
++ihd.c		v	
+ vgadrv.c	v	v
+ rage.c		v	v
+ sis.c		v	v
+diff -Naur svgalib-1.4.3.orig/src/ihd.c svgalib-1.4.3-nbsd/src/ihd.c
+--- svgalib-1.4.3.orig/src/ihd.c	1970-01-01 01:00:00.000000000 +0100
++++ svgalib-1.4.3-nbsd/src/ihd.c	2025-02-18 12:00:16.520229366 +0100
+@@ -0,0 +1,543 @@
++/* VGAlib version 1.4.3 - (c) 2025 Zanthia of Silverhawk Software  */
++/*                                                                 */
++/* This library is free software; you can redistribute it and/or   */
++/* modify it without any restrictions. This library is distributed */
++/* in the hope that it will be useful, but without any warranty.   */
++
++/*
++Intel HD driver (WIP)
++*/
++
++
++#include <stdlib.h>
++#include <stdio.h>		/* for printf */
++#include <string.h>		/* for memset */
++#include <unistd.h>
++#include "vga.h"
++#include "libvga.h"
++#include "driver.h"
++
++
++/* New style driver interface. */
++#include "timing.h"
++#include "vgaregs.h"
++#include "interface.h"
++#include "accel.h"
++#include "vgapci.h"
++
++#define IHDREG_SAVE(i) (VGA_TOTAL_REGS+i)
++#define IHD_TOTAL_REGS (VGA_TOTAL_REGS + 2 + 40)
++
++static int ihd_init(int, int, int);
++static void ihd_unlock(void);
++static void ihd_lock(void);
++
++void __svgalib_ihdaccel_init(AccelSpecs * accelspecs, int bpp, int width_in_pixels);
++
++static int ihd_memory,ihd_chiptype;
++static int ihd_is_linear, ihd_linear_base, ihd_io_base;
++
++static CardSpecs *cardspecs;
++
++static void ihd_setpage(int page)
++{
++   page<<=1;
++   outl(ihd_io_base+0x2c,(inl(ihd_io_base+0x2c)&0xfff00000)|(page)|(page<<10));
++}
++
++static int __svgalib_ihd_inlinearmode(void)
++{
++return ihd_is_linear;
++}
++
++/* Fill in chipset specific mode information */
++
++static void ihd_getmodeinfo(int mode, vga_modeinfo *modeinfo)
++{
++
++    if(modeinfo->colors==16)return;
++
++    modeinfo->maxpixels = ihd_memory*1024/modeinfo->bytesperpixel;
++    modeinfo->maxlogicalwidth = 4088;
++    modeinfo->startaddressrange = ihd_memory * 1024 - 1;
++    modeinfo->haveblit = 0;
++    modeinfo->flags &= ~HAVE_RWPAGE;
++
++    if (modeinfo->bytesperpixel >= 1) {
++	if(ihd_linear_base)modeinfo->flags |= CAPABLE_LINEAR;
++        if (__svgalib_ihd_inlinearmode())
++	    modeinfo->flags |= IS_LINEAR;
++    }
++}
++
++/* Read and save chipset-specific registers */
++
++typedef struct {
++   unsigned int pllCtrl0, pllCtrl1, dacMode, dacAddr,
++      		vidProcCfg, vidScreenSize, vgaInit0,
++                vgaInit1, vidDesktopStartAddr,vidDesktopOverlayStride;
++} *HWRecPtr;
++
++static int ihd_saveregs(unsigned char regs[])
++{ 
++  HWRecPtr save;
++
++  ihd_unlock();		/* May be locked again by other programs (e.g. X) */
++  
++  save=(HWRecPtr)(regs+62);
++  
++  regs[IHDREG_SAVE(0)]=__svgalib_inCR(0x1a);
++  regs[IHDREG_SAVE(1)]=__svgalib_inCR(0x1b);
++  save->pllCtrl0=inl(ihd_io_base+0x40);
++  save->pllCtrl1=inl(ihd_io_base+0x44);
++  save->dacMode=inl(ihd_io_base+0x4c);
++  save->dacAddr=inl(ihd_io_base+0x50);
++  save->vidProcCfg=inl(ihd_io_base+0x5c);
++  save->vidScreenSize=inl(ihd_io_base+0x98);
++  save->vgaInit0=inl(ihd_io_base+0x28);
++  save->vgaInit1=inl(ihd_io_base+0x2c);
++  save->vidDesktopStartAddr=inl(ihd_io_base+0xe4);
++  save->vidDesktopOverlayStride=inl(ihd_io_base+0xe8);
++  
++  return IHD_TOTAL_REGS - VGA_TOTAL_REGS;
++}
++
++/* Set chipset-specific registers */
++
++static void ihd_setregs(const unsigned char regs[], int mode)
++{  
++    HWRecPtr restore;
++
++    ihd_unlock();		/* May be locked again by other programs (eg. X) */
++  
++    restore=(HWRecPtr)(regs+62);
++  
++    __svgalib_outCR(0x1a,regs[IHDREG_SAVE(0)]);
++    __svgalib_outCR(0x1b,regs[IHDREG_SAVE(1)]);
++    outl(ihd_io_base+0x40,restore->pllCtrl0);
++    outl(ihd_io_base+0x44,restore->pllCtrl1);
++    outl(ihd_io_base+0x4c,restore->dacMode);
++    outl(ihd_io_base+0x50,restore->dacAddr);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg);
++    outl(ihd_io_base+0x98,restore->vidScreenSize);
++    outl(ihd_io_base+0x28,restore->vgaInit0);
++    outl(ihd_io_base+0x2c,restore->vgaInit1);
++    outl(ihd_io_base+0xe4,restore->vidDesktopStartAddr);
++    outl(ihd_io_base+0xe8,restore->vidDesktopOverlayStride);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg&0xfffffffe);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg|1);
++    outl(ihd_io_base+0x5c,restore->vidProcCfg);
++
++}
++
++/* Return nonzero if mode is available */
++
++static int ihd_modeavailable(int mode)
++{
++    struct info *info;
++    ModeTiming *modetiming;
++    ModeInfo *modeinfo;
++
++    if ((mode < G640x480x256 )
++	|| mode == G720x348x2)
++	return __svgalib_vga_driverspecs.modeavailable(mode);
++
++    info = &__svgalib_infotable[mode];
++    if (ihd_memory * 1024 < info->ydim * info->xbytes)
++	return 0;
++
++    modeinfo = __svgalib_createModeInfoStructureForSvgalibMode(mode);
++
++    if((modeinfo->bitsPerPixel==16)&&(modeinfo->greenWeight==5)) {
++	free(modeinfo);
++        return 0;
++    }
++
++    modetiming = malloc(sizeof(ModeTiming));
++    if (__svgalib_getmodetiming(modetiming, modeinfo, cardspecs)) {
++	free(modetiming);
++	return 0;
++    }
++    free(modetiming);
++    free(modeinfo);
++
++    return SVGADRV;
++}
++
++static unsigned comp_lmn(int freq) ;
++/* Set a mode */
++
++/* Local, called by ihd_setmode(). */
++
++static void ihd_initializemode(unsigned char *moderegs,
++			    ModeTiming * modetiming, ModeInfo * modeinfo, int mode)
++{ /* long k; */
++
++    int vd,vt,vbs,vbe,ht,hd,hss,hse;
++
++    HWRecPtr ihd_regs;
++
++    ihd_regs=(HWRecPtr)(moderegs+62);
++   
++    ihd_saveregs(moderegs);
++
++    __svgalib_setup_VGA_registers(moderegs, modetiming, modeinfo);
++
++    hd = (modetiming->CrtcHDisplay>>3)-1;
++    hss = (modetiming->CrtcHSyncStart>>3);
++    hse = (modetiming->CrtcHSyncEnd>>3);
++    ht = (modetiming->CrtcHTotal>>3)-5;
++    moderegs[IHDREG_SAVE(0)]=((ht&0x100)>>8) |
++       			    ((hd&0x100)>>6) |
++                            ((hd&0x100)>>4) |
++                            ((ht&0x40)>>1) |
++                            ((hss&0x100)>>2) |
++                            ((hse&0x20)<<2) ; 
++
++    vd    = modetiming->CrtcVDisplay - 1;
++    vt = modetiming->CrtcVTotal - 2;
++    vbs  = modetiming->CrtcVSyncStart - 1;
++    vbe  = vt; 
++    moderegs[IHDREG_SAVE(1)]=((vt & 0x400)>>10) | 
++		            ((vd  & 0x400)>>8) |
++		            ((vbs & 0x400)>>6) |
++		            ((vbe & 0x400)>>4);
++/*
++    if (modetiming->flags & INTERLACED)
++	    moderegs[MXREG_SAVE(3)] |= 0x8;
++*/
++
++    ihd_regs->vidProcCfg&=0xf7e30000;
++    ihd_regs->vidProcCfg|=0x00000c81;
++
++    ihd_regs->vidScreenSize=modeinfo->width|(modeinfo->height<<12);
++
++    if (modetiming->flags & DOUBLESCAN)
++	    ihd_regs->vidProcCfg |= 0x10;
++
++    switch (modeinfo->bitsPerPixel)
++    {
++	    case 8: 
++               	    ihd_regs->vidProcCfg|=0<<18;
++		    break;
++	    case 15: 
++	    case 16:if(modeinfo->greenWeight==5){
++                        ihd_regs->vidProcCfg|=1<<18;
++                    } else ihd_regs->vidProcCfg|=1<<18;
++		    break;
++	    case 24: 
++               	    ihd_regs->vidProcCfg|=2<<18;
++		    break;
++	    case 32: 
++               	    ihd_regs->vidProcCfg|=3<<18;
++		    break;
++	    default: 
++		    break;
++    }
++    
++    ihd_regs->vgaInit0&=0xfffffffb;
++    if(modeinfo->bitsPerPixel!=8){
++        ihd_regs->vgaInit0|=4;
++    };
++
++    ihd_regs->pllCtrl0=comp_lmn(modetiming->pixelClock);
++    moderegs[VGA_MISCOUTPUT]|=0x0c;
++
++    ihd_regs->vidDesktopStartAddr=0;
++    ihd_regs->vidDesktopOverlayStride=modeinfo->lineWidth;    
++
++    ihd_regs->vgaInit0=0x1140;
++    ihd_regs->vgaInit1=0x00100000;
++
++    moderegs[41]=0;
++
++    if(modeinfo->bitsPerPixel==8){
++       moderegs[79]=0;
++    };
++
++    ihd_is_linear=0;
++
++return ;
++
++}
++
++static int ihd_setmode(int mode, int prv_mode)
++{
++    unsigned char *moderegs;
++    ModeTiming modetiming;
++    ModeInfo *modeinfo;
++
++    if ((mode < G640x480x256 /*&& mode != G320x200x256*/)
++	|| mode == G720x348x2) {
++
++	return __svgalib_vga_driverspecs.setmode(mode, prv_mode);
++    }
++    if (!ihd_modeavailable(mode))
++	return 1;
++
++    modeinfo = __svgalib_createModeInfoStructureForSvgalibMode(mode);
++
++    if (__svgalib_getmodetiming(&modetiming, modeinfo, cardspecs)) {
++	free(modeinfo);
++	return 1;
++    }
++
++    moderegs = malloc(IHD_TOTAL_REGS);
++
++    ihd_initializemode(moderegs, &modetiming, modeinfo, mode);
++
++    __svgalib_setregs(moderegs);	/* Set standard regs. */
++    ihd_setregs(moderegs, mode);		/* Set extended regs. */
++    free(moderegs);
++
++    __svgalib_InitializeAcceleratorInterface(modeinfo);
++
++    free(modeinfo);
++
++
++    return 0;
++}
++
++
++/* Unlock chipset-specific registers */
++
++static void ihd_unlock(void)
++{
++    int vgaIOBase, temp;
++
++    vgaIOBase = (inb(0x3CC) & 0x01) ? 0x3D0 : 0x3B0;
++    outb(vgaIOBase + 4, 0x11);
++    temp = inb(vgaIOBase + 5);
++    outb(vgaIOBase + 5, temp & 0x7F);
++    
++    outl(ihd_io_base+0x28,(inl(ihd_io_base+0x28)&0xffffffbf)|(1<<6));
++}
++
++static void ihd_lock(void)
++{
++    int vgaIOBase, temp;
++
++    vgaIOBase = (inb(0x3CC) & 0x01) ? 0x3D0 : 0x3B0;
++    outb(vgaIOBase + 4, 0x11);
++    temp = inb(vgaIOBase + 5);
++    outb(vgaIOBase + 5, temp & 0x7F);
++    
++    outl(ihd_io_base+0x28,(inl(ihd_io_base+0x28)&0xffffffbf));
++}
++
++
++/* Indentify chipset, initialize and return non-zero if detected */
++
++static int ihd_test(void)
++{
++   int found,_ioperm=0;
++   unsigned long buf[64];
++
++   if (getenv("IOPERM") == NULL) {
++      _ioperm=1;
++      if (iopl(3) < 0) {
++        printf("svgalib: ihd: cannot get I/O permissions\n");
++        exit(1);
++      }
++   }
++   found=(!__svgalib_pci_find_vendor_vga(0x121a,buf,0))&&
++          (((buf[0]>>16)==0x0003)||
++          ((buf[0]>>16)==0x0009)||
++          ((buf[0]>>16)==0x0005));
++    
++   if (_ioperm) iopl(0);
++
++   if(found)ihd_init(0,0,0); 
++   return found;
++}
++
++
++/* Set display start address (not for 16 color modes) */
++/* Cirrus supports any address in video memory (up to 2Mb) */
++
++static void ihd_setdisplaystart(int address)
++{ 
++  outw(CRT_IC, ((address>>2) & 0x00FF00) | 0x0C);
++  outw(CRT_IC, (((address>>2) & 0x00FF) << 8) | 0x0D);
++  outl(ihd_io_base+0xe4,address);
++
++}
++
++
++/* Set logical scanline length (usually multiple of 8) */
++
++static void ihd_setlogicalwidth(int width)
++{   
++    int offset = width >> 3;
++ 
++    __svgalib_outCR(0x13,offset&0xff);
++    outl(ihd_io_base+0xe8,width);
++}
++
++static int ihd_linear(int op, int param)
++{
++if (op==LINEAR_ENABLE || op==LINEAR_DISABLE){ ihd_is_linear=1-ihd_is_linear; return 0;}
++if (op==LINEAR_QUERY_BASE) return ihd_linear_base;
++if (op == LINEAR_QUERY_RANGE || op == LINEAR_QUERY_GRANULARITY) return 0;		/* No granularity or range. */
++    else return -1;		/* Unknown function. */
++}
++
++static int ihd_match_programmable_clock(int clock)
++{
++return clock ;
++}
++
++static int ihd_map_clock(int bpp, int clock)
++{
++return clock ;
++}
++
++static int ihd_map_horizontal_crtc(int bpp, int pixelclock, int htiming)
++{
++return htiming;
++}
++
++/* Function table (exported) */
++
++DriverSpecs __svgalib_ihd_driverspecs =
++{
++    ihd_saveregs,
++    ihd_setregs,
++    ihd_unlock,
++    ihd_lock,
++    ihd_test,
++    ihd_init,
++    ihd_setpage,
++    NULL,
++    NULL,
++    ihd_setmode,
++    ihd_modeavailable,
++    ihd_setdisplaystart,
++    ihd_setlogicalwidth,
++    ihd_getmodeinfo,
++    0,				/* old blit funcs */
++    0,
++    0,
++    0,
++    0,
++    0,				/* ext_set */
++    0,				/* accel */
++    ihd_linear,
++    0,				/* accelspecs, filled in during init. */
++    NULL,                       /* Emulation */
++};
++
++/* Initialize chipset (called after detection) */
++
++static int ihd_init(int force, int par1, int par2)
++{
++    unsigned long buf[64];
++    int found=0;
++    int _ioperm=0;
++
++    if (force) {
++	ihd_memory = par1;
++        ihd_chiptype = par2;
++    } else {
++
++    };
++    
++    if (getenv("IOPERM") == NULL) {
++      _ioperm=1;
++      if (iopl(3) < 0) {
++        printf("svgalib: ihd: cannot get I/O permissions\n");
++        exit(1);
++      }
++    }
++     
++    found=(!__svgalib_pci_find_vendor_vga(0x121a,buf,0))&&
++            (((buf[0]>>16)==0x0003)||
++            ((buf[0]>>16)==0x0009)||
++            ((buf[0]>>16)==0x0005));
++    
++/*     if (_ioperm) iopl(0);*/
++    if (found){
++       ihd_linear_base=buf[5]&0xffffff00;
++       ihd_io_base=buf[6]&0xff00;
++    };
++
++    if(ihd_memory==0) {
++       unsigned int draminit0,draminit1;
++       
++       draminit0=inl(ihd_io_base+0x18);
++       draminit1=inl(ihd_io_base+0x1c);
++       if(draminit1&0x40000000) {
++          /* SDRAM */
++          ihd_memory=16*1024;
++       } else {
++          /* SGRAM */
++          ihd_memory=1024*4*
++             (1+((draminit0>>27)&1))* /* SGRAM type - 8MBIT or 16MBIT */
++             (1+((draminit0>>26)&1)); /* Number of sgram chips (4 or 8) */
++       }
++    }
++    
++    ihd_unlock();
++    
++    if (__svgalib_driver_report) {
++	printf("Using Banshee / Voodoo3 driver, %iKB.\n",ihd_memory);
++    }
++    
++    cardspecs = malloc(sizeof(CardSpecs));
++    cardspecs->videoMemory = ihd_memory;
++    cardspecs->maxPixelClock4bpp = 270000;	
++    cardspecs->maxPixelClock8bpp = 270000;	
++    cardspecs->maxPixelClock16bpp = 270000;	
++    cardspecs->maxPixelClock24bpp = 270000;
++    cardspecs->maxPixelClock32bpp = 270000;
++    cardspecs->flags = INTERLACE_DIVIDE_VERT | CLOCK_PROGRAMMABLE;
++    cardspecs->maxHorizontalCrtc = 4088;
++    cardspecs->maxPixelClock4bpp = 0;
++    cardspecs->nClocks =0;
++    cardspecs->mapClock = ihd_map_clock;
++    cardspecs->mapHorizontalCrtc = ihd_map_horizontal_crtc;
++    cardspecs->matchProgrammableClock=ihd_match_programmable_clock;
++    __svgalib_driverspecs = &__svgalib_ihd_driverspecs;
++    __svgalib_banked_mem_base=0xa0000;
++    __svgalib_banked_mem_size=0x10000;
++    __svgalib_linear_mem_base=ihd_linear_base;
++    __svgalib_linear_mem_size=ihd_memory*0x400;
++    return 0;
++}
++
++#define REFFREQ 14318.18
++
++static unsigned
++comp_lmn(int freq)
++{
++  int m, n, k, best_m, best_n, best_k, f_cur, best_error;
++
++  best_error=freq;
++  best_n=best_m=best_k=0;
++  for (n=1; n<256; n++) {
++    f_cur=REFFREQ*(n+2);
++    if (f_cur<freq) {
++      f_cur=f_cur/3;
++      if (freq-f_cur<best_error) {
++        best_error=freq-f_cur;
++        best_n=n;
++        best_m=1;
++        best_k=0;
++        continue;
++      }
++    }
++    for (m=1; m<64; m++) {
++      for (k=0; k<4; k++) {
++        f_cur=REFFREQ*(n+2)/(m+2)/(1<<k);
++        if (abs(f_cur-freq)<best_error) {
++          best_error=abs(f_cur-freq);
++          best_n=n;
++          best_m=m;
++          best_k=k;
++	}
++      }
++    }
++  }
++  return (best_n << 8) | (best_m<<2) | best_k;
++}
++
+diff -Naur svgalib-1.4.3.orig/src/vga.h svgalib-1.4.3-nbsd/src/vga.h
+--- svgalib-1.4.3.orig/src/vga.h	2025-02-18 10:23:12.408464645 +0100
++++ svgalib-1.4.3-nbsd/src/vga.h	2025-02-18 14:11:27.468507143 +0100
+@@ -360,6 +360,7 @@
+ #define G400		29
+ #define R128		30
+ #define SAVAGE		31
++#define IHD		32
+ 
+     /* Hor. sync: */
+ #define MON640_60	0	/* 31.5 KHz (standard VGA) */


Home | Main Index | Thread Index | Old Index