Sync with HEAD nick-nhusb
authorskrll <skrll@NetBSD.org>
Sat, 09 Jul 2016 20:24:48 +0000
branchnick-nhusb
changeset 278596 ee89bca5c9d0
parent 278595 897673730998
child 278597 33e45283cbc7
Sync with HEAD
sys/altq/altq_cbq.c
sys/altq/altq_cdnr.c
sys/altq/altq_subr.c
sys/arch/acorn26/ioc/if_eca.c
sys/arch/acorn26/stand/boot26/boot26.c
sys/arch/acorn32/podulebus/if_ie.c
sys/arch/acorn32/stand/boot32/boot32.c
sys/arch/algor/dev/bonito_mainbus.c
sys/arch/alpha/stand/common/boot.c
sys/arch/alpha/stand/standtest/test.c
sys/arch/amd64/amd64/locore.S
sys/arch/amd64/amd64/machdep.c
sys/arch/amd64/amd64/mainbus.c
sys/arch/amd64/conf/GENERIC
sys/arch/amiga/dev/grf_cv3d.c
sys/arch/amiga/dev/grf_cv3dreg.h
sys/arch/amiga/dev/if_es.c
sys/arch/amiga/dev/if_qn.c
sys/arch/amiga/stand/binpatch/binpatch.c
sys/arch/amiga/stand/bootblock/boot/main.c
sys/arch/arm/allwinner/awin_eth.c
sys/arch/arm/allwinner/awin_otgreg.h
sys/arch/arm/arm/cpufunc.c
sys/arch/arm/at91/at91emac.c
sys/arch/arm/broadcom/bcm53xx_eth.c
sys/arch/arm/ep93xx/epe.c
sys/arch/arm/gemini/gemini_gmac.c
sys/arch/arm/gemini/if_gpn.c
sys/arch/arm/imx/if_enet.c
sys/arch/arm/omap/files.omap2
sys/arch/arm/omap/if_cpsw.c
sys/arch/arm/omap/obio_com.c
sys/arch/arm/omap/omap2430_intr.c
sys/arch/arm/omap/omap2_obiovar.h
sys/arch/arm/omap/omap2_reg.h
sys/arch/arm/omap/omap3_scm.c
sys/arch/arm/omap/omap3_sdhc.c
sys/arch/arm/omap/omap3_sdmmcreg.h
sys/arch/arm/omap/omap_edma.c
sys/arch/arm/omap/omapl1x_emac.c
sys/arch/arm/omap/tiotg.c
sys/arch/arm/rockchip/rockchip_emac.c
sys/arch/arm/samsung/exynos_dwcmmc.c
sys/arch/arm/xscale/ixp425_if_npe.c
sys/arch/atari/stand/bootxx/bootxx.c
sys/arch/bebox/stand/boot/monitor.c
sys/arch/emips/ebus/if_le_ebus.c
sys/arch/evbarm/beagle/beagle_machdep.c
sys/arch/evbarm/conf/BEAGLEBOARDXM
sys/arch/evbarm/conf/BEAGLEBONE
sys/arch/evbarm/conf/TISDP2420
sys/arch/evbarm/conf/VTC100
sys/arch/evbarm/imx7/imx7_machdep.c
sys/arch/evbmips/loongson/loongson_clock.c
sys/arch/evbppc/virtex/dev/if_temac.c
sys/arch/ews4800mips/stand/common/cmd.c
sys/arch/hp300/stand/common/netio.c
sys/arch/hp300/stand/common/samachdep.h
sys/arch/hp300/stand/common/tgets.c
sys/arch/hp300/stand/inst/inst.c
sys/arch/hp300/stand/uboot/uboot.c
sys/arch/hpc/stand/hpcboot/arm/arm_console.cpp
sys/arch/hpcmips/dev/plumpcmcia.c
sys/arch/hpcmips/stand/lcboot/main.c
sys/arch/hpcmips/tx/tx3912video.c
sys/arch/i386/conf/GENERIC
sys/arch/i386/i386/cpu_in_cksum.S
sys/arch/i386/i386/locore.S
sys/arch/i386/i386/mainbus.c
sys/arch/i386/i386/multiboot.c
sys/arch/i386/stand/lib/biosdisk.c
sys/arch/i386/stand/lib/bootinfo.c
sys/arch/i386/stand/lib/bootinfo.h
sys/arch/i386/stand/lib/bootmenu.c
sys/arch/i386/stand/lib/exec.c
sys/arch/i386/stand/lib/menuutils.c
sys/arch/ia64/ia64/mainbus.c
sys/arch/ia64/include/mcontext.h
sys/arch/ia64/stand/common/boot.c
sys/arch/landisk/stand/boot/boot2.c
sys/arch/landisk/stand/boot/monitor.c
sys/arch/mac68k/dev/if_mc.c
sys/arch/mac68k/nubus/if_netdock_nubus.c
sys/arch/macppc/conf/GENERIC_601
sys/arch/macppc/conf/files.macppc
sys/arch/macppc/dev/am79c950.c
sys/arch/macppc/dev/if_bm.c
sys/arch/macppc/dev/if_gm.c
sys/arch/macppc/dev/platinumfb.c
sys/arch/macppc/dev/platinumfbreg.h
sys/arch/macppc/dev/pmu.c
sys/arch/macppc/dev/pmuvar.h
sys/arch/macppc/dev/valkyriefb.c
sys/arch/macppc/macppc/pic_ohare.c
sys/arch/macppc/pci/bandit.c
sys/arch/macppc/stand/ofwboot/boot.c
sys/arch/mips/README.models
sys/arch/mips/adm5120/dev/if_admsw.c
sys/arch/mips/alchemy/dev/if_aumac.c
sys/arch/mips/atheros/dev/if_ae.c
sys/arch/mips/cavium/dev/if_cnmac.c
sys/arch/mips/include/Makefile.inc
sys/arch/mips/mips/locore.S
sys/arch/mips/mips/locore_mips1.S
sys/arch/mips/mips/mipsX_subr.S
sys/arch/mips/mips/pmap.c
sys/arch/mips/ralink/ralink_eth.c
sys/arch/mips/sibyte/dev/sbmac.c
sys/arch/mvme68k/mvme68k/machdep.c
sys/arch/mvme68k/stand/bootst/boot.c
sys/arch/mvme68k/stand/netboot/boot.c
sys/arch/mvmeppc/stand/boot/boot.c
sys/arch/newsmips/apbus/if_sn.c
sys/arch/next68k/dev/if_xe.c
sys/arch/next68k/dev/mb8795.c
sys/arch/next68k/stand/boot/boot.c
sys/arch/ofppc/stand/ofwboot/boot.c
sys/arch/playstation2/dev/if_smap.c
sys/arch/pmax/ibus/sii.c
sys/arch/pmax/include/dec_prom.h
sys/arch/pmax/stand/common/callvec.c
sys/arch/powerpc/booke/dev/pq3etsec.c
sys/arch/powerpc/ibm4xx/dev/if_emac.c
sys/arch/powerpc/oea/oea_machdep.c
sys/arch/prep/stand/boot/monitor.c
sys/arch/rs6000/stand/boot/monitor.c
sys/arch/sandpoint/stand/altboot/main.c
sys/arch/sbmips/stand/common/boot.c
sys/arch/sgimips/hpc/if_sq.c
sys/arch/sgimips/ioc/oiocsc.c
sys/arch/sgimips/mace/if_mec.c
sys/arch/sgimips/sgimips/arcemu.h
sys/arch/shark/isa/clock.c
sys/arch/shark/ofw/ofw.c
sys/arch/shark/shark/i8042reg.h
sys/arch/shark/shark/ns87307.c
sys/arch/shark/shark/opms.c
sys/arch/shark/shark/profile.c
sys/arch/shark/shark/scr.c
sys/arch/shark/shark/sequoia.c
sys/arch/shark/shark/shark_machdep.c
sys/arch/shark/stand/ofwboot/boot.c
sys/arch/sparc/dev/cgfourteen.c
sys/arch/sparc/include/pci_machdep.h
sys/arch/sparc/include/sljit_machdep.h
sys/arch/sparc/stand/boot/boot.c
sys/arch/sparc/stand/ofwboot/boot.c
sys/arch/sparc64/conf/GENERIC
sys/arch/sparc64/conf/files.sparc64
sys/arch/sparc64/dev/cbus.c
sys/arch/sparc64/dev/cbusvar.h
sys/arch/sparc64/dev/ffb.c
sys/arch/sparc64/dev/fhc.c
sys/arch/sparc64/dev/gfb.c
sys/arch/sparc64/dev/psm.c
sys/arch/sparc64/dev/sbus.c
sys/arch/sparc64/dev/tda.c
sys/arch/sparc64/dev/vbus.c
sys/arch/sparc64/dev/vbusvar.h
sys/arch/sparc64/dev/vrtc.c
sys/arch/sparc64/doc/TODO
sys/arch/sparc64/include/bus_defs.h
sys/arch/sparc64/include/cpu.h
sys/arch/sparc64/include/mdesc.h
sys/arch/sparc64/include/pci_machdep.h
sys/arch/sparc64/sparc64/cache.c
sys/arch/sparc64/sparc64/clock.c
sys/arch/sparc64/sparc64/compat_16_machdep.c
sys/arch/sparc64/sparc64/locore.s
sys/arch/sparc64/sparc64/ofw_machdep.c
sys/arch/sparc64/sparc64/sunos32_machdep.c
sys/arch/sparc64/sparc64/sunos_machdep.c
sys/arch/sparc64/sparc64/trap.c
sys/arch/sun2/dev/if_ec.c
sys/arch/sun2/dev/zsvar.h
sys/arch/sun2/sun2/mbio.c
sys/arch/sun2/sun2/mbmem.c
sys/arch/sun2/sun2/obio.c
sys/arch/sun2/sun2/obmem.c
sys/arch/sun2/sun2/tod.c
sys/arch/sun3/dev/if_ie.c
sys/arch/sun68k/stand/libsa/gets.c
sys/arch/sun68k/stand/libsa/xxboot.c
sys/arch/sun68k/stand/tapeboot/boot.c
sys/arch/sun68k/sun68k/bus.c
sys/arch/usermode/dev/if_veth.c
sys/arch/usermode/usermode/pmap.c
sys/arch/vax/boot/boot/boot.c
sys/arch/vax/boot/boot/consio.c
sys/arch/vax/mba/hp.c
sys/arch/vax/uba/qv.c
sys/arch/vax/uba/qvaux.c
sys/arch/vax/vax/cfl.c
sys/arch/vax/vax/compat_13_machdep.c
sys/arch/vax/vax/crl.c
sys/arch/vax/vax/ctu.c
sys/arch/vax/vax/gencons.c
sys/arch/vax/vax/ka750.c
sys/arch/vax/vax/ka780.c
sys/arch/vax/vax/sgmap.c
sys/arch/vax/vax/trap.c
sys/arch/vax/vsa/asc_vsbus.c
sys/arch/vax/vsa/smg.c
sys/arch/vax/vsa/spx.c
sys/arch/vax/vsa/vsbus.c
sys/arch/x68k/dev/intio.c
sys/arch/x68k/dev/zs.c
sys/arch/x68k/stand/boot/Makefile
sys/arch/x68k/stand/boot/boot.c
sys/arch/x68k/stand/boot/conf.c
sys/arch/x68k/stand/boot/version
sys/arch/x68k/stand/boot_ustar/Makefile
sys/arch/x68k/stand/boot_ustar/boot_ustar.S
sys/arch/x68k/stand/libsa/devopen.c
sys/arch/x68k/stand/libsa/libx68k.h
sys/arch/x68k/stand/libsa/parseutils.c
sys/arch/x68k/stand/netboot/Makefile
sys/arch/x68k/stand/netboot/conf.c
sys/arch/x68k/stand/netboot/version
sys/arch/x68k/x68k/machdep.c
sys/arch/x86/include/pmap.h
sys/arch/x86/pci/if_vmx.c
sys/arch/x86/pci/pci_machdep.c
sys/arch/x86/pci/pci_ranges.c
sys/arch/x86/x86/coretemp.c
sys/arch/x86/x86/efi.c
sys/arch/x86/x86/intr.c
sys/arch/x86/x86/mpacpi.c
sys/arch/x86/x86/pmap.c
sys/arch/x86/x86/syscall.c
sys/arch/x86/x86/vmt.c
sys/arch/xen/include/intr.h
sys/arch/xen/include/xen-public/arch-x86/xen-mca.h
sys/arch/xen/include/xen-public/domctl.h
sys/arch/xen/include/xen-public/io/blkif.h
sys/arch/xen/include/xen-public/physdev.h
sys/arch/xen/include/xen-public/sysctl.h
sys/arch/xen/include/xen.h
sys/arch/xen/include/xenio.h
sys/arch/xen/x86/cpu.c
sys/arch/xen/x86/x86_xpmap.c
sys/arch/xen/xen/balloon.c
sys/arch/xen/xen/clock.c
sys/arch/xen/xen/hypervisor.c
sys/arch/xen/xen/if_xennet_xenbus.c
sys/arch/xen/xen/pciback.c
sys/arch/xen/xen/xen_debug.c
sys/arch/xen/xen/xen_machdep.c
sys/arch/xen/xen/xennetback_xenbus.c
sys/arch/xen/xenbus/xenbus_comms.c
sys/arch/xen/xenbus/xenbus_dev.c
sys/arch/xen/xenbus/xenbus_probe.c
sys/arch/zaurus/dev/zaudiovar.h
sys/arch/zaurus/stand/zboot/boot.c
sys/arch/zaurus/stand/zboot/bootmenu.c
sys/arch/zaurus/zaurus/machdep.c
sys/coda/coda_psdev.c
sys/compat/common/uipc_syscalls_40.c
sys/compat/linux/common/linux_socket.c
sys/compat/linux32/common/linux32_socket.c
sys/compat/svr4/svr4_sockio.c
sys/conf/files
sys/conf/majors
sys/dev/acpi/acpi.c
sys/dev/acpi/acpivar.h
sys/dev/acpi/files.acpi
sys/dev/acpi/sdhc_acpi.c
sys/dev/acpi/sony_acpi.c
sys/dev/adb/adb_keymap.h
sys/dev/ata/wd.c
sys/dev/bi/if_ni.c
sys/dev/bluetooth/btmagic.c
sys/dev/cadence/if_cemac.c
sys/dev/cardbus/if_ex_cardbus.c
sys/dev/cardbus/if_fxp_cardbus.c
sys/dev/cardbus/if_rtw_cardbus.c
sys/dev/cardbus/ohci_cardbus.c
sys/dev/cardbus/uhci_cardbus.c
sys/dev/cgd.c
sys/dev/dksubr.c
sys/dev/dkwedge/dk.c
sys/dev/fdt/fixedregulator.c
sys/dev/firmload.c
sys/dev/i2c/files.i2c
sys/dev/i2c/hytp14.c
sys/dev/i2c/hytp14var.h
sys/dev/i2c/i2c.c
sys/dev/i2c/i2c_bitbang.c
sys/dev/ic/Makefile
sys/dev/ic/adw.c
sys/dev/ic/ahcisata_core.c
sys/dev/ic/aic6915.c
sys/dev/ic/an.c
sys/dev/ic/arn5008.c
sys/dev/ic/arn9003.c
sys/dev/ic/ath.c
sys/dev/ic/atw.c
sys/dev/ic/awi.c
sys/dev/ic/bwi.c
sys/dev/ic/cac.c
sys/dev/ic/cissreg.h
sys/dev/ic/cs89x0.c
sys/dev/ic/dm9000.c
sys/dev/ic/dp8390.c
sys/dev/ic/dp83932.c
sys/dev/ic/dpt.c
sys/dev/ic/dwc_gmac.c
sys/dev/ic/elink3.c
sys/dev/ic/elinkxl.c
sys/dev/ic/gem.c
sys/dev/ic/hd64570.c
sys/dev/ic/hme.c
sys/dev/ic/i82557.c
sys/dev/ic/i82586.c
sys/dev/ic/i82596.c
sys/dev/ic/lan9118.c
sys/dev/ic/lance.c
sys/dev/ic/lemac.c
sys/dev/ic/malo.c
sys/dev/ic/mb86950.c
sys/dev/ic/mb86960.c
sys/dev/ic/midway.c
sys/dev/ic/mlx.c
sys/dev/ic/mtd803.c
sys/dev/ic/nslm7x.c
sys/dev/ic/nslm7xvar.h
sys/dev/ic/nvme.c
sys/dev/ic/nvmeio.h
sys/dev/ic/nvmereg.h
sys/dev/ic/nvmevar.h
sys/dev/ic/opl.c
sys/dev/ic/pdq_ifsubr.c
sys/dev/ic/rrunner.c
sys/dev/ic/rt2560.c
sys/dev/ic/rt2661.c
sys/dev/ic/rt2860.c
sys/dev/ic/rt2860reg.h
sys/dev/ic/rt2860var.h
sys/dev/ic/rtl8169.c
sys/dev/ic/rtl81x9.c
sys/dev/ic/rtw.c
sys/dev/ic/seeq8005.c
sys/dev/ic/sgec.c
sys/dev/ic/sl811hs.c
sys/dev/ic/smc83c170.c
sys/dev/ic/smc90cx6.c
sys/dev/ic/smc91cxx.c
sys/dev/ic/spicvar.h
sys/dev/ic/tropic.c
sys/dev/ic/tulip.c
sys/dev/ic/wi.c
sys/dev/ieee1394/if_fwip.c
sys/dev/if_ndis/if_ndis.c
sys/dev/isa/adv_isa.c
sys/dev/isa/cs89x0isa.c
sys/dev/isa/if_eg.c
sys/dev/isa/if_el.c
sys/dev/isa/if_iy.c
sys/dev/isa/lm_isa_common.c
sys/dev/isa/slhci_isa.c
sys/dev/isa/wbsio.c
sys/dev/iscsi/iscsi.h
sys/dev/iscsi/iscsi_globals.h
sys/dev/iscsi/iscsi_ioctl.c
sys/dev/iscsi/iscsi_main.c
sys/dev/iscsi/iscsi_pdu.h
sys/dev/iscsi/iscsi_rcv.c
sys/dev/iscsi/iscsi_send.c
sys/dev/iscsi/iscsi_text.c
sys/dev/iscsi/iscsi_utils.c
sys/dev/kttcp.c
sys/dev/marvell/if_gfe.c
sys/dev/marvell/if_mvgbe.c
sys/dev/marvell/if_mvxpe.c
sys/dev/midi.c
sys/dev/mii/acphy.c
sys/dev/mii/bmtphy.c
sys/dev/mii/ciphy.c
sys/dev/mii/dmphy.c
sys/dev/mii/exphy.c
sys/dev/mii/glxtphy.c
sys/dev/mii/gphyter.c
sys/dev/mii/icsphy.c
sys/dev/mii/igphy.c
sys/dev/mii/ihphy.c
sys/dev/mii/ikphy.c
sys/dev/mii/inphy.c
sys/dev/mii/iophy.c
sys/dev/mii/lxtphy.c
sys/dev/mii/makphy.c
sys/dev/mii/micphy.c
sys/dev/mii/nsphy.c
sys/dev/mii/nsphyter.c
sys/dev/mii/pnaphy.c
sys/dev/mii/qsphy.c
sys/dev/mii/rlphy.c
sys/dev/mii/sqphy.c
sys/dev/mii/tqphy.c
sys/dev/mii/ukphy.c
sys/dev/mii/urlphy.c
sys/dev/ofw/ofnet.c
sys/dev/pad/pad.c
sys/dev/pci/aac_pci.c
sys/dev/pci/amr.c
sys/dev/pci/arcmsr.c
sys/dev/pci/arcmsrvar.h
sys/dev/pci/auich.c
sys/dev/pci/auixp.c
sys/dev/pci/autri.c
sys/dev/pci/bktr/bktr_os.c
sys/dev/pci/ciss_pci.c
sys/dev/pci/cmpci.c
sys/dev/pci/cs4280.c
sys/dev/pci/cs4281.c
sys/dev/pci/cxgb/cxgb_sge.c
sys/dev/pci/cy_pci.c
sys/dev/pci/cz.c
sys/dev/pci/eap.c
sys/dev/pci/emuxki.c
sys/dev/pci/esm.c
sys/dev/pci/eso.c
sys/dev/pci/fwohci_pci.c
sys/dev/pci/genfb_pci.c
sys/dev/pci/hdaudio_pci.c
sys/dev/pci/ichsmb.c
sys/dev/pci/if_age.c
sys/dev/pci/if_alc.c
sys/dev/pci/if_bce.c
sys/dev/pci/if_bge.c
sys/dev/pci/if_bnx.c
sys/dev/pci/if_bwi_pci.c
sys/dev/pci/if_de.c
sys/dev/pci/if_dge.c
sys/dev/pci/if_esh_pci.c
sys/dev/pci/if_et.c
sys/dev/pci/if_ipw.c
sys/dev/pci/if_iwi.c
sys/dev/pci/if_iwm.c
sys/dev/pci/if_iwn.c
sys/dev/pci/if_jme.c
sys/dev/pci/if_kse.c
sys/dev/pci/if_lii.c
sys/dev/pci/if_lmc.c
sys/dev/pci/if_msk.c
sys/dev/pci/if_mtd_pci.c
sys/dev/pci/if_nfe.c
sys/dev/pci/if_pcn.c
sys/dev/pci/if_ral_pci.c
sys/dev/pci/if_rtwn.c
sys/dev/pci/if_sf_pci.c
sys/dev/pci/if_sip.c
sys/dev/pci/if_sk.c
sys/dev/pci/if_ste.c
sys/dev/pci/if_stge.c
sys/dev/pci/if_ti.c
sys/dev/pci/if_tl.c
sys/dev/pci/if_tlp_pci.c
sys/dev/pci/if_txp.c
sys/dev/pci/if_vge.c
sys/dev/pci/if_vioif.c
sys/dev/pci/if_vr.c
sys/dev/pci/if_vte.c
sys/dev/pci/if_wm.c
sys/dev/pci/if_wpi.c
sys/dev/pci/if_xge.c
sys/dev/pci/isp_pci.c
sys/dev/pci/ixgbe/ixgbe.c
sys/dev/pci/ixgbe/ixv.c
sys/dev/pci/ld_virtio.c
sys/dev/pci/mly.c
sys/dev/pci/mpt_pci.c
sys/dev/pci/nvme_pci.c
sys/dev/pci/pccbb.c
sys/dev/pci/pci_subr.c
sys/dev/pci/pcidevs
sys/dev/pci/pcidevs.h
sys/dev/pci/pcidevs_data.h
sys/dev/pci/pciide_common.c
sys/dev/pci/puc.c
sys/dev/pci/rtsx_pci.c
sys/dev/pci/trm.c
sys/dev/pci/twa.c
sys/dev/pci/twe.c
sys/dev/pci/ubsec.c
sys/dev/pci/vga_pci.c
sys/dev/pci/viomb.c
sys/dev/pci/virtio.c
sys/dev/pci/weasel_pci.c
sys/dev/pcmcia/esp_pcmcia.c
sys/dev/pcmcia/if_cnw.c
sys/dev/pcmcia/if_cs_pcmcia.c
sys/dev/pcmcia/if_ep_pcmcia.c
sys/dev/pcmcia/if_mbe_pcmcia.c
sys/dev/pcmcia/if_ray.c
sys/dev/pcmcia/if_sm_pcmcia.c
sys/dev/pcmcia/if_wi_pcmcia.c
sys/dev/pcmcia/if_xi.c
sys/dev/pcmcia/pcmciadevs
sys/dev/pcmcia/pcmciadevs.h
sys/dev/pcmcia/pcmciadevs_data.h
sys/dev/qbus/if_dmc.c
sys/dev/qbus/if_qe.c
sys/dev/qbus/if_uba.c
sys/dev/sbus/be.c
sys/dev/sbus/qe.c
sys/dev/scsipi/if_se.c
sys/dev/scsipi/scsiconf.c
sys/dev/sdmmc/sdhc.c
sys/dev/usb/files.usb
sys/dev/usb/if_athn_usb.c
sys/dev/usb/if_atu.c
sys/dev/usb/if_aue.c
sys/dev/usb/if_axe.c
sys/dev/usb/if_axen.c
sys/dev/usb/if_cdce.c
sys/dev/usb/if_cue.c
sys/dev/usb/if_kue.c
sys/dev/usb/if_otus.c
sys/dev/usb/if_rum.c
sys/dev/usb/if_run.c
sys/dev/usb/if_smsc.c
sys/dev/usb/if_udav.c
sys/dev/usb/if_upl.c
sys/dev/usb/if_ural.c
sys/dev/usb/if_url.c
sys/dev/usb/if_urndis.c
sys/dev/usb/if_urtw.c
sys/dev/usb/if_urtwn.c
sys/dev/usb/if_zyd.c
sys/dev/usb/moscom.c
sys/dev/usb/motg.c
sys/dev/usb/pseye.c
sys/dev/usb/slurm.c
sys/dev/usb/stuirda.c
sys/dev/usb/uark.c
sys/dev/usb/uaudio.c
sys/dev/usb/ubsa.c
sys/dev/usb/ubt.c
sys/dev/usb/uchcom.c
sys/dev/usb/ucycom.c
sys/dev/usb/udsbr.c
sys/dev/usb/udsir.c
sys/dev/usb/uftdi.c
sys/dev/usb/ugen.c
sys/dev/usb/ugensa.c
sys/dev/usb/uhid.c
sys/dev/usb/uhidev.c
sys/dev/usb/uhso.c
sys/dev/usb/uipaq.c
sys/dev/usb/uirda.c
sys/dev/usb/ukyopon.c
sys/dev/usb/ulpt.c
sys/dev/usb/umass.c
sys/dev/usb/umass_quirks.c
sys/dev/usb/umass_scsipi.c
sys/dev/usb/umassvar.h
sys/dev/usb/umcs.c
sys/dev/usb/umct.c
sys/dev/usb/umidi.c
sys/dev/usb/umodem.c
sys/dev/usb/umodem_common.c
sys/dev/usb/uplcom.c
sys/dev/usb/urio.c
sys/dev/usb/usbdevs
sys/dev/usb/usbdevs.h
sys/dev/usb/usbdevs_data.h
sys/dev/usb/uscanner.c
sys/dev/usb/uslsa.c
sys/dev/usb/usscanner.c
sys/dev/usb/ustir.c
sys/dev/usb/utoppy.c
sys/dev/usb/uvideo.c
sys/dev/usb/uvisor.c
sys/dev/usb/uvscom.c
sys/dev/usb/xhci.c
sys/dev/wscons/wsconsio.h
sys/dev/wscons/wsdisplay.c
sys/dev/wscons/wsdisplay_vconsvar.h
sys/dev/wscons/wsmux.c
sys/dist/pf/net/if_pfsync.c
sys/dist/pf/net/pf.c
sys/dist/pf/net/pf_if.c
sys/external/bsd/ipf/netinet/ip_compat.h
sys/external/bsd/ipf/netinet/ip_fil_netbsd.c
sys/external/bsd/ipf/netinet/ip_htable.c
sys/external/bsd/ipf/netinet/ip_lookup.c
sys/external/bsd/ipf/netinet/ip_pool.c
sys/external/bsd/sljit/README.import
sys/external/bsd/sljit/dist/API_CHANGES
sys/external/bsd/sljit/dist/Makefile
sys/external/bsd/sljit/dist/README
sys/external/bsd/sljit/dist/doc/overview.txt
sys/external/bsd/sljit/dist/doc/tutorial/99bottles.bf
sys/external/bsd/sljit/dist/doc/tutorial/README
sys/external/bsd/sljit/dist/doc/tutorial/array_access.c
sys/external/bsd/sljit/dist/doc/tutorial/brainfuck.c
sys/external/bsd/sljit/dist/doc/tutorial/branch.c
sys/external/bsd/sljit/dist/doc/tutorial/first_program.c
sys/external/bsd/sljit/dist/doc/tutorial/func_call.c
sys/external/bsd/sljit/dist/doc/tutorial/hello.bf
sys/external/bsd/sljit/dist/doc/tutorial/loop.c
sys/external/bsd/sljit/dist/doc/tutorial/sljit_tutorial.html
sys/external/bsd/sljit/dist/doc/tutorial/struct_access.c
sys/external/bsd/sljit/dist/doc/tutorial/temp_var.c
sys/external/bsd/sljit/dist/hist
sys/external/bsd/sljit/dist/regex_src/regexJIT.c
sys/external/bsd/sljit/dist/regex_src/regexMain.c
sys/external/bsd/sljit/dist/sljit_src/sljitConfig.h
sys/external/bsd/sljit/dist/sljit_src/sljitConfigInternal.h
sys/external/bsd/sljit/dist/sljit_src/sljitExecAllocator.c
sys/external/bsd/sljit/dist/sljit_src/sljitLir.c
sys/external/bsd/sljit/dist/sljit_src/sljitLir.h
sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_32.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_64.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativeARM_T2_32.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_32.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_64.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativeMIPS_common.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_32.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_64.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativePPC_common.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativeSPARC_32.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativeSPARC_common.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativeTILEGX_64.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_32.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_64.c
sys/external/bsd/sljit/dist/sljit_src/sljitNativeX86_common.c
sys/external/bsd/sljit/dist/sljit_src/sljitUtils.c
sys/external/bsd/sljit/dist/test_src/sljitMain.c
sys/external/bsd/sljit/dist/test_src/sljitTest.c
sys/fs/efs/efs_dinode.h
sys/fs/efs/efs_dir.h
sys/fs/efs/efs_vfsops.c
sys/fs/efs/efs_vnops.c
sys/fs/msdosfs/msdosfs_conv.c
sys/fs/nfs/common/krpc_subr.c
sys/fs/nfs/common/nfs_fha.h
sys/fs/nfs/common/nfsm_subs.h
sys/fs/nfs/nlm/nlm.h
sys/fs/nilfs/nilfs_vfsops.c
sys/fs/puffs/puffs_msgif.c
sys/fs/puffs/puffs_sys.h
sys/fs/puffs/puffs_vnops.c
sys/kern/core_elf32.c
sys/kern/init_main.c
sys/kern/init_sysctl.c
sys/kern/init_sysent.c
sys/kern/kern_core.c
sys/kern/kern_ctf.c
sys/kern/kern_exec.c
sys/kern/kern_history.c
sys/kern/kern_ktrace.c
sys/kern/kern_lwp.c
sys/kern/kern_module.c
sys/kern/kern_mutex.c
sys/kern/kern_pmf.c
sys/kern/kern_ras.c
sys/kern/kern_runq.c
sys/kern/kern_sleepq.c
sys/kern/kern_softint.c
sys/kern/kern_synch.c
sys/kern/kern_time.c
sys/kern/subr_autoconf.c
sys/kern/subr_hash.c
sys/kern/subr_kobj.c
sys/kern/subr_kobj_vfs.c
sys/kern/subr_optstr.c
sys/kern/subr_tftproot.c
sys/kern/subr_vmem.c
sys/kern/sys_aio.c
sys/kern/sys_sched.c
sys/kern/sys_socket.c
sys/kern/syscalls.c
sys/kern/syscalls.master
sys/kern/syscalls_autoload.c
sys/kern/systrace_args.c
sys/kern/tty.c
sys/kern/uipc_mbuf.c
sys/kern/uipc_sem.c
sys/kern/uipc_socket.c
sys/lib/libsa/alloc.c
sys/lib/libsa/bootp.c
sys/lib/libsa/getfile.c
sys/lib/libsa/gets.c
sys/lib/libsa/stand.h
sys/modules/Makefile
sys/modules/bpf/Makefile
sys/modules/bpf_filter/Makefile
sys/modules/ext2fs/Makefile
sys/modules/i2c_bitbang/Makefile
sys/modules/iic/Makefile
sys/modules/ipl/Makefile
sys/modules/zfs/Makefile.zfsmod
sys/net/agr/if_agr.c
sys/net/bpf.c
sys/net/bpf_filter.c
sys/net/bpfjit.c
sys/net/bridgestp.c
sys/net/if.c
sys/net/if.h
sys/net/if_atmsubr.c
sys/net/if_bridge.c
sys/net/if_ecosubr.c
sys/net/if_ethersubr.c
sys/net/if_faith.c
sys/net/if_gif.c
sys/net/if_gif.h
sys/net/if_gre.c
sys/net/if_ieee1394subr.c
sys/net/if_llatbl.c
sys/net/if_loop.c
sys/net/if_mpls.c
sys/net/if_ppp.c
sys/net/if_pppoe.c
sys/net/if_sl.c
sys/net/if_spppsubr.c
sys/net/if_srt.c
sys/net/if_stf.c
sys/net/if_strip.c
sys/net/if_tap.c
sys/net/if_tun.c
sys/net/if_vlan.c
sys/net/link_proto.c
sys/net/npf/npf_ext_log.c
sys/net/ppp_tty.c
sys/net/route.c
sys/net/rtsock.c
sys/net80211/ieee80211_output.c
sys/net80211/ieee80211_proto.c
sys/net80211/ieee80211_rssadapt.c
sys/netatalk/aarp.c
sys/netatalk/at_control.c
sys/netatalk/ddp_input.c
sys/netatalk/ddp_output.c
sys/netinet/accf_data.c
sys/netinet/dccp_tcplike.h
sys/netinet/dccp_tfrc.c
sys/netinet/dccp_tfrc.h
sys/netinet/dccp_usrreq.c
sys/netinet/dccp_var.h
sys/netinet/if_arp.c
sys/netinet/igmp.c
sys/netinet/in.c
sys/netinet/in_gif.c
sys/netinet/in_gif.h
sys/netinet/in_pcb.c
sys/netinet/in_selsrc.c
sys/netinet/in_var.h
sys/netinet/ip_carp.c
sys/netinet/ip_encap.c
sys/netinet/ip_encap.h
sys/netinet/ip_etherip.c
sys/netinet/ip_flow.c
sys/netinet/ip_icmp.c
sys/netinet/ip_input.c
sys/netinet/ip_mroute.c
sys/netinet/ip_output.c
sys/netinet/ip_var.h
sys/netinet/sctp_asconf.c
sys/netinet/sctp_input.c
sys/netinet/sctp_output.c
sys/netinet/sctp_pcb.c
sys/netinet/sctp_usrreq.c
sys/netinet/sctputil.c
sys/netinet/tcp_input.c
sys/netinet/tcp_output.c
sys/netinet/tcp_subr.c
sys/netinet/udp_usrreq.c
sys/netinet6/icmp6.c
sys/netinet6/in6.c
sys/netinet6/in6_gif.c
sys/netinet6/in6_gif.h
sys/netinet6/in6_ifattach.c
sys/netinet6/in6_pcb.c
sys/netinet6/in6_proto.c
sys/netinet6/in6_src.c
sys/netinet6/in6_var.h
sys/netinet6/ip6_etherip.c
sys/netinet6/ip6_flow.c
sys/netinet6/ip6_forward.c
sys/netinet6/ip6_input.c
sys/netinet6/ip6_mroute.c
sys/netinet6/ip6_output.c
sys/netinet6/ip6_var.h
sys/netinet6/mld6.c
sys/netinet6/nd6.c
sys/netinet6/nd6_nbr.c
sys/netinet6/nd6_rtr.c
sys/netinet6/raw_ip6.c
sys/netinet6/scope6.c
sys/netinet6/sctp6_usrreq.c
sys/netinet6/udp6_output.c
sys/netinet6/udp6_usrreq.c
sys/netipsec/ipsec6.h
sys/netipsec/ipsec_input.c
sys/netipsec/ipsec_netbsd.c
sys/netipsec/ipsec_osdep.h
sys/netipsec/key.c
sys/netipsec/key_debug.c
sys/netipsec/keysock.c
sys/netipsec/xform_ipip.c
sys/netisdn/i4b_ipr.c
sys/netisdn/i4b_isppp.c
sys/netmpls/mpls_ttl.c
sys/netnatm/natm.c
sys/nfs/krpc_subr.c
sys/nfs/nfs_bootdhcp.c
sys/nfs/nfs_clntsocket.c
sys/nfs/nfs_socket.c
sys/nfs/nfs_subs.c
sys/nfs/nfs_syscalls.c
sys/opencrypto/crypto.c
sys/opencrypto/cryptodev.c
sys/opencrypto/cryptodev.h
sys/rump/Makefile.rump
sys/rump/dev/lib/libpci/pci_user.h
sys/rump/dev/lib/librnd/rnd_component.c
sys/rump/fs/lib/libext2fs/Makefile
sys/rump/include/rump/rump_syscalls.h
sys/rump/librump/rumpkern/klock.c
sys/rump/librump/rumpkern/rump_syscalls.c
sys/rump/net/lib/libshmif/if_shmem.c
sys/rump/net/lib/libvirtif/if_virt.c
sys/sys/cdefs_elf.h
sys/sys/device.h
sys/sys/exec_aout.h
sys/sys/exec_elf.h
sys/sys/fcntl.h
sys/sys/ieee754.h
sys/sys/kobj_impl.h
sys/sys/lwp.h
sys/sys/mbuf.h
sys/sys/md4.h
sys/sys/md5.h
sys/sys/mman.h
sys/sys/param.h
sys/sys/proc.h
sys/sys/pslist.h
sys/sys/rmd160.h
sys/sys/sched.h
sys/sys/sdt.h
sys/sys/sha1.h
sys/sys/signal.h
sys/sys/socketvar.h
sys/sys/syscall.h
sys/sys/syscallargs.h
sys/sys/systm.h
sys/sys/timepps.h
sys/sys/unistd.h
sys/sys/vnode.h
sys/sys/wait.h
sys/ufs/ext2fs/Makefile
sys/ufs/ext2fs/ext2fs.h
sys/ufs/ext2fs/ext2fs_bmap.c
sys/ufs/ext2fs/ext2fs_dir.h
sys/ufs/ext2fs/ext2fs_extents.c
sys/ufs/ext2fs/ext2fs_extents.h
sys/ufs/ext2fs/ext2fs_extern.h
sys/ufs/ext2fs/ext2fs_hash.c
sys/ufs/ext2fs/ext2fs_hash.h
sys/ufs/ext2fs/ext2fs_htree.c
sys/ufs/ext2fs/ext2fs_htree.h
sys/ufs/ext2fs/ext2fs_lookup.c
sys/ufs/ffs/ffs_quota2.c
sys/ufs/ffs/ffs_vfsops.c
sys/ufs/files.ufs
sys/ufs/lfs/lfs.h
sys/ufs/lfs/lfs_accessors.h
sys/ufs/lfs/lfs_extern.h
sys/ufs/lfs/lfs_inode.h
sys/ufs/lfs/lfs_kernel.h
sys/ufs/lfs/lfs_rename.c
sys/ufs/lfs/lfs_vfsops.c
sys/ufs/lfs/lfs_vnops.c
sys/ufs/lfs/ulfs_bswap.h
sys/ufs/lfs/ulfs_dinode.h
sys/ufs/lfs/ulfs_dirhash.c
sys/ufs/lfs/ulfs_dirhash.h
sys/ufs/lfs/ulfs_extattr.c
sys/ufs/lfs/ulfs_extattr.h
sys/ufs/lfs/ulfs_extern.h
sys/ufs/lfs/ulfs_inode.c
sys/ufs/lfs/ulfs_inode.h
sys/ufs/lfs/ulfs_quota.c
sys/ufs/lfs/ulfs_quota.h
sys/ufs/lfs/ulfs_quota1.c
sys/ufs/lfs/ulfs_quota1.h
sys/ufs/lfs/ulfs_quota2.c
sys/ufs/lfs/ulfs_vnops.c
sys/ufs/ufs/inode.h
sys/ufs/ufs/ufs_extattr.c
sys/ufs/ufs/ufs_quota1.c
sys/uvm/pmap/pmap.h
sys/uvm/uvm_map.c
sys/uvm/uvm_mmap.c
sys/uvm/uvm_swap.c
--- a/sys/altq/altq_cbq.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/altq/altq_cbq.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_cbq.c,v 1.28.2.1 2016/04/22 15:44:08 skrll Exp $	*/
+/*	$NetBSD: altq_cbq.c,v 1.28.2.2 2016/07/09 20:24:48 skrll Exp $	*/
 /*	$KAME: altq_cbq.c,v 1.21 2005/04/13 03:44:24 suz Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.28.2.1 2016/04/22 15:44:08 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.28.2.2 2016/07/09 20:24:48 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq.h"
@@ -592,7 +592,7 @@
 	ifp = ifq->altq_ifp;
 	if (ifp->if_start &&
 	    cbqp->cbq_qlen > 0 && (ifp->if_flags & IFF_OACTIVE) == 0)
-		(*ifp->if_start)(ifp);
+		if_start_lock(ifp);
 }
 
 static void
--- a/sys/altq/altq_cdnr.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/altq/altq_cdnr.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_cdnr.c,v 1.20 2011/11/19 22:51:18 tls Exp $	*/
+/*	$NetBSD: altq_cdnr.c,v 1.20.26.1 2016/07/09 20:24:48 skrll Exp $	*/
 /*	$KAME: altq_cdnr.c,v 1.15 2005/04/13 03:44:24 suz Exp $	*/
 
 /*
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: altq_cdnr.c,v 1.20 2011/11/19 22:51:18 tls Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_cdnr.c,v 1.20.26.1 2016/07/09 20:24:48 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq.h"
@@ -139,7 +139,7 @@
 	struct cdnr_block	*cb;
 	struct cdnr_pktinfo	pktinfo;
 
-	ifp = m->m_pkthdr.rcvif;
+	ifp = m_get_rcvif_NOMPSAFE(m);
 	if (!ALTQ_IS_CNDTNING(&ifp->if_snd))
 		/* traffic conditioner is not enabled on this interface */
 		return (1);
--- a/sys/altq/altq_subr.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/altq/altq_subr.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_subr.c,v 1.29.4.2 2016/05/29 08:44:15 skrll Exp $	*/
+/*	$NetBSD: altq_subr.c,v 1.29.4.3 2016/07/09 20:24:48 skrll Exp $	*/
 /*	$KAME: altq_subr.c,v 1.24 2005/04/13 03:44:25 suz Exp $	*/
 
 /*
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: altq_subr.c,v 1.29.4.2 2016/05/29 08:44:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_subr.c,v 1.29.4.3 2016/07/09 20:24:48 skrll Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq.h"
@@ -366,7 +366,7 @@
 		active++;
 		if (!IFQ_IS_EMPTY(&ifp->if_snd) && ifp->if_start != NULL) {
 			int _s = splnet();
-			(*ifp->if_start)(ifp);
+			if_start_lock(ifp);
 			splx(_s);
 		}
 
--- a/sys/arch/acorn26/ioc/if_eca.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/acorn26/ioc/if_eca.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_eca.c,v 1.13 2012/05/11 15:39:18 skrll Exp $	*/
+/*	$NetBSD: if_eca.c,v 1.13.16.1 2016/07/09 20:24:48 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 Ben Harris
@@ -29,7 +29,7 @@
 
 #include <sys/param.h>
 
-__KERNEL_RCSID(0, "$NetBSD: if_eca.c,v 1.13 2012/05/11 15:39:18 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_eca.c,v 1.13.16.1 2016/07/09 20:24:48 skrll Exp $");
 
 #include <sys/device.h>
 #include <sys/malloc.h>
@@ -480,7 +480,7 @@
 			m_freem(mtail->m_next);
 			mtail->m_next = NULL;
 			/* Set up the header of the chain. */
-			m->m_pkthdr.rcvif = ifp;
+			m_set_rcvif(m, ifp);
 			m->m_pkthdr.len = 0;
 			for (n = m; n != NULL; n = n->m_next)
 				m->m_pkthdr.len += n->m_len;
--- a/sys/arch/acorn26/stand/boot26/boot26.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/acorn26/stand/boot26/boot26.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot26.c,v 1.6 2011/01/22 19:19:14 joerg Exp $	*/
+/*	$NetBSD: boot26.c,v 1.6.32.1 2016/07/09 20:24:48 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 Ben Harris
@@ -99,7 +99,7 @@
 	if (file == NULL) {
 		if (howto & RB_ASKNAME) {
 			printf("boot: ");
-			gets(fbuf);
+			kgets(fbuf, sizeof(fbuf));
 			file = fbuf;
 		} else
 			file = "netbsd";
--- a/sys/arch/acorn32/podulebus/if_ie.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/acorn32/podulebus/if_ie.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_ie.c,v 1.34.2.2 2016/03/19 11:29:54 skrll Exp $ */
+/* $NetBSD: if_ie.c,v 1.34.2.3 2016/07/09 20:24:48 skrll Exp $ */
 
 /*
  * Copyright (c) 1995 Melvin Tang-Richardson.
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ie.c,v 1.34.2.2 2016/03/19 11:29:54 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ie.c,v 1.34.2.3 2016/07/09 20:24:48 skrll Exp $");
 
 #define IGNORE_ETHER1_IDROM_CHECKSUM
 
@@ -1102,7 +1102,7 @@
     if ( m==0 )
 	return 0;
 
-    m->m_pkthdr.rcvif = &sc->sc_ethercom.ec_if;
+    m_set_rcvif(m, &sc->sc_ethercom.ec_if);
     m->m_pkthdr.len = totlen;
     len = MHLEN;
     top = 0;
--- a/sys/arch/acorn32/stand/boot32/boot32.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/acorn32/stand/boot32/boot32.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot32.c,v 1.41 2014/03/21 16:43:00 christos Exp $	*/
+/*	$NetBSD: boot32.c,v 1.41.6.1 2016/07/09 20:24:48 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2002 Reinoud Zandijk
@@ -1038,7 +1038,7 @@
 	if (*file == NULL) {
 		if (*howto & RB_ASKNAME) {
 			printf("boot: ");
-			gets(filename);
+			kgets(filename, sizeof(filename));
 			strcpy(file, filename);
 		} else
 			strcpy(file, "netbsd");
--- a/sys/arch/algor/dev/bonito_mainbus.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/algor/dev/bonito_mainbus.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: bonito_mainbus.c,v 1.15.14.1 2015/09/22 12:05:35 skrll Exp $	*/
+/*	$NetBSD: bonito_mainbus.c,v 1.15.14.2 2016/07/09 20:24:49 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bonito_mainbus.c,v 1.15.14.1 2015/09/22 12:05:35 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bonito_mainbus.c,v 1.15.14.2 2016/07/09 20:24:49 skrll Exp $");
 
 #include "opt_algor_p6032.h"
 
@@ -85,6 +85,9 @@
 	 */
 #if defined(ALGOR_P6032)
 	bc = &p6032_configuration.ac_bonito;
+#else
+	/* I guess... XXX? */
+	bc = NULL;
 #endif
 	sc->sc_bonito = bc;
 
--- a/sys/arch/alpha/stand/common/boot.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/alpha/stand/common/boot.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.32 2011/01/22 19:19:15 joerg Exp $ */
+/* $NetBSD: boot.c,v 1.32.32.1 2016/07/09 20:24:49 skrll Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -118,7 +118,7 @@
 
 	if (strchr(boot_flags, 'i') || strchr(boot_flags, 'I')) {
 		printf("Boot file: ");
-		gets(boot_file);
+		kgets(boot_file, sizeof(boot_file));
 	}
 
 #ifdef NO_LOAD_BACKWARDS
--- a/sys/arch/alpha/stand/standtest/test.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/alpha/stand/standtest/test.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: test.c,v 1.5.32.1 2015/12/27 12:09:28 skrll Exp $ */
+/* $NetBSD: test.c,v 1.5.32.2 2016/07/09 20:24:49 skrll Exp $ */
 
 /*
  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
@@ -115,7 +115,7 @@
 
 	do {
 		printf("test> ");
-		gets(input_buf);
+		kgets(input_buf, sizeof(input_buf));
 
 		dispatch_cmd(input_buf, toplevel_cmds);
 	} while (!done);
--- a/sys/arch/amd64/amd64/locore.S	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/amd64/amd64/locore.S	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.77.2.3 2016/05/29 08:44:15 skrll Exp $	*/
+/*	$NetBSD: locore.S,v 1.77.2.4 2016/07/09 20:24:49 skrll Exp $	*/
 
 /*
  * Copyright-o-rama!
@@ -9,7 +9,7 @@
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum and Maxime Villard.
+ * by Charles M. Hannum and by Maxime Villard.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -203,11 +203,12 @@
 #endif
 
 #define PROC0_PML4_OFF	0
-#define PROC0_PTP3_OFF	(PROC0_PML4_OFF + 1 * PAGE_SIZE)
+#define PROC0_STK_OFF	(PROC0_PML4_OFF + 1 * PAGE_SIZE)
+#define PROC0_PTP3_OFF	(PROC0_STK_OFF + UPAGES * PAGE_SIZE)
 #define PROC0_PTP2_OFF	(PROC0_PTP3_OFF + NKL4_KIMG_ENTRIES * PAGE_SIZE)
 #define PROC0_PTP1_OFF	(PROC0_PTP2_OFF + TABLE_L3_ENTRIES * PAGE_SIZE)
 #define TABLESIZE \
-  ((NKL4_KIMG_ENTRIES + TABLE_L3_ENTRIES + TABLE_L2_ENTRIES + 1) \
+  ((NKL4_KIMG_ENTRIES + TABLE_L3_ENTRIES + TABLE_L2_ENTRIES + 1 + UPAGES) \
     * PAGE_SIZE)
 
 /*
@@ -270,21 +271,41 @@
 
 
 #ifdef XEN
+#define __ASSEMBLY__
+#include <xen/xen-public/elfnote.h>
+#include <xen/xen-public/xen.h>
+#define ELFNOTE(name, type, desctype, descdata...) \
+.pushsection .note.name			;	\
+  .align 4				;	\
+  .long 2f - 1f		/* namesz */	;	\
+  .long 4f - 3f		/* descsz */	;	\
+  .long type				;	\
+1:.asciz #name				;	\
+2:.align 4				;	\
+3:desctype descdata			;	\
+4:.align 4				;	\
+.popsection
+
 /*
  * Xen guest identifier and loader selection
  */
 .section __xen_guest
-	.ascii	"GUEST_OS=NetBSD,GUEST_VER=4.99"
-	.ascii	",XEN_VER=xen-3.0"
-	.ascii	",LOADER=generic"
-	.ascii	",VIRT_BASE=0xffffffff80000000"
-	.ascii	",ELF_PADDR_OFFSET=0xffffffff80000000"
-	.ascii	",VIRT_ENTRY=0xffffffff80100000"
-	.ascii	",HYPERCALL_PAGE=0x00000101" /*  (???+HYPERCALL_PAGE_OFFSET)/PAGE_SIZE) */
+	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_OS,       .asciz, "NetBSD")
+	ELFNOTE(Xen, XEN_ELFNOTE_GUEST_VERSION,  .asciz, "4.99")
+	ELFNOTE(Xen, XEN_ELFNOTE_XEN_VERSION,    .asciz, "xen-3.0")
+	ELFNOTE(Xen, XEN_ELFNOTE_VIRT_BASE,      .quad,  KERNBASE)
+	ELFNOTE(Xen, XEN_ELFNOTE_PADDR_OFFSET,   .quad,  KERNBASE)
+	ELFNOTE(Xen, XEN_ELFNOTE_ENTRY,          .quad,  start)
+	ELFNOTE(Xen, XEN_ELFNOTE_HYPERCALL_PAGE, .quad,  hypercall_page)
+	ELFNOTE(Xen, XEN_ELFNOTE_HV_START_LOW,   .quad,  HYPERVISOR_VIRT_START)
+	ELFNOTE(Xen, XEN_ELFNOTE_FEATURES,       .asciz, "")
+	ELFNOTE(Xen, XEN_ELFNOTE_PAE_MODE,       .asciz, "yes")
+	ELFNOTE(Xen, XEN_ELFNOTE_L1_MFN_VALID,   .long,  PG_V, PG_V)\
+	ELFNOTE(Xen, XEN_ELFNOTE_LOADER,         .asciz, "generic")     
+	ELFNOTE(Xen, XEN_ELFNOTE_SUSPEND_CANCEL, .long,  0)
 #if NKSYMS > 0 || defined(DDB) || defined(MODULAR)
-	.ascii	",BSD_SYMTAB=yes"
+	ELFNOTE(Xen, XEN_ELFNOTE_BSD_SYMTAB,     .asciz, "yes")
 #endif
-	.byte	0
 #endif	/* XEN */
 
 /*
@@ -321,23 +342,23 @@
 END(lapic_isr)
 #endif /* NLAPIC > 0 */
 
-	.globl	_C_LABEL(proc0stack)
+	.globl	_C_LABEL(tablesize)
 	.globl	_C_LABEL(nox_flag)
+	.globl	_C_LABEL(cputype)
 	.globl	_C_LABEL(cpuid_level)
 	.globl	_C_LABEL(esym)
 	.globl	_C_LABEL(eblob)
+	.globl	_C_LABEL(atdevbase)
+	.globl	_C_LABEL(PDPpaddr)
 	.globl	_C_LABEL(boothowto)
 	.globl	_C_LABEL(bootinfo)
-	.globl	_C_LABEL(atdevbase)
-	.globl	_C_LABEL(PDPpaddr)
 	.globl	_C_LABEL(biosbasemem)
 	.globl	_C_LABEL(biosextmem)
 	.globl	_C_LABEL(gdtstore)
-	.globl	_C_LABEL(cputype)
 
-	.type	_C_LABEL(proc0stack), @object
-LABEL(proc0stack)	.quad	0	/* physical address of proc0's stack */
-END(proc0stack)
+	.type	_C_LABEL(tablesize), @object
+_C_LABEL(tablesize):	.long	TABLESIZE
+END(tablesize)
 	.type	_C_LABEL(nox_flag), @object
 LABEL(nox_flag)		.long	0	/* 32bit NOX flag, set if supported */
 END(nox_flag)
@@ -564,7 +585,7 @@
 	 * The boot program should check:
 	 *	text+data <= &stack_variable - more_space_for_stack
 	 *	text+data+bss+pad+space_for_page_tables <= end_of_memory
-	 * 
+	 *
 	 * XXX: the gdt is in the carcass of the boot program so clearing
 	 * the rest of memory is still not possible.
 	 */
@@ -585,17 +606,20 @@
  * be referred to as: L4 -> L3 -> L2 -> L1.
  *
  * Virtual address space of the kernel:
- * +------+--------+------+-----+--------+---------------------+-----------+-
- * | TEXT | RODATA | DATA | BSS | [SYMS] | [PRELOADED MODULES] | PROC0 STK |
- * +------+--------+------+-----+--------+---------------------+-----------+-
- *                             (1)      (2)                   (3)         (4)
+ * +------+--------+------+-----+--------+---------------------+----------
+ * | TEXT | RODATA | DATA | BSS | [SYMS] | [PRELOADED MODULES] | L4 ->
+ * +------+--------+------+-----+--------+---------------------+----------
+ *                             (1)      (2)                   (3)
  *
- * -----+-----+-----+----+------------+
- *  L4 -> L3 -> L2 -> L1 | ISA IO MEM |
- * -----+-----+-----+----+------------+
- *                      (5)
+ * --------------+-----+-----+----+-------------+
+ * -> PROC0 STK -> L3 -> L2 -> L1 | ISA I/O MEM |
+ * --------------+-----+-----+----+-------------+
+ *                               (4)
  *
- * (L4 + L3 + L2 + L1) is later referred to as BOOTSTRAP TABLES.
+ * PROC0 STK is obviously not linked as a page level. It just happens to be
+ * caught between L4 and L3.
+ *
+ * (PROC0 STK + L4 + L3 + L2 + L1) is later referred to as BOOTSTRAP TABLES.
  *
  * Important note: the kernel segments are properly 4k-aligned
  * (see kern.ldscript), so there's no need to enforce alignment.
@@ -621,17 +645,11 @@
 	movl	%eax,%edi
 1:
 
-	/* We are on (3). Align up for PROC0 STK. */
+	/* We are on (3). Align up for BOOTSTRAP TABLES. */
 	movl	%edi,%esi
 	addl	$PGOFSET,%esi
 	andl	$~PGOFSET,%esi
 
-	/* Save proc0's stack pa, and allocate it. Brings us on (4). */
-	movl	$RELOC(proc0stack),%ebp
-	movl	%esi,(%ebp)
-	movl	$0,4(%ebp)
-	addl	$USPACE,%esi
-
 	/* We are on the BOOTSTRAP TABLES. Save L4's physical address. */
 	movl	$RELOC(PDPpaddr),%ebp
 	movl	%esi,(%ebp)
@@ -685,16 +703,8 @@
 	orl	$(PG_V|PG_KW),%eax
 	fillkpt_nox
 
-	/* Map [SYMS]+[PRELOADED MODULES] RWX. */
+	/* Map [SYMS]+[PRELOADED MODULES] RW. */
 	movl	$RELOC(__kernel_end),%eax
-	movl	RELOC(proc0stack),%ecx	/* start of PROC0 STK */
-	subl	%eax,%ecx
-	shrl	$PGSHIFT,%ecx
-	orl	$(PG_V|PG_KW),%eax
-	fillkpt
-
-	/* Map PROC0 STK RW. */
-	movl	RELOC(proc0stack),%eax	/* start of PROC0 STK */
 	movl	%esi,%ecx		/* start of BOOTSTRAP TABLES */
 	subl	%eax,%ecx
 	shrl	$PGSHIFT,%ecx
@@ -708,10 +718,12 @@
 	orl	$(PG_V|PG_KW),%eax
 	fillkpt_nox
 
-	/* We are on (5). Map ISA I/O mem (later atdevbase) RWX. */
-	movl	$(IOM_BEGIN|PG_V|PG_KW/*|PG_N*/),%eax
-	movl	$(IOM_SIZE>>PGSHIFT),%ecx
-	fillkpt
+	/* We are on (4). Map ISA I/O MEM RW. */
+	movl	$IOM_BEGIN,%eax
+	movl	$IOM_SIZE,%ecx	/* size of ISA I/O MEM */
+	shrl	$PGSHIFT,%ecx
+	orl	$(PG_V|PG_KW/*|PG_N*/),%eax
+	fillkpt_nox
 
 	/*
 	 * Build L2. Linked to L1.
@@ -765,12 +777,12 @@
 	movl	$NKL4_KIMG_ENTRIES,%ecx
 	fillkpt
 
-	/* Install recursive top level PDE */
+	/* Install recursive top level PDE (one entry) */
 	leal	(PROC0_PML4_OFF + PDIR_SLOT_PTE * PDE_SIZE)(%esi),%ebx
 	leal	(PROC0_PML4_OFF)(%esi),%eax
 	orl	$(PG_V|PG_KW),%eax
-	movl	%eax,(%ebx)
-	movl	$0,(PDE_SIZE-4)(%ebx)
+	movl	$1,%ecx
+	fillkpt_nox
 
 	/*
 	 * Startup checklist:
@@ -870,7 +882,7 @@
 	movq	%rdx,_C_LABEL(atdevbase)(%rip)
 
 	/* Set up bootstrap stack. */
-	movq	_C_LABEL(proc0stack),%rax
+	leaq	(PROC0_STK_OFF)(%rsi),%rax
 	addq	%r8,%rax
 	movq	%rax,(_C_LABEL(lwp0)+L_PCB)(%rip) /* XXX L_PCB != uarea */
 	leaq	(USPACE-FRAMESIZE)(%rax),%rsp
@@ -1060,7 +1072,7 @@
 
 /*
  * struct lwp *cpu_switchto(struct lwp *oldlwp, struct lwp *newlwp,
- *			    bool returning)
+ *     bool returning)
  *
  *	1. if (oldlwp != NULL), save its context.
  *	2. then, restore context of newlwp.
@@ -1079,18 +1091,19 @@
 	movq	%rdi,%r13	/* oldlwp */
 	movq	%rsi,%r12	/* newlwp */
 
-	testq	%r13,%r13
-	jz	1f
+	testq	%r13,%r13	/* oldlwp = NULL ? */
+	jz	skip_save
 
 	/* Save old context. */
 	movq	L_PCB(%r13),%rax
 	movq	%rsp,PCB_RSP(%rax)
 	movq	%rbp,PCB_RBP(%rax)
+skip_save:
 
 	/* Switch to newlwp's stack. */
-1:	movq	L_PCB(%r12),%r14
+	movq	L_PCB(%r12),%r14
 #ifdef XEN /* XXX debug code */
-	cmpq	$0, PCB_RSP(%r14)
+	cmpq	$0,PCB_RSP(%r14)
 	jne 999f
 	callq _C_LABEL(cpu_Debugger);
 999:
@@ -1106,32 +1119,40 @@
 	xchgq	%rcx,CPUVAR(CURLWP)
 
 	/* Skip the rest if returning to a pinned LWP. */
-	testb	%dl,%dl
-	jnz	4f
+	testb	%dl,%dl		/* returning = true ? */
+	jnz	switch_return
 
 	/* Switch ring0 stack */
 #ifndef XEN
 	movq	PCB_RSP0(%r14),%rax
 	movq	%rax,CPUVAR(RSP0)
 #else
-	movq	%r14, %rdi
+	movq	%r14,%rdi
 	callq	_C_LABEL(x86_64_switch_context);
 #endif
 
 	/* Don't bother with the rest if switching to a system process. */
 	testl	$LW_SYSTEM,L_FLAG(%r12)
-	jnz	4f
+	jnz	switch_return
 
 	/* Is this process using RAS (restartable atomic sequences)? */
 	movq	L_PROC(%r12),%rdi
 	cmpq	$0,P_RASLIST(%rdi)
-	jne	5f
+	je	no_RAS
+
+	/* Handle restartable atomic sequences (RAS). */
+	movq	L_MD_REGS(%r12),%rbx
+	movq	TF_RIP(%rbx),%rsi
+	call	_C_LABEL(ras_lookup)
+	cmpq	$-1,%rax
+	je	no_RAS
+	movq	%rax,TF_RIP(%rbx)
+no_RAS:
 
 	/*
 	 * Restore cr0 including FPU state (may have CR0_TS set).  Note that
 	 * IPL_SCHED prevents from FPU interrupt altering the LWP's saved cr0.
 	 */
-2:
 #ifndef XEN
 	movl	$IPL_HIGH,CPUVAR(ILEVEL)
 	movl	PCB_CR0(%r14),%ecx	/* has CR0_TS clear */
@@ -1142,80 +1163,74 @@
 	 * set CR0_TS so we'll trap rather than reuse bogus state.
 	 */
 	cmpq	CPUVAR(FPCURLWP),%r12
-	je	3f
+	je	skip_TS
 	orq	$CR0_TS,%rcx
+skip_TS:
 
 	/* Reloading CR0 is very expensive - avoid if possible. */
-3:	cmpq	%rdx,%rcx
-	je	6f
+	cmpq	%rdx,%rcx
+	je	skip_CR0
 	movq	%rcx,%cr0
+skip_CR0:
 
-6:	testl	$PCB_COMPAT32, PCB_FLAGS(%r14)
+	/* The 32bit LWPs are handled differently. */
+	testl	$PCB_COMPAT32,PCB_FLAGS(%r14)
 	jne	32f
 
 	/* Zero out %fs/%gs registers and GDT descriptors. */
-	xorq	%rax, %rax
-	movw	%ax, %fs
+	xorq	%rax,%rax
+	movw	%ax,%fs
 	CLI(cx)
 	SWAPGS
-	movw	%ax, %gs
+	movw	%ax,%gs
 	SWAPGS
 	STI(cx)
 
 	movq	CPUVAR(GDT),%rcx
-	movq	%rax, (GUFS_SEL*8)(%rcx)
-	movq	%rax, (GUGS_SEL*8)(%rcx)
+	movq	%rax,(GUFS_SEL*8)(%rcx)
+	movq	%rax,(GUGS_SEL*8)(%rcx)
 
 	/* Reload 64-bit %fs/%gs MSRs. */
-	movl	$MSR_FSBASE, %ecx
-	movl	PCB_FS(%r14), %eax
-	movl	4+PCB_FS(%r14), %edx
+	movl	$MSR_FSBASE,%ecx
+	movl	PCB_FS(%r14),%eax
+	movl	4+PCB_FS(%r14),%edx
 	wrmsr
-	movl	$MSR_KERNELGSBASE, %ecx
-	movl	PCB_GS(%r14), %eax
-	movl	4+PCB_GS(%r14), %edx
+	movl	$MSR_KERNELGSBASE,%ecx
+	movl	PCB_GS(%r14),%eax
+	movl	4+PCB_GS(%r14),%edx
 	wrmsr
-	jmp	4f
+	jmp	switch_return
 
 32:
 	/* Reload %fs/%gs GDT descriptors. */
 	movq	CPUVAR(GDT),%rcx
-	movq	PCB_FS(%r14), %rax
-	movq	%rax, (GUFS_SEL*8)(%rcx)
-	movq	PCB_GS(%r14), %rax
-	movq	%rax, (GUGS_SEL*8)(%rcx)
+	movq	PCB_FS(%r14),%rax
+	movq	%rax,(GUFS_SEL*8)(%rcx)
+	movq	PCB_GS(%r14),%rax
+	movq	%rax,(GUGS_SEL*8)(%rcx)
 
 	/* Reload %fs and %gs */
-	movq	L_MD_REGS(%r12), %rbx
-	movw	TF_FS(%rbx), %fs
+	movq	L_MD_REGS(%r12),%rbx
+	movw	TF_FS(%rbx),%fs
 	CLI(ax)
 	SWAPGS
-	movw	TF_GS(%rbx), %gs
+	movw	TF_GS(%rbx),%gs
 	SWAPGS
 	STI(ax)
-
 #else
 	movq	%r12,%rdi
 	callq	_C_LABEL(x86_64_tls_switch)
 #endif
 
+switch_return:
 	/* Return to the new LWP, returning 'oldlwp' in %rax. */
-4:	movq	%r13,%rax
+	movq	%r13,%rax
 	popq	%r15
 	popq	%r14
 	popq	%r13
 	popq	%r12
 	popq	%rbx
 	ret
-
-	/* Check for restartable atomic sequences (RAS). */
-5:	movq	L_MD_REGS(%r12),%rbx
-	movq	TF_RIP(%rbx),%rsi
-	call	_C_LABEL(ras_lookup)
-	cmpq	$-1,%rax
-	je	2b
-	movq	%rax,TF_RIP(%rbx)
-	jmp	2b
 END(cpu_switchto)
 
 /*
--- a/sys/arch/amd64/amd64/machdep.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/amd64/amd64/machdep.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: machdep.c,v 1.211.4.5 2016/05/29 08:44:15 skrll Exp $	*/
+/*	$NetBSD: machdep.c,v 1.211.4.6 2016/07/09 20:24:49 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011
@@ -111,7 +111,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.211.4.5 2016/05/29 08:44:15 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.211.4.6 2016/07/09 20:24:49 skrll Exp $");
 
 /* #define XENDEBUG_LOW  */
 
@@ -267,9 +267,6 @@
 vaddr_t	idt_vaddr;
 paddr_t	idt_paddr;
 
-vaddr_t lo32_vaddr;
-paddr_t lo32_paddr;
-
 vaddr_t module_start, module_end;
 static struct vm_map module_map_store;
 extern struct vm_map *module_map;
@@ -364,7 +361,7 @@
 		for (x = 0; x < btoc(msgbuf_p_seg[y].sz); x++, sz += PAGE_SIZE)
 			pmap_kenter_pa((vaddr_t)msgbuf_vaddr + sz,
 				       msgbuf_p_seg[y].paddr + x * PAGE_SIZE,
-				       VM_PROT_READ | UVM_PROT_WRITE, 0);
+				       VM_PROT_READ | VM_PROT_WRITE, 0);
 	}
 
 	pmap_update(pmap_kernel());
@@ -374,11 +371,22 @@
 	minaddr = 0;
 
 	/*
-	 * Allocate a submap for physio
+	 * Allocate a submap for physio.
 	 */
 	phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
-				   VM_PHYS_SIZE, 0, false, NULL);
+	    VM_PHYS_SIZE, 0, false, NULL);
 
+	/*
+	 * Create the module map.
+	 *
+	 * XXX: the module map is taken as what is left of the bootstrap memory
+	 * created in locore.S, which is not big enough if we want to load many
+	 * modules dynamically. We really should be using kernel_map instead.
+	 *
+	 * But because of the R_X86_64_32 relocations that are usually present
+	 * in dynamic modules, the module map must be in low memory, and this
+	 * wouldn't been guaranteed if we were using kernel_map.
+	 */
 	uvm_map_setup(&module_map_store, module_start, module_end, 0);
 	module_map_store.pmap = pmap_kernel();
 	module_map = &module_map_store;
@@ -1657,7 +1665,6 @@
 	pmap_kenter_pa(idt_vaddr + 2 * PAGE_SIZE, idt_paddr + 2 * PAGE_SIZE,
 	    VM_PROT_READ|VM_PROT_WRITE, 0);
 #endif
-	pmap_kenter_pa(lo32_vaddr, lo32_paddr, VM_PROT_READ|VM_PROT_WRITE, 0);
 	pmap_update(pmap_kernel());
 
 #ifndef XEN
--- a/sys/arch/amd64/amd64/mainbus.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/amd64/amd64/mainbus.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.34.6.2 2015/09/22 12:05:35 skrll Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.34.6.3 2016/07/09 20:24:49 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.34.6.2 2015/09/22 12:05:35 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.34.6.3 2016/07/09 20:24:49 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -248,6 +248,8 @@
 		    PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY |
 		    PCI_FLAGS_MWI_OKAY;
 		mba.mba_acpi.aa_ic = &x86_isa_chipset;
+		mba.mba_acpi.aa_dmat = &pci_bus_dma_tag;
+		mba.mba_acpi.aa_dmat64 = &pci_bus_dma64_tag;
 		config_found_ia(self, "acpibus", &mba.mba_acpi, 0);
 	}
 #endif
--- a/sys/arch/amd64/conf/GENERIC	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/amd64/conf/GENERIC	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.404.2.8 2016/05/29 08:44:15 skrll Exp $
+# $NetBSD: GENERIC,v 1.404.2.9 2016/07/09 20:24:49 skrll Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.404.2.8 $"
+#ident 		"GENERIC-$Revision: 1.404.2.9 $"
 
 maxusers	64		# estimated number of users
 
@@ -319,6 +319,7 @@
 mpu*		at acpi?		# Roland MPU-401 MIDI UART
 pckbc*		at acpi?		# PC keyboard controller
 pcppi*		at acpi?		# AT-style speaker sound
+sdhc*		at acpi?		# SD Host Controller
 sony*		at acpi?		# Sony Notebook Controller
 spic*		at acpi?		# Sony Programmable I/O Controller
 wsmouse*	at spic?		# mouse
@@ -1317,8 +1318,8 @@
 options VERIFIED_EXEC_FP_SHA1
 options VERIFIED_EXEC_FP_MD5
 
-options 	PAX_ASLR_DEBUG=1	# PaX ASLR debug
 options 	PAX_SEGVGUARD=0		# PaX Segmentation fault guard
 options 	PAX_MPROTECT=1		# PaX mprotect(2) restrictions
 options 	PAX_MPROTECT_DEBUG=1	# PaX mprotect debug
 options 	PAX_ASLR=1		# PaX Address Space Layout Randomization
+options 	PAX_ASLR_DEBUG=1	# PaX ASLR debug
--- a/sys/arch/amiga/dev/grf_cv3d.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/amiga/dev/grf_cv3d.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: grf_cv3d.c,v 1.30.6.1 2015/12/27 12:09:28 skrll Exp $ */
+/*	$NetBSD: grf_cv3d.c,v 1.30.6.2 2016/07/09 20:24:49 skrll Exp $ */
 
 /*
  * Copyright (c) 1995 Michael Teske
@@ -33,7 +33,7 @@
 #include "opt_amigacons.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: grf_cv3d.c,v 1.30.6.1 2015/12/27 12:09:28 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: grf_cv3d.c,v 1.30.6.2 2016/07/09 20:24:49 skrll Exp $");
 
 #include "grfcv3d.h"
 #include "ite.h"
@@ -1490,7 +1490,6 @@
 		gp->g_fbkva = (volatile char *)cv3d_boardaddr + 0x04000000 +
 				(0x00400000 * fb_flag);
 	} else {
-		/* XXX This is totaly untested */
 		Select_Zorro2_FrameBuffer(fb_flag);
 	}
 
--- a/sys/arch/amiga/dev/grf_cv3dreg.h	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/amiga/dev/grf_cv3dreg.h	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: grf_cv3dreg.h,v 1.12 2014/01/22 00:25:16 christos Exp $	*/
+/*	$NetBSD: grf_cv3dreg.h,v 1.12.6.1 2016/07/09 20:24:49 skrll Exp $	*/
 
 /*
  * Copyright (c) 1995 Michael Teske
@@ -101,7 +101,6 @@
 #define vgaw16(ba, reg, val) \
 	*((volatile unsigned short *) (((volatile char *)ba)+reg)) = val
 
-/* XXX This is totaly untested */
 #define	Select_Zorro2_FrameBuffer(flag) \
 	do { \
 		*(((volatile char *)cv3d_vcode_switch_base) + \
--- a/sys/arch/amiga/dev/if_es.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/amiga/dev/if_es.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_es.c,v 1.52.6.2 2016/03/19 11:29:55 skrll Exp $ */
+/*	$NetBSD: if_es.c,v 1.52.6.3 2016/07/09 20:24:49 skrll Exp $ */
 
 /*
  * Copyright (c) 1995 Michael L. Hitch
@@ -33,7 +33,7 @@
 #include "opt_ns.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_es.c,v 1.52.6.2 2016/03/19 11:29:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_es.c,v 1.52.6.3 2016/07/09 20:24:49 skrll Exp $");
 
 
 #include <sys/param.h>
@@ -663,7 +663,7 @@
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (m == NULL)
 		return;
-	m->m_pkthdr.rcvif = ifp;
+	m_set_rcvif(m, ifp);
 	m->m_pkthdr.len = pktlen;
 	len = MHLEN;
 	top = NULL;
--- a/sys/arch/amiga/dev/if_qn.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/amiga/dev/if_qn.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_qn.c,v 1.39.14.2 2016/03/19 11:29:55 skrll Exp $ */
+/*	$NetBSD: if_qn.c,v 1.39.14.3 2016/07/09 20:24:49 skrll Exp $ */
 
 /*
  * Copyright (c) 1995 Mika Kortelainen
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_qn.c,v 1.39.14.2 2016/03/19 11:29:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_qn.c,v 1.39.14.3 2016/07/09 20:24:49 skrll Exp $");
 
 #include "qn.h"
 #if NQN > 0
@@ -540,7 +540,7 @@
 	if (len & 1)
 		len++;
 
-	m->m_pkthdr.rcvif = &sc->sc_ethercom.ec_if;
+	m_set_rcvif(m, &sc->sc_ethercom.ec_if);
 	m->m_pkthdr.len = len;
 	m->m_len = 0;
 	head = m;
--- a/sys/arch/amiga/stand/binpatch/binpatch.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/amiga/stand/binpatch/binpatch.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: binpatch.c,v 1.11 2006/06/27 10:53:11 tsutsui Exp $	*/
+/*	$NetBSD: binpatch.c,v 1.11.126.1 2016/07/09 20:24:49 skrll Exp $	*/
 
 /* Author: Markus Wild mw@eunet.ch ???   */
 /* Modified: Rob Leland leland@mitre.org */
@@ -30,9 +30,10 @@
 "\t%s [-b|-w|-l] -s symbol[[[index]][=value]] binary\n"
 "\t%s [-b|-w|-l] [-o offset] -s symbol [-r value] binary\n"
 "\t%s [-b|-w|-l] [-o offset] -a address [-r value] binary\n";
+
 static char desusage[] =
 "DESCRIPTION\n"
-"\tAllows the patching of BSD binaries, for example,a distributed\n"
+"\tAllows the patching of BSD binaries, for example, a distributed\n"
 "\tkernel. Recient additions allows the user to index into an array\n"
 "\tand assign a value. Binpatch has internal variables to allow\n"
 "\tyou to test it on itself under NetBSD.\n"
@@ -74,11 +75,11 @@
 extern char *optarg;
 extern int optind;
 
-void error (char *) __attribute__((__noreturn__));
+void error(char *) __attribute__((__noreturn__));
 static void Synopsis(char *program_name);
 static void Usage(char *program_name);
-static u_long FindAssign(char *symbol,u_long *rvalue);
-static void FindOffset(char *symbol,u_long *index);
+static u_long FindAssign(char *symbol, u_long *rvalue);
+static void FindOffset(char *symbol, u_long *index);
 
 /* The following variables are so binpatch can be tested on itself */
 int test = 1;
@@ -88,331 +89,398 @@
 short vieww[10] = {0,0,1,0,1,1,0,1,1,1};
 long  viewl[10] = {0,0,1,0,1,1,0,1,1,1};
 /* End of test binpatch variables */
+
 int
 main(int argc, char *argv[])
 {
-  struct exec e;
-  int c;
-  u_long addr = 0, offset = 0;
-  u_long index = 0;/* Related to offset */
-  u_long replace = 0, do_replace = 0;
-  char *symbol = 0;
-  char size = 4;  /* default to long */
-  char size_opt = 0; /* Flag to say size option was set, used with index */
-  char *fname;
-  char *pgname = argv[0]; /* Program name */
-  int fd;
-  int type, off;
-  u_long  lval;
-  u_short sval;
-  u_char  cval;
+	struct exec e;
+	int c;
+	u_long addr = 0, offset = 0;
+	/* Related to offset */
+	u_long index = 0;
+	u_long replace = 0, do_replace = 0;
+	char *symbol = 0;
+	/* default to long */
+	char size = 4;
+	/* Flag to say size option was set, used with index */
+	char size_opt = 0;
+	char *fname;
+	/* Program name */
+	char *pgname = argv[0];
+	int fd;
+	int type, off;
+	u_long  lval;
+	u_short sval;
+	u_char  cval;
 
 
-  while ((c = getopt (argc, argv, "H:a:bwlr:s:o:")) != -1)
-    switch (c)
-      {
-      case 'H':
-        Usage(argv[0]);
-        break;
-      case 'a':
-	if (addr || symbol)
-	  error ("only one address/symbol allowed");
-	if (! strncmp (optarg, "0x", 2))
-	  sscanf (optarg, "%x", &addr);
-	else
-	  addr = atoi (optarg);
-	if (! addr)
-	  error ("invalid address");
-	break;
+	while ((c = getopt(argc, argv, "H:a:bwlr:s:o:")) != -1) {
+		switch (c) {
+		case 'H':
+			Usage(argv[0]);
+			break;
+		case 'a':
+			if (addr || symbol) {
+				error("only one address/symbol allowed");
+			}
+			if (!strncmp(optarg, "0x", 2)) {
+				sscanf(optarg, "%x", &addr);
+			} else {
+				addr = atoi(optarg);
+			}
+			if (!addr) {
+				error("invalid address");
+			}
+			break;
 
-      case 'b':
-	size = 1;
-        size_opt = 1;
-	break;
+		case 'b':
+			size = 1;
+			size_opt = 1;
+			break;
+
+		case 'w':
+			size = 2;
+			size_opt = 1;
+			break;
 
-      case 'w':
-	size = 2;
-        size_opt = 1;
-	break;
+		case 'l':
+			size = 4;
+			size_opt = 1;
+			break;
 
-      case 'l':
-	size = 4;
-        size_opt = 1;
-	break;
+		case 'r':
+			do_replace = 1;
+			if (!strncmp(optarg, "0x", 2)) {
+				sscanf(optarg, "%x", &replace);
+			} else {
+				replace = atoi(optarg);
+			}
+			break;
 
-      case 'r':
-	do_replace = 1;
-	if (! strncmp (optarg, "0x", 2))
-	  sscanf (optarg, "%x", &replace);
-	else
-	  replace = atoi (optarg);
-	break;
+		case 's':
+			if (addr || symbol) {
+				error("only one address/symbol allowed");
+			}
+			symbol = optarg;
+			break;
 
-      case 's':
-	if (addr || symbol)
-	  error ("only one address/symbol allowed");
-	symbol = optarg;
-	break;
+		case 'o':
+			if (offset) {
+				error("only one offset allowed");
+			}
+			if (!strncmp(optarg, "0x", 2)) {
+				sscanf(optarg, "%x", &offset);
+			} else {
+				offset = atoi(optarg);
+			}
+			break;
+		}
+		/* end while switch() */
+	}
 
-      case 'o':
-	if (offset)
-	  error ("only one offset allowed");
-	if (! strncmp (optarg, "0x", 2))
-	  sscanf (optarg, "%x", &offset);
-	else
-          offset = atoi (optarg);
-        break;
-      }/* while switch() */
+	if (argc > 1) {
+		if (addr || symbol) {
+			argv += optind;
+			argc -= optind;
+
+			if (argc < 1) {
+				error("No file to patch.");
+			}
 
-  if (argc > 1)
-  {
-    if (addr || symbol)
-    {
-      argv += optind;
-      argc -= optind;
-
-      if (argc < 1)
-        error ("No file to patch.");
+			fname = argv[0];
+			if ((fd = open(fname, 0)) < 0) {
+				error("Can't open file");
+			}
 
-      fname = argv[0];
-      if ((fd = open (fname, 0)) < 0)
-        error ("Can't open file");
+			if (read(fd, &e, sizeof(e)) != sizeof(e)
+			    || N_BADMAG(e)) {
+				error("Not a valid executable.");
+			}
 
-      if (read (fd, &e, sizeof (e)) != sizeof (e)
-        || N_BADMAG (e))
-        error ("Not a valid executable.");
+			/* fake mid, so the N_ macros work on the amiga.. */
+			e.a_midmag |= 127 << 16;
 
-      /* fake mid, so the N_ macros work on the amiga.. */
-      e.a_midmag |= 127 << 16;
+			if (symbol) {
+				struct nlist nl[2];
 
-      if (symbol)
-      {
-        struct nlist nl[2];
-        if (offset == 0)
-	{
-            u_long new_do_replace = 0;
-            new_do_replace = FindAssign(symbol,&replace);
-            if (new_do_replace && do_replace)
-              error("Cannot use both '=' and '-r' option!");
-            FindOffset(symbol,&index);
-            if (size_opt)
-               offset = index*size; /* Treat like an index */
-            else
-               offset = index; /* Treat index like an offset */
-	    if (new_do_replace)
-	       do_replace = new_do_replace;
-	}
-        nl[0].n_un.n_name = symbol;
-        nl[1].n_un.n_name = 0;
-        if (nlist (fname, nl) != 0)
-	{
-          fprintf(stderr,"Symbol is %s ",symbol);
-	  error ("Symbol not found.");
-        }
-        addr = nl[0].n_value;
-        type = nl[0].n_type & N_TYPE;
-      }
-      else
-      {
-        type = N_UNDF;
-        if (addr >= N_TXTADDR(e) && addr < N_DATADDR(e))
-	  type = N_TEXT;
-        else if (addr >= N_DATADDR(e) && addr < N_DATADDR(e) + e.a_data)
-	  type = N_DATA;
-      }
-      addr += offset;
+				if (offset == 0) {
+					u_long new_do_replace = 0;
+
+					new_do_replace = FindAssign(symbol,
+								&replace);
+					if (new_do_replace && do_replace)
+						error("Cannot use both '=' "
+						      "and '-r' option!");
+					FindOffset(symbol, &index);
+					if (size_opt) {
+						/* Treat like an index */
+						offset = index*size;
+					} else {
+						/* Treat like an offset */
+						offset = index;
+					}
+					if (new_do_replace)
+						do_replace = new_do_replace;
+				}
+				nl[0].n_un.n_name = symbol;
+				nl[1].n_un.n_name = 0;
+				if (nlist(fname, nl) != 0) {
+					fprintf(stderr, "Symbol is %s ",
+						symbol);
+					error("Symbol not found.");
+				}
+				addr = nl[0].n_value;
+				type = nl[0].n_type & N_TYPE;
+			} else {
+				type = N_UNDF;
+				if (addr >= N_TXTADDR(e) &&
+				    addr < N_DATADDR(e)) {
+					type = N_TEXT;
+				} else if (addr >= N_DATADDR(e) &&
+				    addr < N_DATADDR(e) + e.a_data) {
+					type = N_DATA;
+				}
+			}
+			addr += offset;
 
-      /* if replace-mode, have to reopen the file for writing.
-         Can't do that from the beginning, or nlist() will not
-         work (at least not under AmigaDOS) */
-      if (do_replace)
-      {
-        close (fd);
-        if ((fd = open (fname, 2)) == -1)
-	  error ("Can't reopen file for writing.");
-      }
+			/*
+			 * if replace-mode, have to reopen the file
+			 * for writing. Can't do that from the
+			 * beginning, or nlist() will not work (at
+			 * least not under AmigaDOS)
+			 */
+			if (do_replace) {
+				close(fd);
+				if ((fd = open(fname, 2)) == -1) {
+					error("Can't reopen file for writing.");
+				}
+			}
 
-      if (type != N_TEXT && type != N_DATA)
-        error ("address/symbol is not in text or data section.");
+			if (type != N_TEXT && type != N_DATA) {
+				error("address/symbol is not in text "
+				      "or data section.");
+			}
 
-      if (type == N_TEXT)
-        off = addr - N_TXTADDR(e) + N_TXTOFF(e);
-      else
-        off = addr - N_DATADDR(e) + N_DATOFF(e);
-
-      if (lseek (fd, off, 0) == -1)
-        error ("lseek");
+			if (type == N_TEXT) {
+				off = addr - N_TXTADDR(e) + N_TXTOFF(e);
+			} else {
+				off = addr - N_DATADDR(e) + N_DATOFF(e);
+			}
 
-      /* not beautiful, but works on big and little endian machines */
-      switch (size)
-        {
-        case 1:
-          if (read (fd, &cval, 1) != 1)
-	    error ("cread");
-          lval = cval;
-          break;
+			if (lseek(fd, off, 0) == -1) {
+				error("lseek");
+			}
 
-        case 2:
-          if (read (fd, &sval, 2) != 2)
-	    error ("sread");
-          lval = sval;
-          break;
+			/*
+			 * not beautiful, but works on big and little
+			 * endian machines
+			 */
+			switch (size) {
+			case 1:
+				if (read(fd, &cval, 1) != 1) {
+					error("cread");
+				}
+				lval = cval;
+				break;
 
-        case 4:
-          if (read (fd, &lval, 4) != 4)
-	    error ("lread");
-          break;
-        }/* switch size */
+			case 2:
+				if (read(fd, &sval, 2) != 2) {
+					error("sread");
+				}
+				lval = sval;
+				break;
+
+			case 4:
+				if (read(fd, &lval, 4) != 4) {
+					error("lread");
+				}
+				break;
+			}/* switch size */
 
 
-      if (symbol)
-        printf ("%s(0x%x): %d (0x%x)\n", symbol, addr, lval, lval);
-      else
-        printf ("0x%x: %d (0x%x)\n", addr, lval, lval);
+			if (symbol) {
+				printf("%s(0x%x): %d (0x%x)\n", symbol, addr,
+					lval, lval);
+			} else {
+				printf("0x%x: %d (0x%x)\n", addr, lval, lval);
+			}
 
-      if (do_replace)
-      {
-        if (lseek (fd, off, 0) == -1)
-	  error ("write-lseek");
-        switch (size)
-	  {
-	  case 1:
-	    cval = replace;
-	    if (cval != replace)
-	      error ("byte-value overflow.");
-	    if (write (fd, &cval, 1) != 1)
-	      error ("cwrite");
-	    break;
+			if (do_replace) {
+				if (lseek(fd, off, 0) == -1) {
+					error("write-lseek");
+				}
+				switch (size) {
+				case 1:
+					cval = replace;
+					if (cval != replace) {
+						error("byte-value overflow.");
+					}
+					if (write(fd, &cval, 1) != 1) {
+						error("cwrite");
+					}
+					break;
 
-	  case 2:
-	    sval = replace;
-	    if (sval != replace)
-	      error ("word-value overflow.");
-	    if (write (fd, &sval, 2) != 2)
-	      error ("swrite");
-	    break;
+				case 2:
+					sval = replace;
+					if (sval != replace) {
+						error("word-value overflow.");
+					}
+					if (write(fd, &sval, 2) != 2) {
+						error("swrite");
+					}
+					break;
 
-	  case 4:
-	    if (write (fd, &replace, 4) != 4)
-	      error ("lwrite");
-	    break;
-	  }/* switch(size) */
-      }/* if (do_replace) */
+				case 4:
+					if (write(fd, &replace, 4) != 4) {
+						error("lwrite");
+					}
+					break;
+				}
+				/* end switch(size) */
+			}
+			/* end if (do_replace) */
 
-      close (fd);
-    }/* if(addr || symbol ) */
-    else
-    {
-      error("Must specify either address or symbol.");
-    }
-  }/* if argc < 1 */
-  else
-  {
-    Synopsis(pgname);
-  }
-  return(0);
-}/* main () */
+			close(fd);
+		} else { 
+			/* not (addr || symbol) */
+			error("Must specify either address or symbol.");
+		}
+	} else {
+		/* if argc <= 1 */
+		Synopsis(pgname);
+	}
+
+	return 0;
+}
+/* end main () */
 
 
 
-void error (char *str)
+void
+error(char *str)
 {
-  fprintf (stderr, "%s\n", str);
-  exit (1);
+	fprintf(stderr, "%s\n", str);
+	exit(1);
 }
 
 /* Give user very short help to avoid scrolling screen much */
-static void Synopsis(char *pgname)
+static void
+Synopsis(char *pgname)
 {
-  fprintf(stdout,synusage,pgname,pgname,pgname,pgname,pgname);
+	fprintf(stdout, synusage, pgname, pgname, pgname, pgname, pgname);
 }
 
 
-static void Usage(char *pgname)
+static void
+Usage(char *pgname)
 {
-  Synopsis(pgname);
-  fprintf(stdout,desusage);
-  exit(0);
+	Synopsis(pgname);
+	fprintf(stdout, desusage);
+	exit(0);
 }
 
 
-/* FindOffset() - Determine if there is an offset, -or- index
-                 embedded in the symbol.
-                 If there is, return it, and truncate symbol to
-                 exclude the [...].
-                 Example: If view is declared as short view[10],
-                          and we want to index the 3rd. element.
-                          which is offset = (3 -1)*sizeof(short) =4.
-                 we would use view[4], which becomes view,4.
-                 The was the code is implemented the [value] is
-                 treated as a index if-and-only-if a '-b -w -l' option
-                 was given. Otherwise it is treated like an offset.
-                 See above documentation in for of help!
-*/
-static void FindOffset(char *symbol,u_long *index)
+/*
+ * FindOffset() - Determine if there is an offset, -or- index
+ * embedded in the symbol.
+ *
+ * If there is, return it, and truncate symbol to exclude the [...].
+ *
+ * Example: If view is declared as short view[10],
+ *                and we want to index the 3rd. element.
+ *                which is offset = (3 -1)*sizeof(short) =4.
+ *          we would use view[4], which becomes view,4.
+ *
+ *          The way the code is implemented the [value] is
+ *          treated as a index if-and-only-if a '-b -w -l' option
+ *          was given. Otherwise it is treated like an offset.
+ *           See above documentation in for of help!
+ */
+static void
+FindOffset(char *symbol, u_long *index)
 {
-  char *sb=strchr(symbol,'['); /* Start of '[', now line must
-                                 contain matching']' */
-  char *eb=strchr(symbol,']'); /* End of ']' */
-  short sz=strlen(symbol);    /* symbol size */
-  if (sb)
-  {
-    if (eb && (eb > sb))
-    {
-      if ((eb - symbol) == (sz - 1))
-      {
-        char *sindex; /* Start of index */
-        u_long newindex = 0;
-        /* In the future we could get fancy and parse the
-           sindex string for mathmatical expressions like:
-           (3 - 1)*2 = 4 from above example,
-           ugh forget I mentioned ot :-) !
-        */
-        sindex = sb + 1;
-        *eb = '\0';
-        newindex = (u_long)atoi(sindex);
-        if (*index == 0)
-        {
-          *index = newindex;
-          *sb = '\0'; /* Make _view[3] look like _view */
-        }
-        else
-          fprintf(stderr,"Error index can only be specified once!\n");
-      }
-      else
-      {
-        fprintf(stderr,"Error: Garbage trailing ']'\n");
-      }
-    }
-    else
-    {
-       fprintf(stderr,"Error ']' in symbol before '[' !\n");
-    }
-  }/* if sb != 0 */
-}/* FindOffset */
+	/* Start of '[', now line must contain matching']' */
+	char *sb = strchr(symbol, '[');
+
+	/* End of ']' */					
+	char *eb = strchr(symbol, ']');
+
+	/* symbol size */
+	short sz = strlen(symbol);
+
+	if (sb) {
+		if (eb && (eb > sb)) {
+			if ((eb - symbol) == (sz - 1)) {
+				/* Start of index */
+				char *sindex;
+				u_long newindex = 0;
 
-/* FindAssign : Scans symbol name for an '=number' strips it off
-   of the symbol and proceeds.
-*/
-static u_long FindAssign(char *symbol,u_long *rvalue)
+				/*
+				 * In the future we could get fancy
+				 * and parse the sindex string for
+				 * mathmatical expressions like: (3 -
+				 * 1)*2 = 4 from above example, ugh
+				 * forget I mentioned ot :-) !
+				 */
+				sindex = sb + 1;
+				*eb = '\0';
+				newindex = (u_long)atoi(sindex);
+				if (*index == 0) {
+					*index = newindex;
+					/* Make _view[3] look like _view */
+					*sb = '\0';
+				} else {
+					fprintf(stderr, "Error index can "
+						"only be specified once!\n");
+				}
+			} else {
+				fprintf(stderr, "Error: Garbage "
+					"trailing ']'\n");
+			}
+		} else {
+			fprintf(stderr, "Error ']' in symbol before '[' !\n");
+		}
+	}
+	/* end if sb != 0 */
+}
+/* end FindOffset */
+
+/*
+ * FindAssign : Scans symbol name for an '=number' strips it off of
+ * the symbol and proceeds.
+ */
+static u_long
+FindAssign(char *symbol, u_long *rvalue)
 {
-  char *ce = rindex(symbol,'='); /* Assign symbol some number */
-  char *cn = ce + 1; /* This should point at some number, no spaces allowed */
-  u_long dr = 0; /* flag for do_replace */
-  if (ce)
-  {
-    int nscan; /* number of variaables scanned in */
-    /* get the number to assign to symbol and strip off = */
-    for (cn=ce + 1;((*cn==' ')&&(*cn!='\0'));cn++)
-    ;
-    if (! strncmp (cn, "0x", 2))
-	nscan = sscanf (cn, "%x",rvalue);
-    else
-        nscan = sscanf(cn,"%d",rvalue);
-    if (nscan != 1)
-      error("Invalid value following '='");
-    dr = 1;
-    *ce = '\0';/* Now were left with just symbol */
-  }/* if (ce) */
-  return(dr);
-}/* FindAssign */
+	/* Assign symbol some number */
+	char *ce = rindex(symbol, '=');
+
+	/* This should point at some number, no spaces allowed */
+	char *cn = ce + 1;
+
+	/* flag for do_replace */
+	u_long dr = 0;
+
+	if (ce) {
+		/* number of variaables scanned in */
+		int nscan;
+
+		/* get the number to assign to symbol and strip off = */
+		for (cn=ce + 1; *cn==' '; cn++)
+			;
+		if (!strncmp(cn, "0x", 2)) {
+			nscan = sscanf(cn, "%x", rvalue);
+		} else {
+			nscan = sscanf(cn, "%d", rvalue);
+		}
+		if (nscan != 1) {
+			error("Invalid value following '='");
+		}
+		dr = 1;
+		/* Now were left with just symbol */
+		*ce = '\0';
+	}
+	/* end if (ce) */
+	return(dr);
+}
+/* end FindAssign */
--- a/sys/arch/amiga/stand/bootblock/boot/main.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/amiga/stand/bootblock/boot/main.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * $NetBSD: main.c,v 1.29.6.1 2016/03/19 11:29:55 skrll Exp $
+ * $NetBSD: main.c,v 1.29.6.2 2016/07/09 20:24:49 skrll Exp $
  *
  *
  * Copyright (c) 1996,1999 Ignatios Souvatzis
@@ -164,7 +164,7 @@
 	printf("\n");
 	printf("Boot: [%s] ", kernel_name);
 
-	gets(linebuf);
+	kgets(linebuf, sizeof(linebuf));
 
 	if (*linebuf == 'q')
 		return 1;
--- a/sys/arch/arm/allwinner/awin_eth.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/allwinner/awin_eth.c	Sat Jul 09 20:24:48 2016 +0000
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: awin_eth.c,v 1.7.2.3 2016/03/19 11:29:55 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_eth.c,v 1.7.2.4 2016/07/09 20:24:49 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -412,7 +412,7 @@
 	m->m_data += 2;
 	m->m_len = rxlen;
 	m->m_pkthdr.len = rxlen;
-	m->m_pkthdr.rcvif = &sc->sc_ec.ec_if;
+	m_set_rcvif(m, &sc->sc_ec.ec_if);
 
 	return m;
 }
--- a/sys/arch/arm/allwinner/awin_otgreg.h	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/allwinner/awin_otgreg.h	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_otgreg.h,v 1.4 2014/10/20 21:18:00 jmcneill Exp $ */
+/* $NetBSD: awin_otgreg.h,v 1.4.4.1 2016/07/09 20:24:49 skrll Exp $ */
 /* FreeBSD: head/sys/dev/usb/controller/musb_otg.h 267122 2014-06-05 18:23:51Z hselasky */
 /*-
  * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
@@ -187,7 +187,7 @@
 #define	MUSB2_MASK_TI_EP_NUM 0x0F
 
 #define	MUSB2_REG_TXNAKLIMIT (0x000D /* EPN=0 */ + MUSB2_REG_INDEXED_CSR)
-#define	MUSB2_REG_RXNAKLIMIT (0x000D /* EPN=0 */ + MUSB2_REG_INDEXED_CSR)
+#define	MUSB2_REG_RXNAKLIMIT (0x000F /* EPN=0 */ + MUSB2_REG_INDEXED_CSR)
 #define	MUSB2_MASK_NAKLIMIT 0xFF
 
 #define MUSB2_REG_FSIZE (0x0010 + MUSB2_REG_INDEXED_CSR)
--- a/sys/arch/arm/arm/cpufunc.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/arm/cpufunc.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.c,v 1.150.4.5 2016/03/19 11:29:55 skrll Exp $	*/
+/*	$NetBSD: cpufunc.c,v 1.150.4.6 2016/07/09 20:24:49 skrll Exp $	*/
 
 /*
  * arm7tdmi support code Copyright (c) 2001 John Fremlin
@@ -49,7 +49,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.150.4.5 2016/03/19 11:29:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpufunc.c,v 1.150.4.6 2016/07/09 20:24:49 skrll Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_cpuoptions.h"
@@ -2330,8 +2330,7 @@
 			registers[base] += offset;
 			DFC_PRINTF(("r%d=%08x\n", base, registers[base]));
 		}
-	} else if ((fault_instruction & 0x0e000000) == 0x0c000000)
-		return ABORT_FIXUP_FAILED;
+	}
 
 	if ((frame->tf_spsr & PSR_MODE) == PSR_SVC32_MODE) {
 
--- a/sys/arch/arm/at91/at91emac.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/at91/at91emac.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,5 +1,5 @@
-/*	$Id: at91emac.c,v 1.13.14.3 2016/03/19 11:29:55 skrll Exp $	*/
-/*	$NetBSD: at91emac.c,v 1.13.14.3 2016/03/19 11:29:55 skrll Exp $	*/
+/*	$Id: at91emac.c,v 1.13.14.4 2016/07/09 20:24:50 skrll Exp $	*/
+/*	$NetBSD: at91emac.c,v 1.13.14.4 2016/07/09 20:24:50 skrll Exp $	*/
 
 /*
  * Copyright (c) 2007 Embedtronics Oy
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: at91emac.c,v 1.13.14.3 2016/03/19 11:29:55 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: at91emac.c,v 1.13.14.4 2016/07/09 20:24:50 skrll Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -279,8 +279,8 @@
 						MCLBYTES, BUS_DMASYNC_POSTREAD);
 				bus_dmamap_unload(sc->sc_dmat,
 					sc->rxq[bi].m_dmamap);
-				sc->rxq[bi].m->m_pkthdr.rcvif = ifp;
-				sc->rxq[bi].m->m_pkthdr.len =
+				m_set_rcvif(sc->rxq[bi].m, ifp);
+				sc->rxq[bi].m->m_pkthdr.len = 
 					sc->rxq[bi].m->m_len = fl;
 				bpf_mtap(ifp, sc->rxq[bi].m);
 				DPRINTFN(2,("received %u bytes packet\n", fl));
--- a/sys/arch/arm/broadcom/bcm53xx_eth.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/broadcom/bcm53xx_eth.c	Sat Jul 09 20:24:48 2016 +0000
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.26.6.1 2016/03/19 11:29:55 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: bcm53xx_eth.c,v 1.26.6.2 2016/07/09 20:24:50 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -1011,7 +1011,7 @@
 		|| *(uint32_t *)&m->m_data[2] != sc->sc_macaddr[1])) {
 		m->m_flags |= M_PROMISC;
 	}
-	m->m_pkthdr.rcvif = ifp;
+	m_set_rcvif(m, ifp);
 
 	ifp->if_ipackets++;
 	ifp->if_ibytes += m->m_pkthdr.len;
--- a/sys/arch/arm/ep93xx/epe.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/ep93xx/epe.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: epe.c,v 1.31.6.2 2016/03/19 11:29:56 skrll Exp $	*/
+/*	$NetBSD: epe.c,v 1.31.6.3 2016/07/09 20:24:50 skrll Exp $	*/
 
 /*
  * Copyright (c) 2004 Jesse Off
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: epe.c,v 1.31.6.2 2016/03/19 11:29:56 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: epe.c,v 1.31.6.3 2016/07/09 20:24:50 skrll Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -227,7 +227,7 @@
 			if (m != NULL && (m->m_flags & M_EXT)) {
 				bus_dmamap_unload(sc->sc_dmat, 
 					sc->rxq[bi].m_dmamap);
-				sc->rxq[bi].m->m_pkthdr.rcvif = ifp;
+				m_set_rcvif(sc->rxq[bi].m, ifp);
 				sc->rxq[bi].m->m_pkthdr.len = 
 					sc->rxq[bi].m->m_len = fl;
 				bpf_mtap(ifp, sc->rxq[bi].m);
--- a/sys/arch/arm/gemini/gemini_gmac.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/gemini/gemini_gmac.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gemini_gmac.c,v 1.7.30.1 2016/03/19 11:29:56 skrll Exp $ */
+/* $NetBSD: gemini_gmac.c,v 1.7.30.2 2016/07/09 20:24:50 skrll Exp $ */
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -49,7 +49,7 @@
 
 #include <sys/gpio.h>
 
-__KERNEL_RCSID(0, "$NetBSD: gemini_gmac.c,v 1.7.30.1 2016/03/19 11:29:56 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gemini_gmac.c,v 1.7.30.2 2016/07/09 20:24:50 skrll Exp $");
 
 #define	SWFREEQ_DESCS	256	/* one page worth */
 #define	HWFREEQ_DESCS	256	/* one page worth */
@@ -847,7 +847,7 @@
 	 * Now get the whole chain.
 	 */
 	m = hwq->hwq_rxmbuf;
-	m->m_pkthdr.rcvif = ifp;	/* set receive interface */
+	m_set_rcvif(m, ifp);	/* set receive interface */
 	ifp->if_ipackets++;
 	ifp->if_ibytes += m->m_pkthdr.len;
 	switch (DESC0_RXSTS_GET(d->d_desc0)) {
--- a/sys/arch/arm/gemini/if_gpn.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/gemini/if_gpn.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_gpn.c,v 1.4.30.1 2016/03/19 11:29:56 skrll Exp $ */
+/* $NetBSD: if_gpn.c,v 1.4.30.2 2016/07/09 20:24:50 skrll Exp $ */
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
 
 #include "opt_gemini.h"
 
-__KERNEL_RCSID(0, "$NetBSD: if_gpn.c,v 1.4.30.1 2016/03/19 11:29:56 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gpn.c,v 1.4.30.2 2016/07/09 20:24:50 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -298,7 +298,7 @@
 		struct mbuf *m;
 		m = sc->sc_rxmbuf;
 		sc->sc_rxmbuf = NULL;
-		m->m_pkthdr.rcvif = ifp;
+		m_set_rcvif(m, ifp);
 		KASSERT(((m->m_pkthdr.len + 63) >> 6) == gd->gd_pktlen64);
 		ifp->if_ipackets++;
 		ifp->if_ibytes += m->m_pkthdr.len;
--- a/sys/arch/arm/imx/if_enet.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/imx/if_enet.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_enet.c,v 1.1.2.4 2016/05/29 08:44:16 skrll Exp $	*/
+/*	$NetBSD: if_enet.c,v 1.1.2.5 2016/07/09 20:24:50 skrll Exp $	*/
 
 /*
  * Copyright (c) 2014 Ryo Shimizu <ryo@nerv.org>
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.1.2.4 2016/05/29 08:44:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.1.2.5 2016/07/09 20:24:50 skrll Exp $");
 
 #include "vlan.h"
 
@@ -641,7 +641,7 @@
 			} else {
 				/* packet receive ok */
 				ifp->if_ipackets++;
-				m0->m_pkthdr.rcvif = ifp;
+				m_set_rcvif(m0, ifp);
 				m0->m_pkthdr.len = amount;
 
 				bus_dmamap_sync(sc->sc_dmat, rxs->rxs_dmamap, 0,
@@ -1744,9 +1744,10 @@
 		sc->sc_txdesc_ring[idx].tx_databuf = map->dm_segs[i].ds_addr;
 		sc->sc_txdesc_ring[idx].tx_flags2 = flags2;
 		sc->sc_txdesc_ring[idx].tx_flags3 = 0;
+		TXDESC_WRITEOUT(idx);
+
 		sc->sc_txdesc_ring[idx].tx_flags1_len =
 		    flags1 | TXFLAGS1_LEN(map->dm_segs[i].ds_len);
-
 		TXDESC_WRITEOUT(idx);
 
 		idx = ENET_TX_NEXTIDX(idx);
--- a/sys/arch/arm/omap/files.omap2	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/omap/files.omap2	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-#	$NetBSD: files.omap2,v 1.29.2.3 2015/12/27 12:09:31 skrll Exp $
+#	$NetBSD: files.omap2,v 1.29.2.4 2016/07/09 20:24:50 skrll Exp $
 #
 # Configuration info for Texas Instruments OMAP2/OMAP3 CPU support
 # Based on xscale/files.pxa2x0
@@ -122,6 +122,17 @@
 attach	gpmc at mainbus
 file	arch/arm/omap/omap2_gpmc.c		gpmc
 
+device	edma
+attach	edma at mainbus
+file	arch/arm/omap/omap_edma.c		edma needs-flag
+
+# TI OTG controller
+define  tiotg_port {[port = -1], [mode = -1]}
+device	tiotg: tiotg_port
+attach	tiotg at mainbus
+file	arch/arm/omap/tiotg.c			tiotg
+attach  motg at tiotg_port
+
 # SDMMC controller
 attach	sdhc at obio with obiosdhc
 file	arch/arm/omap/omap3_sdhc.c		obiosdhc
@@ -144,13 +155,6 @@
 attach	ehci at obio with omap3_ehci
 file	arch/arm/omap/omap3_ehci.c		omap3_ehci
 
-# TI OTG controller
-define  tiotg_port {[port = -1], [mode = -1]}
-device	tiotg: tiotg_port
-attach	tiotg at obio
-file	arch/arm/omap/tiotg.c			tiotg
-attach  motg at tiotg_port
-
 attach	ahcisata at obio with omap5_ahcisata
 file	arch/arm/omap/omap5_ahcisata.c		omap5_ahcisata
 
@@ -171,10 +175,6 @@
 attach 	omapdma at obio
 file	arch/arm/omap/omap3_sdma.c		omapdma needs-flag
 
-device	edma
-attach	edma at obio
-file	arch/arm/omap/omap_edma.c		edma needs-flag
-
 device	trng
 attach	trng at obio
 file	arch/arm/omap/am335x_trng.c		trng
--- a/sys/arch/arm/omap/if_cpsw.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/omap/if_cpsw.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_cpsw.c,v 1.6.4.3 2016/03/19 11:29:56 skrll Exp $	*/
+/*	$NetBSD: if_cpsw.c,v 1.6.4.4 2016/07/09 20:24:50 skrll Exp $	*/
 
 /*
  * Copyright (c) 2013 Jonathan A. Kollasch
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.6.4.3 2016/03/19 11:29:56 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: if_cpsw.c,v 1.6.4.4 2016/07/09 20:24:50 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -1162,7 +1162,7 @@
 		if (ISSET(dw[3], CPDMA_BD_PASSCRC))
 			len -= ETHER_CRC_LEN;
 
-		m->m_pkthdr.rcvif = ifp;
+		m_set_rcvif(m, ifp);
 		m->m_pkthdr.len = m->m_len = len;
 		m->m_data += off;
 
--- a/sys/arch/arm/omap/obio_com.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/omap/obio_com.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: obio_com.c,v 1.5 2014/04/09 21:02:31 hans Exp $	*/
+/*	$NetBSD: obio_com.c,v 1.5.4.1 2016/07/09 20:24:50 skrll Exp $	*/
 
 /*
  * Based on arch/arm/omap/omap_com.c
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: obio_com.c,v 1.5 2014/04/09 21:02:31 hans Exp $");
+__KERNEL_RCSID(0, "$NetBSD: obio_com.c,v 1.5.4.1 2016/07/09 20:24:50 skrll Exp $");
 
 #include "opt_omap.h"
 #include "opt_com.h"
@@ -59,13 +59,38 @@
 #include <arm/omap/omap2_reg.h>
 #include <arm/omap/omap_com.h>
 
+#include <arm/omap/omap2_prcm.h>
+#include <arm/omap/am335x_prcm.h>
+
 #include "locators.h"
 
 static int	obiouart_match(device_t, cfdata_t, void *);
 static void	obiouart_attach(device_t, device_t, void *);
-static int	uart_enable(struct obio_attach_args *);
+#if defined(TI_AM335X)
+static int	uart_enable_am335x(struct obio_attach_args *);
+#else
+static int	uart_enable_omap(struct obio_attach_args *);
+#endif
+static int	uart_enable(struct obio_attach_args *, bus_space_handle_t);
 static void	obiouart_callout(void *);
 
+#if defined(TI_AM335X)
+struct am335x_com {
+	bus_addr_t as_base_addr;
+	int as_intr;
+	struct omap_module as_module;
+};
+
+static const struct am335x_com am335x_com[] = {
+	{ 0x44e09000, 72, { AM335X_PRCM_CM_WKUP, 0xb4 } },
+	{ 0x48022000, 73, { AM335X_PRCM_CM_PER, 0x6c } },
+	{ 0x48024000, 74, { AM335X_PRCM_CM_PER, 0x70 } },
+	{ 0x481a6000, 44, { AM335X_PRCM_CM_PER, 0x74 } },
+	{ 0x481a8000, 45, { AM335X_PRCM_CM_PER, 0x78 } },
+	{ 0x481aa000, 46, { AM335X_PRCM_CM_PER, 0x38 } },
+};
+#endif
+
 struct com_obio_softc {
 	struct com_softc sc_sc;
 	struct callout sc_callout;
@@ -87,7 +112,7 @@
 #if 0
 	/*
 	 * XXX this should be ifdefed on a board-dependent switch
-	 * We don't know what is the irq for com0 on the sdp2430 
+	 * We don't know what is the irq for com0 on the sdp2430
 	 */
 	if (obio->obio_intr == OBIOCF_INTR_DEFAULT)
 		panic("obiouart must have intr specified in config.");
@@ -99,14 +124,12 @@
 	if (com_is_console(obio->obio_iot, obio->obio_addr, NULL))
 		return 1;
 
-	if (uart_enable(obio) != 0)
-		return 1;
-
 	if (bus_space_map(obio->obio_iot, obio->obio_addr, obio->obio_size,
-			  0, &bh))
-		return 1;
-
-	rv = comprobe1(obio->obio_iot, bh);
+			  0, &bh) != 0)
+		return 0;
+	rv = 0;
+	if (uart_enable(obio, bh) == 0)
+		rv = comprobe1(obio->obio_iot, bh);
 
 	bus_space_unmap(obio->obio_iot, bh, obio->obio_size);
 
@@ -128,7 +151,7 @@
 	iot = obio->obio_iot;
 	iobase = obio->obio_addr;
 	sc->sc_frequency = OMAP_COM_FREQ;
-	sc->sc_type = COM_TYPE_NORMAL;
+	sc->sc_type = COM_TYPE_OMAP;
 
 	if (com_is_console(iot, iobase, &ioh) == 0 &&
 	    bus_space_map(iot, iobase, obio->obio_size, 0, &ioh)) {
@@ -161,8 +184,29 @@
 }
 
 
+#if defined(TI_AM335X)
+
 static int
-uart_enable(struct obio_attach_args *obio)
+uart_enable_am335x(struct obio_attach_args *obio)
+{
+	int i;
+
+	/* XXX Not really AM335X-specific.  */
+	for (i = 0; i < __arraycount(am335x_com); i++)
+		if ((obio->obio_addr == am335x_com[i].as_base_addr) &&
+		    (obio->obio_intr == am335x_com[i].as_intr)) {
+			prcm_module_enable(&am335x_com[i].as_module);
+			break;
+		}
+	KASSERT(i < __arraycount(am335x_com));
+
+	return 0;
+}
+
+#else
+
+static int
+uart_enable_omap(struct obio_attach_args *obio)
 {
 	bus_space_handle_t ioh;
 	uint32_t r;
@@ -222,3 +266,33 @@
 
 	return 0;
 }
+
+#endif
+
+static int
+uart_enable(struct obio_attach_args *obio, bus_space_handle_t bh)
+{
+	uint32_t v;
+
+#if defined(TI_AM335X)
+	if (uart_enable_am335x(obio) != 0)
+		return -1;
+#else
+	if (uart_enable_omap(obio) != 0)
+		return -1;
+#endif
+
+	v = bus_space_read_4(obio->obio_iot, bh, OMAP_COM_SYSC);
+	v |= OMAP_COM_SYSC_SOFT_RESET;
+	bus_space_write_4(obio->obio_iot, bh, OMAP_COM_SYSC, v);
+	v = bus_space_read_4(obio->obio_iot, bh, OMAP_COM_SYSS);
+	while (!(v & OMAP_COM_SYSS_RESET_DONE))
+		v = bus_space_read_4(obio->obio_iot, bh, OMAP_COM_SYSS);
+
+	/* Disable smart idle */
+	v = bus_space_read_4(obio->obio_iot, bh, OMAP_COM_SYSC);
+	v |= OMAP_COM_SYSC_NO_IDLE;
+	bus_space_write_4(obio->obio_iot, bh, OMAP_COM_SYSC, v);
+
+	return 0;
+}
--- a/sys/arch/arm/omap/omap2430_intr.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/omap/omap2430_intr.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: omap2430_intr.c,v 1.6 2011/07/01 20:30:21 dyoung Exp $	*/
+/*	$NetBSD: omap2430_intr.c,v 1.6.30.1 2016/07/09 20:24:50 skrll Exp $	*/
 /*
  * Define the SDP2430 specific information and then include the generic OMAP
  * interrupt header.
@@ -35,7 +35,7 @@
 #include "opt_omap.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap2430_intr.c,v 1.6 2011/07/01 20:30:21 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap2430_intr.c,v 1.6.30.1 2016/07/09 20:24:50 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/evcnt.h>
@@ -455,7 +455,9 @@
 	KASSERT((intrgroups[4].ig_pending_irqs & intrgroups[4].ig_irqsbyipl[ipl]) == 0);
 	KASSERT((intrgroups[5].ig_pending_irqs & intrgroups[5].ig_irqsbyipl[ipl]) == 0);
 	KASSERT((intrgroups[6].ig_pending_irqs & intrgroups[6].ig_irqsbyipl[ipl]) == 0);
+#ifdef OMAP_2430
 	KASSERT((intrgroups[7].ig_pending_irqs & intrgroups[7].ig_irqsbyipl[ipl]) == 0);
+#endif
 	if (frame == NULL)
 		last_delivered_ipl = saved_ipl;
 }
--- a/sys/arch/arm/omap/omap2_obiovar.h	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/omap/omap2_obiovar.h	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omap2_obiovar.h,v 1.2.16.2 2016/05/29 08:44:16 skrll Exp $ */
+/* $NetBSD: omap2_obiovar.h,v 1.2.16.3 2016/07/09 20:24:50 skrll Exp $ */
 
 /*
  * Copyright (c) 2007 Microsoft
@@ -54,5 +54,6 @@
 };
 
 uint32_t omap_chipid(void);
+uint32_t omap_devid(void);
 
 #endif /* _ARM_OMAP_OMAP2_OBIOVAR_H_ */
--- a/sys/arch/arm/omap/omap2_reg.h	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/omap/omap2_reg.h	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omap2_reg.h,v 1.28.4.3 2016/05/29 08:44:16 skrll Exp $ */
+/* $NetBSD: omap2_reg.h,v 1.28.4.4 2016/07/09 20:24:50 skrll Exp $ */
 
 /*
  * Copyright (c) 2007 Microsoft
@@ -147,6 +147,22 @@
 #define CHIPID_OMAP3525		0x4c00
 #define CHIPID_OMAP3530		0x0c00
 
+#define DEVID_OMAP35X_ES10	0x0b6d602f
+#define DEVID_OMAP35X_ES20	0x1b7ae02f
+#define DEVID_OMAP35X_ES21	0x2b7ae02f
+#define DEVID_OMAP35X_ES30	0x3b7ae02f
+#define DEVID_OMAP35X_ES31	0x4b7ae02f
+#define DEVID_OMAP35X_ES312	0x7b7ae02f
+
+#define CHIPID_AM3703		0x5e00	/* or 0x5c00 */
+#define CHIPID_AM3715		0x1e00	/* or 0x1c00 */
+#define CHIPID_DM3725		0x4e00	/* or 0x4c00 */
+#define CHIPID_DM3730		0x0e00	/* or 0x0c00 */
+
+#define DEVID_AMDM37X_ES10	0x0b89102f
+#define DEVID_AMDM37X_ES11	0x1b89102f
+#define DEVID_AMDM37X_ES12	0x2b89102f
+
 /*
  * Clock Management registers base, offsets, and size
  */
--- a/sys/arch/arm/omap/omap3_scm.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/omap/omap3_scm.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omap3_scm.c,v 1.2.14.1 2016/05/29 08:44:16 skrll Exp $ */
+/* $NetBSD: omap3_scm.c,v 1.2.14.2 2016/07/09 20:24:50 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013 Jared D. McNeill <jmcneill@invisible.ca>
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap3_scm.c,v 1.2.14.1 2016/05/29 08:44:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap3_scm.c,v 1.2.14.2 2016/07/09 20:24:50 skrll Exp $");
 
 #include "opt_omap.h"
 
@@ -47,12 +47,14 @@
 
 #define SCM_BASE_3530			0x48002000
 #define SCM_SIZE_3530			0x1000
+#define SCM_CONTROL_IDCODE_3530		0x308204
 #define SCM_OFFSET_INTERFACE_3530	0
 #define SCM_OFFSET_GENERAL_3530		0x270
 
 #if defined(OMAP_3430) || defined(OMAP_3530)
 #define SCM_BASE		SCM_BASE_3530
 #define SCM_SIZE		SCM_SIZE_3530
+#define SCM_CONTROL_IDCODE	SCM_CONTROL_IDCODE_3530
 #define SCM_OFFSET_INTERFACE	SCM_OFFSET_INTERFACE_3530
 #define SCM_OFFSET_GENERAL	SCM_OFFSET_GENERAL_3530
 #endif
@@ -105,7 +107,8 @@
 	bus_space_tag_t		sc_iot;
 	bus_space_handle_t	sc_ioh;
 
-	uint32_t		sc_cid;
+	uint32_t		sc_cid;	/* Chip Identification */
+	uint32_t		sc_did;	/* Device IDCODE */
 
 	/* GENERAL */
 	struct sysmon_envsys	*sc_sme;
@@ -143,9 +146,28 @@
 {
 	struct omap3_scm_softc *sc = device_private(self);
 	struct obio_attach_args *obio = opaque;
+	bus_space_handle_t ioh;
 	uint32_t rev;
 	char buf[256];
-	const char *cid;
+	const char *cid, *did, *fmt;
+	const char *omap35x_fmt = "\177\020"
+	    "b\0TO_OUT\0"
+	    "b\1four_bit_mmc\0"
+	    "b\2CCP2_CSI1\0"
+	    "b\3CMADS_FL3G\0"
+	    "b\4NEON_VFPLite\0"
+	    "b\5ISP_disable\0"
+	    "f\6\2IVA2_MHz\0=\0 430\0=\2 266\0"
+	    "f\10\2ARM_MHz\0=\0 600\0=\1 400\0=\2 266\0"
+	    "f\12\2MPU_L2_cache_size\0=\0 0KB\0=\1 64KB\0=\2 128KB\0=\3 Full\0"
+	    "b\14IVA_disable_acc\0"
+	    "f\15\2SGX_scalable_control\0=\0Full\0=\1Half\0=\2not-present\0\0";
+	const char *amdm37x_fmt = "\177\020"
+	    "f\0\4Feature Tiering\0=\0All features aval\0=\1ISP not avail\0"
+	    "f\11\1MPU/IVA frequency\0=\0 800/600 MHz\0=\1 1000/800 MHz\0"
+	    "f\12\2MPU_L2_cache_size\0=\0 0KB\0=\2 128KB\0=\3 Full\0"
+	    "f\14\1IVA 2.2 subsystem\0=\0Full use\0=\1Not available\0"
+	    "f\15\2 2D/3D accelerator\0=\0Full use\0=\2HW not present\0";
 
 	aprint_naive("\n");
 
@@ -159,32 +181,83 @@
 		aprint_error(": couldn't map address space\n");
 		return;
 	}
+	if (bus_space_map(obio->obio_iot,
+	    obio->obio_addr + SCM_CONTROL_IDCODE, sizeof(uint32_t),
+	    0, &ioh) != 0) {
+		aprint_error(": couldn't map CONTROL_IDCODE space\n");
+		return;
+	}
+	sc->sc_did = bus_space_read_4(sc->sc_iot, ioh, 0);
+	bus_space_unmap(sc->sc_iot, ioh, sizeof(uint32_t));
 
 	rev = SCM_READ_REG(sc, CONTROL_REVISION);
 	aprint_normal(": rev. 0x%x\n", rev & 0xff);
 	sc->sc_cid = SCM_READ_REG(sc, CONTROL_OMAP_STATUS & 0xffff);
-	switch (sc->sc_cid) {
-	case CHIPID_OMAP3503:	cid = "OMAP3503";	break;
-	case CHIPID_OMAP3515:	cid = "OMAP3515";	break;
-	case CHIPID_OMAP3525:	cid = "OMAP3525";	break;
-	case CHIPID_OMAP3530:	cid = "OMAP3530";	break;
-	default:		cid = "unknwon";	break;
+	cid = did = fmt = NULL;
+	switch (sc->sc_did) {
+	case DEVID_OMAP35X_ES10:
+	case DEVID_OMAP35X_ES20:
+	case DEVID_OMAP35X_ES21:
+	case DEVID_OMAP35X_ES30:
+	case DEVID_OMAP35X_ES31:
+	case DEVID_OMAP35X_ES312:
+		switch (sc->sc_cid) {
+		case CHIPID_OMAP3503:	cid = "OMAP3503";	break;
+		case CHIPID_OMAP3515:	cid = "OMAP3515";	break;
+		case CHIPID_OMAP3525:	cid = "OMAP3525";	break;
+		case CHIPID_OMAP3530:	cid = "OMAP3530";	break;
+		}
+		switch (sc->sc_did) {
+		case DEVID_OMAP35X_ES10:	did = "ES1.0";	break;
+		case DEVID_OMAP35X_ES20:	did = "ES2.0";	break;
+		case DEVID_OMAP35X_ES21:	did = "ES2.1";	break;
+		case DEVID_OMAP35X_ES30:	did = "ES3.0";	break;
+		case DEVID_OMAP35X_ES31:	did = "ES3.1";	break;
+		case DEVID_OMAP35X_ES312:	did = "ES3.1.2";break;
+		}
+		fmt = omap35x_fmt;
+		break;
+
+	case DEVID_AMDM37X_ES10:
+	case DEVID_AMDM37X_ES11:
+	case DEVID_AMDM37X_ES12:
+		switch (sc->sc_cid) {
+		case CHIPID_OMAP3503:
+		case CHIPID_AM3703:
+			cid = "AM3703";
+			break;
+		case CHIPID_OMAP3515:
+		case CHIPID_AM3715:
+			cid = "AM3715";
+			break;
+		case CHIPID_OMAP3525:
+		case CHIPID_DM3725:
+			cid = "DM3525";
+			break;
+		case CHIPID_OMAP3530:
+		case CHIPID_DM3730:
+			cid = "DM3730";
+			break;
+		}
+		switch (sc->sc_did) {
+		case DEVID_AMDM37X_ES10:	did = "ES1.0";	break;
+		case DEVID_AMDM37X_ES11:	did = "ES1.1";	break;
+		case DEVID_AMDM37X_ES12:	did = "ES1.2";	break;
+		}
+		fmt = amdm37x_fmt;
+		break;
+	break;
+
+	default:
+		aprint_normal_dev(self,
+		    "unknwon ChipID/DeviceID found 0x%08x/0x%08x\n",
+		    sc->sc_cid, sc->sc_did);
+		break;
 	}
-	aprint_normal_dev(self, "%s: ", cid);
-	snprintb(buf, sizeof(buf), "\177\020"
-	    "b\0TO_OUT\0"
-	    "b\1four_bit_mmc\0"
-	    "b\2CCP2_CSI1\0"
-	    "b\3CMADS_FL3G\0"
-	    "b\4NEON_VFPLite\0"
-	    "b\5ISP_disable\0"
-	    "f\6\2IVA2_MHz\0=\0 430\0=\2 266\0"
-	    "f\10\2ARM_MHz\0=\0 600\0=\1 400\0=\2 266\0"
-	    "f\12\2MPU_L2_cache_size\0=\0 0KB\0=\1 64KB\0=\2 128KB\0=\3 Full\0"
-	    "b\14IVA_disable_acc\0"
-	    "f\15\2SGX_scalable_control\0=\0Full\0=\1Half\0=\2not-present\0\0",
-	    sc->sc_cid);
-	aprint_normal("%s\n", buf);
+	if (fmt != NULL)
+		snprintb(buf, sizeof(buf), fmt, sc->sc_cid);
+	if (did != NULL)
+		aprint_normal_dev(self, "%s %s: %s\n", cid, did, buf);
 
 	omap3_scm_sensor_attach(sc);
 }
@@ -266,3 +339,15 @@
 	sc = device_private(dev);
 	return sc->sc_cid;
 }
+
+uint32_t
+omap_devid(void)
+{
+	struct omap3_scm_softc *sc;
+	device_t dev;
+
+	dev = device_find_by_xname("omapscm0");
+	KASSERT(dev != NULL);
+	sc = device_private(dev);
+	return sc->sc_did;
+}
--- a/sys/arch/arm/omap/omap3_sdhc.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/omap/omap3_sdhc.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: omap3_sdhc.c,v 1.14.6.5 2016/05/29 08:44:16 skrll Exp $	*/
+/*	$NetBSD: omap3_sdhc.c,v 1.14.6.6 2016/07/09 20:24:50 skrll Exp $	*/
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap3_sdhc.c,v 1.14.6.5 2016/05/29 08:44:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap3_sdhc.c,v 1.14.6.6 2016/07/09 20:24:50 skrll Exp $");
 
 #include "opt_omap.h"
 #include "edma.h"
@@ -243,8 +243,13 @@
 
 	clksft = ffs(sc->sc.sc_clkmsk) - 1;
 
+#if defined(TI_AM335X)
+	error = bus_space_map(sc->sc_bst, oa->obio_addr + OMAP4_SDMMC_HL_SIZE,
+	    oa->obio_size - OMAP4_SDMMC_HL_SIZE, 0, &sc->sc_bsh);
+#else
 	error = bus_space_map(sc->sc_bst, oa->obio_addr, oa->obio_size, 0,
 	    &sc->sc_bsh);
+#endif
 	if (error) {
 		aprint_error_dev(self,
 		    "can't map registers: %d\n", error);
@@ -261,7 +266,7 @@
 
 		cv_init(&sc->sc_edma_cv, "sdhcedma");
 		sc->sc_edma_fifo = oa->obio_addr +
-		    OMAP3_SDMMC_SDHC_OFFSET + SDHC_DATA;
+		    OMAP4_SDMMC_HL_SIZE + OMAP3_SDMMC_SDHC_OFFSET + SDHC_DATA;
 		sc->sc.sc_flags |= SDHC_FLAG_USE_DMA;
 		sc->sc.sc_flags |= SDHC_FLAG_EXTERNAL_DMA;
 		sc->sc.sc_flags |= SDHC_FLAG_EXTDMA_DMAEN;
--- a/sys/arch/arm/omap/omap3_sdmmcreg.h	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/omap/omap3_sdmmcreg.h	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: omap3_sdmmcreg.h,v 1.7 2013/07/27 17:10:28 jklos Exp $	*/
+/*	$NetBSD: omap3_sdmmcreg.h,v 1.7.6.1 2016/07/09 20:24:50 skrll Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -45,13 +45,15 @@
 #define SDMMC4_BASE_4430	0x480D1000	// same for omap5
 #define SDMMC5_BASE_4430	0x480D5000	// same for omap5
 
-#define	SDMMC1_BASE_TIAM335X	0x48060100
-#define	SDMMC2_BASE_TIAM335X	0x481d8100
-#define	SDMMC3_BASE_TIAM335X	0x47810100
+#define	SDMMC1_BASE_TIAM335X	0x48060000
+#define	SDMMC2_BASE_TIAM335X	0x481d8000
+#define	SDMMC3_BASE_TIAM335X	0x47810000
 
 #define	OMAP3_SDMMC_SDHC_OFFSET	0x100
 #define	OMAP3_SDMMC_SDHC_SIZE	0x100
 
+#define	OMAP4_SDMMC_HL_SIZE	0x100
+
 #define MMCHS_SYSCONFIG		0x010	/* System Configuration */
 #  define SYSCONFIG_CLOCKACTIVITY_MASK	(3 << 8)
 #  define SYSCONFIG_CLOCKACTIVITY_FCLK	(2 << 8)
--- a/sys/arch/arm/omap/omap_edma.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/omap/omap_edma.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: omap_edma.c,v 1.1.4.2 2015/06/06 14:39:56 skrll Exp $ */
+/* $NetBSD: omap_edma.c,v 1.1.4.3 2016/07/09 20:24:50 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 Jared D. McNeill <jmcneill@invisible.ca>
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: omap_edma.c,v 1.1.4.2 2015/06/06 14:39:56 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omap_edma.c,v 1.1.4.3 2016/07/09 20:24:50 skrll Exp $");
 
 #include "opt_omap.h"
 
@@ -39,14 +39,16 @@
 #include <sys/bus.h>
 #include <sys/bitops.h>
 
+#include <arm/mainbus/mainbus.h>
+
 #include <arm/omap/am335x_prcm.h>
 #include <arm/omap/omap2_prcm.h>
 #include <arm/omap/sitara_cm.h>
 #include <arm/omap/sitara_cmreg.h>
 
 #include <arm/omap/omap2_reg.h>
-#include <arm/omap/omap2_obiovar.h>
 #include <arm/omap/omap_edma.h>
+#include <arm/omap/omap_var.h>
 
 #ifdef TI_AM335X
 static const struct omap_module edma3cc_module =
@@ -120,12 +122,12 @@
 static int
 edma_match(device_t parent, cfdata_t match, void *aux)
 {
-	struct obio_attach_args *obio = aux;
+	struct mainbus_attach_args *mb = aux;
 
 #ifdef TI_AM335X
-	if (obio->obio_addr == AM335X_TPCC_BASE &&
-	    obio->obio_size == AM335X_TPCC_SIZE &&
-	    obio->obio_intrbase == AM335X_INT_EDMACOMPINT)
+	if (mb->mb_iobase == AM335X_TPCC_BASE &&
+	    mb->mb_iosize == AM335X_TPCC_SIZE &&
+	    mb->mb_intrbase == AM335X_INT_EDMACOMPINT)
 		return 1;
 #endif
 
@@ -136,13 +138,13 @@
 edma_attach(device_t parent, device_t self, void *aux)
 {
 	struct edma_softc *sc = device_private(self);
-	struct obio_attach_args *obio = aux;
+	struct mainbus_attach_args *mb = aux;
 	int idx;
 
 	sc->sc_dev = self;
-	sc->sc_iot = obio->obio_iot;
+	sc->sc_iot = &omap_bs_tag;
 	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_SCHED);
-	if (bus_space_map(obio->obio_iot, obio->obio_addr, obio->obio_size,
+	if (bus_space_map(sc->sc_iot, mb->mb_iobase, mb->mb_iosize,
 	    0, &sc->sc_ioh) != 0) {
 		aprint_error(": couldn't map address spcae\n");
 		return;
@@ -163,13 +165,13 @@
 
 	edma_init(sc);
 
-	sc->sc_ih = intr_establish(obio->obio_intrbase + 0,
+	sc->sc_ih = intr_establish(mb->mb_intrbase + 0,
 	    IPL_SCHED, IST_LEVEL, edma_intr, sc);
 	KASSERT(sc->sc_ih != NULL);
 
-	sc->sc_mperr_ih = intr_establish(obio->obio_intrbase + 1,
+	sc->sc_mperr_ih = intr_establish(mb->mb_intrbase + 1,
 	    IPL_SCHED, IST_LEVEL, edma_mperr_intr, sc);
-	sc->sc_errint_ih = intr_establish(obio->obio_intrbase + 2,
+	sc->sc_errint_ih = intr_establish(mb->mb_intrbase + 2,
 	    IPL_SCHED, IST_LEVEL, edma_errint_intr, sc);
 }
 
--- a/sys/arch/arm/omap/omapl1x_emac.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/omap/omapl1x_emac.c	Sat Jul 09 20:24:48 2016 +0000
@@ -30,7 +30,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: omapl1x_emac.c,v 1.1.12.2 2016/03/19 11:29:56 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omapl1x_emac.c,v 1.1.12.3 2016/07/09 20:24:50 skrll Exp $");
 
 #include "opt_omapl1x.h"
 
@@ -653,7 +653,7 @@
 		buf_len -= ETHER_CRC_LEN;
 
 	bus_dmamap_unload(sc->sc_buft, map);
-	mb->m_pkthdr.rcvif = ifp;
+	m_set_rcvif(mb, ifp);
 	mb->m_pkthdr.len = mb->m_len = buf_len;
 	ifp->if_ipackets++;
 
--- a/sys/arch/arm/omap/tiotg.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/omap/tiotg.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tiotg.c,v 1.2.8.4 2015/03/19 17:26:42 skrll Exp $ */
+/* $NetBSD: tiotg.c,v 1.2.8.5 2016/07/09 20:24:50 skrll Exp $ */
 /*
  * Copyright (c) 2013 Manuel Bouyer.  All rights reserved.
  *
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tiotg.c,v 1.2.8.4 2015/03/19 17:26:42 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tiotg.c,v 1.2.8.5 2016/07/09 20:24:50 skrll Exp $");
 
 #include "opt_omap.h"
 #include "locators.h"
@@ -38,7 +38,8 @@
 #include <sys/kernel.h>
 #include <sys/mutex.h>
 #include <sys/condvar.h>
-#include <arm/omap/omap2_obiovar.h>
+#include <arm/mainbus/mainbus.h>
+#include <arm/omap/omap_var.h>
 
 #include <arm/omap/omap2_reg.h>
 #include <arm/omap/tiotgreg.h>
@@ -127,10 +128,11 @@
 static int
 tiotg_match(device_t parent, cfdata_t match, void *aux)
 {
-        struct obio_attach_args *obio = aux;
+	struct mainbus_attach_args *mb = aux;
 
-        if ((obio->obio_addr == -1) || (obio->obio_size == 0) ||
-	    (obio->obio_intrbase == -1))
+	if (mb->mb_iobase == MAINBUSCF_BASE_DEFAULT ||
+	    mb->mb_iosize == MAINBUSCF_SIZE_DEFAULT ||
+	    mb->mb_intrbase == MAINBUSCF_INTRBASE_DEFAULT)
                 return 0;
         return 1;
 }
@@ -139,21 +141,21 @@
 tiotg_attach(device_t parent, device_t self, void *aux)
 {
 	struct tiotg_softc       *sc = device_private(self);
-	struct obio_attach_args *obio = aux;
+	struct mainbus_attach_args *mb = aux;
 	uint32_t val;
 
-	sc->sc_iot = obio->obio_iot;
-	sc->sc_dmat = obio->obio_dmat;
+	sc->sc_iot = &omap_bs_tag;
+	sc->sc_dmat = &omap_bus_dma_tag;
 	sc->sc_dev = self;
 
-	if (bus_space_map(obio->obio_iot, obio->obio_addr, obio->obio_size, 0,
+	if (bus_space_map(sc->sc_iot, mb->mb_iobase, mb->mb_iosize, 0,
 	    &sc->sc_ioh)) {
 		aprint_error(": couldn't map register space\n");
 		return;
 	}
 
-	sc->sc_intrbase = obio->obio_intrbase;
-	sc->sc_ih = intr_establish(obio->obio_intrbase, IPL_USB, IST_LEVEL,
+	sc->sc_intrbase = mb->mb_intrbase;
+	sc->sc_ih = intr_establish(mb->mb_intrbase, IPL_USB, IST_LEVEL,
 	    tiotg_intr, sc);
         KASSERT(sc->sc_ih != NULL);
 	aprint_normal(": TI dual-port USB controller");
--- a/sys/arch/arm/rockchip/rockchip_emac.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/rockchip/rockchip_emac.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rockchip_emac.c,v 1.12.2.4 2016/04/22 15:44:09 skrll Exp $ */
+/* $NetBSD: rockchip_emac.c,v 1.12.2.5 2016/07/09 20:24:50 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
@@ -29,7 +29,7 @@
 #include "opt_rkemac.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rockchip_emac.c,v 1.12.2.4 2016/04/22 15:44:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rockchip_emac.c,v 1.12.2.5 2016/07/09 20:24:50 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -874,7 +874,7 @@
 		rx->rx_ptr = htole32(rd->rd_map->dm_segs[0].ds_addr);
 
 		m->m_pkthdr.len = m->m_len = len;
-		m->m_pkthdr.rcvif = ifp;
+		m_set_rcvif(m, ifp);
 		m->m_flags |= M_HASFCS;
 
 		bpf_mtap(ifp, m);
--- a/sys/arch/arm/samsung/exynos_dwcmmc.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/samsung/exynos_dwcmmc.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exynos_dwcmmc.c,v 1.2.2.2 2016/03/19 11:29:57 skrll Exp $ */
+/* $NetBSD: exynos_dwcmmc.c,v 1.2.2.3 2016/07/09 20:24:50 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill@invisible.ca>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exynos_dwcmmc.c,v 1.2.2.2 2016/03/19 11:29:57 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exynos_dwcmmc.c,v 1.2.2.3 2016/07/09 20:24:50 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -84,7 +84,7 @@
 	char intrstr[128];
 	bus_addr_t addr;
 	bus_size_t size;
-	u_int bus_width, ciu_div, fifo_depth;
+	u_int ciu_div, fifo_depth;
 	int error;
 
 	if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
@@ -92,9 +92,9 @@
 		return;
 	}
 
-	if (of_getprop_uint32(phandle, "bus-width", &bus_width)) {
-		bus_width = 4;
-	}
+	//if (of_getprop_uint32(phandle, "bus-width", &bus_width)) {
+	//	bus_width = 4;
+	//}
 	if (of_getprop_uint32(phandle, "fifo-depth", &fifo_depth)) {
 		fifo_depth = 64;
 	}
--- a/sys/arch/arm/xscale/ixp425_if_npe.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/arm/xscale/ixp425_if_npe.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: ixp425_if_npe.c,v 1.27.2.3 2016/03/19 11:29:57 skrll Exp $ */
+/*	$NetBSD: ixp425_if_npe.c,v 1.27.2.4 2016/07/09 20:24:50 skrll Exp $ */
 
 /*-
  * Copyright (c) 2006 Sam Leffler.  All rights reserved.
@@ -28,7 +28,7 @@
 #if 0
 __FBSDID("$FreeBSD: src/sys/arm/xscale/ixp425/if_npe.c,v 1.1 2006/11/19 23:55:23 sam Exp $");
 #endif
-__KERNEL_RCSID(0, "$NetBSD: ixp425_if_npe.c,v 1.27.2.3 2016/03/19 11:29:57 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ixp425_if_npe.c,v 1.27.2.4 2016/07/09 20:24:50 skrll Exp $");
 
 /*
  * Intel XScale NPE Ethernet driver.
@@ -953,7 +953,7 @@
 			/* set m_len etc. per rx frame size */
 			mrx->m_len = be32toh(hw->ix_ne[0].len) & 0xffff;
 			mrx->m_pkthdr.len = mrx->m_len;
-			mrx->m_pkthdr.rcvif = ifp;
+			m_set_rcvif(mrx, ifp);
 			/* Don't add M_HASFCS. See below */
 
 #if 1
--- a/sys/arch/atari/stand/bootxx/bootxx.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/atari/stand/bootxx/bootxx.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootxx.c,v 1.16 2014/11/15 06:30:10 tsutsui Exp $	*/
+/*	$NetBSD: bootxx.c,v 1.16.2.1 2016/07/09 20:24:50 skrll Exp $	*/
 
 /*
  * Copyright (c) 1995 Waldi Ravens.
@@ -66,7 +66,7 @@
 	setheap((void *)HEAPSTART, (void *)HEAPEND);
 
 	printf("\033v\nNetBSD/atari secondary bootloader"
-						" ($Revision: 1.16 $)\n\n");
+						" ($Revision: 1.16.2.1 $)\n\n");
 
 	if (init_dskio(readsector, disklabel, -1))
 		return -1;
@@ -109,7 +109,7 @@
 
 	printf("\nEnter os-type [.%s] root-fs [:a] kernel [%s]"
 	       " options [none]:\n\033e", od->ostype, od->osname);
-	gets(p);
+	kgets(p, sizeof(line));
 	printf("\033f");
 
 	for (;;) {
--- a/sys/arch/bebox/stand/boot/monitor.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/bebox/stand/boot/monitor.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: monitor.c,v 1.10 2014/06/01 17:21:50 phx Exp $	*/
+/*	$NetBSD: monitor.c,v 1.10.4.1 2016/07/09 20:24:50 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -69,7 +69,7 @@
 
 	while (1) {
 		printf("db> ");
-		gets(line);
+		kgets(line, sizeof(line));
 
 		flag = 0;
 		for (p = line, argc = 0; *p != '\0'; p++) {
--- a/sys/arch/emips/ebus/if_le_ebus.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/emips/ebus/if_le_ebus.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_le_ebus.c,v 1.6.4.2 2016/03/19 11:29:57 skrll Exp $	*/
+/*	$NetBSD: if_le_ebus.c,v 1.6.4.3 2016/07/09 20:24:50 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_le_ebus.c,v 1.6.4.2 2016/03/19 11:29:57 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le_ebus.c,v 1.6.4.3 2016/07/09 20:24:50 skrll Exp $");
 
 #include "opt_inet.h"
 
@@ -451,7 +451,7 @@
 		MGETHDR(m, waitmode, MT_DATA);
 		if (m == 0)
 			break;
-		m->m_pkthdr.rcvif = &sc->sc_ethercom.ec_if;
+		m_set_rcvif(m, &sc->sc_ethercom.ec_if);
 		m->m_pkthdr.len = 0;
 
 		MCLGET(m, waitmode);
@@ -498,7 +498,7 @@
 	MGETHDR(m, waitmode, MT_DATA);
 	if (m == NULL)
 		return;
-	m->m_pkthdr.rcvif = &sc->sc_ethercom.ec_if;
+	m_set_rcvif(m, &sc->sc_ethercom.ec_if);
 	m->m_pkthdr.len = 0;
 
 	MCLGET(m, waitmode);
@@ -969,7 +969,7 @@
 	MGETHDR(n, M_NOWAIT, MT_DATA);
 	if (n == NULL)
 		goto Bad;
-	n->m_pkthdr.rcvif = &sc->sc_ethercom.ec_if;
+	m_set_rcvif(n, &sc->sc_ethercom.ec_if);
 	n->m_pkthdr.len = tlen;
 
 	MCLGET(n, M_NOWAIT);
--- a/sys/arch/evbarm/beagle/beagle_machdep.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/evbarm/beagle/beagle_machdep.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: beagle_machdep.c,v 1.60.4.2 2015/12/27 12:09:33 skrll Exp $ */
+/*	$NetBSD: beagle_machdep.c,v 1.60.4.3 2016/07/09 20:24:51 skrll Exp $ */
 
 /*
  * Machine dependent functions for kernel setup for TI OSK5912 board.
@@ -125,7 +125,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.60.4.2 2015/12/27 12:09:33 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: beagle_machdep.c,v 1.60.4.3 2016/07/09 20:24:51 skrll Exp $");
 
 #include "opt_machdep.h"
 #include "opt_ddb.h"
@@ -141,6 +141,7 @@
 #include "sdhc.h"
 #include "ukbd.h"
 #include "arml2cc.h"
+#include "tps65217pmic.h"
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -421,6 +422,7 @@
 }
 #endif
 
+#ifdef VERBOSE_INIT_ARM
 void beagle_putchar(char c);
 void
 beagle_putchar(char c)
@@ -442,6 +444,9 @@
 	}
 #endif
 }
+#else
+#define beagle_putchar(c)	((void)0)
+#endif
 
 /*
  * u_int initarm(...)
@@ -1121,10 +1126,15 @@
 int
 set_mpu_volt(int mvolt)
 {
+
+#if NTPS65217PMIC > 0
 	if (pmic_dev == NULL)
 		return ENODEV;
 
 	/* MPU voltage is on vdcd2 */
 	return tps65217pmic_set_volt(pmic_dev, "DCDC2", mvolt);
+#else
+	return -1;
+#endif
 }
 #endif
--- a/sys/arch/evbarm/conf/BEAGLEBOARDXM	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/evbarm/conf/BEAGLEBOARDXM	Sat Jul 09 20:24:48 2016 +0000
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: BEAGLEBOARDXM,v 1.19.2.1 2015/09/22 12:05:40 skrll Exp $
+#	$NetBSD: BEAGLEBOARDXM,v 1.19.2.2 2016/07/09 20:24:51 skrll Exp $
 #
 #	BEAGLEBOARD -- TI OMAP 3530 Eval Board Kernel
 #
@@ -136,10 +136,10 @@
 makeoptions	COPY_SYMTAB=1
 
 ## USB Debugging options
-options USB_DEBUG
-options EHCI_DEBUG
-options OHCI_DEBUG
-options UHUB_DEBUG
+#options USB_DEBUG
+#options EHCI_DEBUG
+#options OHCI_DEBUG
+#options UHUB_DEBUG
 
 
 # Valid options for BOOT_ARGS:
--- a/sys/arch/evbarm/conf/BEAGLEBONE	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/evbarm/conf/BEAGLEBONE	Sat Jul 09 20:24:48 2016 +0000
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: BEAGLEBONE,v 1.29.2.4 2015/12/27 12:09:34 skrll Exp $
+#	$NetBSD: BEAGLEBONE,v 1.29.2.5 2016/07/09 20:24:51 skrll Exp $
 #
 #	BEAGLEBONE -- TI AM335x board Kernel
 #
@@ -176,18 +176,18 @@
 #L3i0		at mainbus?
 
 # OBIO
-obio0		at mainbus? base 0x44000000 size 0x0c000000
-#obio0		at mainbus? base 0x44c00000 size 0x00400000	# L4_WKUP
-#obio1		at mainbus? base 0x48000000 size 0x01000000	# L4_PER
-#obio2		at mainbus? base 0x4a000000 size 0x01000000	# L4_FAST
+obio0		at mainbus? base 0x44c00000 size 0x00400000	# L4_WKUP
+obio1		at mainbus? base 0x48000000 size 0x01000000	# L4_PER
+obio2		at mainbus? base 0x4a000000 size 0x01000000	# L4_FAST
 
-
+# Enhanced Direct Memory Access controller
+edma0		at mainbus? base 0x49000000 size 0x100000 intrbase 12
 
 # General Purpose Memory Controller
 gpmc0		at mainbus? base 0x50000000
 
 # Interrupt Controller
-omapicu0	at obio0 addr 0x48200000 size 0x1000 intrbase 0
+omapicu0	at obio1 addr 0x48200000 size 0x1000 intrbase 0
 
 # Power, Reset and Clock Management
 prcm0		at obio0 addr 0x44e00000 size 0x2000	# PRM Module
@@ -195,20 +195,14 @@
 # Control Module
 sitaracm0	at obio0 addr 0x44e10000 size 0x2000
 
-# Enhanced Direct Memory Access controller
-edma0		at obio0 addr 0x49000000 size 0x100000 intrbase 12
-
 # SDHC controllers
-# XXX Kludge -- the am335x's mmc registers start at an offset of #x100
-# from other omap3.  (What about omap4?)  Need to adapt the omap sdhc
-# driver to handle this.
-sdhc0		at obio0 addr 0x48060100 size 0x0f00 intr 64 edmabase 24
+sdhc0		at obio1 addr 0x48060000 size 0x1000 intr 64 edmabase 24
 sdmmc0		at sdhc0
 ld0		at sdmmc0
-sdhc1		at obio0 addr 0x481d8100 size 0x0f00 intr 28 edmabase 2 # BB Black
+sdhc1		at obio1 addr 0x481d8000 size 0x1000 intr 28 edmabase 2 # BB Black
 sdmmc1		at sdhc1
 ld1		at sdmmc1
-#sdhc2		at obio0 addr 0x47810100 size 0xff00 intr 29
+#sdhc2		at obio0 addr 0x47810000 size 0x1000 intr 29
 #sdmmc2		at sdhc2
 #ld2		at sdmmc2
 sdmmc*		at sdhc?		# SD/MMC bus
@@ -219,11 +213,11 @@
 # General-purpose I/O pins
 omapgpio0	at obio0 addr 0x44e07000 size 0x1000 # intrbase 128 intr 29
 gpio0		at omapgpio0
-omapgpio1	at obio0 addr 0x4804c000 size 0x1000 # intrbase 160 intr 30
+omapgpio1	at obio1 addr 0x4804c000 size 0x1000 # intrbase 160 intr 30
 gpio1		at omapgpio1
-omapgpio2	at obio0 addr 0x481ac000 size 0x1000 # intrbase 192 intr 32
+omapgpio2	at obio1 addr 0x481ac000 size 0x1000 # intrbase 192 intr 32
 gpio2		at omapgpio2
-omapgpio3	at obio0 addr 0x481ae000 size 0x1000 # intrbase 224 intr 32
+omapgpio3	at obio1 addr 0x481ae000 size 0x1000 # intrbase 224 intr 32
 gpio3		at omapgpio3
 
 # I2C Controller
@@ -242,22 +236,22 @@
 # choice.
 
 # Hardclock timer
-omapdmtimer0	at obio0 addr 0x48040000 size 0x1000 intr 68	# DM Timer 2
+omapdmtimer0	at obio1 addr 0x48040000 size 0x1000 intr 68	# DM Timer 2
 
 # Time counter
 omapdmtimer1	at obio0 addr 0x44e31000 size 0x1000 intr 67	# DM Timer 1ms
 
 # Statclock timer
-omapdmtimer2	at obio0 addr 0x48044000 size 0x1000 intr 92	# DM Timer 4
+omapdmtimer2	at obio1 addr 0x48044000 size 0x1000 intr 92	# DM Timer 4
 
 # Watchdog timers
 omapwdt32k*	at obio0 addr 0x44e35000 size 0x1000	# WDT1
 
 # Random number generator
-trng*		at obio0 addr 0x48310000 size 0x2000 intr 111	# TRNG
+trng*		at obio1 addr 0x48310000 size 0x2000 intr 111	# TRNG
 
 # onboard video, experimental. Video mode is hardcoded in the driver
-#tifb* 	at obio0 addr 0x4830E000 size 0x1000 intr 36
+#tifb* 	at obio1 addr 0x4830E000 size 0x1000 intr 36
 
 # make sure the console display is always wsdisplay0
 #wsdisplay*	at wsemuldisplaydev?
@@ -280,7 +274,7 @@
 pseudo-device	wsfont
 
 # On-board USB. Experimental
-tiotg* 	at obio0 addr 0x47400000 size 0x5000 intrbase 17
+tiotg* 	at mainbus? base 0x47400000 size 0x5000 intrbase 17
 motg*	at tiotg? port ?
 usb*		at motg?
 uhub*		at usb?
@@ -339,7 +333,7 @@
 axe*		at uhub? port ? configuration ? interface ?
 
 # Ethernet
-cpsw*		at obio0 addr 0x4a100000 size 0x8000 intrbase 40
+cpsw*		at obio2 addr 0x4a100000 size 0x8000 intrbase 40
 ukphy*		at mii?
 
 # Pseudo-Devices
--- a/sys/arch/evbarm/conf/TISDP2420	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/evbarm/conf/TISDP2420	Sat Jul 09 20:24:48 2016 +0000
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: TISDP2420,v 1.32.2.1 2015/09/22 12:05:40 skrll Exp $
+#	$NetBSD: TISDP2420,v 1.32.2.2 2016/07/09 20:24:51 skrll Exp $
 #
 #	TISDP2420 -- TI OMAP 2420 Eval Board Kernel
 #
@@ -136,9 +136,9 @@
 makeoptions	COPY_SYMTAB=1
 
 ## USB Debugging options
-options USB_DEBUG
-options OHCI_DEBUG
-options UHUB_DEBUG
+#options USB_DEBUG
+#options OHCI_DEBUG
+#options UHUB_DEBUG
 
 
 # Valid options for BOOT_ARGS:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/evbarm/conf/VTC100	Sat Jul 09 20:24:48 2016 +0000
@@ -0,0 +1,353 @@
+#
+#	$NetBSD: VTC100,v 1.1.2.2 2016/07/09 20:24:51 skrll Exp $
+#
+#	BEAGLEBONE -- TI AM335x board Kernel
+#
+
+include	"arch/evbarm/conf/std.beagle"
+
+# estimated number of users
+
+maxusers	32
+
+# Standard system options
+
+options 	RTC_OFFSET=0	# hardware clock is this many mins. west of GMT
+#options 	NTP		# NTP phase/frequency locked loop
+
+# CPU options
+
+options 	CPU_CORTEXA8
+options 	TI_AM335X
+options 	PMAPCOUNTERS
+
+# XXX The Cortex PMC delay() doesn't seem to work.
+#no options	CORTEX_PMC
+
+# Architecture options
+#makeoptions	CPUFLAGS+="-mthumb"
+
+# File systems
+
+file-system	FFS		# UFS
+#file-system	LFS		# log-structured file system
+file-system	MFS		# memory file system
+file-system	NFS		# Network file system
+#file-system 	ADOSFS		# AmigaDOS-compatible file system
+file-system 	EXT2FS		# second extended file system (linux)
+#file-system	CD9660		# ISO 9660 + Rock Ridge file system
+file-system	MSDOSFS		# MS-DOS file system
+#file-system	FDESC		# /dev/fd
+#file-system	KERNFS		# /kern
+file-system	NULLFS		# loopback file system
+#file-system	PROCFS		# /proc
+#file-system	PUFFS		# Userspace file systems (e.g. ntfs-3g & sshfs)
+#file-system	UMAPFS		# NULLFS + uid and gid remapping
+#file-system	UNION		# union file system
+file-system	TMPFS		# memory file system
+file-system	PTYFS		# /dev/pts/N support
+
+# File system options
+#options 	QUOTA		# legacy UFS quotas
+#options 	QUOTA2		# new, in-filesystem UFS quotas
+#options 	FFS_EI		# FFS Endian Independent support
+#options 	NFSSERVER
+options 	WAPBL		# File system journaling support
+#options 	FFS_NO_SNAPSHOT	# No FFS snapshot support
+
+# Networking options
+
+#options 	GATEWAY		# packet forwarding
+options 	INET		# IP + ICMP + TCP + UDP
+options 	INET6		# IPV6
+#options 	IPSEC		# IP security
+#options 	IPSEC_DEBUG	# debug for IP security
+#options 	MROUTING	# IP multicast routing
+#options 	PIM		# Protocol Independent Multicast
+#options 	NETATALK	# AppleTalk networking
+#options 	PPP_BSDCOMP	# BSD-Compress compression support for PPP
+#options 	PPP_DEFLATE	# Deflate compression support for PPP
+#options 	PPP_FILTER	# Active filter support for PPP (requires bpf)
+#options 	TCP_DEBUG	# Record last TCP_NDEBUG packets with SO_DEBUG
+
+options 	NFS_BOOT_BOOTP
+options 	NFS_BOOT_DHCP
+#options		NFS_BOOT_BOOTSTATIC
+#options		NFS_BOOTSTATIC_MYIP="\"192.168.1.4\""
+#options		NFS_BOOTSTATIC_GWIP="\"192.168.1.1\""
+#options		NFS_BOOTSTATIC_MASK="\"255.255.255.0\""
+#options		NFS_BOOTSTATIC_SERVADDR="\"192.168.1.1\""
+#options		NFS_BOOTSTATIC_SERVER="\"192.168.1.1:/nfs/sdp2430\""
+
+options		NFS_BOOT_RWSIZE=1024
+
+# Compatibility options
+
+options		COMPAT_NETBSD32	# allow running arm (e.g. non-earm) binaries
+#options 	COMPAT_43	# 4.3BSD compatibility.
+#options 	COMPAT_09	# NetBSD 0.9,
+#options 	COMPAT_10	# NetBSD 1.0,
+#options 	COMPAT_11	# NetBSD 1.1,
+#options 	COMPAT_12	# NetBSD 1.2,
+#options 	COMPAT_13	# NetBSD 1.3,
+#options 	COMPAT_14	# NetBSD 1.4,
+#options 	COMPAT_15	# NetBSD 1.5,
+#options 	COMPAT_16	# NetBSD 1.6,
+#options 	COMPAT_20	# NetBSD 2.0,
+options 	COMPAT_30	# NetBSD 3.0,
+options 	COMPAT_40	# NetBSD 4.0,
+options 	COMPAT_50	# NetBSD 5.0,
+options 	COMPAT_60	# NetBSD 6.0, and
+options 	COMPAT_70	# NetBSD 7.0 binary compatibility.
+#options 	TCP_COMPAT_42	# 4.2BSD TCP/IP bug compat. Not recommended.
+#options		COMPAT_BSDPTY	# /dev/[pt]ty?? ptys.
+
+# Shared memory options
+
+options 	SYSVMSG		# System V-like message queues
+options 	SYSVSEM		# System V-like semaphores
+options 	SYSVSHM		# System V-like memory sharing
+
+# Device options
+
+#options 	MEMORY_DISK_HOOKS	# boottime setup of ramdisk
+#options 	MEMORY_DISK_ROOT_SIZE=8192	# Size in blocks
+#options 	MEMORY_DISK_DYNAMIC
+#options 	MINIROOTSIZE=1000	# Size in blocks
+#options 	MEMORY_DISK_IS_ROOT	# use memory disk as root
+
+# Wedge support
+options 	DKWEDGE_AUTODISCOVER	# Automatically add dk(4) instances
+options 	DKWEDGE_METHOD_GPT	# Supports GPT partitions as wedges
+
+# Miscellaneous kernel options
+options 	KTRACE		# system call tracing, a la ktrace(1)
+#options 	SCSIVERBOSE	# Verbose SCSI errors
+#options 	MIIVERBOSE	# Verbose MII autoconfuration messages
+#options 	DDB_KEYCODE=0x40
+#options 	USERCONF	# userconf(4) support
+#options	PIPE_SOCKETPAIR	# smaller, but slower pipe(2)
+
+# Development and Debugging options
+
+#options 	PERFCTRS	# performance counters
+options 	DIAGNOSTIC	# internal consistency checks
+options 	DEBUG
+#options 	KDTRACE_HOOKS	# kernel DTrace hooks
+#options 	PMAP_DEBUG	# Enable pmap_debug_level code
+#options 	IPKDB		# remote kernel debugging
+#options 	VERBOSE_INIT_ARM # verbose bootstraping messages
+options 	DDB		# in-kernel debugger
+options		DDB_ONPANIC=1
+options 	DDB_HISTORY_SIZE=100	# Enable history editing in DDB
+#options 	KGDB
+makeoptions	DEBUG="-g"	# compile full symbol table
+makeoptions	COPY_SYMTAB=1
+
+## USB Debugging options
+options USB_DEBUG
+options EHCI_DEBUG
+options OHCI_DEBUG
+options UHUB_DEBUG
+
+
+# Valid options for BOOT_ARGS:
+#  single		Boot to single user only
+#  kdb			Give control to kernel debugger
+#  ask			Ask for file name to reboot from
+#  pmapdebug=<n>	If PMAP_DEBUG, set pmap_debug_level to <n>
+#  memorydisk=<n>	Set memorydisk size to <n> KB
+#  quiet		Show aprint_naive output
+#  verbose		Show aprint_normal and aprint_verbose output
+options		BOOT_ARGS="\"-v\""
+
+config		netbsd		root on ? type ?
+
+# The main bus device
+mainbus0	at root
+
+# The boot cpu
+cpu0		at mainbus?
+
+# L3 Interconnect
+#L3i0		at mainbus?
+
+# OBIO
+obio0		at mainbus? base 0x44c00000 size 0x00400000	# L4_WKUP
+obio1		at mainbus? base 0x48000000 size 0x01000000	# L4_PER
+obio2		at mainbus? base 0x4a000000 size 0x01000000	# L4_FAST
+
+# Enhanced Direct Memory Access controller
+edma0		at mainbus? base 0x49000000 size 0x100000 intrbase 12
+
+# General Purpose Memory Controller
+gpmc0		at mainbus? base 0x50000000
+
+# Interrupt Controller
+omapicu0	at obio1 addr 0x48200000 size 0x1000 intrbase 0
+
+# Power, Reset and Clock Management
+prcm0		at obio0 addr 0x44e00000 size 0x2000	# PRM Module
+
+# Control Module
+sitaracm0	at obio0 addr 0x44e10000 size 0x2000
+
+# SDHC controllers
+sdhc0		at obio1 addr 0x48060000 size 0x1000 intr 64 edmabase 24
+sdmmc*		at sdhc?
+ld*		at sdmmc?
+#options SDMMC_DEBUG
+#options SDHC_DEBUG
+
+# General-purpose I/O pins
+omapgpio0	at obio0 addr 0x44e07000 size 0x1000 # intrbase 128 intr 29
+gpio0		at omapgpio0
+omapgpio1	at obio1 addr 0x4804c000 size 0x1000 # intrbase 160 intr 30
+gpio1		at omapgpio1
+omapgpio2	at obio1 addr 0x481ac000 size 0x1000 # intrbase 192 intr 32
+gpio2		at omapgpio2
+omapgpio3	at obio1 addr 0x481ae000 size 0x1000 # intrbase 224 intr 32
+gpio3		at omapgpio3
+
+# I2C Controller
+tiiic0		at obio0 addr 0x44e0b000 size 0x1000 intr 70
+iic*		at tiiic?
+#?		at iic? addr 0x00
+#tps65910pmic0	at iic? addr 0x12	# TPS65910 ID0 (SmartReflex)
+#tlv320aic3x	at iic? addr 0x18	# TLV320AIC3x
+#tps65910pmic1	at iic? addr 0x2d	# TPS65910 ID1	# RTC
+#micon		at iic? addr 0x5a
+#?		at iic? addr 0x76
+
+# On-board 16550 UARTs
+com0		at obio1 addr 0x48022000 size 0x1000 intr 73 mult 4	# UART1
+options 	CONSADDR=0x48022000, CONSPEED=115200
+# GPS
+com1		at obio1 addr 0x481a6000 size 0x1000 intr 44 mult 4	# UART3
+
+# XXX Clock assignment is kinda random.  My DM timer 3 seems to be
+# unhappy and I don't know why.  DM timer 0 doesn't seem to deliver
+# interrupts for the hard clock, although it seems to be the obvious
+# choice.
+
+# Hardclock timer
+omapdmtimer0	at obio1 addr 0x48040000 size 0x1000 intr 68	# DM Timer 2
+
+# Time counter
+omapdmtimer1	at obio0 addr 0x44e31000 size 0x1000 intr 67	# DM Timer 1ms
+
+# Statclock timer
+omapdmtimer2	at obio1 addr 0x48044000 size 0x1000 intr 92	# DM Timer 4
+
+# Watchdog timers
+omapwdt32k*	at obio0 addr 0x44e35000 size 0x1000	# WDT1
+
+# onboard video, experimental. Video mode is hardcoded in the driver
+#tifb* 		at obio1 addr 0x4830E000 size 0x1000 intr 36
+
+# make sure the console display is always wsdisplay0
+#wsdisplay*	at wsemuldisplaydev?
+
+# various options for wscons - we try to look as much like a standard
+# sun console as possible
+#options 	WSEMUL_VT100
+#options 	WSDISPLAY_COMPAT_PCVT
+#options 	WSDISPLAY_COMPAT_SYSCONS
+#options 	WSDISPLAY_COMPAT_USL
+#options 	WSDISPLAY_SCROLLSUPPORT
+#options 	WS_KERNEL_FG=WSCOL_GREEN
+#options 	WSDISPLAY_DEFAULTSCREENS=4
+#options 	FONT_GALLANT12x22
+#options 	FONT_BOLD8x16
+# compatibility to other console drivers
+#options 	WSDISPLAY_COMPAT_RAWKBD 	# can get raw scancodes
+
+pseudo-device	wsmux			# mouse & keyboard multiplexor
+pseudo-device	wsfont
+
+# Ethernet
+cpsw*		at obio2 addr 0x4a100000 size 0x8000 intrbase 93
+ukphy*		at mii?
+
+# On-board USB. Experimental
+tiotg* 	at mainbus0 base 0x47400000 size 0x5000 intrbase 17
+motg*	at tiotg? port ?
+usb*		at motg?
+uhub*		at usb?
+uhub*		at uhub? port ?
+
+uhidev*		at uhub?
+
+# USB Keyboards
+ukbd*	at uhidev? reportid ?
+wskbd*	at ukbd? console ? mux 1
+
+# USB Mice
+ums*	at uhidev? reportid ?
+wsmouse* at ums? mux 0
+
+# USB generic touchscreen
+uts*	at uhidev? reportid ?
+wsmouse* at uts? mux 0
+
+# USB Modem
+umodem* at uhub? port ? configuration ?
+ucom*	at umodem?
+# Serial adapters
+ubsa*	at uhub? port ?		# Belkin serial adapter
+ucom*	at ubsa? portno ?
+
+uchcom* at uhub? port ? 	# WinChipHead CH341/CH340 serial adapter
+ucom*	at uchcom? portno ?
+
+uftdi*	at uhub? port ?		# FTDI FT8U100AX serial adapter
+ucom*	at uftdi? portno ?
+
+uipaq*	at uhub? port ?		# iPAQ PDAs
+ucom*	at uipaq? portno ?
+
+umct*	at uhub? port ?		# MCT USB-RS232 serial adapter
+ucom*	at umct? portno ?
+
+uplcom* at uhub? port ? 	# I/O DATA USB-RSAQ2 serial adapter
+ucom*	at uplcom? portno ?
+
+uslsa*	at uhub? port ?		# Silicon Labs USB-RS232 serial adapter
+ucom*	at uslsa? portno ?
+
+uvscom* at uhub? port ? 	# SUNTAC Slipper U VS-10U serial adapter
+ucom*	at uvscom? portno ?
+
+
+umass*		at uhub? port ? configuration ? interface ?
+wd*		at umass?
+# SCSI bus support
+scsibus*	at scsi?
+# SCSI devices
+sd*		at scsibus? target ? lun ?      # SCSI disk drives
+
+axe*		at uhub? port ? configuration ? interface ?
+
+# Pseudo-Devices
+
+# disk/mass storage pseudo-devices
+#pseudo-device	md			# memory disk device (ramdisk)
+#pseudo-device	vnd			# disk-like interface to files
+#pseudo-device	fss			# file system snapshot device
+#pseudo-device	putter			# for puffs and pud
+pseudo-device	drvctl			# driver control
+
+# network pseudo-devices
+pseudo-device	bpfilter		# Berkeley packet filter
+pseudo-device	loop			# network loopback
+#pseudo-device	kttcp			# network loopback
+
+# miscellaneous pseudo-devices
+pseudo-device	pty			# pseudo-terminals
+#options	RND_COM
+#pseudo-device	clockctl		# user control of clock subsystem
+pseudo-device	ksyms			# /dev/ksyms
+pseudo-device	lockstat		# lock profiling
+
+# local configuration
+cinclude "arch/evbarm/conf/BEAGLEBONE.local"
--- a/sys/arch/evbarm/imx7/imx7_machdep.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/evbarm/imx7/imx7_machdep.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: imx7_machdep.c,v 1.2.2.2 2016/05/29 08:44:16 skrll Exp $	*/
+/*	$NetBSD: imx7_machdep.c,v 1.2.2.3 2016/07/09 20:24:51 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imx7_machdep.c,v 1.2.2.2 2016/05/29 08:44:16 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx7_machdep.c,v 1.2.2.3 2016/07/09 20:24:51 skrll Exp $");
 
 #include "opt_evbarm_boardtype.h"
 #include "opt_arm_debug.h"
@@ -211,6 +211,12 @@
 
 #ifdef MEMSIZE
 	memsize = MEMSIZE * 1024 * 1024;
+#else
+/*
+ * Ugh... but this is better than proceeding using an uninitialized
+ * value in memsize, as the code did before I added this branch...
+ */
+#error "MEMSIZE not set"
 #endif
 
 	bootconfig.dramblocks = 1;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/evbmips/loongson/loongson_clock.c	Sat Jul 09 20:24:48 2016 +0000
@@ -0,0 +1,391 @@
+/*	$NetBSD: loongson_clock.c,v 1.1.2.2 2016/07/09 20:24:51 skrll Exp $	*/
+
+/*
+ * Copyright (c) 2011, 2016 Michael Lorenz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: loongson_clock.c,v 1.1.2.2 2016/07/09 20:24:51 skrll Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+#include <sys/cpu.h>
+#include <sys/timetc.h>
+#include <sys/sysctl.h>
+
+#include <mips/mips3_clock.h>
+#include <mips/locore.h>
+#include <mips/bonito/bonitoreg.h>
+#include <mips/bonito/bonitovar.h>
+
+#ifdef LOONGSON_CLOCK_DEBUG
+#define DPRINTF aprint_error
+#else
+#define DPRINTF while (0) printf
+#endif
+
+static uint32_t sc_last;
+static uint32_t sc_scale[8];
+static uint32_t sc_count;	/* should probably be 64 bit */
+static int sc_step = 7;
+static int sc_step_wanted = 7;
+static void *sc_shutdown_cookie;
+
+/* 0, 1/4, 3/8, 1/2, 5/8, 3/4, 7/8, 1 */
+static int scale_m[] = {1, 1, 3, 1, 5, 3, 7, 1};
+static int scale_d[] = {0, 4, 8, 2, 8, 4, 8, 1};
+static int cycles[8];
+
+#define scale(x, f) (x * scale_d[f] / scale_m[f])
+#define rscale(x, f) (x * scale_m[f] / scale_d[f])
+
+static void loongson_set_speed(int);
+static int  loongson_cpuspeed_temp(SYSCTLFN_ARGS);
+static int  loongson_cpuspeed_cur(SYSCTLFN_ARGS);
+static int  loongson_cpuspeed_available(SYSCTLFN_ARGS);
+
+static void loongson_clock_shutdown(void *);
+static u_int get_loongson_timecount(struct timecounter *);
+void	    loongson_delay(int);
+void	    loongson_setstatclockrate(int);
+void        loongson_initclocks(void);
+
+static struct timecounter loongson_timecounter = {
+	get_loongson_timecount,	/* get_timecount */
+	0,			/* no poll_pps */
+	0xffffffff,		/* counter_mask */
+	0,			/* frequency */
+	"loongson",		/* name */
+	100,			/* quality */
+	NULL,			/* tc_priv */
+	NULL			/* tc_next */
+};
+
+void
+loongson_initclocks(void)
+{
+	const struct sysctlnode *sysctl_node, *me, *freq;
+	int clk;
+
+	/*
+	 * Establish a hook so on shutdown we can set the CPU clock back to
+	 * full speed. This is necessary because PMON doesn't change the 
+	 * clock scale register on a warm boot, the MIPS clock code gets
+	 * confused if we're too slow and the loongson-specific bits run
+	 * too late in the boot process
+	 */
+	sc_shutdown_cookie = shutdownhook_establish(loongson_clock_shutdown, NULL);
+
+	for (clk = 1; clk < 8; clk++) {
+		sc_scale[clk] = rscale(curcpu()->ci_cpu_freq / 1000000, clk);
+		cycles[clk] =
+		    (rscale(curcpu()->ci_cpu_freq, clk) + hz / 2) / (2 * hz);
+	}
+#ifdef LOONGSON_CLOCK_DEBUG
+	for (clk = 1; clk < 8; clk++) {
+		aprint_normal("frequencies: %d/8: %d\n", clk + 1,
+		    sc_scale[clk]);
+	}
+#endif
+
+	/* now setup sysctl */
+	if (sysctl_createv(NULL, 0, NULL, 
+	    &me, 
+	    CTLFLAG_READWRITE, CTLTYPE_NODE, "loongson", NULL, NULL,
+	    0, NULL, 0, CTL_MACHDEP, CTL_CREATE, CTL_EOL) != 0)
+		aprint_error("couldn't create 'loongson' node\n");
+
+	if (sysctl_createv(NULL, 0, NULL, 
+	    &freq, 
+	    CTLFLAG_READWRITE, CTLTYPE_NODE, "frequency", NULL, NULL, 0, NULL,
+	    0, CTL_MACHDEP, me->sysctl_num, CTL_CREATE, CTL_EOL) != 0)
+		aprint_error("couldn't create 'frequency' node\n");
+
+	if (sysctl_createv(NULL, 0, NULL, 
+	    &sysctl_node, 
+	    CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+	    CTLTYPE_INT, "target", "CPU speed", loongson_cpuspeed_temp, 
+	    0, NULL, 0, CTL_MACHDEP, me->sysctl_num, freq->sysctl_num, 
+	    CTL_CREATE, CTL_EOL) == 0) {
+	} else
+		aprint_error("couldn't create 'target' node\n");
+
+	if (sysctl_createv(NULL, 0, NULL, 
+	    &sysctl_node, 
+	    CTLFLAG_READWRITE,
+	    CTLTYPE_INT, "current", NULL, loongson_cpuspeed_cur, 
+	    1, NULL, 0, CTL_MACHDEP, me->sysctl_num, freq->sysctl_num, 
+	    CTL_CREATE, CTL_EOL) == 0) {
+	} else
+		aprint_error("couldn't create 'current' node\n");
+
+	if (sysctl_createv(NULL, 0, NULL, 
+	    &sysctl_node, 
+	    CTLFLAG_READWRITE,
+	    CTLTYPE_STRING, "available", NULL, loongson_cpuspeed_available, 
+	    2, NULL, 0, CTL_MACHDEP, me->sysctl_num, freq->sysctl_num, 
+	    CTL_CREATE, CTL_EOL) == 0) {
+	} else
+		aprint_error("couldn't create 'available' node\n");
+
+	sc_count = 0;
+	loongson_timecounter.tc_frequency = curcpu()->ci_cpu_freq / 2;
+	curcpu()->ci_cctr_freq = loongson_timecounter.tc_frequency;
+
+	sc_last = mips3_cp0_count_read();
+	mips3_cp0_compare_write(sc_last + curcpu()->ci_cycles_per_hz);
+
+	tc_init(&loongson_timecounter);
+
+	/*
+	 * Now we can enable all interrupts including hardclock(9)
+	 * by CPU INT5.
+	 */
+	spl0();
+	printf("boom\n");
+}
+
+static void
+loongson_clock_shutdown(void *cookie)
+{
+
+	/* just in case the interrupt handler runs again after this */
+	sc_step_wanted = 7;
+	/* set the clock to full speed */
+	REGVAL(LS2F_CHIPCFG0) =
+	    (REGVAL(LS2F_CHIPCFG0) & ~LS2FCFG_FREQSCALE_MASK) | 7;
+}
+
+void
+loongson_set_speed(int speed)
+{
+
+	if ((speed < 1) || (speed > 7))
+		return;
+	sc_step_wanted = speed;
+	DPRINTF("%s: %d\n", __func__, speed);
+}
+
+/*
+ * the clock interrupt handler
+ * we don't have a CPU clock independent, high resolution counter so we're
+ * stuck with a PWM that can't count and a CP0 counter that slows down or
+ * speeds up with the actual CPU speed. In order to still get halfway
+ * accurate time we do the following:
+ * - only change CPU speed in the timer interrupt
+ * - each timer interrupt we measure how many CP0 cycles passed since last
+ *   time, adjust for CPU speed since we can be sure it didn't change, use
+ *   that to update a separate counter
+ * - when reading the time counter we take the number of CP0 ticks since 
+ *   the last timer interrupt, scale it to CPU clock, return that plus the
+ *   interrupt updated counter mentioned above to get something close to
+ *   CP0 running at full speed 
+ * - when changing CPU speed do it as close to taking the time from CP0 as
+ *   possible to keep the period of time we spend with CP0 running at the
+ *   wrong frequency as short as possible - hopefully short enough to stay
+ *   insignificant compared to other noise since switching speeds isn't
+ *   going to happen all that often
+ */
+
+void
+mips3_clockintr(struct clockframe *cf)
+{
+	uint32_t now, diff, next, new_cnt;
+
+	/*
+	 * this looks kinda funny but what we want here is this:
+	 * - reading the counter and changing the CPU clock should be as
+	 *   close together as possible in order to remain halfway accurate
+	 * - we need to use the previous sc_step in order to scale the
+	 *   interval passed since the last clock interrupt correctly, so
+	 *   we only change sc_step after doing that
+	 */
+	if (sc_step_wanted != sc_step) {
+
+		REGVAL(LS2F_CHIPCFG0) =
+		    (REGVAL(LS2F_CHIPCFG0) & ~LS2FCFG_FREQSCALE_MASK) |
+		     sc_step_wanted;
+	}
+
+	now = mips3_cp0_count_read();		
+	diff = now - sc_last;
+	sc_count += scale(diff, sc_step);
+	sc_last = now;
+	if (sc_step_wanted != sc_step) {
+		sc_step = sc_step_wanted;
+		curcpu()->ci_cycles_per_hz = cycles[sc_step];
+	}
+	next = now + curcpu()->ci_cycles_per_hz;
+	curcpu()->ci_ev_count_compare.ev_count++;
+
+	mips3_cp0_compare_write(next);
+
+	/* Check for lost clock interrupts */
+	new_cnt = mips3_cp0_count_read();
+
+	/* 
+	 * Missed one or more clock interrupts, so let's start 
+	 * counting again from the current value.
+	 */
+	if ((next - new_cnt) & 0x80000000) {
+
+		next = new_cnt + curcpu()->ci_cycles_per_hz;
+		mips3_cp0_compare_write(next);
+		curcpu()->ci_ev_count_compare_missed.ev_count++;
+	}
+ 
+	hardclock(cf);
+}
+
+static u_int
+get_loongson_timecount(struct timecounter *tc)
+{
+	uint32_t now, diff;
+
+	now = mips3_cp0_count_read();
+	diff = now - sc_last;
+	return sc_count + scale(diff, sc_step);
+}
+
+static int
+loongson_cpuspeed_temp(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node = *rnode;
+	int mhz, i;
+
+	mhz = sc_scale[sc_step_wanted];
+
+	node.sysctl_data = &mhz;
+	if (sysctl_lookup(SYSCTLFN_CALL(&node)) == 0) {
+		int new_reg;
+
+		new_reg = *(int *)node.sysctl_data;
+		i = 1;
+		while ((i < 8) && (sc_scale[i] != new_reg))
+			i++;
+		if (i > 7)
+			return EINVAL;
+		loongson_set_speed(i);
+		return 0;
+	}
+	return EINVAL;
+}
+
+static int
+loongson_cpuspeed_cur(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node = *rnode;
+	int mhz;
+
+	mhz = sc_scale[sc_step];
+	node.sysctl_data = &mhz;
+	return sysctl_lookup(SYSCTLFN_CALL(&node));
+}
+
+static int
+loongson_cpuspeed_available(SYSCTLFN_ARGS)
+{
+	struct sysctlnode node = *rnode;
+	char buf[128];
+
+	snprintf(buf, 128, "%d %d %d %d %d %d %d", sc_scale[1],
+	    sc_scale[2], sc_scale[3], sc_scale[4],
+	    sc_scale[5], sc_scale[6], sc_scale[7]);
+	node.sysctl_data = buf;
+	return(sysctl_lookup(SYSCTLFN_CALL(&node)));
+}
+
+/*
+ * Wait for at least "n" microseconds.
+ */
+void
+loongson_delay(int n)
+{
+	u_long divisor_delay;
+	uint32_t cur, last, delta, usecs;
+
+	last = mips3_cp0_count_read();
+	delta = usecs = 0;
+
+	divisor_delay = rscale(curcpu()->ci_divisor_delay, sc_step);
+	if (divisor_delay == 0) {
+		/*
+		 * Frequency values in curcpu() are not initialized.
+		 * Assume faster frequency since longer delays are harmless.
+		 * Note CPU_MIPS_DOUBLE_COUNT is ignored here.
+		 */
+#define FAST_FREQ	(300 * 1000 * 1000)	/* fast enough? */
+		divisor_delay = FAST_FREQ / (1000 * 1000);
+	}
+
+	while (n > usecs) {
+		cur = mips3_cp0_count_read();
+
+		/*
+		 * The MIPS3 CP0 counter always counts upto UINT32_MAX,
+		 * so no need to check wrapped around case.
+		 */
+		delta += (cur - last);
+
+		last = cur;
+
+		while (delta >= divisor_delay) {
+			/*
+			 * delta is not so larger than divisor_delay here,
+			 * and using DIV/DIVU ops could be much slower.
+			 * (though longer delay may be harmless)
+			 */
+			usecs++;
+			delta -= divisor_delay;
+		}
+	}
+}
+
+SYSCTL_SETUP(sysctl_ams_setup, "sysctl obio subtree setup")
+{
+
+	sysctl_createv(NULL, 0, NULL, NULL,
+		       CTLFLAG_PERMANENT,
+		       CTLTYPE_NODE, "machdep", NULL,
+		       NULL, 0, NULL, 0,
+		       CTL_MACHDEP, CTL_EOL);
+}
+
+/*
+ * We assume newhz is either stathz or profhz, and that neither will
+ * change after being set up above.  Could recalculate intervals here
+ * but that would be a drag.
+ */
+void
+loongson_setstatclockrate(int newhz)
+{
+
+	/* nothing we can do */
+}
+
+__weak_alias(setstatclockrate, loongson_setstatclockrate);
+__weak_alias(cpu_initclocks, loongson_initclocks);
+__weak_alias(delay, loongson_delay);
\ No newline at end of file
--- a/sys/arch/evbppc/virtex/dev/if_temac.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/evbppc/virtex/dev/if_temac.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* 	$NetBSD: if_temac.c,v 1.9.16.1 2016/03/19 11:29:59 skrll Exp $ */
+/* 	$NetBSD: if_temac.c,v 1.9.16.2 2016/07/09 20:24:51 skrll Exp $ */
 
 /*
  * Copyright (c) 2006 Jachym Holecek
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_temac.c,v 1.9.16.1 2016/03/19 11:29:59 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_temac.c,v 1.9.16.2 2016/07/09 20:24:51 skrll Exp $");
 
 
 #include <sys/param.h>
@@ -1190,7 +1190,7 @@
 		    BUS_DMASYNC_POSTREAD);
 
 		m = sc->sc_rxsoft[sc->sc_rxreap].rxs_mbuf;
-		m->m_pkthdr.rcvif = ifp;
+		m_set_rcvif(m, ifp);
 		m->m_pkthdr.len = m->m_len = rxsize;
 
  badframe:
--- a/sys/arch/ews4800mips/stand/common/cmd.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/ews4800mips/stand/common/cmd.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: cmd.c,v 1.2 2008/04/28 20:23:18 martin Exp $	*/
+/*	$NetBSD: cmd.c,v 1.2.64.1 2016/07/09 20:24:51 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -99,7 +99,7 @@
 		if (*p == ' ') {
 			*p = 0;
 			sep = 1;
-		} else if (sep && (*p != ' ' || *p == '\0')) {
+		} else if (sep) {
 			sep = 0;
 			argp[argc++] = p;
 		}
--- a/sys/arch/hp300/stand/common/netio.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/hp300/stand/common/netio.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: netio.c,v 1.14 2011/07/17 20:54:40 joerg Exp $	*/
+/*	$NetBSD: netio.c,v 1.14.30.1 2016/07/09 20:24:51 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -169,7 +169,7 @@
  get_my_ip:
 		printf("My IP address? ");
 		memset(input_line, 0, sizeof(input_line));
-		gets(input_line);
+		kgets(input_line, sizeof(input_line));
 		if ((myip.s_addr = inet_addr(input_line)) ==
 		    htonl(INADDR_NONE)) {
 			printf("invalid IP address: %s\n", input_line);
@@ -179,7 +179,7 @@
  get_my_netmask:
 		printf("My netmask? ");
 		memset(input_line, 0, sizeof(input_line)); 
-		gets(input_line);
+		kgets(input_line, sizeof(input_line));
 		if ((netmask = inet_addr(input_line)) ==
 		    htonl(INADDR_NONE)) {
 			printf("invalid netmask: %s\n", input_line);
@@ -189,7 +189,7 @@
  get_my_gateway:
 		printf("My gateway? ");
 		memset(input_line, 0, sizeof(input_line)); 
-		gets(input_line);
+		kgets(input_line, sizeof(input_line));
 		if ((gateip.s_addr = inet_addr(input_line)) ==
 		    htonl(INADDR_NONE)) {
 			printf("invalid IP address: %s\n", input_line);
@@ -199,7 +199,7 @@
  get_server_ip:
 		printf("Server IP address? ");
 		memset(input_line, 0, sizeof(input_line)); 
-		gets(input_line);
+		kgets(input_line, sizeof(input_line));
 		if ((rootip.s_addr = inet_addr(input_line)) ==
 		    htonl(INADDR_NONE)) {
 			printf("invalid IP address: %s\n", input_line);
@@ -209,7 +209,7 @@
  get_server_path:
 		printf("Server path? ");
 		memset(rootpath, 0, sizeof(rootpath)); 
-		gets(rootpath);
+		kgets(rootpath, sizeof(rootpath));
 		if (rootpath[0] == '\0' || rootpath[0] == '\n')
 			goto get_server_path;
 
--- a/sys/arch/hp300/stand/common/samachdep.h	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/hp300/stand/common/samachdep.h	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: samachdep.h,v 1.18 2014/08/10 07:40:49 isaki Exp $	*/
+/*	$NetBSD: samachdep.h,v 1.18.4.1 2016/07/09 20:24:51 skrll Exp $	*/
 
 /*
  * Copyright (c) 1982, 1990, 1993
@@ -98,7 +98,7 @@
 void _transfer(char *, int, int, int, char *, char *);
 
 /* tget.c */
-int tgets(char *);
+int tgets(char *, size_t);
 
 
 #define DELAY(n)							\
--- a/sys/arch/hp300/stand/common/tgets.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/hp300/stand/common/tgets.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: tgets.c,v 1.5 2005/12/11 12:17:19 christos Exp $	*/
+/*	$NetBSD: tgets.c,v 1.5.142.1 2016/07/09 20:24:51 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -38,13 +38,18 @@
 #include <hp300/stand/common/samachdep.h>
 
 int
-tgets(char *buf)
+tgets(char *buf, size_t size)
 {
 	int c;
 	int i;
 	char *lp = buf;
 
 	for (i = 240000; i > 0; i--) {
+                if (lp - buf == size) {
+                        lp--;
+                        *lp = '\0';
+                        return 0;
+                }
 		c = tgetchar() & 0177;
 		if (c) {
 			for (;;) {
--- a/sys/arch/hp300/stand/inst/inst.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/hp300/stand/inst/inst.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: inst.c,v 1.20 2014/08/10 07:40:49 isaki Exp $	*/
+/*	$NetBSD: inst.c,v 1.20.4.1 2016/07/09 20:24:51 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -131,7 +131,7 @@
 	for (;;) {
 		printf("sys_inst> ");
 		memset(line, 0, sizeof(line));
-		gets(line);
+		kgets(line, sizeof(line));
 		if (line[0] == '\n' || line[0] == '\0')
 			continue;
 
@@ -200,7 +200,7 @@
  disklabel_loop:
 	memset(line, 0, sizeof(line));
 	printf("(z)ap, (e)dit, (s)how, (w)rite, (d)one > ");
-	gets(line);
+	kgets(line, sizeof(line));
 	if (line[0] == '\n' || line[0] == '\0')
 		goto disklabel_loop;
 
@@ -259,28 +259,28 @@
 #define GETNUM(out, num)						\
 	printf((out), (num));						\
 	memset(line, 0, sizeof(line));					\
-	gets(line);							\
+	kgets(line, sizeof(line));							\
 	if (line[0])							\
 		(num) = atoi(line);
 
 #define GETNUM2(out, num1, num2)					\
 	printf((out), (num1), (num2));					\
 	memset(line, 0, sizeof(line));					\
-	gets(line);							\
+	kgets(line, sizeof(line));							\
 	if (line[0])							\
 		(num2) = atoi(line);
 
 #define GETSTR(out, str)						\
 	printf((out), (str));						\
 	memset(line, 0, sizeof(line));					\
-	gets(line);							\
+	kgets(line, sizeof(line));							\
 	if (line[0])							\
 		strcpy((str), line);
 
 #define FLAGS(out, flag)						\
 	printf((out), lp->d_flags & (flag) ? 'y' : 'n');		\
 	memset(line, 0, sizeof(line));					\
-	gets(line);							\
+	kgets(line, sizeof(line));							\
 	if (line[0] == 'y' || line[0] == 'Y')				\
 		lp->d_flags |= (flag);					\
 	else								\
@@ -514,7 +514,7 @@
 	printf("%s ", question);
 	memset(diskname, 0, len);
 	memset(fulldiskname, 0, sizeof(fulldiskname));
-	gets(diskname);
+	kgets(diskname, sizeof(diskname));
 	if (diskname[0] == '\n' || diskname[0] == '\0')
 		goto getdiskname;
 
@@ -570,7 +570,7 @@
  getsource:
 	printf("Source? (N)FS, (t)ape, (d)one > ");
 	memset(line, 0, sizeof(line));
-	gets(line);
+	kgets(line, sizeof(line));
 	if (line[0] == '\0')
 		goto getsource;
 
@@ -581,7 +581,7 @@
 		printf("Name of miniroot file? ");
 		memset(line, 0, sizeof(line));
 		memset(minirootname, 0, sizeof(minirootname));
-		gets(line);
+		kgets(line, sizeof(line));
 		if (line[0] == '\0')
 			goto name_of_nfs_miniroot;
 		(void)strcat(minirootname, "le0a:");
@@ -613,7 +613,7 @@
 		memset(line, 0, sizeof(line));
 		memset(minirootname, 0, sizeof(minirootname));
 		memset(tapename, 0, sizeof(tapename));
-		gets(line);
+		kgets(line, sizeof(line));
 		if (line[0] == '\0')
 			goto name_of_tape_miniroot;
 		strcat(minirootname, line);
@@ -621,7 +621,7 @@
 
 		printf("File number (first == 1)? ");
 		memset(line, 0, sizeof(line));
-		gets(line);
+		kgets(line, sizeof(line));
 		fileno = a2int(line);
 		if (fileno < 1 || fileno > 8) {
 			printf("Invalid file number: %s\n", line);
@@ -643,7 +643,7 @@
 		ignoreshread = 0;
 		printf("Copy how many %d byte blocks? ", DEV_BSIZE);
 		memset(line, 0, sizeof(line));
-		gets(line);
+		kgets(line, sizeof(line));
 		nblks = a2int(line);
 		if (nblks < 0) {
 			printf("Invalid block count: %s\n", line);
@@ -723,7 +723,7 @@
 	printf("Disk to boot from? ");
 	memset(diskname, 0, sizeof(diskname));
 	memset(bootname, 0, sizeof(bootname));
-	gets(diskname);
+	kgets(diskname, sizeof(diskname));
 	if (diskname[0] == '\n' || diskname[0] == '\0')
 		goto getdiskname;
 
--- a/sys/arch/hp300/stand/uboot/uboot.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/hp300/stand/uboot/uboot.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: uboot.c,v 1.15 2008/07/16 13:44:51 tsutsui Exp $	*/
+/*	$NetBSD: uboot.c,v 1.15.58.1 2016/07/09 20:24:51 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -109,7 +109,7 @@
 	printf("Boot: [[[%s%d%c:]%s][-a][-c][-d][-s][-v][-q]] :- ",
 	    devsw[bdev].dv_name, bctlr + (8 * badapt), 'a' + bpart, name);
 
-	if (tgets(line)) {
+	if (tgets(line, sizeof(line))) {
 		if (strcmp(line, "reset") == 0) {
 			call_req_reboot();      /* reset machine */
 			printf("panic: can't reboot, halting\n");
--- a/sys/arch/hpc/stand/hpcboot/arm/arm_console.cpp	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/hpc/stand/hpcboot/arm/arm_console.cpp	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* -*-C++-*-	$NetBSD: arm_console.cpp,v 1.7 2009/01/29 21:23:38 nonaka Exp $	*/
+/* -*-C++-*-	$NetBSD: arm_console.cpp,v 1.7.42.1 2016/07/09 20:24:51 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -77,7 +77,7 @@
 	if (!setupMultibyteBuffer())
 		return;
 
-	for (int i = 0; _bufm[i] != '\0' && i < CONSOLE_BUFSIZE; i++) {
+	for (int i = 0; i < CONSOLE_BUFSIZE && _bufm[i] != '\0'; i++) {
 		char s = _bufm[i];
 		if (s == '\n')
 			__putc('\r');
--- a/sys/arch/hpcmips/dev/plumpcmcia.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/hpcmips/dev/plumpcmcia.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: plumpcmcia.c,v 1.27 2014/03/26 17:53:36 christos Exp $ */
+/*	$NetBSD: plumpcmcia.c,v 1.27.6.1 2016/07/09 20:24:51 skrll Exp $ */
 
 /*
  * Copyright (c) 1999, 2000 UCHIYAMA Yasushi. All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: plumpcmcia.c,v 1.27 2014/03/26 17:53:36 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plumpcmcia.c,v 1.27.6.1 2016/07/09 20:24:51 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -844,6 +844,7 @@
 	bus_space_tag_t regt = ph->ph_regt;
 	bus_space_handle_t regh = ph->ph_regh;
 	plumreg_t reg;
+	void *ih __diagused;
 	
 	/* enable CARD DETECT ENABLE only */
 	plum_conf_write(regt, regh, PLUM_PCMCIA_CSCINT,
@@ -855,7 +856,7 @@
 	plum_conf_write(regt, regh, PLUM_PCMCIA_GLOBALCTRL, reg);
 	
 	/* install interrupt handler (don't fail) */
-	plum_intr_establish(sc->sc_pc, irq, IST_EDGE, IPL_TTY,
+	ih = plum_intr_establish(sc->sc_pc, irq, IST_EDGE, IPL_TTY,
 	    plum_csc_intr, ph);
 	KASSERT(ih != 0);
 }
--- a/sys/arch/hpcmips/stand/lcboot/main.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/hpcmips/stand/lcboot/main.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.6 2011/01/22 19:19:18 joerg Exp $ */
+/* $NetBSD: main.c,v 1.6.32.1 2016/07/09 20:24:52 skrll Exp $ */
 
 /*
  * Copyright (c) 2003 Naoto Shimazaki.
@@ -107,7 +107,7 @@
  *
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: main.c,v 1.6 2011/01/22 19:19:18 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: main.c,v 1.6.32.1 2016/07/09 20:24:52 skrll Exp $");
 
 #include <lib/libsa/stand.h>
 
@@ -833,7 +833,7 @@
 		/* input a line */
 		input[0] = '\0';
 		printf("> ");
-		gets(input);
+		kgets(input, sizeof(input));
 		cmd = input;
 
 		/* skip leading whitespace. */
--- a/sys/arch/hpcmips/tx/tx3912video.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/hpcmips/tx/tx3912video.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: tx3912video.c,v 1.43 2014/06/07 18:59:16 he Exp $ */
+/*	$NetBSD: tx3912video.c,v 1.43.4.1 2016/07/09 20:24:52 skrll Exp $ */
 
 /*-
  * Copyright (c) 1999-2002 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tx3912video.c,v 1.43 2014/06/07 18:59:16 he Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tx3912video.c,v 1.43.4.1 2016/07/09 20:24:52 skrll Exp $");
 
 #define TX3912VIDEO_DEBUG
 
@@ -39,11 +39,10 @@
 
 #include <sys/param.h>
 #include <sys/systm.h>
+#include <sys/buf.h>
 #include <sys/device.h>
 #include <sys/extent.h>
-
 #include <sys/ioctl.h>
-#include <sys/buf.h>
 
 #include <uvm/uvm_extern.h>
 
--- a/sys/arch/i386/conf/GENERIC	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/i386/conf/GENERIC	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.1118.2.8 2016/05/29 08:44:17 skrll Exp $
+# $NetBSD: GENERIC,v 1.1118.2.9 2016/07/09 20:24:52 skrll Exp $
 #
 # GENERIC machine description file
 #
@@ -22,7 +22,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.1118.2.8 $"
+#ident 		"GENERIC-$Revision: 1.1118.2.9 $"
 
 maxusers	64		# estimated number of users
 
@@ -369,6 +369,7 @@
 mpu*		at acpi?		# Roland MPU-401 MIDI UART
 pckbc*		at acpi?		# PC keyboard controller
 pcppi*		at acpi?		# AT-style speaker sound
+sdhc*		at acpi?		# SD Host Controller
 sony*		at acpi?		# Sony Miscellaneous Controller
 thinkpad*	at acpi?		# IBM/Lenovo Thinkpad hotkeys
 #tpm*		at acpi?		# ACPI TPM (Experimental)
--- a/sys/arch/i386/i386/cpu_in_cksum.S	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/i386/i386/cpu_in_cksum.S	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpu_in_cksum.S,v 1.4 2008/04/28 20:23:24 martin Exp $	*/
+/*	$NetBSD: cpu_in_cksum.S,v 1.4.64.1 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.4 2008/04/28 20:23:24 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_in_cksum.S,v 1.4.64.1 2016/07/09 20:24:52 skrll Exp $");
 
 #include "assym.h"
 
@@ -329,9 +329,21 @@
 	ret
 
 .Lout_of_mbufs:
-	pushl	$1f
+#ifdef __PIC__
+	PIC_PROLOGUE
+	leal	PIC_GOTOFF(.Mout_of_mbufs_msg), %eax
+	pushl	%eax
+	call	PIC_PLT(_C_LABEL(printf))
+	leal	4(%esp), %esp
+	PIC_EPILOGUE
+#else
+	pushl	.Mout_of_mbufs_msg
 	call	_C_LABEL(printf)
 	leal	4(%esp), %esp
+#endif
 	jmp	.Lreturn
-1:
+
+	.section        .rodata
+	.type           .Mout_of_mbufs_msg, @object
+.Mout_of_mbufs_msg:
 	.asciz	"cksum: out of data\n"
--- a/sys/arch/i386/i386/locore.S	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/i386/i386/locore.S	Sat Jul 09 20:24:48 2016 +0000
@@ -1,10 +1,39 @@
-/*	$NetBSD: locore.S,v 1.113.2.2 2016/05/29 08:44:17 skrll Exp $	*/
+/*	$NetBSD: locore.S,v 1.113.2.3 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*
  * Copyright-o-rama!
  */
 
 /*
+ * Copyright (c) 1998, 2000, 2004, 2006, 2007, 2009, 2016
+ * The NetBSD Foundation, Inc., All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum, by Andrew Doran and by Maxime Villard.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
  * Copyright (c) 2006 Manuel Bouyer.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -65,35 +94,6 @@
  */
 
 /*-
- * Copyright (c) 1998, 2000, 2004, 2006, 2007, 2009 The NetBSD Foundation, Inc.
- * All rights reserved.
- *
- * This code is derived from software contributed to The NetBSD Foundation
- * by Charles M. Hannum, and by Andrew Doran.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/*-
  * Copyright (c) 1990 The Regents of the University of California.
  * All rights reserved.
  *
@@ -128,7 +128,7 @@
  */
 
 #include <machine/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.113.2.2 2016/05/29 08:44:17 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locore.S,v 1.113.2.3 2016/07/09 20:24:52 skrll Exp $");
 
 #include "opt_compat_oldboot.h"
 #include "opt_copy_symtab.h"
@@ -147,13 +147,14 @@
 #include <sys/errno.h>
 #include <sys/syscall.h>
 
-#include <machine/cputypes.h>
 #include <machine/segments.h>
 #include <machine/specialreg.h>
 #include <machine/trap.h>
 #include <machine/i82489reg.h>
 #include <machine/frameasm.h>
 #include <machine/i82489reg.h>
+#include <machine/cputypes.h>
+
 #ifndef XEN
 #include <machine/multiboot.h>
 #endif
@@ -218,6 +219,20 @@
 2:					;
 
 /*
+ * fillkpt_blank - Fill in a kernel page table with blank entries
+ *	ebx = page table address
+ *	ecx = number of pages to map
+ */
+#define fillkpt_blank	\
+	cmpl	$0,%ecx			;	/* zero-sized? */	\
+	je 	2f			; \
+1:	movl	$0,(PDE_SIZE-4)(%ebx)	;	/* upper 32 bits: 0 */	\
+	movl	$0,(%ebx)		;	/* lower 32 bits: 0 */	\
+	addl	$PDE_SIZE,%ebx		;	/* next PTE/PDE */	\
+	loop	1b			; \
+2:					;
+
+/*
  * killkpt - Destroy a kernel page table
  *	ebx = page table address
  *	ecx = number of pages to destroy
@@ -255,16 +270,6 @@
  */
 	.data
 
-	.globl	_C_LABEL(nox_flag)
-	.globl	_C_LABEL(cputype)
-	.globl	_C_LABEL(cpuid_level)
-	.globl	_C_LABEL(esym)
-	.globl	_C_LABEL(eblob)
-	.globl	_C_LABEL(atdevbase)
-	.globl	_C_LABEL(lwp0uarea)
-	.globl	_C_LABEL(PDPpaddr)
-	.globl	_C_LABEL(gdt)
-	.globl	_C_LABEL(idt)
 	.globl	_C_LABEL(lapic_tpr)
 
 #if NLAPIC > 0
@@ -273,7 +278,9 @@
 #else
 	.align	12
 #endif
-	.globl _C_LABEL(local_apic), _C_LABEL(lapic_id)
+	.globl	_C_LABEL(local_apic)
+	.globl	_C_LABEL(lapic_id)
+
 	.type	_C_LABEL(local_apic), @object
 LABEL(local_apic)
 	.space	LAPIC_ID
@@ -302,6 +309,21 @@
 END(lapic_tpr)
 #endif
 
+	.globl	_C_LABEL(tablesize)
+	.globl	_C_LABEL(nox_flag)
+	.globl	_C_LABEL(cputype)
+	.globl	_C_LABEL(cpuid_level)
+	.globl	_C_LABEL(esym)
+	.globl	_C_LABEL(eblob)
+	.globl	_C_LABEL(atdevbase)
+	.globl	_C_LABEL(PDPpaddr)
+	.globl	_C_LABEL(lwp0uarea)
+	.globl	_C_LABEL(gdt)
+	.globl	_C_LABEL(idt)
+
+	.type	_C_LABEL(tablesize), @object
+_C_LABEL(tablesize):	.long	0
+END(tablesize)
 	.type	_C_LABEL(nox_flag), @object
 LABEL(nox_flag)		.long	0	/* 32bit NOX flag, set if supported */
 END(nox_flag)
@@ -309,7 +331,7 @@
 LABEL(cputype)		.long	0	/* are we 80486, Pentium, or.. */
 END(cputype)
 	.type	_C_LABEL(cpuid_level), @object
-LABEL(cpuid_level)	.long	0
+LABEL(cpuid_level)	.long	-1	/* max. level accepted by cpuid instr */
 END(cpuid_level)
 	.type	_C_LABEL(atdevbase), @object
 LABEL(atdevbase)	.long	0	/* location of start of iomem in virt */
@@ -320,9 +342,6 @@
 	.type	_C_LABEL(PDPpaddr), @object
 LABEL(PDPpaddr)		.long	0	/* paddr of PDP, for libkvm */
 END(PDPpaddr)
-	.type	_C_LABEL(tablesize), @object
-_C_LABEL(tablesize):	.long	0
-END(tablesize)
 
 	/* Space for the temporary stack */
 	.size	tmpstk, tmpstk - .
@@ -397,8 +416,6 @@
 	xorl	%eax,%eax
 	movw	%ax,%fs
 	movw	%ax,%gs
-	decl	%eax
-	movl	%eax,RELOC(cpuid_level)
 
 	/* Find out our CPU type. */
 
@@ -610,9 +627,9 @@
  * +------+--------+------+-----+--------+---------------------+-----------
  *                             (1)      (2)                   (3)
  *
- * -------+------------+
- * TABLES | ISA IO MEM |
- * -------+------------+
+ * -------+-------------+
+ * TABLES | ISA I/O MEM |
+ * -------+-------------+
  *       (4)
  *
  * PROC0 STK is obviously not linked as a page level. It just happens to be
@@ -693,15 +710,12 @@
 	leal	(PROC0_PTP1_OFF)(%esi),%ebx
 
 	/* Skip the first MB. */
-	movl	$(KERNTEXTOFF - KERNBASE),%eax
-	movl	%eax,%ecx
-	shrl	$(PGSHIFT-2),%ecx	/* ((n >> PGSHIFT) << 2) for # PDEs */
-#ifdef PAE
-	shll	$1,%ecx			/* PDEs are twice larger with PAE */
-#endif
-	addl	%ecx,%ebx
+	movl	$(KERNTEXTOFF - KERNBASE),%ecx
+	shrl	$PGSHIFT,%ecx
+	fillkpt_blank
 
 	/* Map the kernel text RX. */
+	movl	$(KERNTEXTOFF - KERNBASE),%eax	/* start of TEXT */
 	movl	$RELOC(__rodata_start),%ecx
 	subl	%eax,%ecx
 	shrl	$PGSHIFT,%ecx
@@ -724,13 +738,13 @@
 	orl	$(PG_V|PG_KW),%eax
 	fillkpt_nox
 
-	/* Map [SYMS]+[PRELOADED MODULES] RWX. */
+	/* Map [SYMS]+[PRELOADED MODULES] RW. */
 	movl	$RELOC(__kernel_end),%eax
 	movl	%esi,%ecx		/* start of BOOTSTRAP TABLES */
 	subl	%eax,%ecx
 	shrl	$PGSHIFT,%ecx
 	orl	$(PG_V|PG_KW),%eax
-	fillkpt
+	fillkpt_nox
 
 	/* Map the BOOTSTRAP TABLES RW. */
 	movl	%esi,%eax		/* start of BOOTSTRAP TABLES */
@@ -739,10 +753,12 @@
 	orl	$(PG_V|PG_KW),%eax
 	fillkpt_nox
 
-	/* We are on (4). Map ISA I/O mem (later atdevbase) RWX. */
-	movl	$(IOM_BEGIN|PG_V|PG_KW/*|PG_N*/),%eax
-	movl	$(IOM_SIZE>>PGSHIFT),%ecx
-	fillkpt
+	/* We are on (4). Map ISA I/O MEM RW. */
+	movl	$IOM_BEGIN,%eax
+	movl	$IOM_SIZE,%ecx	/* size of ISA I/O MEM */
+	shrl	$PGSHIFT,%ecx
+	orl	$(PG_V|PG_KW/*|PG_N*/),%eax
+	fillkpt_nox
 
 	/*
 	 * Build L2 for identity mapping. Linked to L1.
@@ -760,12 +776,12 @@
 	movl	RELOC(nkptp)+1*4,%ecx
 	fillkpt
 
-	/* Install a PDE recursively mapping page directory as a page table! */
+	/* Install recursive top level PDE */
 	leal	(PROC0_PDIR_OFF + PDIR_SLOT_PTE * PDE_SIZE)(%esi),%ebx
 	leal	(PROC0_PDIR_OFF)(%esi),%eax
 	orl	$(PG_V|PG_KW),%eax
 	movl	$PDP_SIZE,%ecx
-	fillkpt
+	fillkpt_nox
 
 #ifdef PAE
 	/*
@@ -1084,7 +1100,7 @@
 
 /*
  * struct lwp *cpu_switchto(struct lwp *oldlwp, struct lwp *newlwp,
- *			    bool returning)
+ *     bool returning)
  *
  *	1. if (oldlwp != NULL), save its context.
  *	2. then, restore context of newlwp.
@@ -1112,16 +1128,18 @@
 	movl	16(%esp),%esi		/* oldlwp */
 	movl	20(%esp),%edi		/* newlwp */
 	movl	24(%esp),%edx		/* returning */
-	testl	%esi,%esi
-	jz	1f
+
+	testl	%esi,%esi		/* oldlwp = NULL ? */
+	jz	skip_save
 
 	/* Save old context. */
 	movl	L_PCB(%esi),%eax
 	movl	%esp,PCB_ESP(%eax)
 	movl	%ebp,PCB_EBP(%eax)
+skip_save:
 
 	/* Switch to newlwp's stack. */
-1:	movl	L_PCB(%edi),%ebx
+	movl	L_PCB(%edi),%ebx
 	movl	PCB_EBP(%ebx),%ebp
 	movl	PCB_ESP(%ebx),%esp
 
@@ -1134,33 +1152,33 @@
 
 	/* Skip the rest if returning to a pinned LWP. */
 	testl	%edx,%edx
-	jnz	4f
+	jnz	switch_return
 
+	/* Switch ring0 stack */
 #ifdef XEN
 	pushl	%edi
 	call	_C_LABEL(i386_switch_context)
 	addl	$4,%esp
-#else /* !XEN */
-	/* Switch ring0 esp */
+#else
 	movl	PCB_ESP0(%ebx),%eax
 	movl	%eax,CPUVAR(ESP0)
-#endif /* !XEN */
+#endif
 
 	/* Don't bother with the rest if switching to a system process. */
 	testl	$LW_SYSTEM,L_FLAG(%edi)
-	jnz	4f
+	jnz	switch_return
 
 #ifndef XEN
 	/* Restore thread-private %fs/%gs descriptors. */
 	movl	CPUVAR(GDT),%ecx
-	movl	PCB_FSD(%ebx), %eax
-	movl	PCB_FSD+4(%ebx), %edx
-	movl	%eax, (GUFS_SEL*8)(%ecx)
-	movl	%edx, (GUFS_SEL*8+4)(%ecx)
-	movl	PCB_GSD(%ebx), %eax
-	movl	PCB_GSD+4(%ebx), %edx
-	movl	%eax, (GUGS_SEL*8)(%ecx)
-	movl	%edx, (GUGS_SEL*8+4)(%ecx)
+	movl	PCB_FSD(%ebx),%eax
+	movl	PCB_FSD+4(%ebx),%edx
+	movl	%eax,(GUFS_SEL*8)(%ecx)
+	movl	%edx,(GUFS_SEL*8+4)(%ecx)
+	movl	PCB_GSD(%ebx),%eax
+	movl	PCB_GSD+4(%ebx),%edx
+	movl	%eax,(GUGS_SEL*8)(%ecx)
+	movl	%edx,(GUGS_SEL*8+4)(%ecx)
 #endif /* !XEN */
 
 	/* Switch I/O bitmap */
@@ -1173,14 +1191,25 @@
 	/* Is this process using RAS (restartable atomic sequences)? */
 	movl	L_PROC(%edi),%eax
 	cmpl	$0,P_RASLIST(%eax)
-	jne	5f
+	je	no_RAS
+
+	/* Handle restartable atomic sequences (RAS). */
+	movl	L_MD_REGS(%edi),%ecx
+	pushl	TF_EIP(%ecx)
+	pushl	%eax
+	call	_C_LABEL(ras_lookup)
+	addl	$8,%esp
+	cmpl	$-1,%eax
+	je	no_RAS
+	movl	L_MD_REGS(%edi),%ecx
+	movl	%eax,TF_EIP(%ecx)
+no_RAS:
 
 	/*
 	 * Restore cr0 (including FPU state).  Raise the IPL to IPL_HIGH.
 	 * FPU IPIs can alter the LWP's saved cr0.  Dropping the priority
 	 * is deferred until mi_switch(), when cpu_switchto() returns.
 	 */
-2:
 #ifdef XEN
 	pushl	%edi
 	call	_C_LABEL(i386_tls_switch)
@@ -1195,34 +1224,24 @@
 	 * set CR0_TS so we'll trap rather than reuse bogus state.
 	 */
 	cmpl	CPUVAR(FPCURLWP),%edi
-	je	3f
+	je	skip_TS
 	orl	$CR0_TS,%ecx
+skip_TS:
 
 	/* Reloading CR0 is very expensive - avoid if possible. */
-3:	cmpl	%edx,%ecx
-	je	4f
+	cmpl	%edx,%ecx
+	je	switch_return
 	movl	%ecx,%cr0
 #endif /* !XEN */
 
+switch_return:
 	/* Return to the new LWP, returning 'oldlwp' in %eax. */
-4:	movl	%esi,%eax
+	movl	%esi,%eax
 	popl	%edi
 	popl	%esi
 	popl	%ebx
 	ret
 
-	/* Check for restartable atomic sequences (RAS). */
-5:	movl	L_MD_REGS(%edi),%ecx
-	pushl	TF_EIP(%ecx)
-	pushl	%eax
-	call	_C_LABEL(ras_lookup)
-	addl	$8,%esp
-	cmpl	$-1,%eax
-	je	2b
-	movl	L_MD_REGS(%edi),%ecx
-	movl	%eax,TF_EIP(%ecx)
-	jmp	2b
-
 .Lcopy_iobitmap:
 	/* Copy I/O bitmap. */
 	incl	_C_LABEL(pmap_iobmp_evcnt)+EV_COUNT
--- a/sys/arch/i386/i386/mainbus.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/i386/i386/mainbus.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.98.6.2 2015/09/22 12:05:44 skrll Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.98.6.3 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.98.6.2 2015/09/22 12:05:44 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.98.6.3 2016/07/09 20:24:52 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -345,6 +345,8 @@
 		    PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY |
 		    PCI_FLAGS_MWI_OKAY;
 		mba.mba_acpi.aa_ic = &x86_isa_chipset;
+		mba.mba_acpi.aa_dmat = &pci_bus_dma_tag;
+		mba.mba_acpi.aa_dmat64 = NULL;
 		sc->sc_acpi =
 		    config_found_ia(self, "acpibus", &mba.mba_acpi, 0);
 #if 0 /* XXXJRT not yet */
--- a/sys/arch/i386/i386/multiboot.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/i386/i386/multiboot.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: multiboot.c,v 1.22 2012/12/07 04:49:08 msaitoh Exp $	*/
+/*	$NetBSD: multiboot.c,v 1.22.14.1 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: multiboot.c,v 1.22 2012/12/07 04:49:08 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: multiboot.c,v 1.22.14.1 2016/07/09 20:24:52 skrll Exp $");
 
 #include "opt_multiboot.h"
 
@@ -593,7 +593,7 @@
 	/* Skip kernel file name. */
 	while (*cl != '\0' && *cl != ' ')
 		cl++;
-	while (*cl != '\0' && *cl == ' ')
+	while (*cl == ' ')
 		cl++;
 
 	/* Check if there are flags and set 'howto' accordingly. */
--- a/sys/arch/i386/stand/lib/biosdisk.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/i386/stand/lib/biosdisk.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.43.6.1 2015/04/06 15:17:58 skrll Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.43.6.2 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -701,24 +701,13 @@
 static void
 add_biosdisk_bootinfo(void)
 {
-	static bool done;
-
 	if (bootinfo == NULL) {
-		done = false;
 		return;
 	}
-	
-	if (done)
-		return;
-
 	BI_ADD(&bi_disk, BTINFO_BOOTDISK, sizeof(bi_disk));
 	BI_ADD(&bi_wedge, BTINFO_BOOTWEDGE, sizeof(bi_wedge));
-
-	done = true;
-
 	return;
 }
-
 #endif
 
 int
--- a/sys/arch/i386/stand/lib/bootinfo.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/i386/stand/lib/bootinfo.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo.c,v 1.5 2008/12/14 18:46:33 christos Exp $	*/
+/*	$NetBSD: bootinfo.c,v 1.5.42.1 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -40,6 +40,11 @@
 	what->len = size;
 	what->type = type;
 
-	if (bootinfo)
-		bootinfo->entry[bootinfo->nentries++] = vtophys(what);
+	if (bootinfo == NULL) {
+		return;
+	}
+	if (bootinfo->nentries >= BTINFO_MAX) {
+		panic("bootinfo too big");
+	}
+	bootinfo->entry[bootinfo->nentries++] = vtophys(what);
 }
--- a/sys/arch/i386/stand/lib/bootinfo.h	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/i386/stand/lib/bootinfo.h	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo.h,v 1.10 2013/11/18 03:52:45 jakllsch Exp $	*/
+/*	$NetBSD: bootinfo.h,v 1.10.6.1 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -35,6 +35,8 @@
 
 extern struct bootinfo *bootinfo;
 
+#define BTINFO_MAX	32
+
 #define BI_ALLOC(max) (bootinfo = alloc(sizeof(struct bootinfo) \
                                         + ((max) - 1) * sizeof(uint32_t))) \
                       ->nentries = 0
--- a/sys/arch/i386/stand/lib/bootmenu.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/i386/stand/lib/bootmenu.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootmenu.c,v 1.14 2014/08/10 07:40:49 isaki Exp $	*/
+/*	$NetBSD: bootmenu.c,v 1.14.4.1 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -178,7 +178,7 @@
 				printf("\nOption: [%d]:",
 				    bootcfg_info.def + 1);
 
-			gets(input);
+			kgets(input, sizeof(input));
 			choice = getchoicefrominput(input, bootcfg_info.def);
 		} else if (bootcfg_info.timeout == 0)
 			choice = bootcfg_info.def;
--- a/sys/arch/i386/stand/lib/exec.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/i386/stand/lib/exec.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.59 2014/04/06 19:18:00 jakllsch Exp $	 */
+/*	$NetBSD: exec.c,v 1.59.4.1 2016/07/09 20:24:52 skrll Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -356,7 +356,7 @@
 	       file ? file : "NULL", loadaddr);
 #endif
 
-	BI_ALLOC(32); /* ??? */
+	BI_ALLOC(BTINFO_MAX);
 
 	BI_ADD(&btinfo_console, BTINFO_CONSOLE, sizeof(struct btinfo_console));
 
@@ -411,7 +411,7 @@
 
 out:
 	BI_FREE();
-	bootinfo = 0;
+	bootinfo = NULL;
 	return -1;
 }
 
--- a/sys/arch/i386/stand/lib/menuutils.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/i386/stand/lib/menuutils.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: menuutils.c,v 1.4 2014/04/06 19:11:26 jakllsch Exp $	*/
+/*	$NetBSD: menuutils.c,v 1.4.4.1 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997
@@ -71,7 +71,7 @@
 
 		input[0] = '\0';
 		printf("> ");
-		gets(input);
+		kgets(input, sizeof(input));
 
 		/*
 		 * Skip leading whitespace.
--- a/sys/arch/ia64/ia64/mainbus.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/ia64/ia64/mainbus.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: mainbus.c,v 1.9 2011/05/17 17:34:50 dyoung Exp $	*/
+/*	$NetBSD: mainbus.c,v 1.9.32.1 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2006 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.9 2011/05/17 17:34:50 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mainbus.c,v 1.9.32.1 2016/07/09 20:24:52 skrll Exp $");
 
 #include "acpica.h"
 
@@ -124,6 +124,8 @@
 	    PCI_FLAGS_MRL_OKAY | PCI_FLAGS_MRM_OKAY |
 	    PCI_FLAGS_MWI_OKAY;
 	aaa.aa_ic = 0;
+	aaa.aa_dmat = NULL;	/* XXX */
+	aaa.aa_dmat64 = NULL;	/* XXX */
 	config_found_ia(self, "acpibus", &aaa, 0);
 #endif
 
--- a/sys/arch/ia64/include/mcontext.h	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/ia64/include/mcontext.h	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: mcontext.h,v 1.3 2012/12/26 19:43:10 martin Exp $	*/
+/*	$NetBSD: mcontext.h,v 1.3.14.1 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -91,9 +91,8 @@
 	struct _high_fp		mc_high_fp;
 } mcontext_t;
 
-#ifndef _UC_MACHINE_SP
 #define _UC_MACHINE_SP(uc)	((uc)->uc_mcontext.mc_special.sp)
-#endif
+#define	_UC_MACHINE_PC(uc)	((uc)->uc_mcontext.mc_special.rp)
 
 static __inline void *
 __lwp_getprivate_fast(void)
--- a/sys/arch/ia64/stand/common/boot.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/ia64/stand/common/boot.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.7 2014/04/08 21:51:06 martin Exp $	*/
+/*	$NetBSD: boot.c,v 1.7.4.1 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1998 Michael Smith <msmith@freebsd.org>
@@ -318,7 +318,7 @@
 	while ((*cp != 0) && isspace(*cp))
 	    cp++;
 	/* must have /<space> to be root */
-	if ((*cp == 0) || (*cp != '/') || !isspace(*(cp + 1)))
+	if ((*cp != '/') || !isspace(*(cp + 1)))
 	    continue;
 	/* skip whitespace up to fstype */
 	cp += 2;
--- a/sys/arch/landisk/stand/boot/boot2.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/landisk/stand/boot/boot2.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot2.c,v 1.4 2014/03/26 17:47:10 christos Exp $	*/
+/*	$NetBSD: boot2.c,v 1.4.6.1 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*
  * Copyright (c) 2003
@@ -410,7 +410,7 @@
 
 		input[0] = '\0';
 		printf("> ");
-		gets(input);
+		kgets(input, sizeof(input));
 
 		/*
 		 * Skip leading whitespace.
@@ -442,7 +442,7 @@
 		*options++ = '\0';
 
 	/* trim leading blanks */
-	while (*options && *options == ' ')
+	while (*options == ' ')
 		options++;
 
 	return (options);
--- a/sys/arch/landisk/stand/boot/monitor.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/landisk/stand/boot/monitor.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: monitor.c,v 1.3 2009/03/14 15:36:08 dsl Exp $	*/
+/*	$NetBSD: monitor.c,v 1.3.40.1 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 
 	for (;;) {
 		printf("db> ");
-		gets(line);
+		kgets(line, sizeof(line));
 
 		flag = 0;
 		argc = 0;
--- a/sys/arch/mac68k/dev/if_mc.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/mac68k/dev/if_mc.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_mc.c,v 1.40.6.1 2016/03/19 11:30:01 skrll Exp $	*/
+/*	$NetBSD: if_mc.c,v 1.40.6.2 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1997 David Huang <khym@azeotrope.org>
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.40.6.1 2016/03/19 11:30:01 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_mc.c,v 1.40.6.2 2016/07/09 20:24:52 skrll Exp $");
 
 #include "opt_ddb.h"
 #include "opt_inet.h"
@@ -604,7 +604,7 @@
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (m == 0)
 		return (0);
-	m->m_pkthdr.rcvif = &sc->sc_if;
+	m_set_rcvif(m, &sc->sc_if);
 	m->m_pkthdr.len = totlen;
 	len = MHLEN;
 	top = 0;
--- a/sys/arch/mac68k/nubus/if_netdock_nubus.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/mac68k/nubus/if_netdock_nubus.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_netdock_nubus.c,v 1.22.14.1 2016/03/19 11:30:01 skrll Exp $	*/
+/*	$NetBSD: if_netdock_nubus.c,v 1.22.14.2 2016/07/09 20:24:52 skrll Exp $	*/
 
 /*
  * Copyright (C) 2000,2002 Daishi Kato <daishi@axlight.com>
@@ -43,7 +43,7 @@
 /***********************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_netdock_nubus.c,v 1.22.14.1 2016/03/19 11:30:01 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_netdock_nubus.c,v 1.22.14.2 2016/07/09 20:24:52 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -784,7 +784,7 @@
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (m == NULL)
 		return (NULL);
-	m->m_pkthdr.rcvif = &sc->sc_if;
+	m_set_rcvif(m, &sc->sc_if);
 	m->m_pkthdr.len = datalen;
 	len = MHLEN;
 	top = NULL;
--- a/sys/arch/macppc/conf/GENERIC_601	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/macppc/conf/GENERIC_601	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC_601,v 1.7 2014/10/21 08:49:55 macallan Exp $
+# $NetBSD: GENERIC_601,v 1.7.2.1 2016/07/09 20:24:53 skrll Exp $
 #
 # GENERIC machine description file
 # 
@@ -28,7 +28,7 @@
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-ident 		"GENERIC-$Revision: 1.7 $"
+ident 		"GENERIC-$Revision: 1.7.2.1 $"
 
 maxusers	32
 
@@ -216,12 +216,16 @@
 
 # Display devices
 #
-# The 7200's onboard video is unsupported ( by OF no less ) so we need either a
+# The 7200's onboard video is unsupported by OF so we need either a
 # graphics card that works as OF console or a serial console.
 # The only cards known to work ( so far ) are PCI Voodoo3s flashed with the
 # official Macintosh firmware from 3Dfx. The others should work but are
 # untested with OF 1.0.5
 
+# this will take over the console if output-device is set to 'screen' or
+# 'platinum'. It will provide a NetBSD console, but still won't work with OF
+platinumfb0 	at mainbus?
+
 #gffb*		at pci?	function ?	# NVIDIA GeForce2 MX
 #machfb*		at pci? function ?	# ATI Mach 64, Rage, Rage Pro
 #r128fb*		at pci? function ?	# ATI Rage 128
--- a/sys/arch/macppc/conf/files.macppc	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/macppc/conf/files.macppc	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-#	$NetBSD: files.macppc,v 1.101 2014/10/11 07:03:09 uebayasi Exp $
+#	$NetBSD: files.macppc,v 1.101.2.1 2016/07/09 20:24:53 skrll Exp $
 #
 # macppc-specific configuration info
 
@@ -307,3 +307,7 @@
 attach valkyriefb at mainbus
 file arch/macppc/dev/valkyriefb.c			valkyriefb
 defflag opt_valkyriefb.h VALKYRIEFB_DEBUG
+
+device platinumfb: wsemuldisplaydev, rasops8, vcons, videomode
+attach platinumfb at mainbus
+file arch/macppc/dev/platinumfb.c			platinumfb
--- a/sys/arch/macppc/dev/am79c950.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/macppc/dev/am79c950.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: am79c950.c,v 1.33.6.1 2016/03/19 11:30:01 skrll Exp $	*/
+/*	$NetBSD: am79c950.c,v 1.33.6.2 2016/07/09 20:24:53 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1997 David Huang <khym@bga.com>
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: am79c950.c,v 1.33.6.1 2016/03/19 11:30:01 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: am79c950.c,v 1.33.6.2 2016/07/09 20:24:53 skrll Exp $");
 
 #include "opt_inet.h"
 
@@ -616,7 +616,7 @@
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (m == 0)
 		return (0);
-	m->m_pkthdr.rcvif = &sc->sc_if;
+	m_set_rcvif(m, &sc->sc_if);
 	m->m_pkthdr.len = totlen;
 	len = MHLEN;
 	top = 0;
--- a/sys/arch/macppc/dev/if_bm.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/macppc/dev/if_bm.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_bm.c,v 1.46.16.1 2016/03/19 11:30:02 skrll Exp $	*/
+/*	$NetBSD: if_bm.c,v 1.46.16.2 2016/07/09 20:24:53 skrll Exp $	*/
 
 /*-
  * Copyright (C) 1998, 1999, 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_bm.c,v 1.46.16.1 2016/03/19 11:30:02 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_bm.c,v 1.46.16.2 2016/07/09 20:24:53 skrll Exp $");
 
 #include "opt_inet.h"
 
@@ -645,7 +645,7 @@
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (m == 0)
 		return 0;
-	m->m_pkthdr.rcvif = &sc->sc_if;
+	m_set_rcvif(m, &sc->sc_if);
 	m->m_pkthdr.len = totlen;
 	len = MHLEN;
 	top = 0;
--- a/sys/arch/macppc/dev/if_gm.c	Wed Jun 29 06:38:12 2016 +0000
+++ b/sys/arch/macppc/dev/if_gm.c	Sat Jul 09 20:24:48 2016 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_gm.c,v 1.44.4.2 2016/03/19 11:30:02 skrll Exp $	*/
+/*	$NetBSD: if_gm.c,v 1.44.4.3 2016/07/09 20:24:53 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2000 Tsubai Masanari.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gm.c,v 1.44.4.2 2016/03/19 11:30:02 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gm.c,v 1.44.4.3 2016/07/09 20:24:53 skrll Exp $");
 
 #include "opt_inet.h"
 
@@ -412,7 +412,7 @@
 	MGETHDR(m, M_DONTWAIT, MT_DATA);
 	if (m == 0)
 		return 0;
-	m->m_pkthdr.rcvif = &sc->sc_if;
+	m_set_rcvif(m, &sc->sc_if);
 	m->m_pkthdr.len = totlen;
 	len = MHLEN;
 	top = 0;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/macppc/dev/platinumfb.c	Sat Jul 09 20:24:48 2016 +0000
@@ -0,0 +1,1038 @@
+/*
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* A console driver for Apple's Platinum onboard video controller,
+ * found in (all?) Catalyst logic boards including the Powermac 7200.
+ *
+ * Used valkyriefb.c from NetBSD, and platinumfb.c/platinumfb.h from
+ * Linux sources as templates.
+ *
+ * Platinum is broken regarding openfirmware video variables.  In OF,
+ * for a powermac 7200, doing "dev /platinum .properties" results in:
+ *
+ *	name                    platinum
+ *	device_type             display
+ *	model                   AAPL,343S1184
+ *	AAPL,connector          monitor
+ *	reg                     F8000000  00000800
+ *	                        F1000000  01000000
+ *	AAPL,interrupts         0000001E
+ *
+ * The first reg is the register set, and the second is for the
+ * framebuffer.  There is also a set of colormap registers hardcoded
+ * in platinumfbreg.h that (I think) aren't in openfirmware.
+ *
+ * powermac 7200 VRAM min and max limits are 1 and 4 Mb respectively.
+ * OF claims 16M so we don't use that value.  If other machines can
+ * can have more or less VRAM this code will need to be modified
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: platinumfb.c,v 1.2.2.2 2016/07/09 20:24:53 skrll Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/device.h>
+
+#include <uvm/uvm_param.h>
+
+#include <dev/ofw/openfirm.h>
+
+#include <machine/autoconf.h>
+#include <machine/pio.h>
+
+#include <dev/wscons/wsdisplayvar.h>
+#include <dev/wscons/wsconsio.h>
+#include <dev/wsfont/wsfont.h>
+#include <dev/rasops/rasops.h>
+#include <dev/wscons/wsdisplay_vconsvar.h>
+
+#include <dev/videomode/videomode.h>
+
+#include <arch/macppc/dev/platinumfbreg.h>
+
+#include <sys/sysctl.h>
+
+#include "opt_wsemul.h"
+
+/*
+ * here is a link of supported modes and resolutions:
+ *  https://support.apple.com/kb/SP343?locale=en_US
+ *
+ * default console and X bpp/depth for built-in X config file,
+ * select 8 or 16 or 32. 
+ *
+ */
+#define PLATINUM_CONSOLE_DEPTH 8
+#define PLATINUM_FB_DEPTH      16
+
+/*
+ * resolution, from one of platinumfb_setting vmode_name's.
+ */
+#define PLATINUM_FB_VMODE "1024x768x60"
+
+struct platinumfb_setting {
+	char vmode_name[24];
+	int32_t width;
+	int32_t height;
+    	uint8_t freq;
+	uint8_t macmode;
+
+	int32_t	pitch[3];
+	uint32_t regs[26];
+	uint8_t offset[3];
+	uint8_t mode[3];
+	uint8_t dacula_ctrl[3];
+	uint8_t clock_params[2][2];
+};
+
+struct platinumfb_softc {
+	device_t sc_dev;
+	int sc_node;
+
+        uint8_t *sc_reg;
+	uint32_t sc_reg_size;
+
+    	uint8_t *sc_cmap;
+	uint32_t sc_cmap_size;
+
+	uint8_t *sc_fb;
+	uint32_t sc_fb_size;
+
+ 	int sc_depth;
+	int sc_width, sc_height, sc_linebytes;
+	const struct videomode *sc_videomode;
+	uint8_t sc_modereg;
+
+        int sc_mode;
+
+	u_char sc_cmap_red[256];
+	u_char sc_cmap_green[256];
+	u_char sc_cmap_blue[256];
+
+	struct vcons_data vd;
+
+        uint8_t sc_cmode;
+        uint8_t sc_dac_type;
+        uint32_t sc_vram;
+        int sc_on;
+        struct platinumfb_setting *sc_pfs;
+};
+
+#define DIV2	0x20
+#define DIV4	0x40
+#define DIV8	0x60
+#define DIV16	0x80
+
+static struct platinumfb_setting platinum_5 = {
+    "640x480x60",
+    640, 480, 60, 5,
+    { 672, 1312, 2592 },
+    { 0xff0, 4, 0, 0, 0, 0, 0x320, 0,
+      0, 0x15e, 0xc8, 0x18, 0x18f, 0x2f, 0x35, 0x3e,
+      0x42, 0x182, 0x18e, 0x41a, 0x418, 2, 7, 0x44,
+      0x404, 0x408 }, { 0x34, 0x3c, 0x41 },
+    { 2, 0, 0xff }, { 0x11, 0x15, 0x19 },
+    {{ 26, 0 + DIV8 }, { 14, 2 + DIV4 }}
+};
+
+static struct platinumfb_setting platinum_12 = {
+    "800x600x75",
+    800, 600, 75, 12,
+    { 832, 1632, 3232 },
+    { 0xff0, 4, 0, 0, 0, 0, 0x320, 0,
+      0, 0x1ce, 0x108, 0x14, 0x20f, 0x27, 0x30, 0x39,
+      0x72, 0x202, 0x20e, 0x4e2, 0x4e0, 4, 9, 0x2e,
+      0x4de, 0x4df }, { 0x64, 0x6c, 0x71 },
+    { 2, 0, 0xff }, { 0x11, 0x15, 0x19 },
+    {{ 122, 7 + DIV4 }, { 62, 9 + DIV2 }}
+};
+
+static struct platinumfb_setting platinum_14 = {
+    "1024x768x60",
+    1024, 768, 60, 14,
+    { 1056, 2080, 4128 },
+    { 0xff0, 4, 0, 0, 0, 0, 0x320, 0,
+      0, 0x25a, 0x14f, 0x22, 0x29f, 0x43, 0x49, 0x5b,
+      0x8e, 0x28e, 0x29e, 0x64c, 0x64a, 0xa, 0xf, 0x44,
+      0x644, 0x646 }, { 0x80, 0x88, 0x8d },
+    { 2, 0, 0xff }, { 0x11, 0x15, 0x19 },
+    {{ 71, 6 + DIV2 }, { 118, 13 + DIV2 }}
+};
+
+static struct platinumfb_setting platinum_20 = {
+    "1280x1024x75",
+    1280, 1024, 75, 20,
+    { 1312, 2592, 2592 },
+    { 0xffc, 4, 0, 0, 0, 0, 0x428, 0,
+      0, 0xb3, 0xd3, 0x12, 0x1a5, 0x23, 0x28, 0x2d,
+      0x5e, 0x19e, 0x1a4, 0x854, 0x852, 4, 9, 0x50,
+      0x850, 0x851 }, { 0x58, 0x5d, 0x5d },
+    { 0, 0xff, 0xff }, { 0x51, 0x55, 0x55 },
+    {{ 45, 3 }, { 66, 7 }}
+};
+
+static struct platinumfb_setting *pfb_setting[] = {
+    &platinum_5,
+    &platinum_12,
+    &platinum_14,
+    &platinum_20
+};
+
+static struct vcons_screen platinumfb_console_screen;
+
+static int	platinumfb_match(device_t, cfdata_t, void *);
+static void	platinumfb_attach(device_t, device_t, void *);
+
+CFATTACH_DECL_NEW(platinumfb, sizeof(struct platinumfb_softc),
+    platinumfb_match, platinumfb_attach, NULL, NULL);
+
+static int	platinumfb_init(device_t);
+static int 	platinumfb_set_mode(struct platinumfb_softc *,
+				    const struct videomode *, int);
+static void     platinumfb_set_rasops(struct platinumfb_softc *,
+				      struct rasops_info *, int);
+static int	platinumfb_ioctl(void *, void *, u_long, void *, int,
+				 struct lwp *);
+static paddr_t	platinumfb_mmap(void *, void *, off_t, int);
+static void	platinumfb_init_screen(void *, struct vcons_screen *, int,
+				       long *);
+static int	platinumfb_putcmap(struct platinumfb_softc *,
+				   struct wsdisplay_cmap *);
+static int 	platinumfb_getcmap(struct platinumfb_softc *,
+				   struct wsdisplay_cmap *);
+static void	platinumfb_init_cmap(struct platinumfb_softc *);
+static void	platinumfb_restore_palette(struct platinumfb_softc *);
+static void	platinumfb_putpalreg(struct platinumfb_softc *,
+				     uint8_t, uint8_t, uint8_t, uint8_t);
+static uint32_t platinumfb_line_tweak(struct platinumfb_softc *);
+static paddr_t	platinumfb_page_align_up(struct platinumfb_softc *);
+static void 	platinumfb_set_clock(struct platinumfb_softc *);
+static void	platinumfb_dac_type(struct platinumfb_softc *);
+static void	platinumfb_memory_size(struct platinumfb_softc *);
+static void	platinumfb_set_hardware(struct platinumfb_softc *);
+
+static inline void platinumfb_write_reg(struct platinumfb_softc *,
+ 					int, uint32_t);
+ 					
+#ifdef notyet
+static inline uint32_t platinumfb_read_reg(struct platinumfb_softc *, int);
+#endif
+static inline void platinumfb_write_cmap_reg(struct platinumfb_softc *, 
+ 					     int, uint8_t);
+static inline uint8_t platinumfb_read_cmap_reg(struct platinumfb_softc *, int);
+static inline void platinumfb_store_d2(struct platinumfb_softc *, 
+				       uint8_t, uint8_t);
+
+struct wsscreen_descr platinumfb_defaultscreen = {
+	"default",
+	0, 0,
+	NULL,
+	8, 16,
+	WSSCREEN_WSCOLORS | WSSCREEN_HILIT,
+	NULL,
+};
+
+const struct wsscreen_descr *_platinumfb_scrlist[] = {
+	&platinumfb_defaultscreen,
+	/* XXX other formats, graphics screen? */
+};
+
+struct wsscreen_list platinumfb_screenlist = {
+	sizeof(_platinumfb_scrlist) / sizeof(struct wsscreen_descr *),
+	_platinumfb_scrlist
+};
+
+struct wsdisplay_accessops platinumfb_accessops = {
+	platinumfb_ioctl,
+	platinumfb_mmap,
+	NULL,
+	NULL,
+	NULL,
+	NULL,	/* load_font */
+	NULL,	/* polls */
+	NULL,	/* scroll */
+};
+
+static inline void
+platinumfb_write_reg(struct platinumfb_softc *sc, int reg, uint32_t val)
+{
+	out32(sc->sc_reg + PLATINUM_REG_OFFSET_ADDR(reg), val);
+}
+
+#ifdef notyet
+static inline uint32_t
+platinumfb_read_reg(struct platinumfb_softc *sc, int reg)
+{
+	return in32(sc->sc_reg + PLATINUM_REG_OFFSET_ADDR(reg));
+}
+#endif
+
+static inline void
+platinumfb_write_cmap_reg(struct platinumfb_softc *sc, 
+			  int reg_offset, uint8_t val)
+{
+	out8(sc->sc_cmap + reg_offset, val);
+}
+
+static inline uint8_t
+platinumfb_read_cmap_reg(struct platinumfb_softc *sc, int reg_offset)
+{
+	return in8(sc->sc_cmap + reg_offset);
+}
+
+static inline void
+platinumfb_store_d2(struct platinumfb_softc *sc, 
+			  uint8_t a, uint8_t d)
+{
+	platinumfb_write_cmap_reg(sc, PLATINUM_CMAP_ADDR_OFFSET, a + 32);
+	platinumfb_write_cmap_reg(sc, PLATINUM_CMAP_D2_OFFSET, d);
+}
+
+static void
+platinumfb_putpalreg(struct platinumfb_softc *sc,
+    uint8_t reg, uint8_t r, uint8_t g, uint8_t b)
+{
+	platinumfb_write_cmap_reg(sc, PLATINUM_CMAP_ADDR_OFFSET, reg);
+	platinumfb_write_cmap_reg(sc, PLATINUM_CMAP_LUT_OFFSET, r);
+	platinumfb_write_cmap_reg(sc, PLATINUM_CMAP_LUT_OFFSET, g);
+	platinumfb_write_cmap_reg(sc, PLATINUM_CMAP_LUT_OFFSET, b);
+}
+
+static uint32_t
+platinumfb_line_tweak(struct platinumfb_softc *sc)
+{
+	/* bytes per line adjustment depending on resolution and depth */
+	if (sc->sc_cmode > PLATINUM_CMODE_8 &&
+	    strcmp(sc->sc_pfs->vmode_name, "832x624x75") == 0)
+		return 0x10;
+	else
+		return 0x20;
+}
+
+static paddr_t
+platinumfb_page_align_up(struct platinumfb_softc *sc)
+{
+	/* round up framebuffer address to the next highest page */
+	paddr_t addr = (paddr_t)sc->sc_fb;
+	paddr_t ret = round_page(addr);
+
+	if (ret == addr)
+		ret = round_page(addr + 1);
+
+	return ret;
+}
+
+/* 2 versions of platinum clock, older one uses clock[1] and
+ *     freq = 14.3Mhz * c0 / (c1 & 0x1f) / (1 << (c1 >> 5))
+ * newer one uses clock[0] and
+ *     freq = 15Mhz * c0 / ((c1 & 0x1f) + 2) / (1 << (c1 >> 5))
+ */
+static void
+platinumfb_set_clock(struct platinumfb_softc *sc)
+{
+	uint8_t clk_idx = sc->sc_dac_type == PLATINUM_DAC_1 ? 1 : 0;
+	uint8_t d2;
+
+	platinumfb_store_d2(sc, 6, 0xc6);
+
+	platinumfb_write_cmap_reg(sc, PLATINUM_CMAP_ADDR_OFFSET, 3+32);
+	d2 = platinumfb_read_cmap_reg(sc, PLATINUM_CMAP_D2_OFFSET);
+
+	if (d2 == 2) {
+		platinumfb_store_d2(sc, 7, sc->sc_pfs->clock_params[clk_idx][0]);
+		platinumfb_store_d2(sc, 8, sc->sc_pfs->clock_params[clk_idx][1]);
+		platinumfb_store_d2(sc, 3, 3);
+	} else {
+		platinumfb_store_d2(sc, 4, sc->sc_pfs->clock_params[clk_idx][0]);
+		platinumfb_store_d2(sc, 5, sc->sc_pfs->clock_params[clk_idx][1]);
+		platinumfb_store_d2(sc, 3, 2);
+	}
+
+	delay(5000);
+	platinumfb_store_d2(sc, 9, 0xa6);
+}
+
+static void
+platinumfb_dac_type(struct platinumfb_softc *sc)
+{
+	uint8_t dtype = 0;
+
+	platinumfb_write_cmap_reg(sc, PLATINUM_CMAP_ADDR_OFFSET, 0x40);
+	dtype = platinumfb_read_cmap_reg(sc, PLATINUM_CMAP_D2_OFFSET);
+
+	switch (dtype) {
+		case PLATINUM_DAC_0:
+		case PLATINUM_DAC_1:
+	 	/* do nothing */
+	 	break;
+	default:
+		aprint_error_dev(sc->sc_dev, "unknown dac 0x%x, using 0x%x\n",
+				 dtype, PLATINUM_DAC_0);
+		dtype = PLATINUM_DAC_0;
+		break;
+	}
+
+	/* save type */
+	sc->sc_dac_type = dtype;
+}
+
+static void
+platinumfb_memory_size(struct platinumfb_softc *sc)
+{
+	int i;
+	off_t offset = PLATINUM_FB_BANK_SIZE;
+	paddr_t total_vram = PLATINUM_FB_MIN_SIZE;
+
+	uint8_t test_val[] = {0x34, 0x56, 0x78};
+	uint8_t bank[] = {0, 0, 0};
+	uint8_t num_elems = sizeof(test_val)/sizeof(test_val[0]);
+
+	volatile uint8_t *fbuffer = mapiodev((paddr_t)sc->sc_fb, sc->sc_fb_size, false);
+
+	if (fbuffer == NULL)
+		panic("platinumfb could not mapiodev");
+
+	/* turn on all banks of RAM */
+	platinumfb_write_reg(sc, 16, (paddr_t)sc->sc_fb);
+	platinumfb_write_reg(sc, 20, 0x1011);
+	platinumfb_write_reg(sc, 24, 0);
+
+	/*
+	 * write "unique" value to each bank of memory and read value
+	 * back. if match assumes VRAM bank exists.  On the powermac 7200,
+	 * bank0 is always there and soldered to motherboard, don't know
+	 * if that is the case for others
+	 */
+	for (i = 0 ; i < num_elems; i++) {
+		out8(fbuffer + offset, test_val[i]);
+		out8(fbuffer + offset + 0x8, 0x0);
+
+		__asm volatile ("eieio; dcbf 0,%0"::"r"(&fbuffer[offset]):"memory");
+
+		bank[i] = fbuffer[offset] == test_val[i];
+		total_vram += bank[i] * PLATINUM_FB_BANK_SIZE;
+		offset += PLATINUM_FB_BANK_SIZE;
+	}
+
+	/* save total vram or minimum */
+	if (total_vram >= PLATINUM_FB_MIN_SIZE && total_vram <= PLATINUM_FB_MAX_SIZE) {
+		sc->sc_vram = total_vram;
+	} else {
+		aprint_error_dev(sc->sc_dev,
+				 "invalid VRAM size 0x%lx, using min 0x%x\n",
+				 total_vram, PLATINUM_FB_MIN_SIZE);
+		sc->sc_vram = PLATINUM_FB_MIN_SIZE;
+	}
+
+	unmapiodev((paddr_t)fbuffer, sc->sc_fb_size);
+}
+
+static int
+platinumfb_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct confargs *ca = aux;
+
+	return (strcmp(ca->ca_name, "platinum") == 0);
+}
+
+static void
+platinumfb_attach(device_t parent, device_t self, void *aux)
+{
+	struct platinumfb_softc *sc = device_private(self);
+	struct confargs *ca = aux;
+	u_int *reg = ca->ca_reg;
+
+	sc->sc_dev = self;
+	sc->sc_node = ca->ca_node;
+
+	sc->sc_reg = (uint8_t *)reg[0];
+	sc->sc_reg_size = reg[1];
+
+	sc->sc_fb = (uint8_t *)reg[2];
+	sc->sc_fb_size = PLATINUM_FB_MAX_SIZE;
+
+	sc->sc_cmap = (uint8_t *)PLATINUM_CMAP_BASE_ADDR;
+	sc->sc_cmap_size = PLATINUM_CMAP_SIZE;
+
+	aprint_normal(" reg-addr 0x%08lx fb-addr 0x%08lx cmap-addr 0x%08lx\n",
+		      (paddr_t)sc->sc_reg, 
+		      (paddr_t)sc->sc_fb,
+		      (paddr_t)sc->sc_cmap);
+
+	config_finalize_register(sc->sc_dev, platinumfb_init);
+}
+
+static void
+platinumfb_init_cmap(struct platinumfb_softc *sc)
+{
+	int i;
+	uint8_t tmp;
+
+	switch (sc->sc_cmode) {
+	case PLATINUM_CMODE_8:
+	default:
+		/* R3G3B2 colormap */
+		for (i = 0; i < 256; i++) {
+			tmp = i & 0xe0;
+			/*
+			 * replicate bits so 0xe0 maps to a red value of 0xff
+			 * in order to make white look actually white
+			 */
+			tmp |= (tmp >> 3) | (tmp >> 6);
+			sc->sc_cmap_red[i] = tmp;
+
+			tmp = (i & 0x1c) << 3;
+			tmp |= (tmp >> 3) | (tmp >> 6);
+			sc->sc_cmap_green[i] = tmp;
+
+			tmp = (i & 0x03) << 6;
+			tmp |= tmp >> 2;
+			tmp |= tmp >> 4;
+			sc->sc_cmap_blue[i] = tmp;
+		}
+		break;
+
+	case PLATINUM_CMODE_16:
+		for (i = 0; i < 32; i++) {
+			tmp = 255 * i / 32;
+			sc->sc_cmap_red[i] = tmp;
+			sc->sc_cmap_green[i] = tmp;
+			sc->sc_cmap_blue[i] = tmp;
+		}
+		for (i = 32; i < 256; i++) {
+			sc->sc_cmap_red[i] =  0;
+			sc->sc_cmap_blue[i] = 0;
+			sc->sc_cmap_green[i] = 0;
+		}
+		break;
+
+	case PLATINUM_CMODE_32:
+		for (i = 0; i < 256; i++) {
+			sc->sc_cmap_red[i] = i;
+			sc->sc_cmap_green[i] = i;
+			sc->sc_cmap_blue[i] = i;
+		}
+		break;
+	}
+}
+
+static void
+platinumfb_restore_palette(struct platinumfb_softc *sc)
+{
+	int i;
+
+	for (i = 0; i < 256; i++) {
+		platinumfb_putpalreg(sc, i, sc->sc_cmap_red[i],
+ 			     sc->sc_cmap_green[i], sc->sc_cmap_blue[i]);
+	}
+}
+
+static int
+platinumfb_init(device_t self)
+{
+	struct platinumfb_softc *sc = device_private(self);
+	const struct videomode *mode = NULL;
+	struct rasops_info *ri;
+
+	struct wsemuldisplaydev_attach_args aa;
+	bool is_console = FALSE;
+	long defattr;
+
+	int i;
+
+	/*
+	 * become console if OF variable "output-device" is "screen" or
+	 * contains "platinum", since normal OF video variables are unavailable
+	 */
+	int options;
+	char output_device[128];
+	options = OF_finddevice("/options");
+	if (options == 0 || 
+	    options == -1 ||
+	    OF_getprop(options, "output-device", output_device,
+		 sizeof(output_device)) == 0 ) {
+		aprint_error_dev(sc->sc_dev,
+		    "could not get output-device prop, assuming not console\n");
+	} else {
+		if (strstr(output_device,"platinum") ||
+		    strcmp(output_device,"screen") == 0 ) {
+			is_console = TRUE;
+		}
+	}	
+
+	sc->sc_pfs = NULL;
+	sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
+	sc->sc_on = WSDISPLAYIO_VIDEO_ON;
+
+	/* determine vram memory and dac clock type */
+	platinumfb_memory_size(sc);
+	platinumfb_dac_type(sc);
+
+	aprint_normal_dev(sc->sc_dev,"is_console %d dac 0x%x vram 0x%x\n",
+			  is_console, sc->sc_dac_type, sc->sc_vram);
+
+	for (i=0; i < sizeof(pfb_setting)/sizeof(pfb_setting[0]); i++) {
+		if (strcmp(PLATINUM_FB_VMODE, pfb_setting[i]->vmode_name)==0) {
+			mode = pick_mode_by_ref(pfb_setting[i]->width, 
+						pfb_setting[i]->height,
+ 						pfb_setting[i]->freq);
+			break;
+		}
+	}
+
+	if (!mode) {
+		aprint_error_dev(sc->sc_dev,
+		    "pick_mode_by_ref failed, using default\n");
+		mode = pick_mode_by_ref(800, 600, 75);
+	}
+
+	if (platinumfb_set_mode(sc, mode, PLATINUM_CONSOLE_DEPTH) != 0) {
+		aprint_error_dev(sc->sc_dev, "platinumfb_set_mode failed\n");
+		return 0;
+	}
+
+	vcons_init(&sc->vd, sc, &platinumfb_defaultscreen,
+		   &platinumfb_accessops);
+	sc->vd.init_screen = platinumfb_init_screen;
+
+	ri = &platinumfb_console_screen.scr_ri;
+	vcons_init_screen(&sc->vd, &platinumfb_console_screen, 1, &defattr);
+
+	platinumfb_console_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
+
+	platinumfb_defaultscreen.textops = &ri->ri_ops;
+	platinumfb_defaultscreen.capabilities = ri->ri_caps;
+	platinumfb_defaultscreen.nrows = ri->ri_rows;
+	platinumfb_defaultscreen.ncols = ri->ri_cols;
+
+	if (is_console) {
+		wsdisplay_cnattach(&platinumfb_defaultscreen, ri, 0, 0,
+		    defattr);
+		vcons_replay_msgbuf(&platinumfb_console_screen);
+	}
+
+	aa.console = is_console;
+	aa.scrdata = &platinumfb_screenlist;
+	aa.accessops = &platinumfb_accessops;
+	aa.accesscookie = &sc->vd;
+
+	config_found(self, &aa, wsemuldisplaydevprint);
+
+	return 0;
+}
+
+static void
+platinumfb_set_hardware(struct platinumfb_softc *sc)
+{
+	int i;
+	bool one_bank = sc->sc_vram == PLATINUM_FB_BANK_SIZE;
+
+	/* now start programming the chip */
+	platinumfb_write_reg(sc, 24, 7);    /* turn off display */
+
+	for (i = 0; i < 26; ++i)
+		platinumfb_write_reg(sc, i+32, sc->sc_pfs->regs[i]);
+
+	platinumfb_write_reg(sc, 26+32, one_bank ? 
+			 sc->sc_pfs->offset[sc->sc_cmode] + 4 - sc->sc_cmode :
+			 sc->sc_pfs->offset[sc->sc_cmode]);
+
+	/*
+	 * reg 16 apparently needs an address 0x10 less the where frame
+	 * buffer/ri_bits start for console text to be aligned.  In
+	 * addition, X memory maps (mmap) the frame buffer starting on
+	 * page boundaries.  So to get both X and console text aligned we
+	 * start at the first page up from sc_fb[0]. Starting at sc_fb[0]
+	 * did work on my machine but not sure if this negative offset
+	 * would be problematic elsewhere.
+	 *
+	 * Not sure why linux used different fb offsets for each mode, as
+	 * any addresses seemed to work as long as relative difference was
+	 * 0x10.
+	 */
+	platinumfb_write_reg(sc, 16, platinumfb_page_align_up(sc) - 0x10);
+
+	platinumfb_write_reg(sc, 18, sc->sc_pfs->pitch[sc->sc_cmode]);
+
+	/* 
+	 * XXX register 19 setting looks wrong for 1 bank & 32 bpp.
+	 * 512x384 is only resolution that would use such a setting, but
+	 * that is not currently in videomodes.c
+	 */
+	if (sc->sc_cmode == PLATINUM_CMODE_32 &&
+	   (sc->sc_pfs->macmode == 1 || sc->sc_pfs->macmode == 2))
+		aprint_error_dev(sc->sc_dev,
+		    "platinumfb reg19 array out-of-bounds");
+
+	platinumfb_write_reg(sc, 19, one_bank ? 
+	    sc->sc_pfs->mode[sc->sc_cmode+1] : /* XXX fix this for 32 bpp */
+	    sc->sc_pfs->mode[sc->sc_cmode]);
+
+	platinumfb_write_reg(sc, 20, one_bank ? 0x11 : 0x1011);
+	platinumfb_write_reg(sc, 21, 0x100);
+	platinumfb_write_reg(sc, 22, 1);
+	platinumfb_write_reg(sc, 23, 1);
+	platinumfb_write_reg(sc, 26, 0xc00);
+	platinumfb_write_reg(sc, 27, 0x235);
+	/* platinumfb_write_reg(sc, 27, 0x2aa); */
+
+	platinumfb_store_d2(sc, 0,
+	    one_bank ? sc->sc_pfs->dacula_ctrl[sc->sc_cmode] & 0xf :
+	               sc->sc_pfs->dacula_ctrl[sc->sc_cmode]);
+	platinumfb_store_d2(sc, 1, 4);
+	platinumfb_store_d2(sc, 2, 0);
+
+	platinumfb_set_clock(sc);
+
+	platinumfb_write_reg(sc, 24, 0);  /* turn display on */
+}
+
+static int
+platinumfb_set_mode(struct platinumfb_softc *sc,
+    const struct videomode *mode, int depth)
+{
+	int i;
+
+	/* first find the parameter for the mode register */
+	i = 0;
+	while((i < __arraycount(pfb_setting)) &&
+	      (strcmp(mode->name, pfb_setting[i]->vmode_name) != 0))
+	    i++;
+
+	if (i >= __arraycount(pfb_setting)) {
+		aprint_error_dev(sc->sc_dev,
+		    "Can't find a mode register value for %s\n", 
+				 mode->name);
+		return EINVAL;
+	}
+
+	/* found a mode */
+	sc->sc_pfs = pfb_setting[i];
+
+	/* determine depth settings */
+	switch (depth) {
+	case 8:
+	default:
+		sc->sc_depth = 8;
+		sc->sc_cmode = PLATINUM_CMODE_8;
+		break;
+	case 15:
+	case 16:
+		/* 15 bpp but use 16 so X/wsfb works */
+		sc->sc_depth = 16;
+		sc->sc_cmode = PLATINUM_CMODE_16;
+		break;
+	case 24:
+	case 32:
+		/* 24 bpp but use 32 so X/wsfb works */
+		sc->sc_depth = 32;
+		sc->sc_cmode = PLATINUM_CMODE_32;
+		break;
+	}
+
+	sc->sc_modereg = sc->sc_pfs->macmode;
+	sc->sc_videomode = mode;
+	sc->sc_height = mode->vdisplay;
+	sc->sc_width = mode->hdisplay;
+	sc->sc_linebytes = sc->sc_width * (1 << sc->sc_cmode) + platinumfb_line_tweak(sc);
+
+	/* check if we have enough video memory */
+	if (sc->sc_height * sc->sc_linebytes > sc->sc_vram - PAGE_SIZE) {
+		aprint_error_dev(sc->sc_dev, "Not enough video RAM for %s\n",
+ 			     mode->name);
+		return EINVAL;
+	}
+
+	/* set up and write colormap */
+	platinumfb_init_cmap(sc);
+	platinumfb_restore_palette(sc);
+
+	/* set hardware registers */
+	platinumfb_set_hardware(sc);