From 8f31919cdb61a5d8449627f61377ea2548a57410 Mon Sep 17 00:00:00 2001 From: purplerain Date: Mon, 12 Jun 2023 03:32:40 +0000 Subject: [PATCH] sync code with last fixes and improvements from OpenBSD --- bin/ksh/c_test.c | 19 +- bin/ksh/ksh.1 | 26 +- bin/test/test.1 | 6 +- distrib/amd64/ramdiskA/Makefile | 5 +- distrib/i386/ramdisk/Makefile | 5 +- lib/libcrypto/Makefile | 3 +- lib/libcrypto/cms/cms_cd.c | 128 - lib/libcrypto/cms/cms_lib.c | 7 +- lib/libcrypto/cms/cms_smime.c | 53 +- lib/libcrypto/comp/c_zlib.c | 542 +-- lib/libcrypto/comp/comp.h | 8 +- lib/libcrypto/err/err_all.c | 5 +- lib/libcrypto/x509/x509_vfy.c | 16 +- lib/libssl/ssl_clnt.c | 62 +- lib/libssl/ssl_srvr.c | 74 +- lib/libssl/tls13_client.c | 16 +- lib/libssl/tls13_server.c | 16 +- regress/lib/libssl/tlsfuzzer/tlsfuzzer.py | 4 +- regress/usr.bin/pkg-config/Makefile | 47 +- regress/usr.bin/pkg-config/pcdir/lib-flags.pc | 4 + sbin/ifconfig/ifconfig.8 | 8 +- sbin/ifconfig/ifconfig.c | 7 +- sys/arch/arm64/arm64/cpu.c | 12 +- sys/arch/arm64/arm64/machdep.c | 19 +- sys/arch/arm64/arm64/pmap.c | 35 +- sys/arch/arm64/arm64/process_machdep.c | 8 +- sys/arch/arm64/arm64/trap.c | 9 +- sys/arch/arm64/arm64/vm_machdep.c | 10 +- sys/arch/arm64/conf/GENERIC | 3 +- sys/arch/arm64/conf/RAMDISK | 3 +- sys/arch/arm64/include/armreg.h | 7 +- sys/arch/arm64/include/cpu.h | 7 +- sys/arch/arm64/include/pmap.h | 9 +- sys/arch/arm64/include/ptrace.h | 7 +- sys/arch/hppa/Makefile | 50 - sys/arch/hppa/compile/GENERIC.MP/Makefile | 1 - sys/arch/hppa/compile/GENERIC/Makefile | 1 - sys/arch/hppa/compile/Makefile | 7 - sys/arch/hppa/compile/Makefile.inc | 19 - sys/arch/hppa/compile/RAMDISK/Makefile | 1 - sys/arch/hppa/conf/GENERIC | 361 -- sys/arch/hppa/conf/GENERIC.MP | 8 - sys/arch/hppa/conf/Makefile.hppa | 174 - sys/arch/hppa/conf/RAMDISK | 216 -- sys/arch/hppa/conf/files.hppa | 350 -- sys/arch/hppa/conf/ld.script | 85 - sys/arch/hppa/dev/Makefile | 7 - sys/arch/hppa/dev/apic.c | 360 -- sys/arch/hppa/dev/asp.c | 194 -- sys/arch/hppa/dev/astro.c | 763 ----- sys/arch/hppa/dev/clock.c | 212 -- sys/arch/hppa/dev/com_dino.c | 116 - sys/arch/hppa/dev/com_ssio.c | 83 - sys/arch/hppa/dev/cpu.c | 287 -- sys/arch/hppa/dev/cpudevs | 489 --- sys/arch/hppa/dev/cpudevs.h | 373 --- sys/arch/hppa/dev/cpudevs_data.h | 354 -- sys/arch/hppa/dev/devlist2h.awk | 119 - sys/arch/hppa/dev/dino.c | 1840 ----------- sys/arch/hppa/dev/elroy.c | 1351 -------- sys/arch/hppa/dev/elroyreg.h | 148 - sys/arch/hppa/dev/elroyvar.h | 57 - sys/arch/hppa/dev/gecko.c | 91 - sys/arch/hppa/dev/lasi.c | 238 -- sys/arch/hppa/dev/lcd.c | 156 - sys/arch/hppa/dev/lpt_ssio.c | 70 - sys/arch/hppa/dev/mongoose.c | 594 ---- sys/arch/hppa/dev/mongoosereg.h | 130 - sys/arch/hppa/dev/mongoosevar.h | 71 - sys/arch/hppa/dev/pdc.c | 447 --- sys/arch/hppa/dev/phantomas.c | 77 - sys/arch/hppa/dev/power.c | 191 -- sys/arch/hppa/dev/siop_sgc.c | 166 - sys/arch/hppa/dev/ssio.c | 364 --- sys/arch/hppa/dev/ssiovar.h | 29 - sys/arch/hppa/dev/sti_pci_machdep.c | 68 - sys/arch/hppa/dev/sti_sgc.c | 223 -- sys/arch/hppa/dev/uturn.c | 136 - sys/arch/hppa/dev/viper.h | 215 -- sys/arch/hppa/dev/wax.c | 119 - sys/arch/hppa/gsc/arcofi_gsc.c | 87 - sys/arch/hppa/gsc/com_gsc.c | 106 - sys/arch/hppa/gsc/fdc_gsc.c | 95 - sys/arch/hppa/gsc/gscbus.c | 159 - sys/arch/hppa/gsc/gscbusvar.h | 69 - sys/arch/hppa/gsc/gsckbc.c | 1021 ------ sys/arch/hppa/gsc/gsckbcreg.h | 64 - sys/arch/hppa/gsc/harmony.c | 1150 ------- sys/arch/hppa/gsc/harmonyreg.h | 152 - sys/arch/hppa/gsc/harmonyvar.h | 114 - sys/arch/hppa/gsc/hil_gsc.c | 93 - sys/arch/hppa/gsc/if_ie_gsc.c | 396 --- sys/arch/hppa/gsc/lpt_gsc.c | 187 -- sys/arch/hppa/gsc/mongoose_gsc.c | 95 - sys/arch/hppa/gsc/oosiop_gsc.c | 172 - sys/arch/hppa/gsc/osiop_gsc.c | 193 -- sys/arch/hppa/gsc/siop_gsc.c | 162 - sys/arch/hppa/hppa/autoconf.c | 522 --- sys/arch/hppa/hppa/conf.c | 278 -- sys/arch/hppa/hppa/db_disasm.c | 2359 -------------- sys/arch/hppa/hppa/db_interface.c | 349 -- sys/arch/hppa/hppa/disksubr.c | 265 -- sys/arch/hppa/hppa/fpemu.S | 330 -- sys/arch/hppa/hppa/fpu.c | 126 - sys/arch/hppa/hppa/genassym.cf | 175 - sys/arch/hppa/hppa/in_cksum.c | 123 - sys/arch/hppa/hppa/intr.c | 398 --- sys/arch/hppa/hppa/ipi.c | 137 - sys/arch/hppa/hppa/lock_machdep.c | 231 -- sys/arch/hppa/hppa/locore.S | 2897 ----------------- sys/arch/hppa/hppa/locore0.S | 270 -- sys/arch/hppa/hppa/machdep.c | 1491 --------- sys/arch/hppa/hppa/mainbus.c | 1298 -------- sys/arch/hppa/hppa/mem.c | 431 --- sys/arch/hppa/hppa/mutex.c | 154 - sys/arch/hppa/hppa/pmap.c | 1310 -------- sys/arch/hppa/hppa/process_machdep.c | 177 - sys/arch/hppa/hppa/sys_machdep.c | 58 - sys/arch/hppa/hppa/trap.c | 965 ------ sys/arch/hppa/hppa/vm_machdep.c | 201 -- sys/arch/hppa/hppa/wscons_machdep.c | 90 - sys/arch/hppa/include/_float.h | 71 - sys/arch/hppa/include/_types.h | 146 - sys/arch/hppa/include/asm.h | 271 -- sys/arch/hppa/include/atomic.h | 266 -- sys/arch/hppa/include/autoconf.h | 83 - sys/arch/hppa/include/bus.h | 427 --- sys/arch/hppa/include/cdefs.h | 43 - sys/arch/hppa/include/conf.h | 38 - sys/arch/hppa/include/cpu.h | 311 -- sys/arch/hppa/include/cpufunc.h | 219 -- sys/arch/hppa/include/db_machdep.h | 93 - sys/arch/hppa/include/disklabel.h | 131 - sys/arch/hppa/include/eisa_machdep.h | 71 - sys/arch/hppa/include/endian.h | 39 - sys/arch/hppa/include/exec.h | 107 - sys/arch/hppa/include/fenv.h | 94 - sys/arch/hppa/include/fpu.h | 36 - sys/arch/hppa/include/frame.h | 145 - sys/arch/hppa/include/hil_machdep.h | 53 - sys/arch/hppa/include/ieee.h | 124 - sys/arch/hppa/include/ieeefp.h | 24 - sys/arch/hppa/include/intr.h | 180 - sys/arch/hppa/include/iomod.h | 414 --- sys/arch/hppa/include/isa_machdep.h | 59 - sys/arch/hppa/include/kcore.h | 37 - sys/arch/hppa/include/limits.h | 54 - sys/arch/hppa/include/loadfile_machdep.h | 80 - sys/arch/hppa/include/mplock.h | 74 - sys/arch/hppa/include/mutex.h | 93 - sys/arch/hppa/include/param.h | 70 - sys/arch/hppa/include/pcb.h | 43 - sys/arch/hppa/include/pci_machdep.h | 102 - sys/arch/hppa/include/pdc.h | 782 ----- sys/arch/hppa/include/pmap.h | 167 - sys/arch/hppa/include/proc.h | 47 - sys/arch/hppa/include/profile.h | 45 - sys/arch/hppa/include/psl.h | 105 - sys/arch/hppa/include/pte.h | 72 - sys/arch/hppa/include/ptrace.h | 27 - sys/arch/hppa/include/rbus_machdep.h | 43 - sys/arch/hppa/include/reg.h | 205 -- sys/arch/hppa/include/reloc.h | 123 - sys/arch/hppa/include/setjmp.h | 7 - sys/arch/hppa/include/signal.h | 62 - sys/arch/hppa/include/som.h | 148 - sys/arch/hppa/include/spinlock.h | 10 - sys/arch/hppa/include/tcb.h | 46 - sys/arch/hppa/include/timetc.h | 23 - sys/arch/hppa/include/trap.h | 110 - sys/arch/hppa/include/vmparam.h | 90 - sys/arch/hppa/spmath/cnv_float.h | 312 -- sys/arch/hppa/spmath/dbl_float.h | 540 --- sys/arch/hppa/spmath/dfadd.c | 502 --- sys/arch/hppa/spmath/dfcmp.c | 154 - sys/arch/hppa/spmath/dfdiv.c | 381 --- sys/arch/hppa/spmath/dfmpy.c | 371 --- sys/arch/hppa/spmath/dfrem.c | 271 -- sys/arch/hppa/spmath/dfsqrt.c | 167 - sys/arch/hppa/spmath/dfsub.c | 500 --- sys/arch/hppa/spmath/divsfm.c | 81 - sys/arch/hppa/spmath/divsfr.c | 76 - sys/arch/hppa/spmath/divsim.c | 83 - sys/arch/hppa/spmath/divsir.c | 75 - sys/arch/hppa/spmath/divu.S | 150 - sys/arch/hppa/spmath/divufr.c | 39 - sys/arch/hppa/spmath/divuir.c | 33 - sys/arch/hppa/spmath/fcnvff.c | 285 -- sys/arch/hppa/spmath/fcnvfx.c | 481 --- sys/arch/hppa/spmath/fcnvfxt.c | 291 -- sys/arch/hppa/spmath/fcnvxf.c | 347 -- sys/arch/hppa/spmath/float.h | 474 --- sys/arch/hppa/spmath/fpbits.h | 55 - sys/arch/hppa/spmath/frnd.c | 236 -- sys/arch/hppa/spmath/hppa.h | 32 - sys/arch/hppa/spmath/impys.S | 291 -- sys/arch/hppa/spmath/impyu.S | 289 -- sys/arch/hppa/spmath/md.h | 81 - sys/arch/hppa/spmath/mpyaccs.c | 40 - sys/arch/hppa/spmath/mpyaccu.c | 39 - sys/arch/hppa/spmath/mpys.c | 32 - sys/arch/hppa/spmath/mpyscv.c | 26 - sys/arch/hppa/spmath/mpyu.c | 32 - sys/arch/hppa/spmath/mpyucv.c | 26 - sys/arch/hppa/spmath/quad_float.h | 77 - sys/arch/hppa/spmath/sfadd.c | 493 --- sys/arch/hppa/spmath/sfcmp.c | 128 - sys/arch/hppa/spmath/sfdiv.c | 368 --- sys/arch/hppa/spmath/sfmpy.c | 351 -- sys/arch/hppa/spmath/sfrem.c | 263 -- sys/arch/hppa/spmath/sfsqrt.c | 158 - sys/arch/hppa/spmath/sfsub.c | 496 --- sys/arch/hppa/spmath/sgl_float.h | 319 -- sys/arch/hppa/stand/Makefile | 11 - sys/arch/hppa/stand/Makefile.inc | 41 - sys/arch/hppa/stand/boot/Makefile | 65 - sys/arch/hppa/stand/boot/boot.8 | 316 -- sys/arch/hppa/stand/boot/conf.c | 63 - sys/arch/hppa/stand/boot/exec.c | 52 - sys/arch/hppa/stand/boot/ld.script | 50 - sys/arch/hppa/stand/boot/srt0.S | 163 - sys/arch/hppa/stand/cdboot/Makefile | 66 - sys/arch/hppa/stand/cdboot/cdboot.c | 99 - sys/arch/hppa/stand/cdboot/elf64.c | 36 - sys/arch/hppa/stand/cdboot/ld.script | 50 - sys/arch/hppa/stand/libsa/Makefile | 44 - sys/arch/hppa/stand/libsa/cmd_hppa.c | 1017 ------ sys/arch/hppa/stand/libsa/ct.c | 79 - sys/arch/hppa/stand/libsa/dev_hppa.c | 197 -- sys/arch/hppa/stand/libsa/dev_hppa.h | 43 - sys/arch/hppa/stand/libsa/dk.c | 101 - sys/arch/hppa/stand/libsa/elf32.c | 32 - sys/arch/hppa/stand/libsa/elf64.c | 32 - sys/arch/hppa/stand/libsa/itecons.c | 219 -- sys/arch/hppa/stand/libsa/lf.c | 53 - sys/arch/hppa/stand/libsa/libsa.h | 79 - sys/arch/hppa/stand/libsa/lif.c | 270 -- sys/arch/hppa/stand/libsa/machdep.c | 84 - sys/arch/hppa/stand/libsa/pdc.c | 461 --- sys/arch/hppa/stand/libsa/time.c | 56 - sys/arch/hppa/stand/libz/Makefile | 10 - sys/arch/hppa/stand/mkboot/Makefile | 14 - sys/arch/hppa/stand/mkboot/mkboot.8 | 55 - sys/arch/hppa/stand/mkboot/mkboot.c | 370 --- sys/dev/fdt/files.fdt | 7 +- sys/dev/fdt/qcpas.c | 1286 ++++++++ sys/dev/pci/drm/amd/amdgpu/amdgpu_devlist.h | 10 +- sys/dev/pci/pcidevs | 4 +- sys/dev/pci/pcidevs.h | 4 +- sys/dev/pci/pcidevs_data.h | 10 +- sys/kern/exec_elf.c | 23 +- sys/kern/sys_process.c | 15 +- sys/sys/exec_elf.h | 3 +- sys/ufs/ext2fs/ext2fs_vfsops.c | 4 +- sys/ufs/ffs/ffs_balloc.c | 2 +- sys/ufs/ffs/ffs_inode.c | 6 +- sys/ufs/ffs/ffs_softdep.c | 110 +- sys/ufs/ffs/ffs_softdep_stub.c | 14 +- sys/ufs/ffs/ffs_vfsops.c | 10 +- sys/ufs/ffs/ffs_vnops.c | 2 +- sys/ufs/ffs/fs.h | 6 +- sys/ufs/ffs/softdep.h | 14 +- usr.bin/file/magdir/OpenBSD | 22 +- usr.bin/file/magdir/SecBSD | 22 +- usr.bin/openssl/apps.c | 71 +- usr.bin/openssl/apps.h | 8 +- usr.bin/openssl/enc.c | 76 +- usr.bin/openssl/openssl.1 | 139 +- usr.bin/openssl/openssl.c | 11 +- usr.bin/pkg-config/OpenBSD/PkgConfig.pm | 108 +- usr.bin/pkg-config/pkg-config | 233 +- usr.bin/printf/printf.c | 24 +- usr.bin/tmux/popup.c | 4 +- usr.bin/tmux/tmux.h | 16 +- usr.sbin/fw_update/fw_update.sh | 2 +- usr.sbin/fw_update/patterns.c | 2 +- usr.sbin/hostapd/parse.y | 2 +- usr.sbin/httpd/patterns.c | 2 +- usr.sbin/installboot/i386_installboot.c | 35 +- usr.sbin/pkg_add/OpenBSD/Delete.pm | 2 +- usr.sbin/pkg_add/OpenBSD/Getopt.pod | 2 +- usr.sbin/pkg_add/OpenBSD/PackingElement.pm | 2 +- usr.sbin/pkg_add/OpenBSD/SharedLibs.pm | 2 +- usr.sbin/pkg_add/OpenBSD/Ustar.pm | 2 +- usr.sbin/relayd/ca.c | 4 +- usr.sbin/sensorsd/sensorsd.c | 2 +- usr.sbin/smtpd/ssl.c | 4 +- usr.sbin/tcpdump/addrtoname.c | 4 +- usr.sbin/tcpdump/bootp.h | 1 - usr.sbin/tcpdump/decnet.h | 2 +- usr.sbin/tcpdump/ethertype.h | 2 +- usr.sbin/tcpdump/gtp.h | 2 +- usr.sbin/tcpdump/ike.h | 6 +- usr.sbin/tcpdump/install-sh | 14 +- usr.sbin/tcpdump/ipx.h | 2 +- usr.sbin/tcpdump/l2tp.h | 12 +- usr.sbin/tcpdump/makemib | 6 +- usr.sbin/tcpdump/nameser.h | 6 +- usr.sbin/tcpdump/pf_print_state.c | 4 +- usr.sbin/tcpdump/pfctl_osfp.c | 4 +- usr.sbin/tcpdump/print-802_11.c | 20 +- usr.sbin/tcpdump/print-bgp.c | 24 +- usr.sbin/tcpdump/print-cdp.c | 2 +- usr.sbin/tcpdump/print-ether.c | 2 +- usr.sbin/tcpdump/print-gtp.c | 12 +- usr.sbin/tcpdump/print-icmp.c | 2 +- usr.sbin/tcpdump/print-icmp6.c | 2 +- usr.sbin/tcpdump/print-ike.c | 6 +- usr.sbin/tcpdump/print-ip.c | 10 +- usr.sbin/tcpdump/print-ip6.c | 2 +- usr.sbin/tcpdump/print-ip6opts.c | 4 +- usr.sbin/tcpdump/print-ipsec.c | 22 +- usr.sbin/tcpdump/print-isoclns.c | 2 +- usr.sbin/tcpdump/print-l2tp.c | 18 +- usr.sbin/tcpdump/print-mobile.c | 12 +- usr.sbin/tcpdump/print-nfs.c | 4 +- usr.sbin/tcpdump/print-ospf6.c | 2 +- usr.sbin/tcpdump/print-ppp.c | 22 +- usr.sbin/tcpdump/print-radius.c | 38 +- usr.sbin/tcpdump/print-snmp.c | 6 +- usr.sbin/tcpdump/print-tcp.c | 2 +- usr.sbin/tcpdump/print-timed.c | 2 +- usr.sbin/tcpdump/print-udp.c | 2 +- usr.sbin/tcpdump/radius.h | 4 +- usr.sbin/tcpdump/smbutil.c | 2 +- 325 files changed, 2094 insertions(+), 51856 deletions(-) delete mode 100644 lib/libcrypto/cms/cms_cd.c create mode 100644 regress/usr.bin/pkg-config/pcdir/lib-flags.pc delete mode 100644 sys/arch/hppa/Makefile delete mode 100644 sys/arch/hppa/compile/GENERIC.MP/Makefile delete mode 100644 sys/arch/hppa/compile/GENERIC/Makefile delete mode 100644 sys/arch/hppa/compile/Makefile delete mode 100644 sys/arch/hppa/compile/Makefile.inc delete mode 100644 sys/arch/hppa/compile/RAMDISK/Makefile delete mode 100644 sys/arch/hppa/conf/GENERIC delete mode 100644 sys/arch/hppa/conf/GENERIC.MP delete mode 100644 sys/arch/hppa/conf/Makefile.hppa delete mode 100644 sys/arch/hppa/conf/RAMDISK delete mode 100644 sys/arch/hppa/conf/files.hppa delete mode 100644 sys/arch/hppa/conf/ld.script delete mode 100644 sys/arch/hppa/dev/Makefile delete mode 100644 sys/arch/hppa/dev/apic.c delete mode 100644 sys/arch/hppa/dev/asp.c delete mode 100644 sys/arch/hppa/dev/astro.c delete mode 100644 sys/arch/hppa/dev/clock.c delete mode 100644 sys/arch/hppa/dev/com_dino.c delete mode 100644 sys/arch/hppa/dev/com_ssio.c delete mode 100644 sys/arch/hppa/dev/cpu.c delete mode 100644 sys/arch/hppa/dev/cpudevs delete mode 100644 sys/arch/hppa/dev/cpudevs.h delete mode 100644 sys/arch/hppa/dev/cpudevs_data.h delete mode 100644 sys/arch/hppa/dev/devlist2h.awk delete mode 100644 sys/arch/hppa/dev/dino.c delete mode 100644 sys/arch/hppa/dev/elroy.c delete mode 100644 sys/arch/hppa/dev/elroyreg.h delete mode 100644 sys/arch/hppa/dev/elroyvar.h delete mode 100644 sys/arch/hppa/dev/gecko.c delete mode 100644 sys/arch/hppa/dev/lasi.c delete mode 100644 sys/arch/hppa/dev/lcd.c delete mode 100644 sys/arch/hppa/dev/lpt_ssio.c delete mode 100644 sys/arch/hppa/dev/mongoose.c delete mode 100644 sys/arch/hppa/dev/mongoosereg.h delete mode 100644 sys/arch/hppa/dev/mongoosevar.h delete mode 100644 sys/arch/hppa/dev/pdc.c delete mode 100644 sys/arch/hppa/dev/phantomas.c delete mode 100644 sys/arch/hppa/dev/power.c delete mode 100644 sys/arch/hppa/dev/siop_sgc.c delete mode 100644 sys/arch/hppa/dev/ssio.c delete mode 100644 sys/arch/hppa/dev/ssiovar.h delete mode 100644 sys/arch/hppa/dev/sti_pci_machdep.c delete mode 100644 sys/arch/hppa/dev/sti_sgc.c delete mode 100644 sys/arch/hppa/dev/uturn.c delete mode 100644 sys/arch/hppa/dev/viper.h delete mode 100644 sys/arch/hppa/dev/wax.c delete mode 100644 sys/arch/hppa/gsc/arcofi_gsc.c delete mode 100644 sys/arch/hppa/gsc/com_gsc.c delete mode 100644 sys/arch/hppa/gsc/fdc_gsc.c delete mode 100644 sys/arch/hppa/gsc/gscbus.c delete mode 100644 sys/arch/hppa/gsc/gscbusvar.h delete mode 100644 sys/arch/hppa/gsc/gsckbc.c delete mode 100644 sys/arch/hppa/gsc/gsckbcreg.h delete mode 100644 sys/arch/hppa/gsc/harmony.c delete mode 100644 sys/arch/hppa/gsc/harmonyreg.h delete mode 100644 sys/arch/hppa/gsc/harmonyvar.h delete mode 100644 sys/arch/hppa/gsc/hil_gsc.c delete mode 100644 sys/arch/hppa/gsc/if_ie_gsc.c delete mode 100644 sys/arch/hppa/gsc/lpt_gsc.c delete mode 100644 sys/arch/hppa/gsc/mongoose_gsc.c delete mode 100644 sys/arch/hppa/gsc/oosiop_gsc.c delete mode 100644 sys/arch/hppa/gsc/osiop_gsc.c delete mode 100644 sys/arch/hppa/gsc/siop_gsc.c delete mode 100644 sys/arch/hppa/hppa/autoconf.c delete mode 100644 sys/arch/hppa/hppa/conf.c delete mode 100644 sys/arch/hppa/hppa/db_disasm.c delete mode 100644 sys/arch/hppa/hppa/db_interface.c delete mode 100644 sys/arch/hppa/hppa/disksubr.c delete mode 100644 sys/arch/hppa/hppa/fpemu.S delete mode 100644 sys/arch/hppa/hppa/fpu.c delete mode 100644 sys/arch/hppa/hppa/genassym.cf delete mode 100644 sys/arch/hppa/hppa/in_cksum.c delete mode 100644 sys/arch/hppa/hppa/intr.c delete mode 100644 sys/arch/hppa/hppa/ipi.c delete mode 100644 sys/arch/hppa/hppa/lock_machdep.c delete mode 100644 sys/arch/hppa/hppa/locore.S delete mode 100644 sys/arch/hppa/hppa/locore0.S delete mode 100644 sys/arch/hppa/hppa/machdep.c delete mode 100644 sys/arch/hppa/hppa/mainbus.c delete mode 100644 sys/arch/hppa/hppa/mem.c delete mode 100644 sys/arch/hppa/hppa/mutex.c delete mode 100644 sys/arch/hppa/hppa/pmap.c delete mode 100644 sys/arch/hppa/hppa/process_machdep.c delete mode 100644 sys/arch/hppa/hppa/sys_machdep.c delete mode 100644 sys/arch/hppa/hppa/trap.c delete mode 100644 sys/arch/hppa/hppa/vm_machdep.c delete mode 100644 sys/arch/hppa/hppa/wscons_machdep.c delete mode 100644 sys/arch/hppa/include/_float.h delete mode 100644 sys/arch/hppa/include/_types.h delete mode 100644 sys/arch/hppa/include/asm.h delete mode 100644 sys/arch/hppa/include/atomic.h delete mode 100644 sys/arch/hppa/include/autoconf.h delete mode 100644 sys/arch/hppa/include/bus.h delete mode 100644 sys/arch/hppa/include/cdefs.h delete mode 100644 sys/arch/hppa/include/conf.h delete mode 100644 sys/arch/hppa/include/cpu.h delete mode 100644 sys/arch/hppa/include/cpufunc.h delete mode 100644 sys/arch/hppa/include/db_machdep.h delete mode 100644 sys/arch/hppa/include/disklabel.h delete mode 100644 sys/arch/hppa/include/eisa_machdep.h delete mode 100644 sys/arch/hppa/include/endian.h delete mode 100644 sys/arch/hppa/include/exec.h delete mode 100644 sys/arch/hppa/include/fenv.h delete mode 100644 sys/arch/hppa/include/fpu.h delete mode 100644 sys/arch/hppa/include/frame.h delete mode 100644 sys/arch/hppa/include/hil_machdep.h delete mode 100644 sys/arch/hppa/include/ieee.h delete mode 100644 sys/arch/hppa/include/ieeefp.h delete mode 100644 sys/arch/hppa/include/intr.h delete mode 100644 sys/arch/hppa/include/iomod.h delete mode 100644 sys/arch/hppa/include/isa_machdep.h delete mode 100644 sys/arch/hppa/include/kcore.h delete mode 100644 sys/arch/hppa/include/limits.h delete mode 100644 sys/arch/hppa/include/loadfile_machdep.h delete mode 100644 sys/arch/hppa/include/mplock.h delete mode 100644 sys/arch/hppa/include/mutex.h delete mode 100644 sys/arch/hppa/include/param.h delete mode 100644 sys/arch/hppa/include/pcb.h delete mode 100644 sys/arch/hppa/include/pci_machdep.h delete mode 100644 sys/arch/hppa/include/pdc.h delete mode 100644 sys/arch/hppa/include/pmap.h delete mode 100644 sys/arch/hppa/include/proc.h delete mode 100644 sys/arch/hppa/include/profile.h delete mode 100644 sys/arch/hppa/include/psl.h delete mode 100644 sys/arch/hppa/include/pte.h delete mode 100644 sys/arch/hppa/include/ptrace.h delete mode 100644 sys/arch/hppa/include/rbus_machdep.h delete mode 100644 sys/arch/hppa/include/reg.h delete mode 100644 sys/arch/hppa/include/reloc.h delete mode 100644 sys/arch/hppa/include/setjmp.h delete mode 100644 sys/arch/hppa/include/signal.h delete mode 100644 sys/arch/hppa/include/som.h delete mode 100644 sys/arch/hppa/include/spinlock.h delete mode 100644 sys/arch/hppa/include/tcb.h delete mode 100644 sys/arch/hppa/include/timetc.h delete mode 100644 sys/arch/hppa/include/trap.h delete mode 100644 sys/arch/hppa/include/vmparam.h delete mode 100644 sys/arch/hppa/spmath/cnv_float.h delete mode 100644 sys/arch/hppa/spmath/dbl_float.h delete mode 100644 sys/arch/hppa/spmath/dfadd.c delete mode 100644 sys/arch/hppa/spmath/dfcmp.c delete mode 100644 sys/arch/hppa/spmath/dfdiv.c delete mode 100644 sys/arch/hppa/spmath/dfmpy.c delete mode 100644 sys/arch/hppa/spmath/dfrem.c delete mode 100644 sys/arch/hppa/spmath/dfsqrt.c delete mode 100644 sys/arch/hppa/spmath/dfsub.c delete mode 100644 sys/arch/hppa/spmath/divsfm.c delete mode 100644 sys/arch/hppa/spmath/divsfr.c delete mode 100644 sys/arch/hppa/spmath/divsim.c delete mode 100644 sys/arch/hppa/spmath/divsir.c delete mode 100644 sys/arch/hppa/spmath/divu.S delete mode 100644 sys/arch/hppa/spmath/divufr.c delete mode 100644 sys/arch/hppa/spmath/divuir.c delete mode 100644 sys/arch/hppa/spmath/fcnvff.c delete mode 100644 sys/arch/hppa/spmath/fcnvfx.c delete mode 100644 sys/arch/hppa/spmath/fcnvfxt.c delete mode 100644 sys/arch/hppa/spmath/fcnvxf.c delete mode 100644 sys/arch/hppa/spmath/float.h delete mode 100644 sys/arch/hppa/spmath/fpbits.h delete mode 100644 sys/arch/hppa/spmath/frnd.c delete mode 100644 sys/arch/hppa/spmath/hppa.h delete mode 100644 sys/arch/hppa/spmath/impys.S delete mode 100644 sys/arch/hppa/spmath/impyu.S delete mode 100644 sys/arch/hppa/spmath/md.h delete mode 100644 sys/arch/hppa/spmath/mpyaccs.c delete mode 100644 sys/arch/hppa/spmath/mpyaccu.c delete mode 100644 sys/arch/hppa/spmath/mpys.c delete mode 100644 sys/arch/hppa/spmath/mpyscv.c delete mode 100644 sys/arch/hppa/spmath/mpyu.c delete mode 100644 sys/arch/hppa/spmath/mpyucv.c delete mode 100644 sys/arch/hppa/spmath/quad_float.h delete mode 100644 sys/arch/hppa/spmath/sfadd.c delete mode 100644 sys/arch/hppa/spmath/sfcmp.c delete mode 100644 sys/arch/hppa/spmath/sfdiv.c delete mode 100644 sys/arch/hppa/spmath/sfmpy.c delete mode 100644 sys/arch/hppa/spmath/sfrem.c delete mode 100644 sys/arch/hppa/spmath/sfsqrt.c delete mode 100644 sys/arch/hppa/spmath/sfsub.c delete mode 100644 sys/arch/hppa/spmath/sgl_float.h delete mode 100644 sys/arch/hppa/stand/Makefile delete mode 100644 sys/arch/hppa/stand/Makefile.inc delete mode 100644 sys/arch/hppa/stand/boot/Makefile delete mode 100644 sys/arch/hppa/stand/boot/boot.8 delete mode 100644 sys/arch/hppa/stand/boot/conf.c delete mode 100644 sys/arch/hppa/stand/boot/exec.c delete mode 100644 sys/arch/hppa/stand/boot/ld.script delete mode 100644 sys/arch/hppa/stand/boot/srt0.S delete mode 100644 sys/arch/hppa/stand/cdboot/Makefile delete mode 100644 sys/arch/hppa/stand/cdboot/cdboot.c delete mode 100644 sys/arch/hppa/stand/cdboot/elf64.c delete mode 100644 sys/arch/hppa/stand/cdboot/ld.script delete mode 100644 sys/arch/hppa/stand/libsa/Makefile delete mode 100644 sys/arch/hppa/stand/libsa/cmd_hppa.c delete mode 100644 sys/arch/hppa/stand/libsa/ct.c delete mode 100644 sys/arch/hppa/stand/libsa/dev_hppa.c delete mode 100644 sys/arch/hppa/stand/libsa/dev_hppa.h delete mode 100644 sys/arch/hppa/stand/libsa/dk.c delete mode 100644 sys/arch/hppa/stand/libsa/elf32.c delete mode 100644 sys/arch/hppa/stand/libsa/elf64.c delete mode 100644 sys/arch/hppa/stand/libsa/itecons.c delete mode 100644 sys/arch/hppa/stand/libsa/lf.c delete mode 100644 sys/arch/hppa/stand/libsa/libsa.h delete mode 100644 sys/arch/hppa/stand/libsa/lif.c delete mode 100644 sys/arch/hppa/stand/libsa/machdep.c delete mode 100644 sys/arch/hppa/stand/libsa/pdc.c delete mode 100644 sys/arch/hppa/stand/libsa/time.c delete mode 100644 sys/arch/hppa/stand/libz/Makefile delete mode 100644 sys/arch/hppa/stand/mkboot/Makefile delete mode 100644 sys/arch/hppa/stand/mkboot/mkboot.8 delete mode 100644 sys/arch/hppa/stand/mkboot/mkboot.c create mode 100644 sys/dev/fdt/qcpas.c diff --git a/bin/ksh/c_test.c b/bin/ksh/c_test.c index 7038a52bf..c1e490733 100644 --- a/bin/ksh/c_test.c +++ b/bin/ksh/c_test.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_test.c,v 1.27 2019/06/28 13:34:59 deraadt Exp $ */ +/* $OpenBSD: c_test.c,v 1.28 2023/06/10 07:24:21 op Exp $ */ /* * test(1); version 7-like -- author Erik Baalbergen @@ -156,12 +156,6 @@ c_test(char **wp) } if (argc == 1) { opnd1 = (*te.getopnd)(&te, TO_NONOP, 1); - /* Historically, -t by itself test if fd 1 - * is a file descriptor, but POSIX says its - * a string test... - */ - if (!Flag(FPOSIX) && strcmp(opnd1, "-t") == 0) - break; res = (*te.eval)(&te, TO_STNZE, opnd1, NULL, 1); if (invert & 1) @@ -271,14 +265,11 @@ test_eval(Test_env *te, Test_op op, const char *opnd1, const char *opnd2, case TO_FILGZ: /* -s */ return stat(opnd1, &b1) == 0 && b1.st_size > 0L; case TO_FILTT: /* -t */ - if (opnd1 && !bi_getn(opnd1, &res)) { + if (!bi_getn(opnd1, &res)) { te->flags |= TEF_ERROR; - res = 0; - } else { - /* generate error if in FPOSIX mode? */ - res = isatty(opnd1 ? res : 0); + return 0; } - return res; + return isatty(res); case TO_FILUID: /* -O */ return stat(opnd1, &b1) == 0 && b1.st_uid == ksheuid; case TO_FILGID: /* -G */ @@ -527,7 +518,7 @@ static const char * ptest_getopnd(Test_env *te, Test_op op, int do_eval) { if (te->pos.wp >= te->wp_end) - return op == TO_FILTT ? "1" : NULL; + return NULL; return *te->pos.wp++; } diff --git a/bin/ksh/ksh.1 b/bin/ksh/ksh.1 index cd3bfc3eb..9c68d6ba2 100644 --- a/bin/ksh/ksh.1 +++ b/bin/ksh/ksh.1 @@ -1,8 +1,8 @@ -.\" $OpenBSD: ksh.1,v 1.218 2022/12/26 17:45:27 jmc Exp $ +.\" $OpenBSD: ksh.1,v 1.219 2023/06/10 07:24:21 op Exp $ .\" .\" Public Domain .\" -.Dd $Mdocdate: December 26 2022 $ +.Dd $Mdocdate: June 10 2023 $ .Dt KSH 1 .Os .Sh NAME @@ -2569,20 +2569,6 @@ in non-POSIX mode: alias a='for ' i='j' a i in 1 2; do echo i=$i j=$j; done .Ed -.It -.Ic test . -In POSIX mode, the expression -.Sq Fl t -(preceded by some number of -.Sq \&! -arguments) is always true as it is a non-zero length string; -in non-POSIX mode, it tests if file descriptor 1 is a -.Xr tty 4 -(i.e. the -.Ar fd -argument to the -.Fl t -test may be left out and defaults to 1). .El .Ss Strict Bourne shell mode When the @@ -3857,18 +3843,12 @@ socket. .It Fl s Ar file .Ar file is not empty. -.It Fl t Op Ar fd +.It Fl t Ar fd File descriptor .Ar fd is a .Xr tty 4 device. -If the -.Ic posix -option is not set, -.Ar fd -may be left out, in which case it is taken to be 1 (the behaviour differs due -to the special POSIX rules described above). .It Fl u Ar file .Ar file Ns 's mode has the setuid bit set. diff --git a/bin/test/test.1 b/bin/test/test.1 index 6af8fcb71..2371acdda 100644 --- a/bin/test/test.1 +++ b/bin/test/test.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: test.1,v 1.33 2016/08/16 18:51:25 schwarze Exp $ +.\" $OpenBSD: test.1,v 1.34 2023/06/10 07:19:39 op Exp $ .\" $NetBSD: test.1,v 1.6 1995/03/21 07:04:03 cgd Exp $ .\" .\" Copyright (c) 1991, 1993 @@ -33,7 +33,7 @@ .\" .\" @(#)test.1 8.1 (Berkeley) 5/31/93 .\" -.Dd $Mdocdate: August 16 2016 $ +.Dd $Mdocdate: June 10 2023 $ .Dt TEST 1 .Os .Sh NAME @@ -153,7 +153,7 @@ than zero. True if the file whose file descriptor number is .Ar file_descriptor -(default 1) is open and is associated with a terminal. +is open and is associated with a terminal. .It Fl u Ar file True if .Ar file diff --git a/distrib/amd64/ramdiskA/Makefile b/distrib/amd64/ramdiskA/Makefile index b4e5a950f..c060ece7e 100644 --- a/distrib/amd64/ramdiskA/Makefile +++ b/distrib/amd64/ramdiskA/Makefile @@ -1,8 +1,7 @@ -# $OpenBSD: Makefile,v 1.20 2023/04/28 18:14:59 krw Exp $ +# $OpenBSD: Makefile,v 1.21 2023/06/11 14:00:04 krw Exp $ FS= floppy${OSrev}.img FSSIZE= 2880 -FSDISKTYPE= floppy3 MOUNT_POINT= /mnt MTREE= ${UTILS}/mtree.conf RAMDISK= RAMDISK @@ -17,7 +16,7 @@ all: ${FS} ${FS}: bsd.gz dd if=/dev/zero of=${FS} bs=512 count=${FSSIZE} vnconfig -v ${FS} > vnd - disklabel -w `cat vnd` ${FSDISKTYPE} + echo '/ *' | disklabel -wAT- `cat vnd` newfs -O 1 -m 0 -o space -i 524288 -c ${FSSIZE} -b 4096 -f 512 /dev/r`cat vnd`a mount /dev/`cat vnd`a ${MOUNT_POINT} objcopy -S -R .comment ${DESTDIR}/usr/mdec/fdboot ${.OBJDIR}/boot diff --git a/distrib/i386/ramdisk/Makefile b/distrib/i386/ramdisk/Makefile index db488151a..46321bb10 100644 --- a/distrib/i386/ramdisk/Makefile +++ b/distrib/i386/ramdisk/Makefile @@ -1,8 +1,7 @@ -# $OpenBSD: Makefile,v 1.21 2023/04/28 18:14:59 krw Exp $ +# $OpenBSD: Makefile,v 1.22 2023/06/11 14:00:04 krw Exp $ FS= floppy${OSrev}.img FSSIZE= 2880 -FSDISKTYPE= floppy3 MOUNT_POINT= /mnt MTREE= ${UTILS}/mtree.conf RAMDISK= RAMDISK @@ -15,7 +14,7 @@ all: ${FS} ${FS}: bsd.gz dd if=/dev/zero of=${FS} bs=512 count=${FSSIZE} vnconfig -v ${FS} > vnd - disklabel -w `cat vnd` ${FSDISKTYPE} + echo '/ *' | disklabel -wAT- `cat vnd` newfs -O 1 -m 0 -o space -i 524288 -c ${FSSIZE} -b 4096 -f 512 /dev/r`cat vnd`a mount /dev/`cat vnd`a ${MOUNT_POINT} objcopy -S -R .comment ${DESTDIR}/usr/mdec/fdboot ${.OBJDIR}/boot diff --git a/lib/libcrypto/Makefile b/lib/libcrypto/Makefile index 4c782918e..89bd94d79 100644 --- a/lib/libcrypto/Makefile +++ b/lib/libcrypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.129 2023/05/07 14:39:55 tb Exp $ +# $OpenBSD: Makefile,v 1.130 2023/06/11 05:35:43 tb Exp $ LIB= crypto LIBREBUILD=y @@ -236,7 +236,6 @@ SRCS+= cmac.c # cms/ SRCS+= cms_asn1.c SRCS+= cms_att.c -SRCS+= cms_cd.c SRCS+= cms_dd.c SRCS+= cms_enc.c SRCS+= cms_env.c diff --git a/lib/libcrypto/cms/cms_cd.c b/lib/libcrypto/cms/cms_cd.c deleted file mode 100644 index 3ecf801bc..000000000 --- a/lib/libcrypto/cms/cms_cd.c +++ /dev/null @@ -1,128 +0,0 @@ -/* $OpenBSD: cms_cd.c,v 1.16 2022/11/26 16:08:51 tb Exp $ */ -/* - * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL - * project. - */ -/* ==================================================================== - * Copyright (c) 2008 The OpenSSL Project. 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. - * - * 3. All advertising materials mentioning features or use of this - * software must display the following acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)" - * - * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to - * endorse or promote products derived from this software without - * prior written permission. For written permission, please contact - * licensing@OpenSSL.org. - * - * 5. Products derived from this software may not be called "OpenSSL" - * nor may "OpenSSL" appear in their names without prior written - * permission of the OpenSSL Project. - * - * 6. Redistributions of any form whatsoever must retain the following - * acknowledgment: - * "This product includes software developed by the OpenSSL Project - * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)" - * - * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY - * EXPRESSED 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 OpenSSL PROJECT OR - * ITS 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. - * ==================================================================== - */ - -#include "cryptlib.h" -#include -#include -#include -#include -#include -#include -#include -#include "cms_local.h" - -#ifdef ZLIB - -/* CMS CompressedData Utilities */ - -CMS_ContentInfo * -cms_CompressedData_create(int comp_nid) -{ - CMS_ContentInfo *cms; - CMS_CompressedData *cd; - - /* - * Will need something cleverer if there is ever more than one - * compression algorithm or parameters have some meaning... - */ - if (comp_nid != NID_zlib_compression) { - CMSerror(CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM); - return NULL; - } - cms = CMS_ContentInfo_new(); - if (cms == NULL) - return NULL; - - cd = (CMS_CompressedData *)ASN1_item_new(&CMS_CompressedData_it); - - if (cd == NULL) - goto err; - - cms->contentType = OBJ_nid2obj(NID_id_smime_ct_compressedData); - cms->d.compressedData = cd; - - cd->version = 0; - - X509_ALGOR_set0(cd->compressionAlgorithm, - OBJ_nid2obj(NID_zlib_compression), V_ASN1_UNDEF, NULL); - - cd->encapContentInfo->eContentType = OBJ_nid2obj(NID_pkcs7_data); - - return cms; - - err: - CMS_ContentInfo_free(cms); - return NULL; -} - -BIO * -cms_CompressedData_init_bio(CMS_ContentInfo *cms) -{ - CMS_CompressedData *cd; - const ASN1_OBJECT *compoid; - - if (OBJ_obj2nid(cms->contentType) != NID_id_smime_ct_compressedData) { - CMSerror(CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA); - return NULL; - } - cd = cms->d.compressedData; - X509_ALGOR_get0(&compoid, NULL, NULL, cd->compressionAlgorithm); - if (OBJ_obj2nid(compoid) != NID_zlib_compression) { - CMSerror(CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM); - return NULL; - } - return BIO_new(BIO_f_zlib()); -} - -#endif diff --git a/lib/libcrypto/cms/cms_lib.c b/lib/libcrypto/cms/cms_lib.c index ee9385910..f8d950de0 100644 --- a/lib/libcrypto/cms/cms_lib.c +++ b/lib/libcrypto/cms/cms_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_lib.c,v 1.16 2022/11/26 16:08:51 tb Exp $ */ +/* $OpenBSD: cms_lib.c,v 1.17 2023/06/11 05:35:43 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -160,11 +160,6 @@ CMS_dataInit(CMS_ContentInfo *cms, BIO *icont) case NID_pkcs7_digest: cmsbio = cms_DigestedData_init_bio(cms); break; -#ifdef ZLIB - case NID_id_smime_ct_compressedData: - cmsbio = cms_CompressedData_init_bio(cms); - break; -#endif case NID_pkcs7_encrypted: cmsbio = cms_EncryptedData_init_bio(cms); diff --git a/lib/libcrypto/cms/cms_smime.c b/lib/libcrypto/cms/cms_smime.c index d21ff124d..e9001d0f0 100644 --- a/lib/libcrypto/cms/cms_smime.c +++ b/lib/libcrypto/cms/cms_smime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cms_smime.c,v 1.25 2022/11/26 16:08:51 tb Exp $ */ +/* $OpenBSD: cms_smime.c,v 1.26 2023/06/11 05:35:43 tb Exp $ */ /* * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project. @@ -868,55 +868,6 @@ CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, unsigned int flags) return ret; } -#ifdef ZLIB - -int -CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out, unsigned int flags) -{ - BIO *cont; - int r; - - if (OBJ_obj2nid(CMS_get0_type(cms)) != NID_id_smime_ct_compressedData) { - CMSerror(CMS_R_TYPE_NOT_COMPRESSED_DATA); - return 0; - } - - if (!dcont && !check_content(cms)) - return 0; - - cont = CMS_dataInit(cms, dcont); - if (!cont) - return 0; - r = cms_copy_content(out, cont, flags); - do_free_upto(cont, dcont); - - return r; -} - -CMS_ContentInfo * -CMS_compress(BIO *in, int comp_nid, unsigned int flags) -{ - CMS_ContentInfo *cms; - - if (comp_nid <= 0) - comp_nid = NID_zlib_compression; - cms = cms_CompressedData_create(comp_nid); - if (!cms) - return NULL; - - if (!(flags & CMS_DETACHED)) - CMS_set_detached(cms, 0); - - if ((flags & CMS_STREAM) || CMS_final(cms, in, NULL, flags)) - return cms; - - CMS_ContentInfo_free(cms); - - return NULL; -} - -#else - int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out, unsigned int flags) { @@ -930,5 +881,3 @@ CMS_compress(BIO *in, int comp_nid, unsigned int flags) CMSerror(CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM); return NULL; } - -#endif diff --git a/lib/libcrypto/comp/c_zlib.c b/lib/libcrypto/comp/c_zlib.c index 009737d59..ec98b26f5 100644 --- a/lib/libcrypto/comp/c_zlib.c +++ b/lib/libcrypto/comp/c_zlib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: c_zlib.c,v 1.26 2023/04/17 13:18:00 tb Exp $ */ +/* $OpenBSD: c_zlib.c,v 1.27 2023/06/11 05:35:43 tb Exp $ */ /* * --------------------------------------------------------------------------- * Major patches to this file were contributed by @@ -132,551 +132,13 @@ static COMP_METHOD zlib_method_nozlib = { .name = "(undef)" }; -#ifdef ZLIB - -#include - -static int zlib_stateful_init(COMP_CTX *ctx); -static void zlib_stateful_finish(COMP_CTX *ctx); -static int zlib_stateful_compress_block(COMP_CTX *ctx, unsigned char *out, - unsigned int olen, unsigned char *in, unsigned int ilen); -static int zlib_stateful_expand_block(COMP_CTX *ctx, unsigned char *out, - unsigned int olen, unsigned char *in, unsigned int ilen); - - -/* memory allocations functions for zlib initialization */ -static void* -zlib_zalloc(void* opaque, unsigned int no, unsigned int size) -{ - return calloc(no, size); -} - -static void -zlib_zfree(void* opaque, void* address) -{ - free(address); -} - -static COMP_METHOD zlib_stateful_method = { - .type = NID_zlib_compression, - .name = LN_zlib_compression, - .init = zlib_stateful_init, - .finish = zlib_stateful_finish, - .compress = zlib_stateful_compress_block, - .expand = zlib_stateful_expand_block -}; - -struct zlib_state { - z_stream istream; - z_stream ostream; -}; - -static int zlib_stateful_ex_idx = -1; - -static int -zlib_stateful_init(COMP_CTX *ctx) -{ - int err; - struct zlib_state *state = malloc(sizeof(struct zlib_state)); - - if (state == NULL) - goto err; - - state->istream.zalloc = zlib_zalloc; - state->istream.zfree = zlib_zfree; - state->istream.opaque = Z_NULL; - state->istream.next_in = Z_NULL; - state->istream.next_out = Z_NULL; - state->istream.avail_in = 0; - state->istream.avail_out = 0; - err = inflateInit_(&state->istream, ZLIB_VERSION, sizeof(z_stream)); - if (err != Z_OK) - goto err; - - state->ostream.zalloc = zlib_zalloc; - state->ostream.zfree = zlib_zfree; - state->ostream.opaque = Z_NULL; - state->ostream.next_in = Z_NULL; - state->ostream.next_out = Z_NULL; - state->ostream.avail_in = 0; - state->ostream.avail_out = 0; - err = deflateInit_(&state->ostream, Z_DEFAULT_COMPRESSION, - ZLIB_VERSION, sizeof(z_stream)); - if (err != Z_OK) - goto err; - - CRYPTO_new_ex_data(CRYPTO_EX_INDEX_COMP, ctx, &ctx->ex_data); - CRYPTO_set_ex_data(&ctx->ex_data, zlib_stateful_ex_idx, state); - return 1; - -err: - free(state); - return 0; -} - -static void -zlib_stateful_finish(COMP_CTX *ctx) -{ - struct zlib_state *state = - (struct zlib_state *)CRYPTO_get_ex_data(&ctx->ex_data, - zlib_stateful_ex_idx); - - inflateEnd(&state->istream); - deflateEnd(&state->ostream); - free(state); - CRYPTO_free_ex_data(CRYPTO_EX_INDEX_COMP, ctx, &ctx->ex_data); -} - -static int -zlib_stateful_compress_block(COMP_CTX *ctx, unsigned char *out, - unsigned int olen, unsigned char *in, unsigned int ilen) -{ - int err = Z_OK; - struct zlib_state *state = - (struct zlib_state *)CRYPTO_get_ex_data(&ctx->ex_data, - zlib_stateful_ex_idx); - - if (state == NULL) - return -1; - - state->ostream.next_in = in; - state->ostream.avail_in = ilen; - state->ostream.next_out = out; - state->ostream.avail_out = olen; - if (ilen > 0) - err = deflate(&state->ostream, Z_SYNC_FLUSH); - if (err != Z_OK) - return -1; - -#ifdef DEBUG_ZLIB - fprintf(stderr, "compress(%4d)->%4d %s\n", - ilen, olen - state->ostream.avail_out, - (ilen != olen - state->ostream.avail_out)?"zlib":"clear"); -#endif - - return olen - state->ostream.avail_out; -} - -static int -zlib_stateful_expand_block(COMP_CTX *ctx, unsigned char *out, - unsigned int olen, unsigned char *in, unsigned int ilen) -{ - int err = Z_OK; - - struct zlib_state *state = - (struct zlib_state *)CRYPTO_get_ex_data(&ctx->ex_data, - zlib_stateful_ex_idx); - - if (state == NULL) - return 0; - - state->istream.next_in = in; - state->istream.avail_in = ilen; - state->istream.next_out = out; - state->istream.avail_out = olen; - if (ilen > 0) - err = inflate(&state->istream, Z_SYNC_FLUSH); - if (err != Z_OK) - return -1; - -#ifdef DEBUG_ZLIB - fprintf(stderr, "expand(%4d)->%4d %s\n", - ilen, olen - state->istream.avail_out, - (ilen != olen - state->istream.avail_out)?"zlib":"clear"); -#endif - - return olen - state->istream.avail_out; -} - -#endif - COMP_METHOD * COMP_zlib(void) { - COMP_METHOD *meth = &zlib_method_nozlib; - -#ifdef ZLIB - { - /* init zlib_stateful_ex_idx here so that in a multi-process - * application it's enough to initialize openssl before forking - * (idx will be inherited in all the children) */ - if (zlib_stateful_ex_idx == -1) { - CRYPTO_w_lock(CRYPTO_LOCK_COMP); - if (zlib_stateful_ex_idx == -1) - zlib_stateful_ex_idx = - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_COMP, - 0, NULL, NULL, NULL, NULL); - CRYPTO_w_unlock(CRYPTO_LOCK_COMP); - if (zlib_stateful_ex_idx == -1) - goto err; - } - if (!OPENSSL_init_crypto(0, NULL)) - goto err; - - meth = &zlib_stateful_method; - } - -err: -#endif - - return (meth); + return &zlib_method_nozlib; } void COMP_zlib_cleanup(void) { } - -#ifdef ZLIB - -/* Zlib based compression/decompression filter BIO */ - -typedef struct { - unsigned char *ibuf; /* Input buffer */ - int ibufsize; /* Buffer size */ - z_stream zin; /* Input decompress context */ - unsigned char *obuf; /* Output buffer */ - int obufsize; /* Output buffer size */ - unsigned char *optr; /* Position in output buffer */ - int ocount; /* Amount of data in output buffer */ - int odone; /* deflate EOF */ - int comp_level; /* Compression level to use */ - z_stream zout; /* Output compression context */ -} BIO_ZLIB_CTX; - -#define ZLIB_DEFAULT_BUFSIZE 1024 - -static int bio_zlib_new(BIO *bi); -static int bio_zlib_free(BIO *bi); -static int bio_zlib_read(BIO *b, char *out, int outl); -static int bio_zlib_write(BIO *b, const char *in, int inl); -static long bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr); -static long bio_zlib_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp); - -static BIO_METHOD bio_meth_zlib = { - .type = BIO_TYPE_COMP, - .name = "zlib", - .bwrite = bio_zlib_write, - .bread = bio_zlib_read, - .ctrl = bio_zlib_ctrl, - .create = bio_zlib_new, - .destroy = bio_zlib_free, - .callback_ctrl = bio_zlib_callback_ctrl -}; - -BIO_METHOD * -BIO_f_zlib(void) -{ - return &bio_meth_zlib; -} - - -static int -bio_zlib_new(BIO *bi) -{ - BIO_ZLIB_CTX *ctx; - - ctx = malloc(sizeof(BIO_ZLIB_CTX)); - if (!ctx) { - COMPerror(ERR_R_MALLOC_FAILURE); - return 0; - } - ctx->ibuf = NULL; - ctx->obuf = NULL; - ctx->ibufsize = ZLIB_DEFAULT_BUFSIZE; - ctx->obufsize = ZLIB_DEFAULT_BUFSIZE; - ctx->zin.zalloc = Z_NULL; - ctx->zin.zfree = Z_NULL; - ctx->zin.next_in = NULL; - ctx->zin.avail_in = 0; - ctx->zin.next_out = NULL; - ctx->zin.avail_out = 0; - ctx->zout.zalloc = Z_NULL; - ctx->zout.zfree = Z_NULL; - ctx->zout.next_in = NULL; - ctx->zout.avail_in = 0; - ctx->zout.next_out = NULL; - ctx->zout.avail_out = 0; - ctx->odone = 0; - ctx->comp_level = Z_DEFAULT_COMPRESSION; - bi->init = 1; - bi->ptr = (char *)ctx; - bi->flags = 0; - return 1; -} - -static int -bio_zlib_free(BIO *bi) -{ - BIO_ZLIB_CTX *ctx; - - if (!bi) - return 0; - ctx = (BIO_ZLIB_CTX *)bi->ptr; - if (ctx->ibuf) { - /* Destroy decompress context */ - inflateEnd(&ctx->zin); - free(ctx->ibuf); - } - if (ctx->obuf) { - /* Destroy compress context */ - deflateEnd(&ctx->zout); - free(ctx->obuf); - } - free(ctx); - bi->ptr = NULL; - bi->init = 0; - bi->flags = 0; - return 1; -} - -static int -bio_zlib_read(BIO *b, char *out, int outl) -{ - BIO_ZLIB_CTX *ctx; - int ret; - z_stream *zin; - - if (!out || !outl) - return 0; - ctx = (BIO_ZLIB_CTX *)b->ptr; - zin = &ctx->zin; - BIO_clear_retry_flags(b); - if (!ctx->ibuf) { - ctx->ibuf = malloc(ctx->ibufsize); - if (!ctx->ibuf) { - COMPerror(ERR_R_MALLOC_FAILURE); - return 0; - } - inflateInit(zin); - zin->next_in = ctx->ibuf; - zin->avail_in = 0; - } - - /* Copy output data directly to supplied buffer */ - zin->next_out = (unsigned char *)out; - zin->avail_out = (unsigned int)outl; - for (;;) { - /* Decompress while data available */ - while (zin->avail_in) { - ret = inflate(zin, 0); - if ((ret != Z_OK) && (ret != Z_STREAM_END)) { - COMPerror(COMP_R_ZLIB_INFLATE_ERROR); - ERR_asprintf_error_data("zlib error:%s", - zError(ret)); - return 0; - } - /* If EOF or we've read everything then return */ - if ((ret == Z_STREAM_END) || !zin->avail_out) - return outl - zin->avail_out; - } - - /* No data in input buffer try to read some in, - * if an error then return the total data read. - */ - ret = BIO_read(b->next_bio, ctx->ibuf, ctx->ibufsize); - if (ret <= 0) { - /* Total data read */ - int tot = outl - zin->avail_out; - BIO_copy_next_retry(b); - if (ret < 0) - return (tot > 0) ? tot : ret; - return tot; - } - zin->avail_in = ret; - zin->next_in = ctx->ibuf; - } -} - -static int -bio_zlib_write(BIO *b, const char *in, int inl) -{ - BIO_ZLIB_CTX *ctx; - int ret; - z_stream *zout; - - if (!in || !inl) - return 0; - ctx = (BIO_ZLIB_CTX *)b->ptr; - if (ctx->odone) - return 0; - zout = &ctx->zout; - BIO_clear_retry_flags(b); - if (!ctx->obuf) { - ctx->obuf = malloc(ctx->obufsize); - /* Need error here */ - if (!ctx->obuf) { - COMPerror(ERR_R_MALLOC_FAILURE); - return 0; - } - ctx->optr = ctx->obuf; - ctx->ocount = 0; - deflateInit(zout, ctx->comp_level); - zout->next_out = ctx->obuf; - zout->avail_out = ctx->obufsize; - } - /* Obtain input data directly from supplied buffer */ - zout->next_in = (void *)in; - zout->avail_in = inl; - for (;;) { - /* If data in output buffer write it first */ - while (ctx->ocount) { - ret = BIO_write(b->next_bio, ctx->optr, ctx->ocount); - if (ret <= 0) { - /* Total data written */ - int tot = inl - zout->avail_in; - BIO_copy_next_retry(b); - if (ret < 0) - return (tot > 0) ? tot : ret; - return tot; - } - ctx->optr += ret; - ctx->ocount -= ret; - } - - /* Have we consumed all supplied data? */ - if (!zout->avail_in) - return inl; - - /* Compress some more */ - - /* Reset buffer */ - ctx->optr = ctx->obuf; - zout->next_out = ctx->obuf; - zout->avail_out = ctx->obufsize; - /* Compress some more */ - ret = deflate(zout, 0); - if (ret != Z_OK) { - COMPerror(COMP_R_ZLIB_DEFLATE_ERROR); - ERR_asprintf_error_data("zlib error:%s", zError(ret)); - return 0; - } - ctx->ocount = ctx->obufsize - zout->avail_out; - } -} - -static int -bio_zlib_flush(BIO *b) -{ - BIO_ZLIB_CTX *ctx; - int ret; - z_stream *zout; - - ctx = (BIO_ZLIB_CTX *)b->ptr; - /* If no data written or already flush show success */ - if (!ctx->obuf || (ctx->odone && !ctx->ocount)) - return 1; - zout = &ctx->zout; - BIO_clear_retry_flags(b); - /* No more input data */ - zout->next_in = NULL; - zout->avail_in = 0; - for (;;) { - /* If data in output buffer write it first */ - while (ctx->ocount) { - ret = BIO_write(b->next_bio, ctx->optr, ctx->ocount); - if (ret <= 0) { - BIO_copy_next_retry(b); - return ret; - } - ctx->optr += ret; - ctx->ocount -= ret; - } - if (ctx->odone) - return 1; - - /* Compress some more */ - - /* Reset buffer */ - ctx->optr = ctx->obuf; - zout->next_out = ctx->obuf; - zout->avail_out = ctx->obufsize; - /* Compress some more */ - ret = deflate(zout, Z_FINISH); - if (ret == Z_STREAM_END) - ctx->odone = 1; - else if (ret != Z_OK) { - COMPerror(COMP_R_ZLIB_DEFLATE_ERROR); - ERR_asprintf_error_data("zlib error:%s", zError(ret)); - return 0; - } - ctx->ocount = ctx->obufsize - zout->avail_out; - } -} - -static long -bio_zlib_ctrl(BIO *b, int cmd, long num, void *ptr) -{ - BIO_ZLIB_CTX *ctx; - int ret, *ip; - int ibs, obs; - if (!b->next_bio) - return 0; - ctx = (BIO_ZLIB_CTX *)b->ptr; - switch (cmd) { - - case BIO_CTRL_RESET: - ctx->ocount = 0; - ctx->odone = 0; - ret = 1; - break; - - case BIO_CTRL_FLUSH: - ret = bio_zlib_flush(b); - if (ret > 0) - ret = BIO_flush(b->next_bio); - break; - - case BIO_C_SET_BUFF_SIZE: - ibs = -1; - obs = -1; - if (ptr != NULL) { - ip = ptr; - if (*ip == 0) - ibs = (int) num; - else - obs = (int) num; - } else { - ibs = (int)num; - obs = ibs; - } - - if (ibs != -1) { - free(ctx->ibuf); - ctx->ibuf = NULL; - ctx->ibufsize = ibs; - } - - if (obs != -1) { - free(ctx->obuf); - ctx->obuf = NULL; - ctx->obufsize = obs; - } - ret = 1; - break; - - case BIO_C_DO_STATE_MACHINE: - BIO_clear_retry_flags(b); - ret = BIO_ctrl(b->next_bio, cmd, num, ptr); - BIO_copy_next_retry(b); - break; - - default: - ret = BIO_ctrl(b->next_bio, cmd, num, ptr); - break; - - } - - return ret; -} - - -static long -bio_zlib_callback_ctrl(BIO *b, int cmd, BIO_info_cb *fp) -{ - if (!b->next_bio) - return 0; - return BIO_callback_ctrl(b->next_bio, cmd, fp); -} - -#endif diff --git a/lib/libcrypto/comp/comp.h b/lib/libcrypto/comp/comp.h index 58b51c6e8..8f3645f37 100644 --- a/lib/libcrypto/comp/comp.h +++ b/lib/libcrypto/comp/comp.h @@ -1,4 +1,4 @@ -/* $OpenBSD: comp.h,v 1.11 2022/12/24 07:12:09 tb Exp $ */ +/* $OpenBSD: comp.h,v 1.12 2023/06/11 05:35:43 tb Exp $ */ /* * --------------------------------------------------------------------------- * Patches to this file were contributed by @@ -131,12 +131,6 @@ COMP_METHOD *COMP_rle(void ); COMP_METHOD *COMP_zlib(void ); void COMP_zlib_cleanup(void); -#ifdef HEADER_BIO_H -#ifdef ZLIB -BIO_METHOD *BIO_f_zlib(void); -#endif -#endif - void ERR_load_COMP_strings(void); /* Error codes for the COMP functions. */ diff --git a/lib/libcrypto/err/err_all.c b/lib/libcrypto/err/err_all.c index 74d39d307..9a46e93c2 100644 --- a/lib/libcrypto/err/err_all.c +++ b/lib/libcrypto/err/err_all.c @@ -1,4 +1,4 @@ -/* $OpenBSD: err_all.c,v 1.27 2022/05/07 17:20:41 tb Exp $ */ +/* $OpenBSD: err_all.c,v 1.28 2023/06/11 05:35:43 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -122,9 +122,6 @@ ERR_load_crypto_strings_internal(void) ERR_load_BUF_strings(); #ifndef OPENSSL_NO_CMS ERR_load_CMS_strings(); -#endif -#ifdef ZLIB - ERR_load_COMP_strings(); #endif ERR_load_CONF_strings(); ERR_load_CRYPTO_strings(); diff --git a/lib/libcrypto/x509/x509_vfy.c b/lib/libcrypto/x509/x509_vfy.c index 0c2144752..c4ba3d5b1 100644 --- a/lib/libcrypto/x509/x509_vfy.c +++ b/lib/libcrypto/x509/x509_vfy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509_vfy.c,v 1.124 2023/05/28 05:25:24 tb Exp $ */ +/* $OpenBSD: x509_vfy.c,v 1.125 2023/06/08 22:02:40 beck Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -754,23 +754,14 @@ x509_vfy_check_chain_extensions(X509_STORE_CTX *ctx) goto end; } ret = X509_check_ca(x); - switch (must_be_ca) { - case -1: + if (must_be_ca == -1) { if ((ctx->param->flags & X509_V_FLAG_X509_STRICT) && (ret != 1) && (ret != 0)) { ret = 0; ctx->error = X509_V_ERR_INVALID_CA; } else ret = 1; - break; - case 0: - if (ret != 0) { - ret = 0; - ctx->error = X509_V_ERR_INVALID_NON_CA; - } else - ret = 1; - break; - default: + } else { if ((ret == 0) || ((ctx->param->flags & X509_V_FLAG_X509_STRICT) && (ret != 1))) { @@ -778,7 +769,6 @@ x509_vfy_check_chain_extensions(X509_STORE_CTX *ctx) ctx->error = X509_V_ERR_INVALID_CA; } else ret = 1; - break; } if (ret == 0) { ctx->error_depth = i; diff --git a/lib/libssl/ssl_clnt.c b/lib/libssl/ssl_clnt.c index c721aede4..6aea59013 100644 --- a/lib/libssl/ssl_clnt.c +++ b/lib/libssl/ssl_clnt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_clnt.c,v 1.158 2022/12/26 07:31:44 jmc Exp $ */ +/* $OpenBSD: ssl_clnt.c,v 1.160 2023/06/11 19:01:01 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1299,13 +1299,17 @@ ssl3_get_server_kex_ecdhe(SSL *s, CBS *cbs) static int ssl3_get_server_key_exchange(SSL *s) { - CBS cbs, signature; + CBB cbb; + CBS cbs, params, signature; EVP_MD_CTX *md_ctx; - const unsigned char *param; - size_t param_len; + unsigned char *signed_params = NULL; + size_t signed_params_len; + size_t params_len; long alg_k, alg_a; int al, ret; + memset(&cbb, 0, sizeof(cbb)); + alg_k = s->s3->hs.cipher->algorithm_mkey; alg_a = s->s3->hs.cipher->algorithm_auth; @@ -1341,8 +1345,14 @@ ssl3_get_server_key_exchange(SSL *s) return (1); } - param = CBS_data(&cbs); - param_len = CBS_len(&cbs); + if (!CBB_init(&cbb, 0)) + goto err; + if (!CBB_add_bytes(&cbb, s->s3->client_random, SSL3_RANDOM_SIZE)) + goto err; + if (!CBB_add_bytes(&cbb, s->s3->server_random, SSL3_RANDOM_SIZE)) + goto err; + + CBS_dup(&cbs, ¶ms); if (alg_k & SSL_kDHE) { if (!ssl3_get_server_kex_dhe(s, &cbs)) @@ -1356,7 +1366,12 @@ ssl3_get_server_key_exchange(SSL *s) goto fatal_err; } - param_len -= CBS_len(&cbs); + if ((params_len = CBS_offset(&cbs)) > CBS_len(¶ms)) + goto err; + if (!CBB_add_bytes(&cbb, CBS_data(¶ms), params_len)) + goto err; + if (!CBB_finish(&cbb, &signed_params, &signed_params_len)) + goto err; /* if it was signed, check the signature */ if ((alg_a & SSL_aNULL) == 0) { @@ -1400,21 +1415,13 @@ ssl3_get_server_key_exchange(SSL *s) if (!EVP_DigestVerifyInit(md_ctx, &pctx, sigalg->md(), NULL, pkey)) goto err; - if (!EVP_DigestVerifyUpdate(md_ctx, s->s3->client_random, - SSL3_RANDOM_SIZE)) - goto err; if ((sigalg->flags & SIGALG_FLAG_RSA_PSS) && (!EVP_PKEY_CTX_set_rsa_padding(pctx, RSA_PKCS1_PSS_PADDING) || !EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1))) goto err; - if (!EVP_DigestVerifyUpdate(md_ctx, s->s3->server_random, - SSL3_RANDOM_SIZE)) - goto err; - if (!EVP_DigestVerifyUpdate(md_ctx, param, param_len)) - goto err; - if (EVP_DigestVerifyFinal(md_ctx, CBS_data(&signature), - CBS_len(&signature)) <= 0) { + if (EVP_DigestVerify(md_ctx, CBS_data(&signature), + CBS_len(&signature), signed_params, signed_params_len) <= 0) { al = SSL_AD_DECRYPT_ERROR; SSLerror(s, SSL_R_BAD_SIGNATURE); goto fatal_err; @@ -1428,6 +1435,7 @@ ssl3_get_server_key_exchange(SSL *s) } EVP_MD_CTX_free(md_ctx); + free(signed_params); return (1); @@ -1439,7 +1447,9 @@ ssl3_get_server_key_exchange(SSL *s) ssl3_send_alert(s, SSL3_AL_FATAL, al); err: + CBB_cleanup(&cbb); EVP_MD_CTX_free(md_ctx); + free(signed_params); return (-1); } @@ -2125,12 +2135,7 @@ ssl3_send_client_verify_sigalgs(SSL *s, EVP_PKEY *pkey, SSLerror(s, ERR_R_EVP_LIB); goto err; } - if (!EVP_DigestSignUpdate(mctx, hdata, hdata_len)) { - SSLerror(s, ERR_R_EVP_LIB); - goto err; - } - if (!EVP_DigestSignFinal(mctx, NULL, &signature_len) || - signature_len == 0) { + if (!EVP_DigestSign(mctx, NULL, &signature_len, hdata, hdata_len)) { SSLerror(s, ERR_R_EVP_LIB); goto err; } @@ -2138,7 +2143,7 @@ ssl3_send_client_verify_sigalgs(SSL *s, EVP_PKEY *pkey, SSLerror(s, ERR_R_MALLOC_FAILURE); goto err; } - if (!EVP_DigestSignFinal(mctx, signature, &signature_len)) { + if (!EVP_DigestSign(mctx, signature, &signature_len, hdata, hdata_len)) { SSLerror(s, ERR_R_EVP_LIB); goto err; } @@ -2267,12 +2272,7 @@ ssl3_send_client_verify_gost(SSL *s, EVP_PKEY *pkey, CBB *cert_verify) SSLerror(s, ERR_R_EVP_LIB); goto err; } - if (!EVP_DigestSignUpdate(mctx, hdata, hdata_len)) { - SSLerror(s, ERR_R_EVP_LIB); - goto err; - } - if (!EVP_DigestSignFinal(mctx, NULL, &signature_len) || - signature_len == 0) { + if (!EVP_DigestSign(mctx, NULL, &signature_len, hdata, hdata_len)) { SSLerror(s, ERR_R_EVP_LIB); goto err; } @@ -2280,7 +2280,7 @@ ssl3_send_client_verify_gost(SSL *s, EVP_PKEY *pkey, CBB *cert_verify) SSLerror(s, ERR_R_MALLOC_FAILURE); goto err; } - if (!EVP_DigestSignFinal(mctx, signature, &signature_len)) { + if (!EVP_DigestSign(mctx, signature, &signature_len, hdata, hdata_len)) { SSLerror(s, ERR_R_EVP_LIB); goto err; } diff --git a/lib/libssl/ssl_srvr.c b/lib/libssl/ssl_srvr.c index 556107f5a..8edbf7715 100644 --- a/lib/libssl/ssl_srvr.c +++ b/lib/libssl/ssl_srvr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl_srvr.c,v 1.153 2022/12/26 07:31:44 jmc Exp $ */ +/* $OpenBSD: ssl_srvr.c,v 1.155 2023/06/11 19:01:01 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -1431,12 +1431,13 @@ ssl3_send_server_kex_ecdhe(SSL *s, CBB *cbb) static int ssl3_send_server_key_exchange(SSL *s) { - CBB cbb, cbb_params, cbb_signature, server_kex; + CBB cbb, cbb_signature, cbb_signed_params, server_kex; + CBS params; const struct ssl_sigalg *sigalg = NULL; + unsigned char *signed_params = NULL; + size_t signed_params_len; unsigned char *signature = NULL; size_t signature_len = 0; - unsigned char *params = NULL; - size_t params_len; const EVP_MD *md = NULL; unsigned long type; EVP_MD_CTX *md_ctx = NULL; @@ -1445,7 +1446,7 @@ ssl3_send_server_key_exchange(SSL *s) int al; memset(&cbb, 0, sizeof(cbb)); - memset(&cbb_params, 0, sizeof(cbb_params)); + memset(&cbb_signed_params, 0, sizeof(cbb_signed_params)); if ((md_ctx = EVP_MD_CTX_new()) == NULL) goto err; @@ -1456,15 +1457,26 @@ ssl3_send_server_key_exchange(SSL *s) SSL3_MT_SERVER_KEY_EXCHANGE)) goto err; - if (!CBB_init(&cbb_params, 0)) + if (!CBB_init(&cbb_signed_params, 0)) goto err; + if (!CBB_add_bytes(&cbb_signed_params, s->s3->client_random, + SSL3_RANDOM_SIZE)) { + SSLerror(s, ERR_R_INTERNAL_ERROR); + goto err; + } + if (!CBB_add_bytes(&cbb_signed_params, s->s3->server_random, + SSL3_RANDOM_SIZE)) { + SSLerror(s, ERR_R_INTERNAL_ERROR); + goto err; + } + type = s->s3->hs.cipher->algorithm_mkey; if (type & SSL_kDHE) { - if (!ssl3_send_server_kex_dhe(s, &cbb_params)) + if (!ssl3_send_server_kex_dhe(s, &cbb_signed_params)) goto err; } else if (type & SSL_kECDHE) { - if (!ssl3_send_server_kex_ecdhe(s, &cbb_params)) + if (!ssl3_send_server_kex_ecdhe(s, &cbb_signed_params)) goto err; } else { al = SSL_AD_HANDSHAKE_FAILURE; @@ -1472,10 +1484,16 @@ ssl3_send_server_key_exchange(SSL *s) goto fatal_err; } - if (!CBB_finish(&cbb_params, ¶ms, ¶ms_len)) + if (!CBB_finish(&cbb_signed_params, &signed_params, + &signed_params_len)) goto err; - if (!CBB_add_bytes(&server_kex, params, params_len)) + CBS_init(¶ms, signed_params, signed_params_len); + if (!CBS_skip(¶ms, 2 * SSL3_RANDOM_SIZE)) + goto err; + + if (!CBB_add_bytes(&server_kex, CBS_data(¶ms), + CBS_len(¶ms))) goto err; /* Add signature unless anonymous. */ @@ -1507,22 +1525,8 @@ ssl3_send_server_key_exchange(SSL *s) SSLerror(s, ERR_R_EVP_LIB); goto err; } - if (!EVP_DigestSignUpdate(md_ctx, s->s3->client_random, - SSL3_RANDOM_SIZE)) { - SSLerror(s, ERR_R_EVP_LIB); - goto err; - } - if (!EVP_DigestSignUpdate(md_ctx, s->s3->server_random, - SSL3_RANDOM_SIZE)) { - SSLerror(s, ERR_R_EVP_LIB); - goto err; - } - if (!EVP_DigestSignUpdate(md_ctx, params, params_len)) { - SSLerror(s, ERR_R_EVP_LIB); - goto err; - } - if (!EVP_DigestSignFinal(md_ctx, NULL, &signature_len) || - !signature_len) { + if (!EVP_DigestSign(md_ctx, NULL, &signature_len, + signed_params, signed_params_len)) { SSLerror(s, ERR_R_EVP_LIB); goto err; } @@ -1530,7 +1534,8 @@ ssl3_send_server_key_exchange(SSL *s) SSLerror(s, ERR_R_MALLOC_FAILURE); goto err; } - if (!EVP_DigestSignFinal(md_ctx, signature, &signature_len)) { + if (!EVP_DigestSign(md_ctx, signature, &signature_len, + signed_params, signed_params_len)) { SSLerror(s, ERR_R_EVP_LIB); goto err; } @@ -1550,19 +1555,19 @@ ssl3_send_server_key_exchange(SSL *s) } EVP_MD_CTX_free(md_ctx); - free(params); free(signature); + free(signed_params); return (ssl3_handshake_write(s)); fatal_err: ssl3_send_alert(s, SSL3_AL_FATAL, al); err: - CBB_cleanup(&cbb_params); + CBB_cleanup(&cbb_signed_params); CBB_cleanup(&cbb); EVP_MD_CTX_free(md_ctx); - free(params); free(signature); + free(signed_params); return (-1); } @@ -2049,17 +2054,12 @@ ssl3_get_cert_verify(SSL *s) al = SSL_AD_INTERNAL_ERROR; goto fatal_err; } - if (!EVP_DigestVerifyUpdate(mctx, hdata, hdatalen)) { + if (EVP_DigestVerify(mctx, CBS_data(&signature), + CBS_len(&signature), hdata, hdatalen) <= 0) { SSLerror(s, ERR_R_EVP_LIB); al = SSL_AD_INTERNAL_ERROR; goto fatal_err; } - if (EVP_DigestVerifyFinal(mctx, CBS_data(&signature), - CBS_len(&signature)) <= 0) { - al = SSL_AD_DECRYPT_ERROR; - SSLerror(s, SSL_R_BAD_SIGNATURE); - goto fatal_err; - } } else if (EVP_PKEY_id(pkey) == EVP_PKEY_RSA) { RSA *rsa; diff --git a/lib/libssl/tls13_client.c b/lib/libssl/tls13_client.c index 3555ebadd..053cf1689 100644 --- a/lib/libssl/tls13_client.c +++ b/lib/libssl/tls13_client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_client.c,v 1.101 2022/11/26 16:08:56 tb Exp $ */ +/* $OpenBSD: tls13_client.c,v 1.102 2023/06/10 15:34:36 tb Exp $ */ /* * Copyright (c) 2018, 2019 Joel Sing * @@ -688,12 +688,8 @@ tls13_server_certificate_verify_recv(struct tls13_ctx *ctx, CBS *cbs) if (!EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1)) goto err; } - if (!EVP_DigestVerifyUpdate(mdctx, sig_content, sig_content_len)) { - ctx->alert = TLS13_ALERT_DECRYPT_ERROR; - goto err; - } - if (EVP_DigestVerifyFinal(mdctx, CBS_data(&signature), - CBS_len(&signature)) <= 0) { + if (EVP_DigestVerify(mdctx, CBS_data(&signature), CBS_len(&signature), + sig_content, sig_content_len) <= 0) { ctx->alert = TLS13_ALERT_DECRYPT_ERROR; goto err; } @@ -956,13 +952,11 @@ tls13_client_certificate_verify_send(struct tls13_ctx *ctx, CBB *cbb) if (!EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1)) goto err; } - if (!EVP_DigestSignUpdate(mdctx, sig_content, sig_content_len)) - goto err; - if (EVP_DigestSignFinal(mdctx, NULL, &sig_len) <= 0) + if (!EVP_DigestSign(mdctx, NULL, &sig_len, sig_content, sig_content_len)) goto err; if ((sig = calloc(1, sig_len)) == NULL) goto err; - if (EVP_DigestSignFinal(mdctx, sig, &sig_len) <= 0) + if (!EVP_DigestSign(mdctx, sig, &sig_len, sig_content, sig_content_len)) goto err; if (!CBB_add_u16(cbb, sigalg->value)) diff --git a/lib/libssl/tls13_server.c b/lib/libssl/tls13_server.c index 75510a908..dfeb1e016 100644 --- a/lib/libssl/tls13_server.c +++ b/lib/libssl/tls13_server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tls13_server.c,v 1.105 2022/11/26 16:08:56 tb Exp $ */ +/* $OpenBSD: tls13_server.c,v 1.106 2023/06/10 15:34:36 tb Exp $ */ /* * Copyright (c) 2019, 2020 Joel Sing * Copyright (c) 2020 Bob Beck @@ -754,13 +754,11 @@ tls13_server_certificate_verify_send(struct tls13_ctx *ctx, CBB *cbb) if (!EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1)) goto err; } - if (!EVP_DigestSignUpdate(mdctx, sig_content, sig_content_len)) - goto err; - if (EVP_DigestSignFinal(mdctx, NULL, &sig_len) <= 0) + if (!EVP_DigestSign(mdctx, NULL, &sig_len, sig_content, sig_content_len)) goto err; if ((sig = calloc(1, sig_len)) == NULL) goto err; - if (EVP_DigestSignFinal(mdctx, sig, &sig_len) <= 0) + if (!EVP_DigestSign(mdctx, sig, &sig_len, sig_content, sig_content_len)) goto err; if (!CBB_add_u16(cbb, sigalg->value)) @@ -999,12 +997,8 @@ tls13_client_certificate_verify_recv(struct tls13_ctx *ctx, CBS *cbs) if (!EVP_PKEY_CTX_set_rsa_pss_saltlen(pctx, -1)) goto err; } - if (!EVP_DigestVerifyUpdate(mdctx, sig_content, sig_content_len)) { - ctx->alert = TLS13_ALERT_DECRYPT_ERROR; - goto err; - } - if (EVP_DigestVerifyFinal(mdctx, CBS_data(&signature), - CBS_len(&signature)) <= 0) { + if (EVP_DigestVerify(mdctx, CBS_data(&signature), CBS_len(&signature), + sig_content, sig_content_len) <= 0) { ctx->alert = TLS13_ALERT_DECRYPT_ERROR; goto err; } diff --git a/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py b/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py index e7f2006a5..2953320c1 100644 --- a/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py +++ b/regress/lib/libssl/tlsfuzzer/tlsfuzzer.py @@ -1,4 +1,4 @@ -# $OpenBSD: tlsfuzzer.py,v 1.48 2023/01/06 19:25:20 tb Exp $ +# $OpenBSD: tlsfuzzer.py,v 1.49 2023/06/10 05:00:58 tb Exp $ # # Copyright (c) 2020 Theo Buehler # @@ -428,6 +428,8 @@ tls12_failing_tests = TestGroup("failing TLSv1.2 tests", [ Test("test-aesccm.py"), # need server to set up alpn Test("test-alpn-negotiation.py"), + # Failing on TLS_RSA_WITH_AES_128_CBC_SHA because server does not support it. + Test("test-bleichenbacher-timing-pregenerate.py"), # many tests fail due to unexpected server_name extension Test("test-bleichenbacher-workaround.py"), diff --git a/regress/usr.bin/pkg-config/Makefile b/regress/usr.bin/pkg-config/Makefile index a5fb09b8a..0f7358799 100644 --- a/regress/usr.bin/pkg-config/Makefile +++ b/regress/usr.bin/pkg-config/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.62 2020/09/15 07:19:31 jasper Exp $ +# $OpenBSD: Makefile,v 1.63 2023/06/08 08:57:02 espie Exp $ REGRESS_TARGETS=cmp-vers1-1 \ cmp-vers1-2 \ @@ -101,7 +101,12 @@ REGRESS_TARGETS=cmp-vers1-1 \ filter-system-dirs-5 \ filter-system-dirs-6 \ cflags-system-path-1 \ - cflags-system-path-2 + cflags-system-path-2 \ + lib-flags-1 \ + lib-flags-2 \ + lib-flags-3 \ + lib-flags-4 \ + PKG_CONFIG?= /usr/bin/pkg-config PCONFIG = PKG_CONFIG_PATH=${.CURDIR}/pcdir/ ${PKG_CONFIG} @@ -329,7 +334,7 @@ cmp-vers5-10: cmp-vers6-1: # Test suffixed versions in Requires - @echo " -lalpha2" > ${WANT} + @echo "-lalpha2" > ${WANT} @${VPCONFIG} --libs requires-test2 @diff -u ${WANT} ${GOT} @@ -474,7 +479,7 @@ whitespace-libs: whitespace-linebreak: # Test linebreak in Description field - @echo " -lc" > ${WANT} + @echo "-lc" > ${WANT} @${VPCONFIG} --libs linebreak @diff -u ${WANT} ${GOT} @@ -631,19 +636,19 @@ variables-4: variables-5: # Test --variable - @echo ' -lfoo-1' > ${WANT} + @echo '-lfoo-1' > ${WANT} @${VPCONFIG} --libs variables @diff -u ${WANT} ${GOT} variables-6: # Test variable overriding from environment - @echo ' -lfoo-2' > ${WANT} + @echo '-lfoo-2' > ${WANT} @PKG_CONFIG_VARIABLES_FOO_API_VERSION=2 ${VPCONFIG} --libs variables @diff -u ${WANT} ${GOT} variables-7: # Ensure variable overriding only uses uppercase keys - @echo ' -lfoo-1' > ${WANT} + @echo '-lfoo-1' > ${WANT} @PKG_CONFIG_variables_foo_api_version=2 ${VPCONFIG} --libs variables @diff -u ${WANT} ${GOT} @@ -655,13 +660,13 @@ filter-system-dirs-1: filter-system-dirs-2: # Test removing -L/usr/lib as a system directory - @echo ' -lfilter' > ${WANT} + @echo '-lfilter' > ${WANT} @${VPCONFIG} --libs filter @diff -u ${WANT} ${GOT} filter-system-dirs-3: # Test removing -L/usr/lib as a system directory (static) - @echo ' -lfilter -lprivate-filter' > ${WANT} + @echo '-lfilter -lprivate-filter' > ${WANT} @${VPCONFIG} --static --libs filter @diff -u ${WANT} ${GOT} @@ -698,6 +703,30 @@ cflags-system-path-2: clean: rm -f *.want *.got +lib-flags-1: + # Test --libs-only-other + @echo "-pthread" > ${WANT} + @${VPCONFIG} --libs-only-other lib-flags + @diff -u ${WANT} ${GOT} + +lib-flags-2: + # Test --libs + @echo "-L/usr/local/lib -pthread -lalpha2" > ${WANT} + @${VPCONFIG} --libs lib-flags + @diff -u ${WANT} ${GOT} + +lib-flags-3: + # Test --libs-only-L + @echo "-L/usr/local/lib" > ${WANT} + @${VPCONFIG} --libs-only-L lib-flags + @diff -u ${WANT} ${GOT} + +lib-flags-4: + # Test --libs-only-l + @echo "-lalpha2" > ${WANT} + @${VPCONFIG} --libs-only-l lib-flags + @diff -u ${WANT} ${GOT} + .PHONY: ${REGRESS_TARGETS} .include diff --git a/regress/usr.bin/pkg-config/pcdir/lib-flags.pc b/regress/usr.bin/pkg-config/pcdir/lib-flags.pc new file mode 100644 index 000000000..d17071663 --- /dev/null +++ b/regress/usr.bin/pkg-config/pcdir/lib-flags.pc @@ -0,0 +1,4 @@ +Name: lib separation test +Description: pkg-config(1) regress file +Version: 0.0 +Libs: -lalpha2 -L/usr/local/lib -pthread diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 3f03ddf6d..944823793 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ifconfig.8,v 1.396 2023/06/01 18:57:53 kn Exp $ +.\" $OpenBSD: ifconfig.8,v 1.397 2023/06/07 18:42:40 bluhm Exp $ .\" $NetBSD: ifconfig.8,v 1.11 1996/01/04 21:27:29 pk Exp $ .\" $FreeBSD: ifconfig.8,v 1.16 1998/02/01 07:03:29 steve Exp $ .\" @@ -31,7 +31,7 @@ .\" .\" @(#)ifconfig.8 8.4 (Berkeley) 6/1/94 .\" -.Dd $Mdocdate: June 1 2023 $ +.Dd $Mdocdate: June 7 2023 $ .Dt IFCONFIG 8 .Os .Sh NAME @@ -501,7 +501,7 @@ Query and display information and diagnostics from GBIC and SFP modules installed in an interface. It is only supported by drivers implementing the necessary functionality on hardware which supports it. -.It Cm tcprecvoffload +.It Cm tcplro Enable TCP large receive offload (LRO) if it's supported by the hardware; see .Cm hwfeatures . LRO enabled network interfaces modify received TCP/IP packets. @@ -517,7 +517,7 @@ It is not possible to use LRO with interfaces attached to a or .Xr tpmr 4 . Changing this option will re-initialize the network interface. -.It Cm -tcprecvoffload +.It Cm -tcplro Disable LRO. LRO is disabled by default. .It Cm up diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 1ae9a90bb..ecc5edd88 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.465 2023/06/01 18:57:54 kn Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.467 2023/06/09 12:22:01 kn Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -471,8 +471,8 @@ const struct cmd { { "-soii", IFXF_INET6_NOSOII, 0, setifxflags }, { "monitor", IFXF_MONITOR, 0, setifxflags }, { "-monitor", -IFXF_MONITOR, 0, setifxflags }, - { "tcprecvoffload", IFXF_LRO, 0, setifxflags }, - { "-tcprecvoffload", -IFXF_LRO, 0, setifxflags }, + { "tcplro", IFXF_LRO, 0, setifxflags }, + { "-tcplro", -IFXF_LRO, 0, setifxflags }, #ifndef SMALL { "hwfeatures", NEXTARG0, 0, printifhwfeatures }, { "metric", NEXTARG, 0, setifmetric }, @@ -631,6 +631,7 @@ const struct cmd { { "wgkey", NEXTARG, A_WIREGUARD, setwgkey}, { "wgrtable", NEXTARG, A_WIREGUARD, setwgrtable}, { "-wgpeer", NEXTARG, A_WIREGUARD, unsetwgpeer}, + { "-wgpsk", 0, A_WIREGUARD, unsetwgpeerpsk}, { "-wgdescription", 0, A_WIREGUARD, unsetwgpeerdesc}, { "-wgdescr", 0, A_WIREGUARD, unsetwgpeerdesc}, { "-wgpeerall", 0, A_WIREGUARD, unsetwgpeerall}, diff --git a/sys/arch/arm64/arm64/cpu.c b/sys/arch/arm64/arm64/cpu.c index 3e686ee25..4f8f74990 100644 --- a/sys/arch/arm64/arm64/cpu.c +++ b/sys/arch/arm64/arm64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.92 2023/05/30 08:30:00 jsg Exp $ */ +/* $OpenBSD: cpu.c,v 1.94 2023/06/11 21:42:01 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -944,6 +944,7 @@ cpu_init(void) { uint64_t id_aa64mmfr1, sctlr; uint64_t id_aa64pfr0; + uint64_t id_aa64isar1; uint64_t tcr; WRITE_SPECIALREG(ttbr0_el1, pmap_kernel()->pm_pt0pa); @@ -968,6 +969,15 @@ cpu_init(void) if (ID_AA64PFR0_DIT(id_aa64pfr0) >= ID_AA64PFR0_DIT_IMPL) __asm volatile (".arch armv8.4-a; msr dit, #1"); + /* Enable PAuth. */ + id_aa64isar1 = READ_SPECIALREG(id_aa64isar1_el1); + if (ID_AA64ISAR1_API(id_aa64isar1) >= ID_AA64ISAR1_API_BASE) { + sctlr = READ_SPECIALREG(sctlr_el1); + sctlr |= SCTLR_EnIA | SCTLR_EnDA; + sctlr |= SCTLR_EnIB | SCTLR_EnDB; + WRITE_SPECIALREG(sctlr_el1, sctlr); + } + /* Initialize debug registers. */ WRITE_SPECIALREG(mdscr_el1, DBG_MDSCR_TDCC); WRITE_SPECIALREG(oslar_el1, 0); diff --git a/sys/arch/arm64/arm64/machdep.c b/sys/arch/arm64/arm64/machdep.c index 20ad76d57..1a582fa27 100644 --- a/sys/arch/arm64/arm64/machdep.c +++ b/sys/arch/arm64/arm64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.81 2023/04/24 10:22:48 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.82 2023/06/10 19:30:48 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt * Copyright (c) 2021 Mark Kettenis @@ -314,11 +314,6 @@ cpu_switchto(struct proc *old, struct proc *new) cpu_switchto_asm(old, new); } -extern uint64_t cpu_id_aa64isar0; -extern uint64_t cpu_id_aa64isar1; -extern uint64_t cpu_id_aa64pfr0; -extern uint64_t cpu_id_aa64pfr1; - /* * machine dependent system variables. */ @@ -451,13 +446,21 @@ void setregs(struct proc *p, struct exec_package *pack, u_long stack, struct ps_strings *arginfo) { + struct pmap *pm = p->p_vmspace->vm_map.pmap; struct pcb *pcb = &p->p_addr->u_pcb; struct trapframe *tf = pcb->pcb_tf; if (pack->ep_flags & EXEC_NOBTCFI) - p->p_vmspace->vm_map.pmap->pm_guarded = 0; + pm->pm_guarded = 0; else - p->p_vmspace->vm_map.pmap->pm_guarded = ATTR_GP; + pm->pm_guarded = ATTR_GP; + + arc4random_buf(&pm->pm_apiakey, sizeof(pm->pm_apiakey)); + arc4random_buf(&pm->pm_apdakey, sizeof(pm->pm_apdakey)); + arc4random_buf(&pm->pm_apibkey, sizeof(pm->pm_apibkey)); + arc4random_buf(&pm->pm_apdbkey, sizeof(pm->pm_apdbkey)); + arc4random_buf(&pm->pm_apgakey, sizeof(pm->pm_apgakey)); + pmap_setpauthkeys(pm); /* If we were using the FPU, forget about it. */ memset(&pcb->pcb_fpstate, 0, sizeof(pcb->pcb_fpstate)); diff --git a/sys/arch/arm64/arm64/pmap.c b/sys/arch/arm64/arm64/pmap.c index 493b8f333..ca745c75b 100644 --- a/sys/arch/arm64/arm64/pmap.c +++ b/sys/arch/arm64/arm64/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.96 2023/04/16 11:14:26 kettenis Exp $ */ +/* $OpenBSD: pmap.c,v 1.98 2023/06/11 21:42:01 kettenis Exp $ */ /* * Copyright (c) 2008-2009,2014-2016 Dale Rahn * @@ -2228,6 +2228,36 @@ pmap_show_mapping(uint64_t va) pted, vp3->l3[VP_IDX3(va)], VP_IDX3(va)*8); } +void +pmap_setpauthkeys(struct pmap *pm) +{ + if (ID_AA64ISAR1_API(cpu_id_aa64isar1) >= ID_AA64ISAR1_API_BASE) { + __asm volatile (".arch armv8.3-a; msr apiakeylo_el1, %0" + :: "r"(pm->pm_apiakey[0])); + __asm volatile (".arch armv8.3-a; msr apiakeyhi_el1, %0" + :: "r"(pm->pm_apiakey[1])); + __asm volatile (".arch armv8.3-a; msr apdakeylo_el1, %0" + :: "r"(pm->pm_apdakey[0])); + __asm volatile (".arch armv8.3-a; msr apdakeyhi_el1, %0" + :: "r"(pm->pm_apdakey[1])); + __asm volatile (".arch armv8.3-a; msr apibkeylo_el1, %0" + :: "r"(pm->pm_apibkey[0])); + __asm volatile (".arch armv8.3-a; msr apibkeyhi_el1, %0" + :: "r"(pm->pm_apibkey[1])); + __asm volatile (".arch armv8.3-a; msr apdbkeylo_el1, %0" + :: "r"(pm->pm_apdbkey[0])); + __asm volatile (".arch armv8.3-a; msr apdbkeyhi_el1, %0" + :: "r"(pm->pm_apdbkey[1])); + } + + if (ID_AA64ISAR1_GPI(cpu_id_aa64isar1) >= ID_AA64ISAR1_GPI_IMPL) { + __asm volatile (".arch armv8.3-a; msr apgakeylo_el1, %0" + :: "r"(pm->pm_apgakey[0])); + __asm volatile (".arch armv8.3-a; msr apgakeyhi_el1, %0" + :: "r"(pm->pm_apgakey[1])); + } +} + void pmap_setttb(struct proc *p) { @@ -2244,6 +2274,9 @@ pmap_setttb(struct proc *p) (pm->pm_asid & ~PMAP_ASID_MASK) != pmap_asid_gen) pmap_allocate_asid(pm); + if (pm != pmap_kernel()) + pmap_setpauthkeys(pm); + WRITE_SPECIALREG(ttbr0_el1, pmap_kernel()->pm_pt0pa); __asm volatile("isb"); cpu_setttb(pm->pm_asid, pm->pm_pt0pa); diff --git a/sys/arch/arm64/arm64/process_machdep.c b/sys/arch/arm64/arm64/process_machdep.c index 26671a700..e57d7f371 100644 --- a/sys/arch/arm64/arm64/process_machdep.c +++ b/sys/arch/arm64/arm64/process_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: process_machdep.c,v 1.7 2023/04/16 10:14:59 kettenis Exp $ */ +/* $OpenBSD: process_machdep.c,v 1.8 2023/06/10 19:30:48 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt * @@ -136,3 +136,9 @@ process_set_pc(struct proc *p, caddr_t addr) } #endif /* PTRACE */ + +register_t +process_get_pacmask(struct proc *p) +{ + return (-1ULL << USER_SPACE_BITS); +} diff --git a/sys/arch/arm64/arm64/trap.c b/sys/arch/arm64/arm64/trap.c index d7f0d84a9..c356163e1 100644 --- a/sys/arch/arm64/arm64/trap.c +++ b/sys/arch/arm64/arm64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.45 2023/05/15 15:02:06 kettenis Exp $ */ +/* $OpenBSD: trap.c,v 1.46 2023/06/10 19:30:48 kettenis Exp $ */ /*- * Copyright (c) 2014 Andrew Turner * All rights reserved. @@ -220,6 +220,8 @@ do_el1h_sync(struct trapframe *frame) panic("FP exception in the kernel"); case EXCP_BRANCH_TGT: panic("Branch target exception in the kernel"); + case EXCP_FPAC: + panic("Faulting PAC trap in kernel"); case EXCP_INSN_ABORT: kdata_abort(frame, esr, far, 1); break; @@ -286,6 +288,11 @@ do_el0_sync(struct trapframe *frame) sv.sival_ptr = (void *)frame->tf_elr; trapsignal(p, SIGILL, esr, ILL_ILLOPC, sv); break; + case EXCP_FPAC: + curcpu()->ci_flush_bp(); + sv.sival_ptr = (void *)frame->tf_elr; + trapsignal(p, SIGILL, esr, ILL_ILLOPC, sv); + break; case EXCP_SVC: svc_handler(frame); break; diff --git a/sys/arch/arm64/arm64/vm_machdep.c b/sys/arch/arm64/arm64/vm_machdep.c index 0d7a19a32..d2e6a9f1a 100644 --- a/sys/arch/arm64/arm64/vm_machdep.c +++ b/sys/arch/arm64/arm64/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.11 2023/04/11 00:45:07 jsg Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.12 2023/06/10 19:30:48 kettenis Exp $ */ /* $NetBSD: vm_machdep.c,v 1.1 2003/04/26 18:39:33 fvdl Exp $ */ /*- @@ -69,11 +69,19 @@ void cpu_fork(struct proc *p1, struct proc *p2, void *stack, void *tcb, void (*func)(void *), void *arg) { + struct pmap *pm = p2->p_vmspace->vm_map.pmap; + struct pmap *pm1 = p1->p_vmspace->vm_map.pmap; struct pcb *pcb = &p2->p_addr->u_pcb; struct pcb *pcb1 = &p1->p_addr->u_pcb; struct trapframe *tf; struct switchframe *sf; + memcpy(pm->pm_apiakey, pm1->pm_apiakey, sizeof(pm->pm_apiakey)); + memcpy(pm->pm_apdakey, pm1->pm_apdakey, sizeof(pm->pm_apdakey)); + memcpy(pm->pm_apibkey, pm1->pm_apibkey, sizeof(pm->pm_apibkey)); + memcpy(pm->pm_apdbkey, pm1->pm_apdbkey, sizeof(pm->pm_apdbkey)); + memcpy(pm->pm_apgakey, pm1->pm_apgakey, sizeof(pm->pm_apgakey)); + /* Save FPU state to PCB if necessary. */ if (pcb1->pcb_flags & PCB_FPU) fpu_save(p1); diff --git a/sys/arch/arm64/conf/GENERIC b/sys/arch/arm64/conf/GENERIC index d9b3daef1..2bc40c28a 100644 --- a/sys/arch/arm64/conf/GENERIC +++ b/sys/arch/arm64/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.272 2023/05/23 14:10:27 patrick Exp $ +# $OpenBSD: GENERIC,v 1.273 2023/06/10 18:31:38 patrick Exp $ # # GENERIC machine description file # @@ -332,6 +332,7 @@ qciic* at fdt? iic* at qciic? qcipcc* at fdt? qcmtx* at fdt? early 1 +qcpas* at fdt? qcpdc* at fdt? qcscm* at fdt? qcsmem* at fdt? diff --git a/sys/arch/arm64/conf/RAMDISK b/sys/arch/arm64/conf/RAMDISK index ce259b559..ecb47f771 100644 --- a/sys/arch/arm64/conf/RAMDISK +++ b/sys/arch/arm64/conf/RAMDISK @@ -1,4 +1,4 @@ -# $OpenBSD: RAMDISK,v 1.205 2023/05/23 14:10:27 patrick Exp $ +# $OpenBSD: RAMDISK,v 1.206 2023/06/10 18:31:38 patrick Exp $ machine arm64 maxusers 4 @@ -256,6 +256,7 @@ qciic* at fdt? iic* at qciic? qcipcc* at fdt? qcmtx* at fdt? early 1 +qcpas* at fdt? qcpdc* at fdt? qcscm* at fdt? qcsmem* at fdt? diff --git a/sys/arch/arm64/include/armreg.h b/sys/arch/arm64/include/armreg.h index afd293f01..ed36ba3a6 100644 --- a/sys/arch/arm64/include/armreg.h +++ b/sys/arch/arm64/include/armreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: armreg.h,v 1.28 2023/04/16 10:14:59 kettenis Exp $ */ +/* $OpenBSD: armreg.h,v 1.29 2023/06/10 19:30:48 kettenis Exp $ */ /*- * Copyright (c) 2013, 2014 Andrew Turner * Copyright (c) 2015 The FreeBSD Foundation @@ -169,6 +169,7 @@ #define EXCP_ILL_STATE 0x0e /* Illegal execution state */ #define EXCP_SVC 0x15 /* SVC trap */ #define EXCP_MSR 0x18 /* MSR/MRS trap */ +#define EXCP_FPAC 0x1c /* Faulting PAC trap */ #define EXCP_INSN_ABORT_L 0x20 /* Instruction abort, from lower EL */ #define EXCP_INSN_ABORT 0x21 /* Instruction abort, from same EL */ #define EXCP_PC_ALIGN 0x22 /* PC alignment fault */ @@ -642,6 +643,7 @@ #define SCTLR_SED 0x0000000000000100 #define SCTLR_UMA 0x0000000000000200 #define SCTLR_I 0x0000000000001000 +#define SCTLR_EnDB 0x0000000000002000 #define SCTLR_DZE 0x0000000000004000 #define SCTLR_UCT 0x0000000000008000 #define SCTLR_nTWI 0x0000000000010000 @@ -651,6 +653,9 @@ #define SCTLR_EOE 0x0000000001000000 #define SCTLR_EE 0x0000000002000000 #define SCTLR_UCI 0x0000000004000000 +#define SCTLR_EnDA 0x0000000008000000 +#define SCTLR_EnIB 0x0000000040000000 +#define SCTLR_EnIA 0x0000000080000000 /* SPSR_EL1 */ /* diff --git a/sys/arch/arm64/include/cpu.h b/sys/arch/arm64/include/cpu.h index 2ddaec58f..9ca13c882 100644 --- a/sys/arch/arm64/include/cpu.h +++ b/sys/arch/arm64/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.35 2023/02/19 17:16:13 kettenis Exp $ */ +/* $OpenBSD: cpu.h,v 1.36 2023/06/10 19:30:48 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn * @@ -61,6 +61,11 @@ * Kernel-only definitions */ +extern uint64_t cpu_id_aa64isar0; +extern uint64_t cpu_id_aa64isar1; +extern uint64_t cpu_id_aa64pfr0; +extern uint64_t cpu_id_aa64pfr1; + #include #include #include diff --git a/sys/arch/arm64/include/pmap.h b/sys/arch/arm64/include/pmap.h index cccd15334..edb0789f5 100644 --- a/sys/arch/arm64/include/pmap.h +++ b/sys/arch/arm64/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.23 2023/04/16 11:14:26 kettenis Exp $ */ +/* $OpenBSD: pmap.h,v 1.24 2023/06/10 19:30:48 kettenis Exp $ */ /* * Copyright (c) 2008,2009,2014 Dale Rahn * @@ -71,6 +71,11 @@ struct pmap { int pm_privileged; int pm_refs; /* ref count */ struct pmap_statistics pm_stats; /* pmap statistics */ + uint64_t pm_apiakey[2]; + uint64_t pm_apdakey[2]; + uint64_t pm_apibkey[2]; + uint64_t pm_apdbkey[2]; + uint64_t pm_apgakey[2]; }; #define PMAP_PA_MASK ~((paddr_t)PAGE_MASK) /* to remove the flags */ @@ -100,6 +105,8 @@ void pmap_kenter_cache(vaddr_t va, paddr_t pa, vm_prot_t prot, int cacheable); void pmap_page_ro(pmap_t pm, vaddr_t va, vm_prot_t prot); void pmap_page_rw(pmap_t pm, vaddr_t va); +void pmap_setpauthkeys(struct pmap *); + paddr_t pmap_steal_avail(size_t size, int align, void **kva); void pmap_avail_fixup(void); void pmap_physload_avail(void); diff --git a/sys/arch/arm64/include/ptrace.h b/sys/arch/arm64/include/ptrace.h index a5ca94766..ee208d06c 100644 --- a/sys/arch/arm64/include/ptrace.h +++ b/sys/arch/arm64/include/ptrace.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ptrace.h,v 1.1 2016/12/17 23:38:33 patrick Exp $ */ +/* $OpenBSD: ptrace.h,v 1.2 2023/06/10 19:30:48 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt * @@ -20,3 +20,8 @@ #define PT_SETREGS (PT_FIRSTMACH + 2) #define PT_GETFPREGS (PT_FIRSTMACH + 3) #define PT_SETFPREGS (PT_FIRSTMACH + 4) +#define PT_PACMASK (PT_FIRSTMACH + 5) + +#ifdef _KERNEL +register_t process_get_pacmask(struct proc *p); +#endif diff --git a/sys/arch/hppa/Makefile b/sys/arch/hppa/Makefile deleted file mode 100644 index e9994b266..000000000 --- a/sys/arch/hppa/Makefile +++ /dev/null @@ -1,50 +0,0 @@ -# $OpenBSD: Makefile,v 1.13 2017/01/22 03:27:31 tb Exp $ - -.include # for KEEPKERNELS - -S= ${.CURDIR}/../.. -KFILE= GENERIC -.if exists(conf/GENERIC.MP) -KFILE= GENERIC.MP -.endif -TDIRS= ${_arch} include gsc spmath -TAGS= ${.CURDIR}/tags - -NOPROG= -NOMAN= -NOOBJ= -SUBDIR= stand -.if !defined(KEEPKERNELS) || !(make(clean) || make(cleandir)) -SUBDIR+=compile -.endif - -# config the fattest kernel we can find into a temporary dir -# to create a Makefile. Then use make to pull some variables -# out and push them into the sub-shell to expand the paths, -# and finally run ctags. -tags:: - TDIR=`mktemp -d /tmp/_tagXXXXXXXXXX` || exit 1; \ - eval "S=${S}" && \ - config -s ${S} -b $${TDIR} ${.CURDIR}/conf/${KFILE} && \ - eval "_arch=\"`make -V _arch -f $${TDIR}/Makefile`\"" && \ - eval "_mach=\"`make -V _mach -f $${TDIR}/Makefile`\"" && \ - eval "_machdir=\$S/arch/$${_mach}" && \ - eval "_archdir=\$S/arch/$${_arch}" && \ - eval "HFILES=\"`find $S \( -path $S/'arch' -o -path $S/stand -o -path $S/lib/libsa -o -path $S'/lib/libkern/arch' \) -prune -o -name '*.h'; find $${_machdir} $${_archdir} $S/lib/libkern/arch/$${_mach} \( -name boot -o -name stand \) -prune -o -name '*.h'`\"" && \ - eval "SFILES=\"`make -V SFILES -f $${TDIR}/Makefile`\"" && \ - eval "CFILES=\"`make -V CFILES -f $${TDIR}/Makefile`\"" && \ - eval "AFILES=\"`make -V AFILES -f $${TDIR}/Makefile`\"" && \ - ctags -wd -f ${TAGS} $${CFILES} $${HFILES} && \ - egrep "^[_A-Z]*ENTRY[_A-Z]*\(.*\)" $${SFILES} $${AFILES} | \ - sed "s;\\([^:]*\\):\\([^(]*\\)(\\([^, )]*\\)\\(.*\\);\\3 \\1 /^\\2(\\3\\4$$/;" \ - >> ${TAGS} && \ - sort -o ${TAGS} ${TAGS} && \ - rm -rf $${TDIR} - -links: - -for i in conf ${TDIRS}; do \ - (cd $$i && rm -f tags; ln -s tags tags); done - -obj: _SUBDIRUSE - -.include diff --git a/sys/arch/hppa/compile/GENERIC.MP/Makefile b/sys/arch/hppa/compile/GENERIC.MP/Makefile deleted file mode 100644 index 01b5f2341..000000000 --- a/sys/arch/hppa/compile/GENERIC.MP/Makefile +++ /dev/null @@ -1 +0,0 @@ -.include "../Makefile.inc" diff --git a/sys/arch/hppa/compile/GENERIC/Makefile b/sys/arch/hppa/compile/GENERIC/Makefile deleted file mode 100644 index 01b5f2341..000000000 --- a/sys/arch/hppa/compile/GENERIC/Makefile +++ /dev/null @@ -1 +0,0 @@ -.include "../Makefile.inc" diff --git a/sys/arch/hppa/compile/Makefile b/sys/arch/hppa/compile/Makefile deleted file mode 100644 index 83dd5c489..000000000 --- a/sys/arch/hppa/compile/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $OpenBSD: Makefile,v 1.2 2016/10/15 13:45:08 deraadt Exp $ - -.if make(obj) || make(clean) || make(cleandir) -SUBDIR!=find . -type d -maxdepth 1 \! \( -name . -o -name CVS \) | cut -b3- -.endif - -.include diff --git a/sys/arch/hppa/compile/Makefile.inc b/sys/arch/hppa/compile/Makefile.inc deleted file mode 100644 index 9e9e38f1e..000000000 --- a/sys/arch/hppa/compile/Makefile.inc +++ /dev/null @@ -1,19 +0,0 @@ -SYSDIR != cd ${.CURDIR}/../../../..; pwd -CONFDIR != cd ${.CURDIR}/../../conf; pwd - -.if ${.CURDIR} == ${.OBJDIR} -.PHONY: config -config: - @echo make obj required first >&2 - @false -.else -.PHONY: config clean -config: - config ${.CURDIR:M*.PROF:C/.*/-p/} -b ${.OBJDIR} \ - -s ${SYSDIR} ${CONFDIR}/${.CURDIR:T:S/.PROF$//} -.endif - -cleandir clean: - -.include - diff --git a/sys/arch/hppa/compile/RAMDISK/Makefile b/sys/arch/hppa/compile/RAMDISK/Makefile deleted file mode 100644 index 01b5f2341..000000000 --- a/sys/arch/hppa/compile/RAMDISK/Makefile +++ /dev/null @@ -1 +0,0 @@ -.include "../Makefile.inc" diff --git a/sys/arch/hppa/conf/GENERIC b/sys/arch/hppa/conf/GENERIC deleted file mode 100644 index 556587ab8..000000000 --- a/sys/arch/hppa/conf/GENERIC +++ /dev/null @@ -1,361 +0,0 @@ -# $OpenBSD: GENERIC,v 1.184 2022/01/02 05:37:19 jsg Exp $ -# -# For further information on compiling OpenBSD kernels, see the config(8) -# man page. -# -# For further information on hardware support for this architecture, see -# the intro(4) man page. For further information about kernel options -# for this architecture, see the options(4) man page. For an explanation -# of each device driver in this file see the section 4 man page for the -# device. - -machine hppa -include "../../../conf/GENERIC" -maxusers 80 # estimated number of users - -# Support for various CPU types -option HP7000_CPU # PCXS -option HP7100_CPU # PCXT -option HP7200_CPU # PCXT' -option HP7100LC_CPU # PCXL -option HP7300LC_CPU # PCXL2 -option HP8000_CPU # PCXU (in 32bit mode) -option HP8200_CPU # PCXU2 (in 32bit mode) -option HP8500_CPU # PCXW (in 32bit mode) -option HP8700_CPU # PCXW2 (in 32bit mode) -#option USE_HPT - -option FPEMUL -option USELEDS # blink 'em -option USER_PCICONF # user-space PCI configuration -option WSDISPLAY_COMPAT_RAWKBD # provide raw scancodes; needed for X11 - -config bsd swap generic - -mainbus0 at root # root bus - -mem* at mainbus0 flags 0x0000 # /dev/*mem and memory controller -pdc0 at mainbus0 # PDC/IODC wrapper for boot console -power0 at mainbus0 # power/fail manager (iv 30) -lcd0 at mainbus0 # LCD -cpu0 at mainbus0 irq 31 # HP PA-RISC cpu -#fpu* at mainbus0 # HP PA-RISC fpu (iv N/A) -#pmu* at mainbus0 irq 29 # HP PA-RISC performance monitor unit -phantomas0 at mainbus0 # Phantom PseudoBC GSC+ Port -uturn0 at mainbus0 # U2/UTurn Runway IOA -uturn1 at mainbus0 -astro* at mainbus0 # Astro memory & I/O controller - -lasi0 at mainbus0 offset 0x100000 # LASI host adapter -lasi0 at mainbus0 offset 0xfd00000 # LASI on C1[01]0, J2[01]0 -lasi0 at phantomas0 offset 0xfd00000 # LASI on [AB]* -lasi0 at uturn? offset 0xfd00000 # LASI on [CJ]* -lasi1 at mainbus0 offset 0x500000 # 712 GIO card -asp* at mainbus0 # this one comes w/ Viper and LEDs -wax* at mainbus0 # Wax may host EISA as well -wax* at phantomas0 # Wax on [AB]* -wax* at uturn? # Wax on C* -mongoose* at mainbus0 irq 17 # EISA Bus Adapter (i82350 or TI???) -#vmeb* at mainbus0 irq ? # VME bus adapter -dino* at phantomas? # PCI bus bridge on [AB]* -dino* at uturn? # PCI bus bridge on [CJ]* -pci* at dino? -option PCIVERBOSE -#pckbc0 at dino? irq 9 -com1 at dino? irq 11 - -elroy* at astro? -pci* at elroy? - -ppb* at pci? -pci* at ppb? - -ssio* at pci? -com0 at ssio? irq 4 -com1 at ssio? irq 3 -lpt0 at ssio? - -# CardBus bus support -cbb* at pci? -cardslot* at cbb? -cardbus* at cardslot? -option PCMCIAVERBOSE -pcmcia* at cardslot? - -# PCI USB Controllers -ehci* at pci? # Enhanced Host Controller -ehci* at cardbus? -ohci* at pci? # Open Host Controller -ohci* at cardbus? -uhci* at pci? # Universal Host Controller (Intel) - -# USB bus support -usb* at ehci? -usb* at uhci? -usb* at ohci? - -# USB devices -uhub* at usb? # USB Hubs -uhub* at uhub? # USB Hubs -uftdi* at uhub? # FTDI FT8U100AX serial adapter -ucom* at uftdi? -uplcom* at uhub? # I/O DATA USB-RSAQ2 serial adapter -ucom* at uplcom? -uark* at uhub? # Arkmicro ARK3116 serial -ucom* at uark? -umass* at uhub? # USB Mass Storage devices -uhidev* at uhub? # Human Interface Devices -ums* at uhidev? # USB mouse -wsmouse* at ums? mux 0 -ukbd* at uhidev? # USB keyboard -wskbd* at ukbd? mux 1 -uhid* at uhidev? # USB generic HID support -fido* at uhidev? # FIDO/U2F security key support -ucc* at uhidev? # Consumer Control keyboards -wskbd* at ucc? mux 1 -ujoy* at uhidev? # USB joystick/gamecontroller support -uhidpp* at uhidev? # Logitech HID++ Devices -upd* at uhidev? # USB Power Devices sensors -aue* at uhub? # ADMtek AN986 Pegasus Ethernet -url* at uhub? # Realtek RTL8150L based adapters -ure* at uhub? # Realtek RTL8152 based adapters -rsu* at uhub? # Realtek RTL8188SU/RTL8191SU/RTL8192SU - -# untested USB devices -urng* at uhub? # USB Random Number Generator -uonerng* at uhub? # Moonbase Otago OneRNG -umodem* at uhub? # USB Modems/Serial -ucom* at umodem? -uvisor* at uhub? # Handspring Visor -ucom* at uvisor? -uvscom* at uhub? # SUNTAC Slipper U VS-10U serial -ucom* at uvscom? -ubsa* at uhub? # Belkin serial adapter -ucom* at ubsa? -umct* at uhub? # MCT USB-RS232 serial adapter -ucom* at umct? -uslcom* at uhub? # Silicon Laboratories CP210x serial -ucom* at uslcom? -uscom* at uhub? # Simple USB serial adapters -ucom* at uscom? -ucrcom* at uhub? # Chromebook serial -ucom* at ucrcom? -uipaq* at uhub? # iPAQ serial adapter -ucom* at uipaq? -umsm* at uhub? # Qualcomm MSM EVDO -ucom* at umsm? -ucycom* at uhidev? # Cypress serial -ucom* at ucycom? -uslhcom* at uhidev? # Silicon Labs CP2110 USB HID UART -ucom* at uslhcom? -uchcom* at uhub? # WinChipHead CH341/340 serial -ucom* at uchcom? -uaudio* at uhub? # USB Audio -audio* at uaudio? -umidi* at uhub? # USB MIDI -midi* at umidi? -ulpt* at uhub? # USB Printers -atu* at uhub? # Atmel AT76c50x based 802.11b -axe* at uhub? # ASIX Electronics AX88172 USB Ethernet -axen* at uhub? # ASIX Electronics AX88179 USB Ethernet -cue* at uhub? # CATC USB-EL1201A based Ethernet -kue* at uhub? # Kawasaki KL5KUSB101B based Ethernet -smsc* at uhub? # SMSC LAN95xx Ethernet -cdce* at uhub? # CDC Ethernet -urndis* at uhub? # Remote NDIS Ethernet -udav* at uhub? # Davicom DM9601 based Ethernet -upl* at uhub? # Prolific PL2301/PL2302 host-to-host `network' -ugl* at uhub? # Genesys Logic GL620USB-A host-to-host `network' -wi* at uhub? # WaveLAN IEEE 802.11DS -udsbr* at uhub? # D-Link DSB-R100 radio -radio* at udsbr? # USB radio -ugen* at uhub? # USB Generic driver -ural* at uhub? # Ralink RT2500USB -rum* at uhub? # Ralink RT2501USB/RT2601USB -run* at uhub? # Ralink RT2700U/RT2800U/RT3000U -zyd* at uhub? # Zydas ZD1211 -uthum* at uhidev? # TEMPerHUM sensor -ugold* at uhidev? # gold TEMPer sensor -utwitch* at uhidev? # YUREX BBU sensor -uow* at uhub? # Maxim/Dallas DS2490 1-Wire adapter -onewire* at uow? -udl* at uhub? # DisplayLink USB displays -wsdisplay* at udl? - -sti* at mainbus0 # [H]CRX-{8,24,48}[Z] graphics -sti* at phantomas0 # builtin graphics on BC* -sti* at uturn? -sti* at pci? # EG-PCI, FX* - -# internal i/o space -gsc0 at asp? # Snakes, old 715, old 725, 735/755 -gsc0 at lasi0 # 712,715/100,725/64,725/100,[ABCJ]* -gsc1 at lasi1 -gsc2 at wax? # it's another face of LASI - -#vme* at vmeb? -#option VMEVERBOSE -eisa* at mongoose? -#eisa* at wax? -option EISAVERBOSE -#isa* at mongoose? -#isa* at wax? - -# GSC devices - -hil* at gsc? irq 1 # Human Interface Loop, kbd and mouse -hilkbd* at hil? # keyboard, knob and buttons -hilms* at hil? # mouse and tablets -hilid* at hil? # ID module - -# RS/232 serial ports -com0 at gsc0 offset 0x5000 irq 5 # on lasi -com1 at gsc1 offset 0x5000 irq 5 -com1 at gsc2 offset 0x2000 irq 6 # on wax -com0 at gsc0 offset 0x823000 irq 5 # on asp -com1 at gsc0 offset 0x822000 irq 6 -com2 at gsc0 offset 0x0 irq 13 # only on asp0 w/o audio (off ?) -com2 at gsc0 offset 0x4040 irq 13 # gecko's fax/voice/modems -com3 at gsc0 offset 0x4060 irq 13 -#com* at pcmcia? # PCMCIA modems - -lpt0 at gsc? irq 7 # both com and lpt are on WD16C552 -ie0 at gsc0 irq 8 # 82C596DX/CA ether -#ie1 at gsc1 irq 8 -#ie* at eisa? -#ie* at isa? port 0x360 iomem 0xd0000 irq 7 -#ie* at isa? port 0x300 irq 10 -#ie* at pci? -#siop* at gsc? irq 3 # NCR 53C720 (Fast-Wide HVD) -osiop* at gsc? irq 9 # NCR 53C710 (Narrow SE) -#osiop* at eisa? -oosiop* at gsc? irq 9 # NCR 53C700 (Narrow SE) -arcofi* at gsc? irq 13 # Audio Type 1 (PSB2160) -audio* at arcofi? -harmony* at gsc? irq 13 # Audio Type 2 (CS4215/AD1849) -audio* at harmony? -gsckbc* at gsc? irq 26 -pckbd* at gsckbc? # PS/2 keyboard -pms* at gsckbc? # PS/2 mouse - -#sh* at eisa? # Interphase Seahawk 4811 EISA/FDDI -#ahc* at eisa? # Adaptec 274x, aic7770 SCSI controllers -ahc* at pci? # Adaptec 2940 SCSI controllers -mpi* at pci? # LSI Logic Fusion MPT Message Passing Interface -qlw* at pci? # QLogic ISP SCSI -qla* at pci? # QLogic ISP 2[123]xx FibreChannel -qle* at pci? # QLogic ISP 2[45]xx FibreChannel - -siop* at mainbus? irq 3 # NCR 53C720 (Fast-Wide HVD) -siop* at phantomas? irq 3 -siop* at uturn? irq 3 -siop* at pci? # NCR 53C8XX SCSI controllers -#ahd* at pci? # Adaptec 79?? SCSI controllers - -em* at pci? # Intel Pro/1000 ethernet -ti* at pci? # Alteon Tigon 1Gb ethernet -#txp* at pci? # 3com 3CR990 -#epic* at pci? # SMC EPIC/100 ethernet -#de* at pci? # 21x4[012]-based Ethernet -#de* at eisa? -dc* at pci? # 21143, "tulip" clone ethernet -#dc* at cardbus? -rl* at pci? # Realtek 81[23]9 ethernet -#rl* at cardbus? -#ep* at pci? # 3c59x ethernet -#ep* at eisa? # 3c579 ethernet -#ep* at pcmcia? # 3c589 ethernet -xl* at pci? # 3C9xx ethernet -#xl* at cardbus? -fxp* at pci? # EtherExpress 10/100B ethernet -#fxp* at cardbus? -ne* at pci? # NE2000-compatible Ethernet -ne* at pcmcia? -#atw* at pci? # ADMtek ADM8211 (802.11) -#atw* at cardbus? -#an* at pci? # Cisco/Aironet 802.11DS -an* at pcmcia? -#wi* at pci? # WaveLAN IEEE 802.11DS -wi* at pcmcia? -skc* at pci? # SysKonnect GEnesis 984x -sk* at skc? # each port of above -mskc* at pci? # Marvell Yukon-2 -msk* at mskc? # each port of above -bge* at pci? # Broadcom BCM570x (aka Tigon3) -hme* at pci? # Sun Happy Meal -stge* at pci? # Sundance TC9021 GigE - -dcphy* at mii? # Digital Clone PHYs -acphy* at mii? # Altima AC101 PHYs -amphy* at mii? # AMD 79C873 PHYs -exphy* at mii? # 3Com internal PHYs -gentbi* at mii? # Generic 1000BASE-X ten-bit PHY -inphy* at mii? # Intel 82555 PHYs -iophy* at mii? # Intel 82553 PHYs -icsphy* at mii? # ICS1890 PHYs -lxtphy* at mii? # Level One LXT-970 PHYs -nsphy* at mii? # NS83840 PHYs -nsphyter* at mii? # NS83843 PHYs -mtdphy* at mii? # Myson MTD972 PHYs -qsphy* at mii? # Quality Semi QS6612 PHYs -luphy* at mii? # Lucent LU6612 PHY -sqphy* at mii? # Seeq 8022[013] PHYs -#tlphy* at mii? # ThunderLAN PHYs -tqphy* at mii? # TDK Semiconductor PHYs -brgphy* at mii? # Broadcom 10/100/1000 PHYs -bmtphy* at mii? # Broadcom 10/100 PHYs -eephy* at mii? # Marvell 88E1000 Gigabit PHYs -xmphy* at mii? # XaQti XMAC-II PHYs -rlphy* at mii? # Realtek 8139 internal PHYs -urlphy* at mii? # Realtek RTL8150L internal PHY -rgephy* at mii? # Realtek 8169S/8110S PHY -ipgphy* at mii? # IC Plus IP1000A PHYs -ukphy* at mii? # generic unknown PHYs - -# MI devices -#wsdisplay* at vgafb? -wsdisplay* at sti? -wskbd* at pckbd? mux 1 -wskbd* at hilkbd? mux 1 -wsmouse* at pms? mux 0 -wsmouse* at hilms? mux 0 - -#fdc* at gsc? # PC floppy controller (WD37C65C) -#fdc* at isa? port 0x3f0 irq 6 drq 2 -#option FD_DEBUG -#fd* at fdc? # floppy drives - -pciide* at pci? flags 0x0000 -#wdc0 at isa? port 0x1f0 irq 14 -#wdc1 at isa? port 0x170 irq 15 -wdc* at pcmcia? -wd* at wdc? flags 0x0000 -wd* at pciide? flags 0x0000 -atapiscsi* at pciide? - -# These entries find devices on all SCSI busses and assign -# unit numbers dynamically. -scsibus* at scsi? -sd* at scsibus? -st* at scsibus? -cd* at scsibus? -ch* at scsibus? -safte* at scsibus? -ses* at scsibus? -uk* at scsibus? - -mpath0 at root -emc* at scsibus? -hds* at scsibus? -rdac* at scsibus? -sym* at scsibus? - -# 1-Wire devices -option ONEWIREVERBOSE -owid* at onewire? # ID -owsbm* at onewire? # Smart Battery Monitor -owtemp* at onewire? # Temperature -owctr* at onewire? # Counter device - -pseudo-device hotplug 1 # devices hot plugging -pseudo-device wsmux 2 # mouse and keyboard multiplexor diff --git a/sys/arch/hppa/conf/GENERIC.MP b/sys/arch/hppa/conf/GENERIC.MP deleted file mode 100644 index a93964094..000000000 --- a/sys/arch/hppa/conf/GENERIC.MP +++ /dev/null @@ -1,8 +0,0 @@ -# $OpenBSD: GENERIC.MP,v 1.1 2010/06/26 17:43:26 jsing Exp $ - -include "arch/hppa/conf/GENERIC" - -option MULTIPROCESSOR -#option MP_LOCKDEBUG - -cpu* at mainbus? diff --git a/sys/arch/hppa/conf/Makefile.hppa b/sys/arch/hppa/conf/Makefile.hppa deleted file mode 100644 index 44bc65b65..000000000 --- a/sys/arch/hppa/conf/Makefile.hppa +++ /dev/null @@ -1,174 +0,0 @@ -# $OpenBSD: Makefile.hppa,v 1.109 2021/01/28 17:39:03 deraadt Exp $ - -# For instructions on building kernels consult the config(8) and options(4) -# manual pages. -# -# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE -# IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING -# DEBUG is set to -g by config if debugging is requested (config -g). -# PROF is set to -pg by config if profiling is requested (config -p). - -.include - -SIZE?= size -STRIP?= ctfstrip - -# source tree is located via $S relative to the compilation directory -.ifndef S -S!= cd ../../../..; pwd -.endif - -_machdir?= $S/arch/${_mach} -_archdir?= $S/arch/${_arch} - -INCLUDES= -nostdinc -I$S -I${.OBJDIR} -I$S/arch -CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -MD -MP -CWARNFLAGS= -Werror -Wall -Wimplicit-function-declaration \ - -Wno-uninitialized -Wno-pointer-sign \ - -Wframe-larger-than=2047 - -CMACHFLAGS= -mfast-indirect-calls -mportable-runtime -mno-space-regs -CMACHFLAGS+= -ffreestanding ${NOPIE_FLAGS} -CMACHFLAGS+= -fno-stack-protector -SORTR= sort -R -.if ${IDENT:M-DSMALL_KERNEL} -SORTR= cat -COPTIMIZE?= -Oz -.endif - -DEBUG?= -g -COPTIMIZE?= -O2 -CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTIMIZE} ${COPTS} ${PIPE} -AFLAGS= -D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS} -LINKFLAGS= -X -T ld.script -Ttext 80000 --warn-common -nopie - -.if ${IDENT:M-DDDB} != "" -CFLAGS+= -fno-omit-frame-pointer -.endif -.if ${IDENT:M-DSMALL_KERNEL} -SORTR= cat -.endif - -.if ${IDENT:M-DHP7000_CPU} != "" -CFLAGS+= -mpa-risc-1-0 -.elif ${IDENT:M-DHP8*_CPU} != "" -CFLAGS+= -mpa-risc-2-0 -.else -CFLAGS+= -mpa-risc-1-1 -.endif - -HOSTCC?= ${CC} -HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//} -HOSTED_CFLAGS= ${CFLAGS} -HOSTED_C= ${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $< - -NORMAL_C_NOP= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< -NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $< -NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} ${PROF} -c $< - -%OBJS - -%CFILES - -%SFILES - -# load lines for config "xxx" will be emitted as: -# xxx: ${SYSTEM_DEP} swapxxx.o -# ${SYSTEM_LD_HEAD} -# ${SYSTEM_LD} swapxxx.o -# ${SYSTEM_LD_TAIL} -SYSTEM_HEAD= locore0.o gap.o -SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS} param.o ioconf.o -SYSTEM_DEP= Makefile ${SYSTEM_OBJ} ld.script -SYSTEM_LD_HEAD= @rm -f $@ -SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \ - umask 007; \ - echo ${OBJS} param.o ioconf.o vers.o | tr " " "\n" | ${SORTR} > lorder; \ - ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} `cat lorder` -SYSTEM_LD_TAIL= @${SIZE} $@ - -.if ${DEBUG} == "-g" -STRIPFLAGS= -S -SYSTEM_LD_TAIL+=; umask 007; \ - echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \ - echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \ - ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb -.else -LINKFLAGS+= -S -.endif - -%LOAD - -# cc's -MD puts the source and output paths in the dependency file; -# since those are temp files here we need to fix it up. It also -# puts the file in /tmp, so we use -MF to put it in the current -# directory as assym.P and then generate assym.d from it with a -# good target name -assym.h: $S/kern/genassym.sh Makefile \ - ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf - cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \ - sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp - sed '1s/.*/assym.h: \\/' assym.P > assym.d - sort -u assym.h.tmp > assym.h - -param.c: $S/conf/param.c - rm -f param.c - cp $S/conf/param.c . - -param.o: param.c Makefile - ${NORMAL_C} - -mcount.o: $S/lib/libkern/mcount.c Makefile - ${NORMAL_C_NOP} - -ioconf.o: ioconf.c - ${NORMAL_C} - -ld.script: ${_machdir}/conf/ld.script - cp ${_machdir}/conf/ld.script $@ - -makegap.sh: - cp $S/conf/makegap.sh $@ - -MAKE_GAP = LD="${LD}" sh makegap.sh 0x00000000 # BREAK 0,0 -> trap - -gap.o: Makefile makegap.sh vers.o - ${MAKE_GAP} - -vers.o: ${SYSTEM_DEP:Ngap.o} - sh $S/conf/newvers.sh - ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c - -clean: - rm -f *bsd *bsd.gdb *.[dio] [a-z]*.s assym.* \ - gap.link ld.script lorder makegap.sh param.c - -cleandir: clean - rm -f Makefile *.h ioconf.c options machine ${_mach} vers.c - -depend obj: - -locore0.o: ${_machdir}/${_mach}/locore0.S assym.h -locore.o: ${_machdir}/${_mach}/locore.S assym.h -fpemu.o spcopy.o: assym.h - -hardlink-obsd: - [[ ! -f /bsd ]] || cmp -s bsd /bsd || ln -f /bsd /obsd - -newinstall: - install -F -m 700 bsd /bsd && sha256 -h /var/db/kernel.SHA256 /bsd - -install: update-link hardlink-obsd newinstall - -# pull in the dependency information -.ifnmake clean -. for o in ${SYSTEM_OBJ:Ngap.o} assym.h -. if exists(${o:R}.d) -. include "${o:R}.d" -. elif exists($o) - .PHONY: $o -. endif -. endfor -.endif - -%RULES diff --git a/sys/arch/hppa/conf/RAMDISK b/sys/arch/hppa/conf/RAMDISK deleted file mode 100644 index 0a4ad401b..000000000 --- a/sys/arch/hppa/conf/RAMDISK +++ /dev/null @@ -1,216 +0,0 @@ -# $OpenBSD: RAMDISK,v 1.113 2019/09/04 14:29:41 cheloha Exp $ - -machine hppa -maxusers 4 - -option SMALL_KERNEL -option NO_PROPOLICE -option BOOT_CONFIG - -option RAMDISK_HOOKS -option MINIROOTSIZE=7920 - -option SCSITERSE -option PCIVERBOSE - -option FFS -option FFS2 -option NFSCLIENT -option CD9660 -option MSDOSFS -option INET6 - -# Support for various CPU types -option HP7000_CPU # PCXS -option HP7100_CPU # PCXT -option HP7200_CPU # PCXT' -option HP7100LC_CPU # PCXL -option HP7300LC_CPU # PCXL2 -option HP8000_CPU # PCXU (in 32bit mode) -option HP8200_CPU # PCXU2 (in 32bit mode) -option HP8500_CPU # PCXW (in 32bit mode) -option HP8700_CPU # PCXW2 (in 32bit mode) -option FPEMUL - -config bsd root on rd0a swap on rd0b # and sd0b - -mainbus0 at root - -mem* at mainbus0 flags 0x0000 # /dev/*mem and memory controller -pdc0 at mainbus0 # PDC/IODC wrapper for boot console -power0 at mainbus0 # power/fail manager (iv 30) -cpu* at mainbus0 irq 31 # HP PA-RISC cpu -#fpu* at mainbus0 # HP PA-RISC fpu (iv N/A) -phantomas0 at mainbus0 # Phantom PseudoBC GSC+ Port -uturn0 at mainbus0 # U2/UTurn Runway IOA -uturn1 at mainbus0 -astro* at mainbus0 # Astro memory & I/O controller - -lasi0 at mainbus0 offset 0x100000 # LASI host adapter -lasi0 at mainbus0 offset 0xfd00000 # LASI on C1[01]0, J2[01]0 -lasi0 at phantomas0 offset 0xfd00000 # LASI on [AB]* -lasi0 at uturn? offset 0xfd00000 # LASI on [CJ]* -lasi1 at mainbus0 offset 0x500000 # 712 GIO card -asp* at mainbus0 # this one comes w/ Viper and LEDs -wax* at mainbus0 # Wax may host EISA as well -wax* at phantomas0 # Wax on [AB]* -wax* at uturn? # Wax on C* -mongoose* at mainbus0 irq 17 # EISA Bus Adapter (i82350 or TI???) -dino* at phantomas? # PCI bus bridge on [AB]* -dino* at uturn? # PCI bus bridge on [CJ]* -pci* at dino? -com1 at dino? irq 11 - -elroy* at astro? -pci* at elroy? - -ppb* at pci? -pci* at ppb? - -ssio* at pci? -com0 at ssio? irq 4 -com1 at ssio? irq 3 - -cbb* at pci? -cardslot* at cbb? -cardbus* at cardslot? -pcmcia* at cardslot? - -ehci* at pci? -ehci* at cardbus? -ohci* at pci? -ohci* at cardbus? -uhci* at pci? -usb* at ehci? -usb* at uhci? -usb* at ohci? - -uhub* at usb? -uhub* at uhub? -umass* at uhub? -uhidev* at uhub? # Human Interface Devices -ukbd* at uhidev? # USB keyboard -wskbd* at ukbd? mux 1 -uhid* at uhidev? # USB generic HID support -aue* at uhub? # ADMtek AN986 Pegasus Ethernet -url* at uhub? # Realtek RTL8150L based adapters -ure* at uhub? # Realtek RTL8152 based adapters -atu* at uhub? # Atmel AT76c50x based 802.11b -axe* at uhub? # ASIX Electronics AX88172 USB Ethernet -axen* at uhub? # ASIX Electronics AX88179 USB Ethernet -cue* at uhub? # CATC USB-EL1201A based Ethernet -kue* at uhub? # Kawasaki KL5KUSB101B based Ethernet -smsc* at uhub? # SMSC LAN95xx Ethernet -cdce* at uhub? # CDC Ethernet -udav* at uhub? # Davicom DM9601 based Ethernet -upl* at uhub? # Prolific PL2301/PL2302 host-to-host -ugl* at uhub? # Genesys Logic GL620USB-A host-to-host -wi* at uhub? # WaveLAN IEEE 802.11DS -ural* at uhub? # Ralink RT2500 - -sti* at mainbus0 # [H]CRX-{8,24,48}[Z] graphics -sti* at phantomas0 # builtin graphics on BC* -sti* at uturn? -sti* at pci? # EG-PCI, FX* - -gsc0 at asp? # Snakes, old 715, old 725, 735/755 -gsc0 at lasi0 # 712,715/100,725/64,725/100,[ABCJ]* -gsc1 at lasi1 -gsc2 at wax? # it's another face of LASI - -eisa* at mongoose? - -hil* at gsc? irq 1 # Human Interface Loop, kbd and mouse -hilkbd* at hil? # keyboard, knob and buttons - -com0 at gsc0 offset 0x5000 irq 5 # on lasi -com1 at gsc1 offset 0x5000 irq 5 -com1 at gsc2 offset 0x2000 irq 6 # on wax -com0 at gsc0 offset 0x823000 irq 5 # on asp -com1 at gsc0 offset 0x822000 irq 6 -com2 at gsc0 offset 0x0 irq 13 # only on asp0 w/o audio (off ?) -com2 at gsc0 offset 0x4040 irq 13 # gecko's fax/voice/modems -com3 at gsc0 offset 0x4060 irq 13 - -ie0 at gsc0 irq 8 # 82C596DX/CA ether -osiop* at gsc? irq 9 # NCR 53C710 (Narrow SE) -oosiop* at gsc? irq 9 # NCR 53C700 (Narrow SE) -gsckbc* at gsc? irq 26 -pckbd* at gsckbc? # PS/2 keyboard -ahc* at pci? # Adaptec 2940 SCSI controllers -mpi* at pci? # LSI Logic Fusion MPT Message Passing Interface -qlw* at pci? # QLogic ISP SCSI -qla* at pci? # QLogic ISP 2[123]xx FibreChannel -option QLE_NOFIRMWARE -qle* at pci? # QLogic ISP 2[45]xx FibreChannel - -siop* at mainbus? irq 3 # NCR 53C720 (Fast/Wide HVD) -siop* at phantomas? irq 3 -siop* at uturn? irq 3 -siop* at pci? # NCR 53C8XX SCSI controllers -softraid0 at root - -em* at pci? # Intel Pro/1000 ethernet -dc* at pci? # 21143, "tulip" clone ethernet -rl* at pci? # Realtek 81[23]9 ethernet -xl* at pci? # 3C9xx ethernet -fxp* at pci? # EtherExpress 10/100B ethernet -ne* at pci? # NE2000-compatible Ethernet -ne* at pcmcia? -an* at pcmcia? -wi* at pcmcia? -skc* at pci? # SysKonnect GEnesis 984x -sk* at skc? # each port of above -mskc* at pci? # Marvell Yukon-2 -msk* at mskc? # each port of above -bge* at pci? # Broadcom BCM570x (aka Tigon3) -hme* at pci? # Sun Happy Meal -stge* at pci? # Sundance TC9021 GigE - -dcphy* at mii? # Digital Clone PHYs -acphy* at mii? # Altima AC101 PHYs -amphy* at mii? # AMD 79C873 PHYs -exphy* at mii? # 3Com internal PHYs -gentbi* at mii? # Generic 1000BASE-X ten-bit PHY -inphy* at mii? # Intel 82555 PHYs -iophy* at mii? # Intel 82553 PHYs -icsphy* at mii? # ICS1890 PHYs -lxtphy* at mii? # Level One LXT-970 PHYs -nsphy* at mii? # NS83840 PHYs -nsphyter* at mii? # NS83843 PHYs -mtdphy* at mii? # Myson MTD972 PHYs -qsphy* at mii? # Quality Semi QS6612 PHYs -luphy* at mii? # Lucent LU6612 PHY -sqphy* at mii? # Seeq 8022[013] PHYs -tqphy* at mii? # TDK Semiconductor PHYs -brgphy* at mii? # Broadcom 10/100/1000 PHYs -bmtphy* at mii? # Broadcom 10/100 PHYs -eephy* at mii? # Marvell 88E1000 Gigabit PHYs -xmphy* at mii? # XaQti XMAC-II PHYs -rlphy* at mii? # Realtek 8139 internal PHYs -urlphy* at mii? # Realtek RTL8150L internal PHY -rgephy* at mii? # Realtek 8169S/8110S PHY -ipgphy* at mii? # IC Plus IP1000A PHYs -ukphy* at mii? # generic unknown PHYs - -wsdisplay* at sti? -wskbd* at pckbd? mux 1 -wskbd* at hilkbd? mux 1 - -pciide* at pci? flags 0x0000 -wdc* at pcmcia? -wd* at wdc? flags 0x0000 -wd* at pciide? flags 0x0000 -atapiscsi* at pciide? - -scsibus* at scsi? -sd* at scsibus? -st* at scsibus? -cd* at scsibus? - -pseudo-device rd 1 -pseudo-device loop 1 -pseudo-device bpfilter 1 -pseudo-device vlan -pseudo-device wsmux 2 -pseudo-device bio 1 diff --git a/sys/arch/hppa/conf/files.hppa b/sys/arch/hppa/conf/files.hppa deleted file mode 100644 index 479897aa0..000000000 --- a/sys/arch/hppa/conf/files.hppa +++ /dev/null @@ -1,350 +0,0 @@ -# $OpenBSD: files.hppa,v 1.98 2018/02/14 23:51:49 jsg Exp $ -# -# hppa-specific configuration info - -# maxpartitions must be the first item in files.${ARCH} -maxpartitions 16 - -maxusers 2 8 128 - -# -# "workstation console" routines -# -include "dev/wscons/files.wscons" -file arch/hppa/hppa/wscons_machdep.c wsdisplay - -include "dev/rasops/files.rasops" -include "dev/wsfont/files.wsfont" - -# -# Media Independent Interface (mii) -# -include "dev/mii/files.mii" - -# -# Machine-independent SCSI drivers -# -include "scsi/files.scsi" -major {sd = 4} -major {st = 5} -major {cd = 6} - -# -# MI ATAPI drivers -# -include "dev/atapiscsi/files.atapiscsi" -include "dev/ata/files.ata" -major {wd = 8} - -# -# ISA Bus support -# -include "dev/isa/files.isa" -include "dev/isa/files.isapnp" - -# -# EISA Bus support -# -include "dev/eisa/files.eisa" - -# -# PCI Bus support -# -include "dev/pci/files.pci" - -device hme: ether, ifnet, mii, ifmedia -file dev/ic/hme.c hme -attach hme at pci with hme_pci -file dev/pci/if_hme_pci.c hme_pci - -# -# CardBus support -# -include "dev/cardbus/files.cardbus" - -# -# Machine-independent PCMCIA drivers -# -include "dev/pcmcia/files.pcmcia" - -# -# Machine-independent HID support -# -include "dev/hid/files.hid" - -# -# Machine-independent USB drivers -# -include "dev/usb/files.usb" - -# -# HIL Human Interface Loop devices -# -include "dev/hil/files.hil" - -# -# Machine-independent 1-Wire drivers -# -include "dev/onewire/files.onewire" - -# -# Gonzo System Connect Bus -# (GSC, GSC-1X, GSC+, GSC-1.5X, GSC-2X) -# -define gscbus {} - -# -# Mainbus -# - -define gedoens {[offset = -1], [irq = -1]} -device mainbus: gedoens -attach mainbus at root -file arch/hppa/hppa/mainbus.c mainbus - -device pdc -attach pdc at gedoens -file arch/hppa/dev/pdc.c pdc - -device power -attach power at gedoens -file arch/hppa/dev/power.c power needs-flag - -device lcd -attach lcd at gedoens -file arch/hppa/dev/lcd.c lcd needs-flag - -device mem -attach mem at gedoens -file arch/hppa/hppa/mem.c mem - -device cpu -attach cpu at gedoens -file arch/hppa/dev/cpu.c cpu - -device fpu -attach fpu at gedoens -file arch/hppa/dev/fpu.c fpu - -# Phantom PseudoBC GSC+ Port -device phantomas: gedoens -attach phantomas at gedoens -file arch/hppa/dev/phantomas.c phantomas - -# GeckoBOA BC GSC+ port -device gecko: gedoens -attach gecko at gedoens -file arch/hppa/dev/gecko.c gecko - -# U2/Uturn, Runway to GSC Bus bridge & IOA -device uturn: gedoens -attach uturn at gedoens -file arch/hppa/dev/uturn.c uturn - -# Astro memory & I/O controller -device astro: gedoens -attach astro at gedoens -file arch/hppa/dev/astro.c astro - -# 1FT1-0002, 1FU2-0002 -# as goes w/ 7100LC, 7300LC, 7200 and some of 8000, 8200, 8500 -device lasi: gscbus -attach lasi at gedoens -file arch/hppa/dev/lasi.c lasi - -# all the older systems -device asp: gscbus -attach asp at gedoens -file arch/hppa/dev/asp.c asp - -# 1FT4-0001, ASIC used on gecko cards -device wax: gscbus, isabus, eisabus -attach wax at gedoens -file arch/hppa/dev/wax.c wax - -device mongoose: isabus, eisabus -attach mongoose at gedoens with mg_gedoens -file arch/hppa/dev/mongoose.c mongoose - -define dinobus {[offset = -1], [irq = -1]} - -# Dino, GSC-PCI bridge. Includes ps/2, cereal and a flying toaster interfaces -# Cujo is a 64-bit data path Dino -device dino: pcibus, dinobus -attach dino at gedoens -file arch/hppa/dev/dino.c dino - -attach com at dinobus with com_dino -file arch/hppa/dev/com_dino.c com_dino - -# Elroy, Ropes to PCI Bridge. Supports 4X PCI and dual address cycle. -# Mercury; QuickSilver is an AGP also -device elroy: pcibus -attach elroy at gedoens -file arch/hppa/dev/elroy.c elroy -file arch/hppa/dev/apic.c elroy - -attach sti at gedoens with sti_gedoens -file arch/hppa/dev/sti_sgc.c sti_gedoens -file arch/hppa/dev/sti_pci_machdep.c sti_pci - -attach siop at gedoens with siop_gedoens -file arch/hppa/dev/siop_sgc.c siop_gedoens - -device ssio {[irq = -1]} -attach ssio at pci -file arch/hppa/dev/ssio.c ssio - -attach com at ssio with com_ssio -file arch/hppa/dev/com_ssio.c com_ssio - -attach lpt at ssio with lpt_ssio -file arch/hppa/dev/lpt_ssio.c lpt_ssio - -### - -major {vnd = 2} -major {rd = 3} - -# -# GSC bus devices -# - -device gsc {[offset = -1], [irq = -1]} -attach gsc at gscbus -file arch/hppa/gsc/gscbus.c gsc - -# com and lpt are both on WD 16C552 -attach com at gsc with com_gsc -file arch/hppa/gsc/com_gsc.c com_gsc - -attach lpt at gsc with lpt_gsc -file arch/hppa/gsc/lpt_gsc.c lpt_gsc - -attach mongoose at gsc with mg_gsc -file arch/hppa/gsc/mongoose_gsc.c mg_gsc - -#include "dev/fdc/files.fdc" -#major {fd = 7} -#attach fdc at gsc with fdc_gsc -#file arch/hppa/gsc/fdc_gsc.c fdc_gsc - -attach ie at gsc with ie_gsc -file arch/hppa/gsc/if_ie_gsc.c ie_gsc - -attach siop at gsc with siop_gsc -file arch/hppa/gsc/siop_gsc.c siop_gsc - -attach osiop at gsc with osiop_gsc -file arch/hppa/gsc/osiop_gsc.c osiop_gsc - -attach oosiop at gsc with oosiop_gsc -file arch/hppa/gsc/oosiop_gsc.c oosiop_gsc - -attach hil at gsc with hil_gsc -file arch/hppa/gsc/hil_gsc.c hil_gsc - -# PSB 2160-N based 8bit mono audio (705, 710, 745i/*, 747i/*) -attach arcofi at gsc with arcofi_gsc -file arch/hppa/gsc/arcofi_gsc.c arcofi_gsc - -# CS4215/AD1849 based 16bit mono/stereo audio iface (most of others not w/ aone) -# a.k.a. Audio Type 2 (optional beeper) -device harmony: audio -attach harmony at gsc -file arch/hppa/gsc/harmony.c harmony - -# PS/2 input ports -device gsckbc: pckbcslot -attach gsckbc at gsc -file arch/hppa/gsc/gsckbc.c gsckbc - -# PS/2 keyboard and mouse -include "dev/pckbc/files.pckbc" - -# -# Non-device files -# - -file arch/hppa/hppa/autoconf.c -file arch/hppa/hppa/conf.c -file arch/hppa/hppa/db_interface.c ddb -file arch/hppa/hppa/db_disasm.c ddb -file arch/hppa/hppa/disksubr.c disk -file arch/hppa/hppa/fpu.c -file arch/hppa/hppa/ipi.c multiprocessor -file arch/hppa/hppa/lock_machdep.c multiprocessor -file arch/hppa/hppa/machdep.c -file arch/hppa/hppa/mutex.c -file arch/hppa/hppa/pmap.c -file arch/hppa/hppa/process_machdep.c -file arch/hppa/hppa/sys_machdep.c -file arch/hppa/hppa/trap.c -file arch/hppa/hppa/intr.c -file arch/hppa/hppa/vm_machdep.c -file arch/hppa/hppa/in_cksum.c -file arch/hppa/hppa/locore.S -file netinet/in4_cksum.c -file arch/hppa/dev/clock.c -file arch/hppa/hppa/fpemu.S fpemul - -# quad support is necessary for 32 bit architectures -file lib/libkern/adddi3.c -file lib/libkern/anddi3.c -file lib/libkern/ashldi3.c -file lib/libkern/ashrdi3.c -file lib/libkern/cmpdi2.c -file lib/libkern/divdi3.c -file lib/libkern/iordi3.c -file lib/libkern/lshldi3.c -file lib/libkern/lshrdi3.c -file lib/libkern/moddi3.c -file lib/libkern/muldi3.c -file lib/libkern/negdi2.c -file lib/libkern/notdi2.c -file lib/libkern/qdivrem.c -file lib/libkern/subdi3.c -file lib/libkern/ucmpdi2.c -file lib/libkern/udivdi3.c -file lib/libkern/umoddi3.c -file lib/libkern/xordi3.c - -# kern.. -file lib/libkern/arch/hppa/milli.S -file lib/libkern/arch/hppa/spcopy.S - -# fpu emulation -file arch/hppa/spmath/dfadd.c fpemul -file arch/hppa/spmath/dfcmp.c fpemul -file arch/hppa/spmath/dfdiv.c fpemul -file arch/hppa/spmath/dfmpy.c fpemul -file arch/hppa/spmath/dfrem.c fpemul -file arch/hppa/spmath/dfsqrt.c fpemul -file arch/hppa/spmath/dfsub.c fpemul -file arch/hppa/spmath/divsfm.c fpemul -file arch/hppa/spmath/divsfr.c fpemul -file arch/hppa/spmath/divsim.c fpemul -file arch/hppa/spmath/divsir.c fpemul -file arch/hppa/spmath/divufr.c fpemul -file arch/hppa/spmath/divuir.c fpemul -file arch/hppa/spmath/fcnvff.c fpemul -file arch/hppa/spmath/fcnvfx.c fpemul -file arch/hppa/spmath/fcnvfxt.c fpemul -file arch/hppa/spmath/fcnvxf.c fpemul -file arch/hppa/spmath/frnd.c fpemul -file arch/hppa/spmath/mpyaccs.c fpemul -file arch/hppa/spmath/mpyaccu.c fpemul -file arch/hppa/spmath/mpys.c fpemul -file arch/hppa/spmath/mpyscv.c fpemul -file arch/hppa/spmath/mpyu.c fpemul -file arch/hppa/spmath/mpyucv.c fpemul -file arch/hppa/spmath/sfadd.c fpemul -file arch/hppa/spmath/sfcmp.c fpemul -file arch/hppa/spmath/sfdiv.c fpemul -file arch/hppa/spmath/sfmpy.c fpemul -file arch/hppa/spmath/sfrem.c fpemul -file arch/hppa/spmath/sfsqrt.c fpemul -file arch/hppa/spmath/sfsub.c fpemul -file arch/hppa/spmath/divu.S fpemul -file arch/hppa/spmath/impys.S fpemul -file arch/hppa/spmath/impyu.S fpemul diff --git a/sys/arch/hppa/conf/ld.script b/sys/arch/hppa/conf/ld.script deleted file mode 100644 index 27ebb7fbd..000000000 --- a/sys/arch/hppa/conf/ld.script +++ /dev/null @@ -1,85 +0,0 @@ -/* $OpenBSD: ld.script,v 1.19 2017/06/21 23:21:35 deraadt Exp $ */ - -/* - * Copyright (c) 2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - - -OUTPUT_FORMAT("elf32-hppa") -OUTPUT_ARCH(hppa) -ENTRY($start) -SECTIONS -{ - . = + SIZEOF_HEADERS; - .text : - { - kernel_text = . ; - *(.text) *(.text.*) - *(.reginfo) - *(.init) - *(.stub) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - . = ALIGN(4096); - etext = ABSOLUTE(.); - } =0x00000000 - - . = 0x600000; - - .rodata : - { - __rodata_start = .; - *(.rodata) *(.rodata1) - . = ALIGN(8); - __unwind_start = .; - *(.PARISC.unwind) - __unwind_end = .; - . = ALIGN(4096); - __rodata_end = .; - } =0x00000000 - __data_start = ABSOLUTE(.); - - .data : - { - $global$ = . ; - . += 4; - *(.data) - CONSTRUCTORS - . = ALIGN(4096); - edata = ABSOLUTE(.); - } =0x00000000 - .ctors : { *(.ctors) } - .dtors : { *(.dtors) } - - __bss_start = .; - /* .sbss : { *(.sbss) *(.scommon) } */ - .bss : - { - *(.dynbss) *(.bss) - *(COMMON) *($COMMON$) - . = ALIGN(4096); - } - end = ABSOLUTE(.); -} diff --git a/sys/arch/hppa/dev/Makefile b/sys/arch/hppa/dev/Makefile deleted file mode 100644 index 05163bcd0..000000000 --- a/sys/arch/hppa/dev/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# $OpenBSD: Makefile,v 1.4 2014/07/16 20:08:25 okan Exp $ - -AWK?= awk - -cpudevs.h cpudevs_data.h: cpudevs devlist2h.awk - /bin/rm -f cpudevs.h cpudevs_data.h - ${AWK} -f devlist2h.awk cpudevs diff --git a/sys/arch/hppa/dev/apic.c b/sys/arch/hppa/dev/apic.c deleted file mode 100644 index ee416c6e4..000000000 --- a/sys/arch/hppa/dev/apic.c +++ /dev/null @@ -1,360 +0,0 @@ -/* $OpenBSD: apic.c,v 1.19 2018/05/14 13:54:39 kettenis Exp $ */ - -/* - * Copyright (c) 2005 Michael Shalayeff - * Copyright (c) 2007 Mark Kettenis - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#define APIC_INT_LINE_MASK 0x0000ff00 -#define APIC_INT_LINE_SHIFT 8 -#define APIC_INT_IRQ_MASK 0x0000001f - -#define APIC_INT_LINE(x) (((x) & APIC_INT_LINE_MASK) >> APIC_INT_LINE_SHIFT) -#define APIC_INT_IRQ(x) ((x) & APIC_INT_IRQ_MASK) - -/* - * Interrupt types match the Intel MP Specification. - */ - -#define MPS_INTPO_DEF 0 -#define MPS_INTPO_ACTHI 1 -#define MPS_INTPO_ACTLO 3 -#define MPS_INTPO_SHIFT 0 -#define MPS_INTPO_MASK 3 - -#define MPS_INTTR_DEF 0 -#define MPS_INTTR_EDGE 1 -#define MPS_INTTR_LEVEL 3 -#define MPS_INTTR_SHIFT 2 -#define MPS_INTTR_MASK 3 - -#define MPS_INT(p,t) \ - ((((p) & MPS_INTPO_MASK) << MPS_INTPO_SHIFT) | \ - (((t) & MPS_INTTR_MASK) << MPS_INTTR_SHIFT)) - -struct apic_iv { - struct elroy_softc *sc; - pci_intr_handle_t ih; - int (*handler)(void *); - void *arg; - struct apic_iv *next; - struct evcount *cnt; -}; - -struct apic_iv *apic_intr_list[CPU_NINTS]; - -void apic_get_int_tbl(struct elroy_softc *); -u_int32_t apic_get_int_ent0(struct elroy_softc *, int); -#ifdef DEBUG -void apic_dump(struct elroy_softc *); -#endif - -void apic_write(volatile struct elroy_regs *r, u_int32_t reg, - u_int32_t val); -u_int32_t apic_read(volatile struct elroy_regs *r, u_int32_t reg); - -void -apic_write(volatile struct elroy_regs *r, u_int32_t reg, u_int32_t val) -{ - elroy_write32(&r->apic_addr, htole32(reg)); - elroy_write32(&r->apic_data, htole32(val)); - elroy_read32(&r->apic_data); -} - -u_int32_t -apic_read(volatile struct elroy_regs *r, u_int32_t reg) -{ - elroy_write32(&r->apic_addr, htole32(reg)); - return letoh32(elroy_read32(&r->apic_data)); -} - -void -apic_attach(struct elroy_softc *sc) -{ - volatile struct elroy_regs *r = sc->sc_regs; - u_int32_t data; - - data = apic_read(r, APIC_VERSION); - sc->sc_nints = (data & APIC_VERSION_NENT) >> APIC_VERSION_NENT_SHIFT; - printf(" APIC ver %x, %d pins", - data & APIC_VERSION_MASK, sc->sc_nints); - - sc->sc_irq = mallocarray(sc->sc_nints, sizeof(int), M_DEVBUF, - M_NOWAIT | M_ZERO); - if (sc->sc_irq == NULL) - panic("apic_attach: cannot allocate irq table"); - - apic_get_int_tbl(sc); - -#ifdef DEBUG - apic_dump(sc); -#endif -} - -int -apic_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) -{ - struct elroy_softc *sc = pa->pa_pc->_cookie; - pci_chipset_tag_t pc = pa->pa_pc; - pcitag_t tag = pa->pa_tag; - pcireg_t reg; - int line; - - reg = pci_conf_read(pc, tag, PCI_INTERRUPT_REG); -#ifdef DEBUG - printf(" pin=%d line=%d ", PCI_INTERRUPT_PIN(reg), - PCI_INTERRUPT_LINE(reg)); -#endif - line = PCI_INTERRUPT_LINE(reg); - if (sc->sc_irq[line] <= 0) { - if ((sc->sc_irq[line] = cpu_intr_findirq()) == -1) - return 1; - } - *ihp = (line << APIC_INT_LINE_SHIFT) | sc->sc_irq[line]; - return (APIC_INT_IRQ(*ihp) == 0); -} - -const char * -apic_intr_string(void *v, pci_intr_handle_t ih) -{ - static char buf[32]; - - snprintf(buf, 32, "line %ld irq %ld", - APIC_INT_LINE(ih), APIC_INT_IRQ(ih)); - - return (buf); -} - -void * -apic_intr_establish(void *v, pci_intr_handle_t ih, - int pri, int (*handler)(void *), void *arg, const char *name) -{ - struct elroy_softc *sc = v; - volatile struct elroy_regs *r = sc->sc_regs; - hppa_hpa_t hpa = cpu_gethpa(0); - struct evcount *cnt; - struct apic_iv *aiv, *biv; - void *iv; - int irq = APIC_INT_IRQ(ih); - int line = APIC_INT_LINE(ih); - u_int32_t ent0; - - /* no mapping or bogus */ - if (irq <= 0 || irq > 31) - return (NULL); - - aiv = malloc(sizeof(struct apic_iv), M_DEVBUF, M_NOWAIT); - if (aiv == NULL) - return (NULL); - - cnt = malloc(sizeof(struct evcount), M_DEVBUF, M_NOWAIT); - if (!cnt) { - free(aiv, M_DEVBUF, sizeof *aiv); - return (NULL); - } - - aiv->sc = sc; - aiv->ih = ih; - aiv->handler = handler; - aiv->arg = arg; - aiv->next = NULL; - aiv->cnt = cnt; - - evcount_attach(cnt, name, NULL); - - if (apic_intr_list[irq]) { - biv = apic_intr_list[irq]; - while (biv->next) - biv = biv->next; - biv->next = aiv; - return (arg); - } - - if ((iv = cpu_intr_establish(pri, irq, apic_intr, aiv, NULL))) { - ent0 = (31 - irq) & APIC_ENT0_VEC; - ent0 |= apic_get_int_ent0(sc, line); -#if 0 - if (cold) { - sc->sc_imr |= (1 << irq); - ent0 |= APIC_ENT0_MASK; - } -#endif - apic_write(sc->sc_regs, APIC_ENT0(line), APIC_ENT0_MASK); - apic_write(sc->sc_regs, APIC_ENT1(line), - ((hpa & 0x0ff00000) >> 4) | ((hpa & 0x000ff000) << 12)); - apic_write(sc->sc_regs, APIC_ENT0(line), ent0); - - /* Signal EOI. */ - elroy_write32(&r->apic_eoi, - htole32((31 - irq) & APIC_ENT0_VEC)); - - apic_intr_list[irq] = aiv; - } - - return (arg); -} - -void -apic_intr_disestablish(void *v, void *cookie) -{ -} - -int -apic_intr(void *v) -{ - struct apic_iv *iv = v; - struct elroy_softc *sc = iv->sc; - volatile struct elroy_regs *r = sc->sc_regs; - pci_intr_handle_t ih = iv->ih; - int claimed = 0; - - while (iv) { - claimed = iv->handler(iv->arg); - if (claimed != 0 && iv->cnt) - iv->cnt->ec_count++; - if (claimed == 1) - break; - iv = iv->next; - } - - /* Signal EOI. */ - elroy_write32(&r->apic_eoi, - htole32((31 - APIC_INT_IRQ(ih)) & APIC_ENT0_VEC)); - - return (claimed); -} - -/* Maximum number of supported interrupt routing entries. */ -#define MAX_INT_TBL_SZ 16 - -void -apic_get_int_tbl(struct elroy_softc *sc) -{ - struct pdc_pat_io_num int_tbl_sz PDC_ALIGNMENT; - struct pdc_pat_pci_rt int_tbl[MAX_INT_TBL_SZ] PDC_ALIGNMENT; - size_t size; - - /* - * XXX int_tbl should not be allocated on the stack, but we need a - * 1:1 mapping, and malloc doesn't provide that. - */ - - if (pdc_call((iodcio_t)pdc, 0, PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL_SZ, - &int_tbl_sz, 0, 0, 0, 0, 0)) - return; - - if (int_tbl_sz.num > MAX_INT_TBL_SZ) - panic("interrupt routing table too big (%d entries)", - int_tbl_sz.num); - - size = int_tbl_sz.num * sizeof(struct pdc_pat_pci_rt); - sc->sc_int_tbl_sz = int_tbl_sz.num; - sc->sc_int_tbl = malloc(size, M_DEVBUF, M_NOWAIT); - if (sc->sc_int_tbl == NULL) - return; - - if (pdc_call((iodcio_t)pdc, 0, PDC_PCI_INDEX, PDC_PCI_GET_INT_TBL, - &int_tbl_sz, 0, &int_tbl, 0, 0, 0)) - return; - - memcpy(sc->sc_int_tbl, int_tbl, size); -} - -u_int32_t -apic_get_int_ent0(struct elroy_softc *sc, int line) -{ - volatile struct elroy_regs *r = sc->sc_regs; - int trigger = MPS_INT(MPS_INTPO_DEF, MPS_INTTR_DEF); - u_int32_t ent0 = APIC_ENT0_LOW | APIC_ENT0_LEV; - int bus, mpspo, mpstr; - int i; - - bus = letoh32(elroy_read32(&r->busnum)) & 0xff; - for (i = 0; i < sc->sc_int_tbl_sz; i++) { - if (bus == sc->sc_int_tbl[i].bus && - line == sc->sc_int_tbl[i].line) - trigger = sc->sc_int_tbl[i].trigger; - } - - mpspo = (trigger >> MPS_INTPO_SHIFT) & MPS_INTPO_MASK; - mpstr = (trigger >> MPS_INTTR_SHIFT) & MPS_INTTR_MASK; - - switch (mpspo) { - case MPS_INTPO_DEF: - break; - case MPS_INTPO_ACTHI: - ent0 &= ~APIC_ENT0_LOW; - break; - case MPS_INTPO_ACTLO: - ent0 |= APIC_ENT0_LOW; - break; - default: - panic("unknown MPS interrupt polarity %d", mpspo); - } - - switch(mpstr) { - case MPS_INTTR_DEF: - break; - case MPS_INTTR_LEVEL: - ent0 |= APIC_ENT0_LEV; - break; - case MPS_INTTR_EDGE: - ent0 &= ~APIC_ENT0_LEV; - break; - default: - panic("unknown MPS interrupt trigger %d", mpstr); - } - - return ent0; -} - -#ifdef DEBUG -void -apic_dump(struct elroy_softc *sc) -{ - int i; - - for (i = 0; i < sc->sc_nints; i++) - printf("0x%04x 0x%04x\n", apic_read(sc->sc_regs, APIC_ENT0(i)), - apic_read(sc->sc_regs, APIC_ENT1(i))); - - for (i = 0; i < sc->sc_int_tbl_sz; i++) { - printf("type=%x ", sc->sc_int_tbl[i].type); - printf("len=%d ", sc->sc_int_tbl[i].len); - printf("itype=%d ", sc->sc_int_tbl[i].itype); - printf("trigger=%x ", sc->sc_int_tbl[i].trigger); - printf("pin=%x ", sc->sc_int_tbl[i].pin); - printf("bus=%d ", sc->sc_int_tbl[i].bus); - printf("line=%d ", sc->sc_int_tbl[i].line); - printf("addr=%x\n", sc->sc_int_tbl[i].addr); - } -} -#endif diff --git a/sys/arch/hppa/dev/asp.c b/sys/arch/hppa/dev/asp.c deleted file mode 100644 index 56e2d7e82..000000000 --- a/sys/arch/hppa/dev/asp.c +++ /dev/null @@ -1,194 +0,0 @@ -/* $OpenBSD: asp.c,v 1.15 2018/05/14 13:54:39 kettenis Exp $ */ - -/* - * Copyright (c) 1998-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -/* - * References: - * - * 1. Cobra/Coral I/O Subsystem External Reference Specification - * Hewlett-Packard - * - */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -struct asp_hwr { - u_int8_t asp_reset; - u_int8_t asp_resv[31]; - u_int8_t asp_version; - u_int8_t asp_resv1[15]; - u_int8_t asp_scsidsync; - u_int8_t asp_resv2[15]; - u_int8_t asp_error; -}; - -struct asp_trs { - struct gscbus_ic asp_ic; - u_int8_t asp_cled; - u_int8_t asp_resv[3]; - struct { - u_int :20, - asp_spu : 3, /* SPU ID board jumper */ -#define ASP_SPUCOBRA 0 -#define ASP_SPUCORAL 1 -#define ASP_SPUBUSH 2 -#define ASP_SPUHARDBALL 3 -#define ASP_SPUSCORPIO 4 -#define ASP_SPUCORAL2 5 - asp_sw : 1, /* front switch is normal */ - asp_clk : 1, /* SCSI clock is doubled */ - asp_lan : 2, /* LAN iface selector */ -#define ASP_LANINVAL 0 -#define ASP_LANAUI 1 -#define ASP_LANTHIN 2 -#define ASP_LANMISS 3 - asp_lanf: 1, /* LAN AUI fuse is ok */ - asp_spwr: 1, /* SCSI power ok */ - asp_scsi: 3; /* SCSI ctrl ID */ - } _asp_ios; -#define asp_spu _asp_ios.asp_spu -#define asp_sw _asp_ios.asp_sw -#define asp_clk _asp_ios.asp_clk -#define asp_lan _asp_ios.asp_lan -#define asp_lanf _asp_ios.asp_lanf -#define asp_spwr _asp_ios.asp_spwr -#define asp_scsi _asp_ios.asp_scsi -}; - -const struct asp_spus_tag { - char name[12]; - int ledword; -} asp_spus[] = { - { "Cobra", 0 }, - { "Coral", 0 }, - { "Bushmaster", 0 }, - { "Hardball", 1 }, - { "Scorpio", 0 }, - { "Coral II", 1 }, - { "#6", 0 }, - { "#7", 0 } -}; - -#define ASP_IOMASK 0xfe000000 -/* ASP "Primary Controller" HPA */ -#define ASP_CHPA 0xF0800000 - -int aspmatch(struct device *, void *, void *); -void aspattach(struct device *, struct device *, void *); - -const struct cfattach asp_ca = { - sizeof(struct device), aspmatch, aspattach -}; - -struct cfdriver asp_cd = { - NULL, "asp", DV_DULL -}; - -int -aspmatch(parent, cfdata, aux) - struct device *parent; - void *cfdata; - void *aux; -{ - struct confargs *ca = aux; - /* struct cfdata *cf = cfdata; */ - - if (ca->ca_type.iodc_type != HPPA_TYPE_BHA || - ca->ca_type.iodc_sv_model != HPPA_BHA_ASP) - return 0; - - return 1; -} - -void -aspattach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -{ - struct confargs *ca = aux; - volatile struct asp_trs *trs; - volatile struct asp_hwr *hw; - struct gscbus_ic *ic; - struct gsc_attach_args ga; - bus_space_handle_t ioh; - int s; - - if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) { - printf(": can't map IO space\n"); - return; - } - - hw = (struct asp_hwr *)ca->ca_hpa; - trs = (struct asp_trs *)ASP_CHPA; - ic = (struct gscbus_ic *)&trs->asp_ic; - -#ifdef USELEDS - machine_ledaddr = &trs->asp_cled; - machine_ledword = asp_spus[trs->asp_spu].ledword; -#endif - - /* reset ASP */ - /* hw->asp_reset = 1; */ - /* delay(400000); */ - - s = splhigh(); - ic->imr = ~0; - (void)ic->irr; - ic->imr = 0; - splx(s); - - printf (": %s rev %d, lan %d scsi %d\n", - asp_spus[trs->asp_spu].name, hw->asp_version, - trs->asp_lan, trs->asp_scsi); - - ga.ga_ca = *ca; /* clone from us */ - ga.ga_dp.dp_bc[0] = ga.ga_dp.dp_bc[1]; - ga.ga_dp.dp_bc[1] = ga.ga_dp.dp_bc[2]; - ga.ga_dp.dp_bc[2] = ga.ga_dp.dp_bc[3]; - ga.ga_dp.dp_bc[3] = ga.ga_dp.dp_bc[4]; - ga.ga_dp.dp_bc[4] = ga.ga_dp.dp_bc[5]; - ga.ga_dp.dp_bc[5] = ga.ga_dp.dp_mod; - ga.ga_dp.dp_mod = 0; - ga.ga_hpamask = ASP_IOMASK; - ga.ga_name = "gsc"; - ga.ga_parent = gsc_asp; - ga.ga_ic = ic; - config_found(self, &ga, gscprint); -} diff --git a/sys/arch/hppa/dev/astro.c b/sys/arch/hppa/dev/astro.c deleted file mode 100644 index e34608072..000000000 --- a/sys/arch/hppa/dev/astro.c +++ /dev/null @@ -1,763 +0,0 @@ -/* $OpenBSD: astro.c,v 1.18 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2007 Mark Kettenis - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -struct astro_regs { - u_int32_t rid; - u_int32_t pad0000; - u_int32_t ioc_ctrl; - u_int32_t pad0008; - u_int8_t resv1[0x0300 - 0x0010]; - u_int64_t lmmio_direct0_base; - u_int64_t lmmio_direct0_mask; - u_int64_t lmmio_direct0_route; - u_int64_t lmmio_direct1_base; - u_int64_t lmmio_direct1_mask; - u_int64_t lmmio_direct1_route; - u_int64_t lmmio_direct2_base; - u_int64_t lmmio_direct2_mask; - u_int64_t lmmio_direct2_route; - u_int64_t lmmio_direct3_base; - u_int64_t lmmio_direct3_mask; - u_int64_t lmmio_direct3_route; - u_int64_t lmmio_dist_base; - u_int64_t lmmio_dist_mask; - u_int64_t lmmio_dist_route; - u_int64_t gmmio_dist_base; - u_int64_t gmmio_dist_mask; - u_int64_t gmmio_dist_route; - u_int64_t ios_dist_base; - u_int64_t ios_dist_mask; - u_int64_t ios_dist_route; - u_int8_t resv2[0x03c0 - 0x03a8]; - u_int64_t ios_direct_base; - u_int64_t ios_direct_mask; - u_int64_t ios_direct_route; - u_int8_t resv3[0x22000 - 0x03d8]; - u_int64_t func_id; - u_int64_t func_class; - u_int8_t resv4[0x22040 - 0x22010]; - u_int64_t rope_config; - u_int8_t resv5[0x22050 - 0x22048]; - u_int64_t rope_debug; - u_int8_t resv6[0x22200 - 0x22058]; - u_int64_t rope0_control; - u_int64_t rope1_control; - u_int64_t rope2_control; - u_int64_t rope3_control; - u_int64_t rope4_control; - u_int64_t rope5_control; - u_int64_t rope6_control; - u_int64_t rope7_control; - u_int8_t resv7[0x22300 - 0x22240]; - u_int32_t tlb_ibase; - u_int32_t pad22300; - u_int32_t tlb_imask; - u_int32_t pad22308; - u_int32_t tlb_pcom; - u_int32_t pad22310; - u_int32_t tlb_tcnfg; - u_int32_t pad22318; - u_int64_t tlb_pdir_base; -}; - -#define ASTRO_IOC_CTRL_TE 0x0001 /* TOC Enable */ -#define ASTRO_IOC_CTRL_CE 0x0002 /* Coalesce Enable */ -#define ASTRO_IOC_CTRL_DE 0x0004 /* Dillon Enable */ -#define ASTRO_IOC_CTRL_IE 0x0008 /* IOS Enable */ -#define ASTRO_IOC_CTRL_OS 0x0010 /* Outbound Synchronous */ -#define ASTRO_IOC_CTRL_IS 0x0020 /* Inbound Synchronous */ -#define ASTRO_IOC_CTRL_RC 0x0040 /* Read Current Enable */ -#define ASTRO_IOC_CTRL_L0 0x0080 /* 0-length Read Enable */ -#define ASTRO_IOC_CTRL_RM 0x0100 /* Real Mode */ -#define ASTRO_IOC_CTRL_NC 0x0200 /* Non-coherent Mode */ -#define ASTRO_IOC_CTRL_ID 0x0400 /* Interrupt Disable */ -#define ASTRO_IOC_CTRL_D4 0x0800 /* Disable 4-byte Coalescing */ -#define ASTRO_IOC_CTRL_CC 0x1000 /* Increase Coalescing counter value */ -#define ASTRO_IOC_CTRL_DD 0x2000 /* Disable distr. range coalescing */ -#define ASTRO_IOC_CTRL_DC 0x4000 /* Disable the coalescing counter */ - -#define IOTTE_V 0x8000000000000000LL /* Entry valid */ -#define IOTTE_PAMASK 0x000000fffffff000LL -#define IOTTE_CI 0x00000000000000ffLL /* Coherent index */ - -struct astro_softc { - struct device sc_dv; - - bus_dma_tag_t sc_dmat; - struct astro_regs volatile *sc_regs; - u_int64_t *sc_pdir; - - char sc_dvmamapname[20]; - struct extent *sc_dvmamap; - struct mutex sc_dvmamtx; - - struct hppa_bus_dma_tag sc_dmatag; -}; - -/* - * per-map DVMA page table - */ -struct iommu_page_entry { - SPLAY_ENTRY(iommu_page_entry) ipe_node; - paddr_t ipe_pa; - vaddr_t ipe_va; - bus_addr_t ipe_dva; -}; - -struct iommu_page_map { - SPLAY_HEAD(iommu_page_tree, iommu_page_entry) ipm_tree; - int ipm_maxpage; /* Size of allocated page map */ - int ipm_pagecnt; /* Number of entries in use */ - struct iommu_page_entry ipm_map[1]; -}; - -/* - * per-map IOMMU state - */ -struct iommu_map_state { - struct astro_softc *ims_sc; - bus_addr_t ims_dvmastart; - bus_size_t ims_dvmasize; - struct extent_region ims_er; - struct iommu_page_map ims_map; /* map must be last (array at end) */ -}; - -int astro_match(struct device *, void *, void *); -void astro_attach(struct device *, struct device *, void *); - -const struct cfattach astro_ca = { - sizeof(struct astro_softc), astro_match, astro_attach -}; - -struct cfdriver astro_cd = { - NULL, "astro", DV_DULL -}; - -int iommu_dvmamap_create(void *, bus_size_t, int, bus_size_t, bus_size_t, - int, bus_dmamap_t *); -void iommu_dvmamap_destroy(void *, bus_dmamap_t); -int iommu_dvmamap_load(void *, bus_dmamap_t, void *, bus_size_t, - struct proc *, int); -int iommu_iomap_load_map(struct astro_softc *, bus_dmamap_t, int); -int iommu_dvmamap_load_mbuf(void *, bus_dmamap_t, struct mbuf *, int); -int iommu_dvmamap_load_uio(void *, bus_dmamap_t, struct uio *, int); -int iommu_dvmamap_load_raw(void *, bus_dmamap_t, bus_dma_segment_t *, - int, bus_size_t, int); -void iommu_dvmamap_unload(void *, bus_dmamap_t); -void iommu_dvmamap_sync(void *, bus_dmamap_t, bus_addr_t, bus_size_t, int); -int iommu_dvmamem_alloc(void *, bus_size_t, bus_size_t, bus_size_t, - bus_dma_segment_t *, int, int *, int); -void iommu_dvmamem_free(void *, bus_dma_segment_t *, int); -int iommu_dvmamem_map(void *, bus_dma_segment_t *, int, size_t, - caddr_t *, int); -void iommu_dvmamem_unmap(void *, caddr_t, size_t); -paddr_t iommu_dvmamem_mmap(void *, bus_dma_segment_t *, int, off_t, int, int); - -void iommu_enter(struct astro_softc *, bus_addr_t, paddr_t, vaddr_t, int); -void iommu_remove(struct astro_softc *, bus_addr_t); - -struct iommu_map_state *iommu_iomap_create(int); -void iommu_iomap_destroy(struct iommu_map_state *); -int iommu_iomap_insert_page(struct iommu_map_state *, vaddr_t, paddr_t); -bus_addr_t iommu_iomap_translate(struct iommu_map_state *, paddr_t); -void iommu_iomap_clear_pages(struct iommu_map_state *); - -const struct hppa_bus_dma_tag astro_dmat = { - NULL, - iommu_dvmamap_create, iommu_dvmamap_destroy, - iommu_dvmamap_load, iommu_dvmamap_load_mbuf, - iommu_dvmamap_load_uio, iommu_dvmamap_load_raw, - iommu_dvmamap_unload, iommu_dvmamap_sync, - - iommu_dvmamem_alloc, iommu_dvmamem_free, iommu_dvmamem_map, - iommu_dvmamem_unmap, iommu_dvmamem_mmap -}; - -int -astro_match(struct device *parent, void *cfdata, void *aux) -{ - struct confargs *ca = aux; - - /* Astro is a U-Turn variant. */ - if (ca->ca_type.iodc_type != HPPA_TYPE_IOA || - ca->ca_type.iodc_sv_model != HPPA_IOA_UTURN) - return 0; - - if (ca->ca_type.iodc_model == 0x58 && - ca->ca_type.iodc_revision >= 0x20) - return 1; - - return 0; -} - -void -astro_attach(struct device *parent, struct device *self, void *aux) -{ - struct confargs *ca = aux, nca; - struct astro_softc *sc = (struct astro_softc *)self; - volatile struct astro_regs *r; - bus_space_handle_t ioh; - u_int32_t rid, ioc_ctrl; - psize_t size; - vaddr_t va; - paddr_t pa; - struct vm_page *m; - struct pglist mlist; - int iova_bits; - - sc->sc_dmat = ca->ca_dmatag; - if (bus_space_map(ca->ca_iot, ca->ca_hpa, sizeof(struct astro_regs), - 0, &ioh)) { - printf(": can't map IO space\n"); - return; - } - sc->sc_regs = r = (struct astro_regs *)ca->ca_hpa; - - rid = letoh32(r->rid); - printf(": Astro rev %d.%d\n", (rid & 7) + 1, (rid >> 3) & 3); - - ioc_ctrl = letoh32(r->ioc_ctrl); - ioc_ctrl &= ~ASTRO_IOC_CTRL_CE; - ioc_ctrl &= ~ASTRO_IOC_CTRL_RM; - ioc_ctrl &= ~ASTRO_IOC_CTRL_NC; - r->ioc_ctrl = htole32(ioc_ctrl); - - /* - * Setup the iommu. - */ - - /* XXX This gives us 256MB of iova space. */ - iova_bits = 28; - - r->tlb_ibase = htole32(0); - r->tlb_imask = htole32(0xffffffff << iova_bits); - - /* Page size is 4K. */ - r->tlb_tcnfg = htole32(0); - - /* Flush TLB. */ - r->tlb_pcom = htole32(31); - - /* - * Allocate memory for I/O pagetables. They need to be physically - * contiguous. - */ - - size = (1 << (iova_bits - PAGE_SHIFT)) * sizeof(u_int64_t); - TAILQ_INIT(&mlist); - if (uvm_pglistalloc(size, 0, -1, PAGE_SIZE, 0, &mlist, - 1, UVM_PLA_NOWAIT) != 0) - panic("astrottach: no memory"); - - va = (vaddr_t)km_alloc(size, &kv_any, &kp_none, &kd_nowait); - if (va == 0) - panic("astroattach: no memory"); - sc->sc_pdir = (u_int64_t *)va; - - m = TAILQ_FIRST(&mlist); - r->tlb_pdir_base = htole64(VM_PAGE_TO_PHYS(m)); - - /* Map the pages. */ - for (; m != NULL; m = TAILQ_NEXT(m, pageq)) { - pa = VM_PAGE_TO_PHYS(m); - pmap_enter(pmap_kernel(), va, pa, - PROT_READ | PROT_WRITE, PMAP_WIRED); - va += PAGE_SIZE; - } - pmap_update(pmap_kernel()); - memset(sc->sc_pdir, 0, size); - - /* - * The PDC might have set up some devices to do DMA. It will do - * this for the onboard USB controller if an USB keyboard is used - * for console input. In that case, bad things will happen if we - * enable iova space. So reset the PDC devices before we do that. - * Don't do this if we're using a serial console though, since it - * will stop working if we do. This is fine since the serial port - * doesn't do DMA. - */ - if (PAGE0->mem_cons.pz_class != PCL_DUPLEX) - pdc_call((iodcio_t)pdc, 0, PDC_IO, PDC_IO_RESET_DEVICES); - - /* Enable iova space. */ - r->tlb_ibase = htole32(1); - - /* - * Now all the hardware's working we need to allocate a dvma map. - */ - snprintf(sc->sc_dvmamapname, sizeof(sc->sc_dvmamapname), - "%s_dvma", sc->sc_dv.dv_xname); - sc->sc_dvmamap = extent_create(sc->sc_dvmamapname, 0, (1 << iova_bits), - M_DEVBUF, NULL, 0, EX_NOWAIT | EX_NOCOALESCE); - KASSERT(sc->sc_dvmamap); - mtx_init(&sc->sc_dvmamtx, IPL_HIGH); - - sc->sc_dmatag = astro_dmat; - sc->sc_dmatag._cookie = sc; - - nca = *ca; /* clone from us */ - nca.ca_hpamask = HPPA_IOBEGIN; - nca.ca_dmatag = &sc->sc_dmatag; - pdc_scanbus(self, &nca, MAXMODBUS, 0, 0); -} - -int -iommu_dvmamap_create(void *v, bus_size_t size, int nsegments, - bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamap) -{ - struct astro_softc *sc = v; - bus_dmamap_t map; - struct iommu_map_state *ims; - int error; - - error = bus_dmamap_create(sc->sc_dmat, size, nsegments, maxsegsz, - boundary, flags, &map); - if (error) - return (error); - - ims = iommu_iomap_create(atop(round_page(size))); - if (ims == NULL) { - bus_dmamap_destroy(sc->sc_dmat, map); - return (ENOMEM); - } - - ims->ims_sc = sc; - map->_dm_cookie = ims; - *dmamap = map; - - return (0); -} - -void -iommu_dvmamap_destroy(void *v, bus_dmamap_t map) -{ - struct astro_softc *sc = v; - - /* - * The specification (man page) requires a loaded - * map to be unloaded before it is destroyed. - */ - if (map->dm_nsegs) - iommu_dvmamap_unload(sc, map); - - if (map->_dm_cookie) - iommu_iomap_destroy(map->_dm_cookie); - map->_dm_cookie = NULL; - - bus_dmamap_destroy(sc->sc_dmat, map); -} - -int -iommu_iomap_load_map(struct astro_softc *sc, bus_dmamap_t map, int flags) -{ - struct iommu_map_state *ims = map->_dm_cookie; - struct iommu_page_map *ipm = &ims->ims_map; - struct iommu_page_entry *e; - int err, seg; - paddr_t pa, paend; - vaddr_t va; - bus_size_t sgsize; - bus_size_t align, boundary; - u_long dvmaddr; - bus_addr_t dva; - int i; - - /* XXX */ - boundary = map->_dm_boundary; - align = PAGE_SIZE; - - iommu_iomap_clear_pages(ims); - - for (seg = 0; seg < map->dm_nsegs; seg++) { - struct hppa_bus_dma_segment *ds = &map->dm_segs[seg]; - - paend = round_page(ds->ds_addr + ds->ds_len); - for (pa = trunc_page(ds->ds_addr), va = trunc_page(ds->_ds_va); - pa < paend; pa += PAGE_SIZE, va += PAGE_SIZE) { - err = iommu_iomap_insert_page(ims, va, pa); - if (err) { - printf("iomap insert error: %d for " - "va 0x%lx pa 0x%lx\n", err, va, pa); - bus_dmamap_unload(sc->sc_dmat, map); - iommu_iomap_clear_pages(ims); - } - } - } - - sgsize = ims->ims_map.ipm_pagecnt * PAGE_SIZE; - mtx_enter(&sc->sc_dvmamtx); - err = extent_alloc_with_descr(sc->sc_dvmamap, sgsize, align, 0, - boundary, EX_NOWAIT | EX_BOUNDZERO, &ims->ims_er, &dvmaddr); - mtx_leave(&sc->sc_dvmamtx); - if (err) - return (err); - - ims->ims_dvmastart = dvmaddr; - ims->ims_dvmasize = sgsize; - - dva = dvmaddr; - for (i = 0, e = ipm->ipm_map; i < ipm->ipm_pagecnt; ++i, ++e) { - e->ipe_dva = dva; - iommu_enter(sc, e->ipe_dva, e->ipe_pa, e->ipe_va, flags); - dva += PAGE_SIZE; - } - - for (seg = 0; seg < map->dm_nsegs; seg++) { - struct hppa_bus_dma_segment *ds = &map->dm_segs[seg]; - ds->ds_addr = iommu_iomap_translate(ims, ds->ds_addr); - } - - return (0); -} - -int -iommu_dvmamap_load(void *v, bus_dmamap_t map, void *addr, bus_size_t size, - struct proc *p, int flags) -{ - struct astro_softc *sc = v; - int err; - - err = bus_dmamap_load(sc->sc_dmat, map, addr, size, p, flags); - if (err) - return (err); - - return iommu_iomap_load_map(sc, map, flags); -} - -int -iommu_dvmamap_load_mbuf(void *v, bus_dmamap_t map, struct mbuf *m, int flags) -{ - struct astro_softc *sc = v; - int err; - - err = bus_dmamap_load_mbuf(sc->sc_dmat, map, m, flags); - if (err) - return (err); - - return iommu_iomap_load_map(sc, map, flags); -} - -int -iommu_dvmamap_load_uio(void *v, bus_dmamap_t map, struct uio *uio, int flags) -{ - struct astro_softc *sc = v; - - printf("load_uio\n"); - - return (bus_dmamap_load_uio(sc->sc_dmat, map, uio, flags)); -} - -int -iommu_dvmamap_load_raw(void *v, bus_dmamap_t map, bus_dma_segment_t *segs, - int nsegs, bus_size_t size, int flags) -{ - struct astro_softc *sc = v; - - printf("load_raw\n"); - - return (bus_dmamap_load_raw(sc->sc_dmat, map, segs, nsegs, size, flags)); -} - -void -iommu_dvmamap_unload(void *v, bus_dmamap_t map) -{ - struct astro_softc *sc = v; - struct iommu_map_state *ims = map->_dm_cookie; - struct iommu_page_map *ipm = &ims->ims_map; - struct iommu_page_entry *e; - int err, i; - - /* Remove the IOMMU entries. */ - for (i = 0, e = ipm->ipm_map; i < ipm->ipm_pagecnt; ++i, ++e) - iommu_remove(sc, e->ipe_dva); - - /* Clear the iomap. */ - iommu_iomap_clear_pages(ims); - - bus_dmamap_unload(sc->sc_dmat, map); - - mtx_enter(&sc->sc_dvmamtx); - err = extent_free(sc->sc_dvmamap, ims->ims_dvmastart, - ims->ims_dvmasize, EX_NOWAIT); - ims->ims_dvmastart = 0; - ims->ims_dvmasize = 0; - mtx_leave(&sc->sc_dvmamtx); - if (err) - printf("warning: %ld of DVMA space lost\n", ims->ims_dvmasize); -} - -void -iommu_dvmamap_sync(void *v, bus_dmamap_t map, bus_addr_t off, - bus_size_t len, int ops) -{ - /* Nothing to do; DMA is cache-coherent. */ -} - -int -iommu_dvmamem_alloc(void *v, bus_size_t size, bus_size_t alignment, - bus_size_t boundary, bus_dma_segment_t *segs, - int nsegs, int *rsegs, int flags) -{ - struct astro_softc *sc = v; - - return (bus_dmamem_alloc(sc->sc_dmat, size, alignment, boundary, - segs, nsegs, rsegs, flags)); -} - -void -iommu_dvmamem_free(void *v, bus_dma_segment_t *segs, int nsegs) -{ - struct astro_softc *sc = v; - - bus_dmamem_free(sc->sc_dmat, segs, nsegs); -} - -int -iommu_dvmamem_map(void *v, bus_dma_segment_t *segs, int nsegs, size_t size, - caddr_t *kvap, int flags) -{ - struct astro_softc *sc = v; - - return (bus_dmamem_map(sc->sc_dmat, segs, nsegs, size, kvap, flags)); -} - -void -iommu_dvmamem_unmap(void *v, caddr_t kva, size_t size) -{ - struct astro_softc *sc = v; - - bus_dmamem_unmap(sc->sc_dmat, kva, size); -} - -paddr_t -iommu_dvmamem_mmap(void *v, bus_dma_segment_t *segs, int nsegs, off_t off, - int prot, int flags) -{ - struct astro_softc *sc = v; - - return (bus_dmamem_mmap(sc->sc_dmat, segs, nsegs, off, prot, flags)); -} - -/* - * Utility function used by splay tree to order page entries by pa. - */ -static inline int -iomap_compare(struct iommu_page_entry *a, struct iommu_page_entry *b) -{ - return ((a->ipe_pa > b->ipe_pa) ? 1 : - (a->ipe_pa < b->ipe_pa) ? -1 : 0); -} - -SPLAY_PROTOTYPE(iommu_page_tree, iommu_page_entry, ipe_node, iomap_compare); - -SPLAY_GENERATE(iommu_page_tree, iommu_page_entry, ipe_node, iomap_compare); - -/* - * Create a new iomap. - */ -struct iommu_map_state * -iommu_iomap_create(int n) -{ - struct iommu_map_state *ims; - - /* Safety for heavily fragmented data, such as mbufs */ - n += 4; - if (n < 16) - n = 16; - - ims = malloc(sizeof(*ims) + (n - 1) * sizeof(ims->ims_map.ipm_map[0]), - M_DEVBUF, M_NOWAIT | M_ZERO); - if (ims == NULL) - return (NULL); - - /* Initialize the map. */ - ims->ims_map.ipm_maxpage = n; - SPLAY_INIT(&ims->ims_map.ipm_tree); - - return (ims); -} - -/* - * Destroy an iomap. - */ -void -iommu_iomap_destroy(struct iommu_map_state *ims) -{ -#ifdef DIAGNOSTIC - if (ims->ims_map.ipm_pagecnt > 0) - printf("iommu_iomap_destroy: %d page entries in use\n", - ims->ims_map.ipm_pagecnt); -#endif - - free(ims, M_DEVBUF, 0); -} - -/* - * Insert a pa entry in the iomap. - */ -int -iommu_iomap_insert_page(struct iommu_map_state *ims, vaddr_t va, paddr_t pa) -{ - struct iommu_page_map *ipm = &ims->ims_map; - struct iommu_page_entry *e; - - if (ipm->ipm_pagecnt >= ipm->ipm_maxpage) { - struct iommu_page_entry ipe; - - ipe.ipe_pa = pa; - if (SPLAY_FIND(iommu_page_tree, &ipm->ipm_tree, &ipe)) - return (0); - - return (ENOMEM); - } - - e = &ipm->ipm_map[ipm->ipm_pagecnt]; - - e->ipe_pa = pa; - e->ipe_va = va; - e->ipe_dva = 0; - - e = SPLAY_INSERT(iommu_page_tree, &ipm->ipm_tree, e); - - /* Duplicates are okay, but only count them once. */ - if (e) - return (0); - - ++ipm->ipm_pagecnt; - - return (0); -} - -/* - * Translate a physical address (pa) into a DVMA address. - */ -bus_addr_t -iommu_iomap_translate(struct iommu_map_state *ims, paddr_t pa) -{ - struct iommu_page_map *ipm = &ims->ims_map; - struct iommu_page_entry *e; - struct iommu_page_entry pe; - paddr_t offset = pa & PAGE_MASK; - - pe.ipe_pa = trunc_page(pa); - - e = SPLAY_FIND(iommu_page_tree, &ipm->ipm_tree, &pe); - - if (e == NULL) { - panic("couldn't find pa %lx", pa); - return 0; - } - - return (e->ipe_dva | offset); -} - -/* - * Clear the iomap table and tree. - */ -void -iommu_iomap_clear_pages(struct iommu_map_state *ims) -{ - ims->ims_map.ipm_pagecnt = 0; - SPLAY_INIT(&ims->ims_map.ipm_tree); -} - -/* - * Add an entry to the IOMMU table. - */ -void -iommu_enter(struct astro_softc *sc, bus_addr_t dva, paddr_t pa, vaddr_t va, - int flags) -{ - volatile u_int64_t *tte_ptr = &sc->sc_pdir[dva >> PAGE_SHIFT]; - u_int64_t tte; - u_int32_t ci; - -#ifdef DEBUG - printf("iommu_enter dva %lx, pa %lx, va %lx\n", dva, pa, va); -#endif - -#ifdef DIAGNOSTIC - tte = letoh64(*tte_ptr); - - if (tte & IOTTE_V) { - printf("Overwriting valid tte entry (dva %lx pa %lx " - "&tte %p tte %llx)\n", dva, pa, tte_ptr, tte); - extent_print(sc->sc_dvmamap); - panic("IOMMU overwrite"); - } -#endif - - mtsp(HPPA_SID_KERNEL, 1); - __asm volatile("lci 0(%%sr1, %1), %0" : "=r" (ci) : "r" (va)); - - tte = (pa & IOTTE_PAMASK) | ((ci >> 12) & IOTTE_CI); - tte |= IOTTE_V; - - *tte_ptr = htole64(tte); - __asm volatile("fdc 0(%%sr1, %0)\n\tsync" : : "r" (tte_ptr)); -} - -/* - * Remove an entry from the IOMMU table. - */ -void -iommu_remove(struct astro_softc *sc, bus_addr_t dva) -{ - volatile struct astro_regs *r = sc->sc_regs; - u_int64_t *tte_ptr = &sc->sc_pdir[dva >> PAGE_SHIFT]; - u_int64_t tte; - -#ifdef DIAGNOSTIC - if (dva != trunc_page(dva)) { - printf("iommu_remove: unaligned dva: %lx\n", dva); - dva = trunc_page(dva); - } -#endif - - tte = letoh64(*tte_ptr); - -#ifdef DIAGNOSTIC - if ((tte & IOTTE_V) == 0) { - printf("Removing invalid tte entry (dva %lx &tte %p " - "tte %llx)\n", dva, tte_ptr, tte); - extent_print(sc->sc_dvmamap); - panic("IOMMU remove overwrite"); - } -#endif - - *tte_ptr = htole64(tte & ~IOTTE_V); - - /* Flush IOMMU. */ - r->tlb_pcom = htole32(dva | PAGE_SHIFT); -} diff --git a/sys/arch/hppa/dev/clock.c b/sys/arch/hppa/dev/clock.c deleted file mode 100644 index f0ebd3892..000000000 --- a/sys/arch/hppa/dev/clock.c +++ /dev/null @@ -1,212 +0,0 @@ -/* $OpenBSD: clock.c,v 1.35 2023/02/04 19:19:36 cheloha Exp $ */ - -/* - * Copyright (c) 1998-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -uint64_t itmr_nsec_cycle_ratio; -uint64_t itmr_nsec_max; - -u_int itmr_get_timecount(struct timecounter *); -int itmr_intr(void *); -void itmr_rearm(void *, uint64_t); -void itmr_trigger(void); -void itmr_trigger_masked(void); -void itmr_trigger_wrapper(void *); - -struct timecounter itmr_timecounter = { - .tc_get_timecount = itmr_get_timecount, - .tc_counter_mask = 0xffffffff, - .tc_frequency = 0, - .tc_name = "itmr", - .tc_quality = 0, - .tc_priv = NULL, - .tc_user = 0, -}; - -const struct intrclock itmr_intrclock = { - .ic_rearm = itmr_rearm, - .ic_trigger = itmr_trigger_wrapper -}; - -extern todr_chip_handle_t todr_handle; -struct todr_chip_handle pdc_todr; - -int -pdc_gettime(struct todr_chip_handle *handle, struct timeval *tv) -{ - struct pdc_tod tod PDC_ALIGNMENT; - int error; - - if ((error = pdc_call((iodcio_t)pdc, 1, PDC_TOD, PDC_TOD_READ, - &tod, 0, 0, 0, 0, 0))) { - printf("clock: failed to fetch (%d)\n", error); - return EIO; - } - - tv->tv_sec = tod.sec; - tv->tv_usec = tod.usec; - return 0; -} - -int -pdc_settime(struct todr_chip_handle *handle, struct timeval *tv) -{ - int error; - - if ((error = pdc_call((iodcio_t)pdc, 1, PDC_TOD, PDC_TOD_WRITE, - tv->tv_sec, tv->tv_usec))) { - printf("clock: failed to save (%d)\n", error); - return EIO; - } - - return 0; -} - -void -cpu_initclocks(void) -{ - uint64_t itmr_freq = PAGE0->mem_10msec * 100; - - pdc_todr.todr_gettime = pdc_gettime; - pdc_todr.todr_settime = pdc_settime; - todr_handle = &pdc_todr; - - itmr_timecounter.tc_frequency = itmr_freq; - tc_init(&itmr_timecounter); - - stathz = hz; - profhz = stathz * 10; - clockintr_init(CL_RNDSTAT); - - itmr_nsec_cycle_ratio = itmr_freq * (1ULL << 32) / 1000000000; - itmr_nsec_max = UINT64_MAX / itmr_nsec_cycle_ratio; - - cpu_startclock(); -} - -void -cpu_startclock(void) -{ - clockintr_cpu_init(&itmr_intrclock); - clockintr_trigger(); -} - -int -itmr_intr(void *v) -{ - clockintr_dispatch(v); - return (1); -} - -void -setstatclockrate(int newhz) -{ - clockintr_setstatclockrate(newhz); -} - -u_int -itmr_get_timecount(struct timecounter *tc) -{ - u_long __itmr; - - mfctl(CR_ITMR, __itmr); - return (__itmr); -} - -/* - * Program the next clock interrupt, making sure it will - * indeed happen in the future. This is done with interrupts - * disabled to avoid a possible race. - */ -void -itmr_rearm(void *unused, uint64_t nsecs) -{ - uint32_t cycles, t0, t1; - register_t eiem, eirr; - - if (nsecs > itmr_nsec_max) - nsecs = itmr_nsec_max; - cycles = (nsecs * itmr_nsec_cycle_ratio) >> 32; - - eiem = hppa_intr_disable(); - mfctl(CR_ITMR, t0); - mtctl(t0 + cycles, CR_ITMR); - mfctl(CR_ITMR, t1); - mfctl(CR_EIRR, eirr); - - /* - * If at least "cycles" ITMR ticks have elapsed and the interrupt - * isn't pending, we missed. Fall back to itmr_trigger_masked(). - */ - if (cycles <= t1 - t0) { - if (!ISSET(eirr, 1U << 31)) - itmr_trigger_masked(); - } - hppa_intr_enable(eiem); -} - -void -itmr_trigger(void) -{ - register_t eiem; - - eiem = hppa_intr_disable(); - itmr_trigger_masked(); - hppa_intr_enable(eiem); -} - -/* Trigger our own ITMR interrupt by setting EIR{0}. */ -void -itmr_trigger_masked(void) -{ - struct iomod *cpu = (struct iomod *)curcpu()->ci_hpa; - - cpu->io_eir = 0; - __asm volatile ("sync" ::: "memory"); -} - -void -itmr_trigger_wrapper(void *unused) -{ - itmr_trigger(); -} diff --git a/sys/arch/hppa/dev/com_dino.c b/sys/arch/hppa/dev/com_dino.c deleted file mode 100644 index 8115f020c..000000000 --- a/sys/arch/hppa/dev/com_dino.c +++ /dev/null @@ -1,116 +0,0 @@ -/* $OpenBSD: com_dino.c,v 1.5 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -void *dino_intr_establish(void *sc, int irq, int pri, - int (*handler)(void *v), void *arg, const char *name); - -#define COM_DINO_FREQ 7272700 - -struct com_dino_regs { - u_int8_t reset; - u_int8_t pad0[3]; - u_int8_t test; -#define COM_DINO_PAR_LOOP 0x01 -#define COM_DINO_CLK_SEL 0x02 - u_int8_t pad1[3]; - u_int32_t iodc; - u_int8_t pad2[0x54]; - u_int8_t dither; -}; - -int com_dino_match(struct device *, void *, void *); -void com_dino_attach(struct device *, struct device *, void *); - -const struct cfattach com_dino_ca = { - sizeof(struct com_softc), com_dino_match, com_dino_attach -}; - -int -com_dino_match(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct confargs *ca = aux; - - if (ca->ca_type.iodc_type != HPPA_TYPE_FIO || - ca->ca_type.iodc_sv_model != HPPA_FIO_GRS232) - return (0); - - return (1); - /* HOZER comprobe1(ca->ca_iot, ca->ca_hpa + IOMOD_DEVOFFSET); */ -} - -void -com_dino_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct com_softc *sc = (void *)self; - struct confargs *ca = aux; - struct com_dino_regs *regs = (struct com_dino_regs *)ca->ca_hpa; - - sc->sc_iot = ca->ca_iot; - sc->sc_iobase = (bus_addr_t)ca->ca_hpa + IOMOD_DEVOFFSET; - - if (bus_space_map(sc->sc_iot, sc->sc_iobase, COM_NPORTS, - 0, &sc->sc_ioh)) { - printf(": cannot map io space\n"); - return; - } - - if (PAGE0->mem_cons.pz_class == PCL_DUPLEX && - PAGE0->mem_cons.pz_hpa == ca->ca_hpa) { - bus_space_unmap(sc->sc_iot, sc->sc_ioh, COM_NPORTS); - comcnattach(sc->sc_iot, sc->sc_iobase, comdefaultrate, - COM_DINO_FREQ, comconscflag); - } - - /* select clock freq */ - regs->test = COM_DINO_CLK_SEL; - sc->sc_frequency = COM_DINO_FREQ; - - com_attach_subr(sc); - - sc->sc_ih = dino_intr_establish(parent, ca->ca_irq, IPL_TTY, - comintr, sc, sc->sc_dev.dv_xname); -} diff --git a/sys/arch/hppa/dev/com_ssio.c b/sys/arch/hppa/dev/com_ssio.c deleted file mode 100644 index 7c0ca94eb..000000000 --- a/sys/arch/hppa/dev/com_ssio.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $OpenBSD: com_ssio.c,v 1.3 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2007 Mark Kettenis - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#define COM_SSIO_FREQ 1843200 - -int com_ssio_match(struct device *, void *, void *); -void com_ssio_attach(struct device *, struct device *, void *); - -const struct cfattach com_ssio_ca = { - sizeof(struct com_softc), com_ssio_match, com_ssio_attach -}; - -int -com_ssio_match(struct device *parent, void *match, void *aux) -{ - struct cfdata *cf = match; - struct ssio_attach_args *saa = aux; - - if (strcmp(saa->saa_name, "com") != 0) - return (0); - - /* Check locators. */ - if (cf->ssiocf_irq != SSIO_UNK_IRQ && cf->ssiocf_irq != saa->saa_irq) - return (0); - - return (1); -} - -void -com_ssio_attach(struct device *parent, struct device *self, void *aux) -{ - struct com_softc *sc = (void *)self; - struct ssio_attach_args *saa = aux; - - sc->sc_iot = saa->saa_iot; - sc->sc_iobase = saa->saa_iobase; - if (bus_space_map(sc->sc_iot, sc->sc_iobase, COM_NPORTS, - 0, &sc->sc_ioh)) { - printf(": cannot map io space\n"); - return; - } - - if (PAGE0->mem_cons.pz_class == PCL_DUPLEX && - PAGE0->mem_cons.pz_hpa == sc->sc_ioh) { - bus_space_unmap(sc->sc_iot, sc->sc_ioh, COM_NPORTS); - comcnattach(sc->sc_iot, sc->sc_iobase, comdefaultrate, - COM_SSIO_FREQ, comconscflag); - } - - sc->sc_frequency = COM_SSIO_FREQ; - com_attach_subr(sc); - - sc->sc_ih = ssio_intr_establish(IPL_TTY, saa->saa_irq, - comintr, sc, sc->sc_dev.dv_xname); -} diff --git a/sys/arch/hppa/dev/cpu.c b/sys/arch/hppa/dev/cpu.c deleted file mode 100644 index 91dd7dd26..000000000 --- a/sys/arch/hppa/dev/cpu.c +++ /dev/null @@ -1,287 +0,0 @@ -/* $OpenBSD: cpu.c,v 1.44 2022/12/06 00:40:09 cheloha Exp $ */ - -/* - * Copyright (c) 1998-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include - -struct cpu_softc { - struct device sc_dev; -}; - -#ifdef MULTIPROCESSOR -struct cpu_info *cpu_hatch_info; -static volatile int start_secondary_cpu; -#endif - -int cpumatch(struct device *, void *, void *); -void cpuattach(struct device *, struct device *, void *); - -const struct cfattach cpu_ca = { - sizeof(struct cpu_softc), cpumatch, cpuattach -}; - -struct cfdriver cpu_cd = { - NULL, "cpu", DV_DULL -}; - -int -cpumatch(struct device *parent, void *cfdata, void *aux) -{ - struct cfdata *cf = cfdata; - struct confargs *ca = aux; - - /* probe any 1.0, 1.1 or 2.0 */ - if (ca->ca_type.iodc_type != HPPA_TYPE_NPROC || - ca->ca_type.iodc_sv_model != HPPA_NPROC_HPPA) - return 0; - - if (cf->cf_unit >= MAXCPUS) - return 0; - - return 1; -} - -void -cpuattach(struct device *parent, struct device *self, void *aux) -{ - /* machdep.c */ - extern struct pdc_model pdc_model; - extern struct pdc_cache pdc_cache; - extern struct pdc_btlb pdc_btlb; - extern u_int cpu_ticksnum, cpu_ticksdenom; - extern u_int fpu_enable; - /* clock.c */ - extern int itmr_intr(void *); - /* ipi.c */ - extern int hppa_ipi_intr(void *); - - struct confargs *ca = (struct confargs *)aux; - struct cpu_info *ci; - u_int mhz = 100 * cpu_ticksnum / cpu_ticksdenom; - int cpuno = self->dv_unit; - struct pglist mlist; - struct vm_page *m; - const char *p; - int error; - - ci = &cpu_info[cpuno]; - ci->ci_dev = self; - ci->ci_cpuid = cpuno; - ci->ci_hpa = ca->ca_hpa; - - /* Allocate stack for spin up and FPU emulation. */ - TAILQ_INIT(&mlist); - error = uvm_pglistalloc(PAGE_SIZE, 0, -1L, 0, 0, &mlist, 1, - UVM_PLA_NOWAIT); - if (error) { - printf(": unable to allocate CPU stack!\n"); - return; - } - m = TAILQ_FIRST(&mlist); - ci->ci_stack = VM_PAGE_TO_PHYS(m); - - printf (": %s ", cpu_typename); - if (pdc_model.hvers) { - static const char lvls[4][4] = { "0", "1", "1.5", "2" }; - - printf("L%s-%c ", lvls[pdc_model.pa_lvl], "AB"[pdc_model.mc]); - } - - printf ("%d", mhz / 100); - if (mhz % 100 > 9) - printf(".%02d", mhz % 100); - printf("MHz"); - - if (fpu_enable) { - extern u_int fpu_version; - u_int32_t ver[2]; - - mtctl(fpu_enable, CR_CCR); - __asm volatile( - "fstds %%fr0,0(%0)\n\t" - "copr,0,0\n\t" - "fstds %%fr0,0(%0)" - :: "r" (&ver) : "memory"); - mtctl(0, CR_CCR); - fpu_version = HPPA_FPUVER(ver[0]); - printf(", FPU %s rev %d", - hppa_mod_info(HPPA_TYPE_FPU, fpu_version >> 5), - fpu_version & 0x1f); - } - - printf("\n%s: ", self->dv_xname); - p = ""; - if (!pdc_cache.dc_conf.cc_sh) { - printf("%uK(%db/l) Icache, ", - pdc_cache.ic_size / 1024, pdc_cache.ic_conf.cc_line * 16); - p = "D"; - } - - printf("%uK(%db/l) wr-%s %scache, ", - pdc_cache.dc_size / 1024, pdc_cache.dc_conf.cc_line * 16, - pdc_cache.dc_conf.cc_wt? "thru" : "back", p); - - p = ""; - if (!pdc_cache.dt_conf.tc_sh) { - printf("%u ITLB, ", pdc_cache.it_size); - p = "D"; - } - printf("%u %scoherent %sTLB", - pdc_cache.dt_size, pdc_cache.dt_conf.tc_cst? "" : "in", p); - - if (pdc_btlb.finfo.num_c) - printf(", %u BTLB", pdc_btlb.finfo.num_c); - else if (pdc_btlb.finfo.num_i || pdc_btlb.finfo.num_d) - printf(", %u/%u D/I BTLBs", - pdc_btlb.finfo.num_i, pdc_btlb.finfo.num_d); - - cpu_intr_establish(IPL_CLOCK, 31, itmr_intr, NULL, "clock"); -#ifdef MULTIPROCESSOR - cpu_intr_establish(IPL_IPI, 30, hppa_ipi_intr, NULL, "ipi"); -#endif - - printf("\n"); -} - -#ifdef MULTIPROCESSOR -void -cpu_boot_secondary_processors(void) -{ - struct cpu_info *ci; - struct iomod *cpu; - int i, j; - - /* Initialise primary CPU. */ - ci = curcpu(); - ci->ci_flags |= CPUF_RUNNING; - hppa_ipi_init(ci); - - for (i = 0; i < HPPA_MAXCPUS; i++) { - - ci = &cpu_info[i]; - if (ci->ci_cpuid == 0) - continue; - - ci->ci_randseed = (arc4random() & 0x7fffffff) + 1; - - sched_init_cpu(ci); - - /* Release the specified CPU by triggering an EIR{0}. */ - cpu_hatch_info = ci; - cpu = (struct iomod *)(ci->ci_hpa); - cpu->io_eir = 0; - asm volatile ("sync" ::: "memory"); - - /* Wait for CPU to wake up... */ - j = 0; - while (!(ci->ci_flags & CPUF_RUNNING) && j++ < 10000) - delay(1000); - if (!(ci->ci_flags & CPUF_RUNNING)) - printf("failed to hatch cpu %i!\n", ci->ci_cpuid); - } - - /* Release secondary CPUs. */ - start_secondary_cpu = 1; - asm volatile ("sync" ::: "memory"); -} - -void -cpu_hw_init(void) -{ - struct cpu_info *ci = curcpu(); - - /* Purge TLB and flush caches. */ - ptlball(); - ficacheall(); - fdcacheall(); - - /* Enable address translations. */ - ci->ci_psw = PSL_I | PSL_Q | PSL_P | PSL_C | PSL_D; - ci->ci_psw |= (cpu_info[0].ci_psw & PSL_O); -} - -void -cpu_hatch(void) -{ - struct cpu_info *ci = curcpu(); - int s; - - /* Initialise IPIs. */ - hppa_ipi_init(ci); - - /* Initialise clock. */ - mtctl((1U << 31), CR_EIRR); - ci->ci_mask |= (1U << 31); - cpu_startclock(); - - /* Enable interrupts. */ - mtctl(ci->ci_mask, CR_EIEM); - - ncpus++; - ci->ci_flags |= CPUF_RUNNING; - - /* Wait for additional CPUs to spinup. */ - while (!start_secondary_cpu) - ; - - SCHED_LOCK(s); - cpu_switchto(NULL, sched_chooseproc()); -} - -void -cpu_unidle(struct cpu_info *ci) -{ - if (ci != curcpu()) - hppa_ipi_send(ci, HPPA_IPI_NOP); -} -#endif - -void -need_resched(struct cpu_info *ci) -{ - ci->ci_want_resched = 1; - - /* There's a risk we'll be called before the idle threads start */ - if (ci->ci_curproc) { - setsoftast(ci->ci_curproc); - cpu_unidle(ci); - } -} diff --git a/sys/arch/hppa/dev/cpudevs b/sys/arch/hppa/dev/cpudevs deleted file mode 100644 index f261e7175..000000000 --- a/sys/arch/hppa/dev/cpudevs +++ /dev/null @@ -1,489 +0,0 @@ -$OpenBSD: cpudevs,v 1.44 2007/05/18 15:57:35 kettenis Exp $ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -type nproc 0x00 native processor -type memory 0x01 memory -type bdma 0x02 Type-B DMA (NIO Transit, Parallel, ... ) -type bdirect 0x03 Type-B Direct (obsolete) -type adma 0x04 Type-A DMA (NIO HPIB, LAN, ... ) -type adirect 0x05 Type-A Direct (RS232, HIL, ... ) -type other 0x06 other (obsolete) -type bcport 0x07 Bus Converter Port -type cio 0x08 CIO adapter -type console 0x09 console -type fio 0x0a foreign I/O module -type bha 0x0b bus host adaptor -type ioa 0x0c IO Adapter -type bridge 0x0d Bus Bridge to Foreign Bus -type fabric 0x0e Fabric Components -# 0x0f - -# 0x1e reserved -type faulty 0x1f broken -# pseudo-types -type board 0x80 system board -type cpu 0x81 CPU chips -type fpu 0x82 FPU chips -type bus 0x83 Main Busses - - -board HP840 0x004 840/930 (Indigo) -board HP825 0x008 825/925 (FireFox) -board HP835 0x00a 83[45]/[69]35 (TopGun) -board HP845 0x00b 845/645 (Technical ShoGun) -board HP850 0x00C 850/950 (Cheetah) -board HP949 0x00f 949 (Commercial ShoGun) - -board HP950S 0x080 950S (Cheetah) -board HP855 0x081 855/955 (Jaguar) -board HP860 0x082 860/960 (Cougar) -board HP870 0x083 865/870/980 (Panther) - -board HP810 0x100 810 (Burgundy) -board HP822 0x101 822/922 (SilverFox Low) -board HP832 0x102 832/932 (SilverFox High) -board HP808 0x103 808/815/920 (Lego, SilverLite) -board HP842 0x104 842/948 (SilverBullet Low) -board HP852 0x105 852/958 (SilverBullet High) -board HPOBOE 0x106 (Oboe) - -board HPDRAGON 0x180 (Dragon) -board HP890 0x181 890/990/992 (Chimera) -board HP891 0x182 891/T500 (TNT 100) -board HP892 0x183 892/T520 (TNT 120) -board HP893_T540 0x184 893/T540/T600 (Jade 180 U) - -board HPHXPROC 0x1ff Hitachi X Processor - -board HP720 0x200 720 (Cobra) -board HP750_66 0x201 750/66 (Coral) -board HP730_66 0x202 730/66 (King Cobra) -board HP735_99 0x203 735/99 (Hardball) -board HP755_99 0x204 755/99 (Coral II) -board HP755_125 0x205 755/125 (Coral II) -#board HP755_125E 0x205 755/125 (Snake Eagle, opt 91) -board HP735_130 0x206 735/130 (Snake Cheetah) - -board HP817 0x280 817/827/957/957LX/FH20 (Nova Low) -board HP837 0x281 837/847/857/967/967LX/FGHI30 (Nova High) -board HP807 0x282 807/917/917LX/927/927LX/937/937LX/947/947LX/F10 (Nova8) -board HP867 0x283 867/877/977/GHI40 (Nova64) -board HP887T 0x284 887/897/987/GHI50 (TNova) -#board HP 0x285 (TNova64) -#board HP 0x286 (Hydra64 (Nova)) -board HP887 0x287 887/897/GHI70 (Hydra96 (Nova)) -board HP887T96 0x288 887/897/GHI60 (TNova96) - -board HP710 0x300 710/50 (Bushmaster) -board HP705 0x302 705/35 (Flounder) - -board HP715_50 0x310 715/50 (Scorpio) -board HP715_33 0x311 715/33 (Scorpio Jr.) -board HP715S_50 0x312 715S/50 (Spider-50) -board HP715S_33 0x313 715S/33 (Spider-33) -board HP715T_50 0x314 715T/50 (Trailways-50) -board HP715T_33 0x315 715T/33 (Trailways-33) -board HP715_75 0x316 715/75 (Scorpio Sr.) -board HP715_99 0x317 715/99 (Scorpio 100) -board HP725_50 0x318 725/50 (Spectra) -board HP725_75 0x319 725/75 (Spectra) -board HP725_99 0x320 725/99 (Spectra) - -board HP745i_50 0x401 745i/747i/50 (Pace) -board HP742i_50 0x402 742i/50 (Sidewinder) -board HP747i_100 0x403 745i/747i/100 (Fast Pace) - -board HPE23 0x480 806/E23 (Orville) -board HPE25 0x481 806/E25 (Wilbur) -board HPE35 0x482 816/E35 (Wright Brothers 80) -board HPE45 0x483 826/E45 (Wright Brothers 96) -board HPD210 0x484 811/D210/D310 (UltraLight L 100) -board HPD200 0x485 801/D200/D300 (UltraLight L 75) - -board HP778_B132L 0x501 778/B132L (Merlin L2 132) -board HP778_B160L 0x502 778/B160L (Merlin L2 160) -board HP778_B132LP 0x503 778/B132L+ (Merlin L2+ 132) -board HP778_B180L 0x504 778/B180L+ (Merlin L2+ 180) -board HP779_C132L 0x505 779/C132L (Raven L2 132) -board HP779_C160L 0x506 779/C160L (Raven L2 160) -board HP779_C180L 0x507 779/C180L (Raven L2 180) -board HP779_C160L1 0x508 779/C160L (Raven L2 160) -board HP712_132L2 0x509 712/132 (L2 Upgrade) -board HP712_160L2 0x50a 712/160 (L2 Upgrade) -board HP712_132L21 0x50b 712/132 (L2 Upgrade) -board HP712_160L21 0x50c 712/160 (L2 Upgrade) -#board HP 0x50d (Rocky2 L2 120) -#board HP 0x50e (Rocky2 L2 150) -board HP744_132L 0x50f 744/132L (Anole-132L) -board HP744_165L 0x510 744/165L (Anole-165L) -#board HPKIJI132 0x511 (Kiji L2 132) -board HP803 0x512 803/D220 (UltraLight L2 132) -board HP813 0x513 813/D320 (UltraLight L2 160) -board HP778_B132 0x514 778/B132 (Merlin Jr. L2 132) -board HP800_A132 0x515 800/A132 (Staccato L2 132) -board HP800_A180C 0x516 800/A180C (Staccato L2 180) - -board HP809 0x580 809/K100 (KittyHawk DC2-100) -board HP839 0x581 839/K210 (KittyHawk DC3-120) -board HP829 0x582 829/K400 (KittyHawk DC3-100) -board HP849 0x583 849/K410 (KittyHawk DC3-120) -board HP770_J210XC 0x584 770/J210XC (LighteningHawk) -board HP770_J200 0x585 770/J200 (SkyHawk 100) -board HP770_J210 0x586 770/J210 (SkyHawk 120) -board HP841 0x587 841/D210/D410 (UltraLight Proc 1-way T'120) -board HP851 0x588 851/D210-2/D410-2 (UltraLight Proc 2-way T'120) -board HP821_1 0x589 821/D200/D400 (UltraLight Proc 1-way T'100) -board HP831 0x58a 831/D200-2/D400-2 (UltraLight Proc 2-way T'100) -board HP819 0x58b 819/K200 (KittyHawk DC2 100) -board HP859 0x58c 859/K220 (ThunderHawk DC3- 120 1M) -board HP869 0x58d 869/K420 (ThunderHawk DC3 120 1M) -board HP780_C110 0x58e 780/C110 (Raven 120 T') -board HP804 0x58f 804/K450 (Mohawk 160 U 1M DC3) -board HP889 0x590 889/K460 (Mohawk 180 U 1M DC3) -#board HP889_1 0x591 889/K470 (Mohawk 200 U 1M DC3) -board HP780_C100 0x592 780/C100 (Raven 100 T') -#board HP 0x593 (FireHawk 160 U) -board HP780_J282 0x594 780/J282 (FireHawk 180 U) -#board HP 0x595 (FireHawk 220 U) -#board HP 0x596 (FireHawk 240 U) -board HP800V 0x597 800/V2200/V2500 (SPP2000) -board HP780_C230 0x598 780/C230 (Raven U 230) -board HP780_C240 0x599 780/C240 (Raven U 240) -# 0x59a reserved -board HP780_C160 0x59b 780/C160 (Raven U 160) -board HP780_C180XP 0x59c 780/C180XP (Raven U 180) -board HP780_C200 0x59d 780/C200 (Raven U 200) -#board HP 0x59e (ThunderHawk T' 120) -board HP780_C180P 0x59f 780/C180+ (Raven U 180+) -board HP841_1 0x5a0 841/D260/D360 (UltraLight 1-way T120 1MB) -board HP851_1 0x5a1 851/D260/D360 (UltraLight 2-way T120 1MB) -board HP861 0x5a2 861/D270/D370 (UltraLight 1-way U160 512K) -board HP871 0x5a3 871/D270/D370 (UltraLight 2-way U160 512K) -board HP802 0x5a4 802/K250 (MoHawk U160 1M DC3-) -board HP879 0x5a5 879/K260 (MoHawk U180 1M DC3-) -#board HP878? 0x5a6 878/K270 (MoHawk U200 1M DC3-) -#board HP 0x5a7 (UltraLight 1-way U160 1M) -#board HP 0x5a8 (UltraLight 2-way U160 1M) -board HP810D 0x5a9 810/D380/R380 (UltraLight 1-way U180 1M) -board HP820 0x5aa 820/D280 (UltraLight 2-way U180 1M) -# 0x5ab obsolete -# 0x5ac obsolete -#board HP898? 0x5ad 898/K360 (BraveHawk 180 DC3-) -board HP898 0x5ae 898/K370 (BraveHawk 200 DC3-) -#board HP 0x5af (BraveHawk 220 DC3-) -#board HP899? 0x5b0 899/K560 (BraveHawk 180 DC3) -board HP899 0x5b1 899/K570 (BraveHawk 200 DC3) -#board HP 0x5b2 (BraveHawk 220 DC3) -#board HP 0x5b3 (FireHawk 200) -board HP800V2 0x5b4 800/V2500 (SPP2500) -board HP782_J2240 0x5b5 782/J2240 (SummitHawk U+) -board HP800K 0x5b6 800/K580 (DragonHawk U+ 240 DC3) -#board HP800K? 0x5b7 800/K380 (DragonHawk U+ 240 DC3-) -#board 0x5b8 SPP2250 240MHz processor -board HP821 0x5b9 821/D350/R350 (UltraLight 1w U+/240) -board HP800D 0x5ba 800/D390/R390 (UltraLight 2w U+/240) -board HP785_C3000 0x5bb 785/C3000 (AllegroHigh W) -board HP785_B1000 0x5bc 785/B1000 (AllegroLow W) -board HP785_J5000 0x5bd 785/J5000 (Forte W 2w) -board HP800_N400036 0x5be 800/N4000-36/rp7400 (Prelude W) -board HP785_J7000 0x5bf 785/J7000 (Forte W 4w) -#board 0x5c0 (M2250) -#board 0x5c1 (M2500) -#board 0x5c2 (Sonata 440) -#board 0x5c3 (Sonata 360) -board HP800_L200044 0x5c4 800/L2000-44/rp5450 (Rhapsody 440) -board HP800_L200036 0x5c5 800/L2000-36/rp5450 (Rhapsody 360) -board HP785_C360 0x5c6 780/C360 (Raven W 360) -#board 0x5c7 (Halftone W 440) -#board 0x5c8 (Lego 360) -board HP800_L100044 0x5c9 800/L1000-44/rp5400 (Rhapsody DC-440) -board HP800_L100036 0x5ca 800/L1000-36/rp5400 (Rhapsody DC-360) -board HP897_A50044 0x5cb 897/A500-44/rp2450 (Crescendo 440) -board HP800_N400044 0x5cc 800/N4000-44/rp7400 (Prelude W 440) -#board 0x5cd SPP2600 -#board 0x5ce M2600 -board HP785_C3600 0x5cf 785/C3600 (Allegro) -board HP786_B2000 0x5d0 786/B2000 (Kazoo W+) -board HP785_J5600 0x5d1 785/J5600 (Forte W+ 2w) -board HP785_J7600 0x5d2 785/J7600 (Forte W+ 4w) -board HP800_N400055 0x5d3 800/N4000-55/rp7400 (Prelude W+ 550) -board HP785_J6000 0x5d4 785/J6000 (Duet W+) -board HP897_A5005X 0x5d5 897/A500-5X/rp2450 (Crescendo 550) -board HP897_A40044 0x5d6 897/A400-44/rp2400 (Crescendo 440) -board HP800_N40005X 0x5d7 800/N4000-5X/rp7410 (Keystone W+ 550) -board HP800_L150044 0x5d8 800/L1500-44/rp5430 (Rhapsody wave 2 W+) -board HP800_L150036 0x5d9 800/L1500-36/rp5430 (Rhapsody wave 2 W+) -#board 0x5da (Marcato W+ DC-) -board HP800_L30005X 0x5db 800/L3000-5X/rp5470 (Marcato W+) -board HP785_C3700 0x5dc 785/C3700 -board HP785_J6700 0x5dd 785/J6700 (Duet W2) -board HP785_B2600 0x5de 785/B2600 (Piccolo W+) -#board HP 0x5df (Cantata W2) -#board HP 0x5e0 (Cantata DC- W2) -board HP897_A4006X 0x5e1 897/A400-6X/rp2430 (Crescendo DC-W2) -board HP897_A5006X 0x5e2 897/A500-6X/rp2470 (Crescendo 650 W2) -board HP897_A5007X 0x5e3 897/A500-7X/rp2470 (Crescendo 750 W2) -board HP800_N40007X 0x5e4 800/N4000-7X/rp7410 (Keystone/Matterhorn W2 750) -#board HP 0x5e5 (PowerBar W+) -board HP800_N40006X 0x5e6 800/N4000-6X/rp7410 (Keystone/Matterhorn W2 650) -#board 0x5e7 (Caribe W2 750) -#board 0x5e8 (Pikes Peak W2) - -board HITACHIW 0x5ff (Hitachi W) - -board HP785_C8000 0x89c 785/C8000 - -board HP712_60 0x600 712/60 (Gecko) -board HP712_80 0x601 712/80 (King Gecko) -board HP712_100 0x602 712/100 (King Gecko) -board HP743i_64 0x603 743i/64 (Anole-64) -board HP743i_100 0x604 743i/100 (Anole-100) -board HP712_120 0x605 712/120 (King Gecko) -#board HP 0x606 (Gila 80) -#board HP 0x607 (Gila 100) -#board HP 0x608 (Gila 120) -board HP715_80 0x609 715/80 (Scorpio-L) -board HP715_64 0x60A 715/64 (Mirage Jr.) -board HP715_100 0x60B 715/100 (Mirage Sr.) -board HP715_100XC 0x60C 715/100XC (Turnip) -board HP725_100 0x60D 725/100 (Electra) -board HP725_120 0x60E 725/120 (Electra) -board HP715_100L 0x610 715/100L (Scorpio-L) -board HP715_120L 0x611 715/120L (Scorpio-L) -board HP725_80L 0x612 725/80L (Spectra-L) -board HP725_100L 0x613 725/100L (Spectra-L) -board HP725_120L 0x614 725/120L (Spectra-L) -#board HP 0x615 /100 (Piranha 100) -#board HP 0x616 /120 (Piranha 120) -board HP743_50 0x617 743/50 (Jason) -board HP743_100 0x618 743/100 (Jason) -board HP715_80M 0x619 715/80 (Mirage) -board HP811 0x61a 811/DX5 (SAIC L-80) -board HP801 0x61b 801/DX0 (Rocky1 L-80) -board HP743T 0x61c 743T (Anole T) - -board HITACHIT80 0x67e (Hitachi Tiny 80) -board HITACHIT64 0x67f (Hitachi Tiny 64) - -board NEC 0x700 (NEC Aska) - -# IODC_HVERSION[0..4] -bus MID_BUS 0 MID_BUS -bus SMB 1 SMB -bus HPPB 2 HP-PB -bus SUMMIT 3 Summit -bus VVSC 4 Viper-VSC -bus VHPPB 5 Viper-HPPB -bus K9KSC 6 K9-KSC -bus SPSSC 7 Spider-SSC -bus STSSC 8 Stiletto-SSC -bus GSCHPPB 9 GSC-HPPB -bus GSCHSC 10 GSC+(HSC) -bus RUNWAY 11 Runway -bus GSC 12 GSC -bus GSCP 13 GSC++ -bus NECSB 14 NEC System Bus -bus ROPES 15 Ropes -bus MERCED 16 Merced - -cpu SOFTEMU 0x01 Software Emulation -#cpu PCXS 0x02 PCXS (Cheetah) -#cpu PCXT 0x09 PCXT (Thunderbird) -#cpu HARP 0x0a HARP-I -cpu PCXT2 0x0b PCXT' (Thunderbird') -#cpu PA50 0x0c PA-50 (Hitachi) -cpu PCXL 0x0d PCXL (Hummingbird) -cpu PCXU 0x0e PCXU (Onyx) -cpu PCXL2 0x0f PCXL2 (Velociraptor) -cpu PCXUP 0x10 PCXU+ (Vulcan) -cpu PCXW 0x11 PCXW (Vulcan) -#cpu PCXWP 0x?? PCXW+ (Landshark) -cpu PCXW2 0x13 PCXW2 (Piranha) -#cpu PCXM 0x?? Mako -#cpu PCXM2 0x?? Shortfin - -fpu SOFTEMU 0x01 Software Emulation -fpu INDIGO 0x02 Indigo -fpu TYCO 0x03 Sterling I MIU (TYCO) -fpu ROC 0x04 Sterling I MIU (ROC w/Weitek) -fpu FPCW 0x06 FPC (NMOS-III w/Weitek) -fpu FPCB 0x07 FPC (NMOS-III w/Bit) -fpu PCXS 0x08 PCXS (Timex-II) -fpu PCXT 0x09 PCXT (Rolex - CMOS-26B) -fpu HARP 0x0a HARP-I -fpu PCXT2 0x0b PCXT' (Tornado) -fpu PA50 0x0c PA-50 (Hitachi) -fpu PCXL 0x0d PCXL (CMOS-26B) -fpu PCXU 0x0e PCXU/PCXU+ -fpu VR 0x0f VR -fpu PCXW 0x10 PCXW -fpu PCXW2 0x13 PCXW2 - -nproc HPPA 4 PA-RISC - -memory ARCH 0x008 architected memory module -memory PDEP 0x009 pdep memory module - -bdma PARALLEL 0x018 Parallel I/O -bdma PRDB 0x019 Parallel RDB -bdma MIDBUSPSI 0x020 MID_BUS PSI -bdma HPPBTPSI 0x02f HP-PB Transit PSI -bdma HPPBT8023 0x051 HP-PB Transit 802.3 -bdma HPPBLANCON 0x052 Miura LAN/Console (J2146A) -bdma HPPB8024 0x058 HP-PB Transit 802.4 -bdma LANCONS 0x060 LAN/Console -bdma EXERCISER 0x094 GSC+ Exerciser -bdma HPPBHFI 0x100 HP-PB HF Interface - -#bdirect - -adma SCSI 0x039 SCSI -adma FWSCSI0 0x03b Wizard FW SCSI -adma HPIB 0x040 HP-IB -adma HPPBFL 0x041 HP-PB HP-FL -adma HPPBIB 0x042 HP-PB LoQuix HP-IB -adma HPPBCL 0x043 HP-PB Crypt LoQuix -adma HPPBGPS 0x044 HP-PB Shazam GPIO -adma HPPBGPL 0x045 HP-PB LoQuix GPIO -adma 2X25 0x046 2-Port X.25 NIO_ACC -adma 4X25 0x047 4-Port X.25 NIO_ACC -adma NIMBFB 0x04a Nimbus Frame Buffer -adma NIMBCL 0x04b Nimbus Control -adma MRTI 0x04c Martian RTI -adma ACCMUX 0x04d ACC Mux -adma L8023 0x050 Lanbrusca 802.3 -adma LQFDDI 0x056 HP-PB LoQuix FDDI -adma LQFDDI1 0x057 HP-PB LoQuix FDDI (28670A) -adma GTR 0x05e TI TokenRing -adma FWSCSI 0x089 FW SCSI -adma NETFC 0x091 Net FC -adma YATM 0x092 GSC+ YLIASTER ATM -adma MYRI 0x095 Hamlyn GSC+ Network Card -adma LFEMU 0x098 Lo-fat Emulator -adma VATM 0x09a GSC+ Venus ATM -adma HSCPCI 0x09d HP HSC-PCI Cards -adma ATMGSC 0x09e Alaxis GSC+ ATM -adma SHUSB 0x09f SummitHawk 230 USB -adma SHFETH 0x0a0 SummitHawk 230 100BaseT -adma MASSFC 0x0a7 Add-on mass FC -adma IPFC 0x380 Interphase NIO-FC -adma IPATM 0x381 Interphase NIO-ATM -adma IP100T 0x382 Interphase NIO-100BaseT -adma IPNIOVG 0x383 Interphase NIO-100VG - -adirect APMUX 0x00d AP/MUX -adirect RS232 0x00e RS-232 -adirect PEACOCK 0x00f Peacock Graphics -adirect HIL 0x014 HIL -adirect LEONARDO 0x015 Leonardo -adirect HRM 0x016 HP-PB HRM -adirect HRC 0x017 HP-PB HRC -adirect LPT 0x03a Centronics interface -adirect ATTDK 0x04e AT&T DataKit -adirect HPIB 0x09b Test&Meas GSC HPIB -adirect ROCKYKBD 0x0a8 Rocky2 Front Keyboard -adirect HICONS 0x101 Hitachi Console Module -adirect HIBOOT 0x102 Hitachi Boot Module - -other MIDBVM 0x030 MID_BUS Verification Master -other MIDBVS 0x034 MID_BUS Verification Slave -other MIDBEDU 0x038 MID_BUS Verification EDU -other SPECFB 0x048 Spectograph frame buffer -other SPECCTL 0x049 Spectograph control - -bcport PHANTOM 0x000 Phantom Port -bcport PORT 0x00c Bus Converter Port - -cio CIO 0x010 CIO - -console CHEETAH 0x01c Cheetah Console -console NULL 0x01f Jason/Anole Null Console - -fio A_X25 0x02e Armyknife Optional X.25 -fio 8x25 0x04f 8-Port X.25 EISA-ACC -fio SCSI 0x071 NCR 53C700 SCSI -fio LAN 0x072 Core LAN -fio HIL 0x073 Core HIL -fio CENT 0x074 Core Centronics -fio RS232 0x075 Core RS-232C -fio SGC 0x077 SGC Graphics -fio A1 0x07a Core audio (int.) -fio A2NB 0x07b Advanced audio (ext.) -fio FWSCSI 0x07c NCR 53C720 FW-SCSI -fio FDDI 0x07d Core FDDI -fio A1NB 0x07e Core audio (ext.) -fio A2 0x07f Advanced audio (int.) -fio HPIB 0x080 Core HPIB -fio TR9000 0x086 GSC IBM TokenRing -fio VMENET 0x088 VME Networking -fio BOOTROM 0x08f BOOT ROM -fio DINOPCK 0x096 Dino PC Keyboard -fio EISALAN 0x097 Cascade EISA 100VG lan -fio WHPIB 0x099 Wax/Clark/Dino HPIB -fio SPPCON 0x0a1 SPP2000 Console TTY -fio PCILAN 0x0a2 PCI Plug-In LAN -fio PCIDSK 0x0a3 PCI Plug-In Disk -fio SPPCORE 0x0a4 SPP2000 Core BA -fio SONICET 0x0a6 Sonic Ethernet -fio PCIMISC 0x0a9 Misc PCI Plug-in -fio METHEUS 0x320 Metheus Frame Buffer -fio BARCO 0x340 BARCO CX4500 VME Graphics Console -fio HUGHES 0x360 Hughes TOG VME FDDI - -# Gecko section -fio GSCSI 0x082 NCR 53C710 SCSI -fio GPCFD 0x083 floppy controller -fio GPCIO 0x084 PS/2 port -fio GSGC 0x085 GIO Graphics -fio GISDN 0x087 Core ISDN -fio GSCSCSI 0x089 GSC SCSI -fio GLAN 0x08a Core LAN -fio GRS232 0x08c Core RS-232C -fio GRJ16 0x08d Optional RJ-16 - -bha DIO 0x003 DIO Bus Adapter -bha SGC 0x005 SGC Bus Adapter -bha GSC 0x007 GSC Bus Adapter -bha ASP 0x070 Core Bus Adapter (ASP) -bha EISA 0x076 EISA Bus Adapter -bha VME 0x078 VME Bus Adapter -bha LASI 0x081 LASI Bus Adapter -bha PCMCIA 0x08b PCMCIA Bus Adapter -bha WAX 0x08e WAX Bus Adapter -bha WEISA 0x090 WAX EISA Bus Adapter -bha TIMI 0x093 TIMI Bus Adapter -bha EPIC 0x0a5 Epic PCI Bus Adapter - -ioa UTURN 0x00b U2/UTurn Runway BC Port -ioa PLUTO 0x00c Pluto BC Port - -bridge DINO 0x00a PCI Bridge -bridge SAGA 0x0a5 Saga PCI Bridge - -fabric DNACA 0x0aa Halfdome DNA Central Agent -fabric TOGO 0x0ab Halfdome TOGO Fabric Crossbar -fabric SAKURA 0x0ac Halfdome Sakura Fabric Router diff --git a/sys/arch/hppa/dev/cpudevs.h b/sys/arch/hppa/dev/cpudevs.h deleted file mode 100644 index ee0bc3796..000000000 --- a/sys/arch/hppa/dev/cpudevs.h +++ /dev/null @@ -1,373 +0,0 @@ -/* - * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. - * generated from: - * OpenBSD: cpudevs,v 1.44 2007/05/18 15:57:35 kettenis Exp - */ - -#define HPPA_TYPE_NPROC 0x00 -#define HPPA_TYPE_MEMORY 0x01 -#define HPPA_TYPE_BDMA 0x02 -#define HPPA_TYPE_BDIRECT 0x03 -#define HPPA_TYPE_ADMA 0x04 -#define HPPA_TYPE_ADIRECT 0x05 -#define HPPA_TYPE_OTHER 0x06 -#define HPPA_TYPE_BCPORT 0x07 -#define HPPA_TYPE_CIO 0x08 -#define HPPA_TYPE_CONSOLE 0x09 -#define HPPA_TYPE_FIO 0x0a -#define HPPA_TYPE_BHA 0x0b -#define HPPA_TYPE_IOA 0x0c -#define HPPA_TYPE_BRIDGE 0x0d -#define HPPA_TYPE_FABRIC 0x0e -#define HPPA_TYPE_FAULTY 0x1f -#define HPPA_TYPE_BOARD 0x80 -#define HPPA_TYPE_CPU 0x81 -#define HPPA_TYPE_FPU 0x82 -#define HPPA_TYPE_BUS 0x83 -#define HPPA_BOARD_HP840 0x004 -#define HPPA_BOARD_HP825 0x008 -#define HPPA_BOARD_HP835 0x00a -#define HPPA_BOARD_HP845 0x00b -#define HPPA_BOARD_HP850 0x00C -#define HPPA_BOARD_HP949 0x00f -#define HPPA_BOARD_HP950S 0x080 -#define HPPA_BOARD_HP855 0x081 -#define HPPA_BOARD_HP860 0x082 -#define HPPA_BOARD_HP870 0x083 -#define HPPA_BOARD_HP810 0x100 -#define HPPA_BOARD_HP822 0x101 -#define HPPA_BOARD_HP832 0x102 -#define HPPA_BOARD_HP808 0x103 -#define HPPA_BOARD_HP842 0x104 -#define HPPA_BOARD_HP852 0x105 -#define HPPA_BOARD_HPOBOE 0x106 -#define HPPA_BOARD_HPDRAGON 0x180 -#define HPPA_BOARD_HP890 0x181 -#define HPPA_BOARD_HP891 0x182 -#define HPPA_BOARD_HP892 0x183 -#define HPPA_BOARD_HP893_T540 0x184 -#define HPPA_BOARD_HPHXPROC 0x1ff -#define HPPA_BOARD_HP720 0x200 -#define HPPA_BOARD_HP750_66 0x201 -#define HPPA_BOARD_HP730_66 0x202 -#define HPPA_BOARD_HP735_99 0x203 -#define HPPA_BOARD_HP755_99 0x204 -#define HPPA_BOARD_HP755_125 0x205 -#define HPPA_BOARD_HP735_130 0x206 -#define HPPA_BOARD_HP817 0x280 -#define HPPA_BOARD_HP837 0x281 -#define HPPA_BOARD_HP807 0x282 -#define HPPA_BOARD_HP867 0x283 -#define HPPA_BOARD_HP887T 0x284 -#define HPPA_BOARD_HP887 0x287 -#define HPPA_BOARD_HP887T96 0x288 -#define HPPA_BOARD_HP710 0x300 -#define HPPA_BOARD_HP705 0x302 -#define HPPA_BOARD_HP715_50 0x310 -#define HPPA_BOARD_HP715_33 0x311 -#define HPPA_BOARD_HP715S_50 0x312 -#define HPPA_BOARD_HP715S_33 0x313 -#define HPPA_BOARD_HP715T_50 0x314 -#define HPPA_BOARD_HP715T_33 0x315 -#define HPPA_BOARD_HP715_75 0x316 -#define HPPA_BOARD_HP715_99 0x317 -#define HPPA_BOARD_HP725_50 0x318 -#define HPPA_BOARD_HP725_75 0x319 -#define HPPA_BOARD_HP725_99 0x320 -#define HPPA_BOARD_HP745I_50 0x401 -#define HPPA_BOARD_HP742I_50 0x402 -#define HPPA_BOARD_HP747I_100 0x403 -#define HPPA_BOARD_HPE23 0x480 -#define HPPA_BOARD_HPE25 0x481 -#define HPPA_BOARD_HPE35 0x482 -#define HPPA_BOARD_HPE45 0x483 -#define HPPA_BOARD_HPD210 0x484 -#define HPPA_BOARD_HPD200 0x485 -#define HPPA_BOARD_HP778_B132L 0x501 -#define HPPA_BOARD_HP778_B160L 0x502 -#define HPPA_BOARD_HP778_B132LP 0x503 -#define HPPA_BOARD_HP778_B180L 0x504 -#define HPPA_BOARD_HP779_C132L 0x505 -#define HPPA_BOARD_HP779_C160L 0x506 -#define HPPA_BOARD_HP779_C180L 0x507 -#define HPPA_BOARD_HP779_C160L1 0x508 -#define HPPA_BOARD_HP712_132L2 0x509 -#define HPPA_BOARD_HP712_160L2 0x50a -#define HPPA_BOARD_HP712_132L21 0x50b -#define HPPA_BOARD_HP712_160L21 0x50c -#define HPPA_BOARD_HP744_132L 0x50f -#define HPPA_BOARD_HP744_165L 0x510 -#define HPPA_BOARD_HP803 0x512 -#define HPPA_BOARD_HP813 0x513 -#define HPPA_BOARD_HP778_B132 0x514 -#define HPPA_BOARD_HP800_A132 0x515 -#define HPPA_BOARD_HP800_A180C 0x516 -#define HPPA_BOARD_HP809 0x580 -#define HPPA_BOARD_HP839 0x581 -#define HPPA_BOARD_HP829 0x582 -#define HPPA_BOARD_HP849 0x583 -#define HPPA_BOARD_HP770_J210XC 0x584 -#define HPPA_BOARD_HP770_J200 0x585 -#define HPPA_BOARD_HP770_J210 0x586 -#define HPPA_BOARD_HP841 0x587 -#define HPPA_BOARD_HP851 0x588 -#define HPPA_BOARD_HP821_1 0x589 -#define HPPA_BOARD_HP831 0x58a -#define HPPA_BOARD_HP819 0x58b -#define HPPA_BOARD_HP859 0x58c -#define HPPA_BOARD_HP869 0x58d -#define HPPA_BOARD_HP780_C110 0x58e -#define HPPA_BOARD_HP804 0x58f -#define HPPA_BOARD_HP889 0x590 -#define HPPA_BOARD_HP780_C100 0x592 -#define HPPA_BOARD_HP780_J282 0x594 -#define HPPA_BOARD_HP800V 0x597 -#define HPPA_BOARD_HP780_C230 0x598 -#define HPPA_BOARD_HP780_C240 0x599 -#define HPPA_BOARD_HP780_C160 0x59b -#define HPPA_BOARD_HP780_C180XP 0x59c -#define HPPA_BOARD_HP780_C200 0x59d -#define HPPA_BOARD_HP780_C180P 0x59f -#define HPPA_BOARD_HP841_1 0x5a0 -#define HPPA_BOARD_HP851_1 0x5a1 -#define HPPA_BOARD_HP861 0x5a2 -#define HPPA_BOARD_HP871 0x5a3 -#define HPPA_BOARD_HP802 0x5a4 -#define HPPA_BOARD_HP879 0x5a5 -#define HPPA_BOARD_HP810D 0x5a9 -#define HPPA_BOARD_HP820 0x5aa -#define HPPA_BOARD_HP898 0x5ae -#define HPPA_BOARD_HP899 0x5b1 -#define HPPA_BOARD_HP800V2 0x5b4 -#define HPPA_BOARD_HP782_J2240 0x5b5 -#define HPPA_BOARD_HP800K 0x5b6 -#define HPPA_BOARD_HP821 0x5b9 -#define HPPA_BOARD_HP800D 0x5ba -#define HPPA_BOARD_HP785_C3000 0x5bb -#define HPPA_BOARD_HP785_B1000 0x5bc -#define HPPA_BOARD_HP785_J5000 0x5bd -#define HPPA_BOARD_HP800_N400036 0x5be -#define HPPA_BOARD_HP785_J7000 0x5bf -#define HPPA_BOARD_HP800_L200044 0x5c4 -#define HPPA_BOARD_HP800_L200036 0x5c5 -#define HPPA_BOARD_HP785_C360 0x5c6 -#define HPPA_BOARD_HP800_L100044 0x5c9 -#define HPPA_BOARD_HP800_L100036 0x5ca -#define HPPA_BOARD_HP897_A50044 0x5cb -#define HPPA_BOARD_HP800_N400044 0x5cc -#define HPPA_BOARD_HP785_C3600 0x5cf -#define HPPA_BOARD_HP786_B2000 0x5d0 -#define HPPA_BOARD_HP785_J5600 0x5d1 -#define HPPA_BOARD_HP785_J7600 0x5d2 -#define HPPA_BOARD_HP800_N400055 0x5d3 -#define HPPA_BOARD_HP785_J6000 0x5d4 -#define HPPA_BOARD_HP897_A5005X 0x5d5 -#define HPPA_BOARD_HP897_A40044 0x5d6 -#define HPPA_BOARD_HP800_N40005X 0x5d7 -#define HPPA_BOARD_HP800_L150044 0x5d8 -#define HPPA_BOARD_HP800_L150036 0x5d9 -#define HPPA_BOARD_HP800_L30005X 0x5db -#define HPPA_BOARD_HP785_C3700 0x5dc -#define HPPA_BOARD_HP785_J6700 0x5dd -#define HPPA_BOARD_HP785_B2600 0x5de -#define HPPA_BOARD_HP897_A4006X 0x5e1 -#define HPPA_BOARD_HP897_A5006X 0x5e2 -#define HPPA_BOARD_HP897_A5007X 0x5e3 -#define HPPA_BOARD_HP800_N40007X 0x5e4 -#define HPPA_BOARD_HP800_N40006X 0x5e6 -#define HPPA_BOARD_HITACHIW 0x5ff -#define HPPA_BOARD_HP785_C8000 0x89c -#define HPPA_BOARD_HP712_60 0x600 -#define HPPA_BOARD_HP712_80 0x601 -#define HPPA_BOARD_HP712_100 0x602 -#define HPPA_BOARD_HP743I_64 0x603 -#define HPPA_BOARD_HP743I_100 0x604 -#define HPPA_BOARD_HP712_120 0x605 -#define HPPA_BOARD_HP715_80 0x609 -#define HPPA_BOARD_HP715_64 0x60A -#define HPPA_BOARD_HP715_100 0x60B -#define HPPA_BOARD_HP715_100XC 0x60C -#define HPPA_BOARD_HP725_100 0x60D -#define HPPA_BOARD_HP725_120 0x60E -#define HPPA_BOARD_HP715_100L 0x610 -#define HPPA_BOARD_HP715_120L 0x611 -#define HPPA_BOARD_HP725_80L 0x612 -#define HPPA_BOARD_HP725_100L 0x613 -#define HPPA_BOARD_HP725_120L 0x614 -#define HPPA_BOARD_HP743_50 0x617 -#define HPPA_BOARD_HP743_100 0x618 -#define HPPA_BOARD_HP715_80M 0x619 -#define HPPA_BOARD_HP811 0x61a -#define HPPA_BOARD_HP801 0x61b -#define HPPA_BOARD_HP743T 0x61c -#define HPPA_BOARD_HITACHIT80 0x67e -#define HPPA_BOARD_HITACHIT64 0x67f -#define HPPA_BOARD_NEC 0x700 -#define HPPA_BUS_MID_BUS 0 -#define HPPA_BUS_SMB 1 -#define HPPA_BUS_HPPB 2 -#define HPPA_BUS_SUMMIT 3 -#define HPPA_BUS_VVSC 4 -#define HPPA_BUS_VHPPB 5 -#define HPPA_BUS_K9KSC 6 -#define HPPA_BUS_SPSSC 7 -#define HPPA_BUS_STSSC 8 -#define HPPA_BUS_GSCHPPB 9 -#define HPPA_BUS_GSCHSC 10 -#define HPPA_BUS_RUNWAY 11 -#define HPPA_BUS_GSC 12 -#define HPPA_BUS_GSCP 13 -#define HPPA_BUS_NECSB 14 -#define HPPA_BUS_ROPES 15 -#define HPPA_BUS_MERCED 16 -#define HPPA_CPU_SOFTEMU 0x01 -#define HPPA_CPU_PCXT2 0x0b -#define HPPA_CPU_PCXL 0x0d -#define HPPA_CPU_PCXU 0x0e -#define HPPA_CPU_PCXL2 0x0f -#define HPPA_CPU_PCXUP 0x10 -#define HPPA_CPU_PCXW 0x11 -#define HPPA_CPU_PCXW2 0x13 -#define HPPA_FPU_SOFTEMU 0x01 -#define HPPA_FPU_INDIGO 0x02 -#define HPPA_FPU_TYCO 0x03 -#define HPPA_FPU_ROC 0x04 -#define HPPA_FPU_FPCW 0x06 -#define HPPA_FPU_FPCB 0x07 -#define HPPA_FPU_PCXS 0x08 -#define HPPA_FPU_PCXT 0x09 -#define HPPA_FPU_HARP 0x0a -#define HPPA_FPU_PCXT2 0x0b -#define HPPA_FPU_PA50 0x0c -#define HPPA_FPU_PCXL 0x0d -#define HPPA_FPU_PCXU 0x0e -#define HPPA_FPU_VR 0x0f -#define HPPA_FPU_PCXW 0x10 -#define HPPA_FPU_PCXW2 0x13 -#define HPPA_NPROC_HPPA 4 -#define HPPA_MEMORY_ARCH 0x008 -#define HPPA_MEMORY_PDEP 0x009 -#define HPPA_BDMA_PARALLEL 0x018 -#define HPPA_BDMA_PRDB 0x019 -#define HPPA_BDMA_MIDBUSPSI 0x020 -#define HPPA_BDMA_HPPBTPSI 0x02f -#define HPPA_BDMA_HPPBT8023 0x051 -#define HPPA_BDMA_HPPBLANCON 0x052 -#define HPPA_BDMA_HPPB8024 0x058 -#define HPPA_BDMA_LANCONS 0x060 -#define HPPA_BDMA_EXERCISER 0x094 -#define HPPA_BDMA_HPPBHFI 0x100 -#define HPPA_ADMA_SCSI 0x039 -#define HPPA_ADMA_FWSCSI0 0x03b -#define HPPA_ADMA_HPIB 0x040 -#define HPPA_ADMA_HPPBFL 0x041 -#define HPPA_ADMA_HPPBIB 0x042 -#define HPPA_ADMA_HPPBCL 0x043 -#define HPPA_ADMA_HPPBGPS 0x044 -#define HPPA_ADMA_HPPBGPL 0x045 -#define HPPA_ADMA_2X25 0x046 -#define HPPA_ADMA_4X25 0x047 -#define HPPA_ADMA_NIMBFB 0x04a -#define HPPA_ADMA_NIMBCL 0x04b -#define HPPA_ADMA_MRTI 0x04c -#define HPPA_ADMA_ACCMUX 0x04d -#define HPPA_ADMA_L8023 0x050 -#define HPPA_ADMA_LQFDDI 0x056 -#define HPPA_ADMA_LQFDDI1 0x057 -#define HPPA_ADMA_GTR 0x05e -#define HPPA_ADMA_FWSCSI 0x089 -#define HPPA_ADMA_NETFC 0x091 -#define HPPA_ADMA_YATM 0x092 -#define HPPA_ADMA_MYRI 0x095 -#define HPPA_ADMA_LFEMU 0x098 -#define HPPA_ADMA_VATM 0x09a -#define HPPA_ADMA_HSCPCI 0x09d -#define HPPA_ADMA_ATMGSC 0x09e -#define HPPA_ADMA_SHUSB 0x09f -#define HPPA_ADMA_SHFETH 0x0a0 -#define HPPA_ADMA_MASSFC 0x0a7 -#define HPPA_ADMA_IPFC 0x380 -#define HPPA_ADMA_IPATM 0x381 -#define HPPA_ADMA_IP100T 0x382 -#define HPPA_ADMA_IPNIOVG 0x383 -#define HPPA_ADIRECT_APMUX 0x00d -#define HPPA_ADIRECT_RS232 0x00e -#define HPPA_ADIRECT_PEACOCK 0x00f -#define HPPA_ADIRECT_HIL 0x014 -#define HPPA_ADIRECT_LEONARDO 0x015 -#define HPPA_ADIRECT_HRM 0x016 -#define HPPA_ADIRECT_HRC 0x017 -#define HPPA_ADIRECT_LPT 0x03a -#define HPPA_ADIRECT_ATTDK 0x04e -#define HPPA_ADIRECT_HPIB 0x09b -#define HPPA_ADIRECT_ROCKYKBD 0x0a8 -#define HPPA_ADIRECT_HICONS 0x101 -#define HPPA_ADIRECT_HIBOOT 0x102 -#define HPPA_OTHER_MIDBVM 0x030 -#define HPPA_OTHER_MIDBVS 0x034 -#define HPPA_OTHER_MIDBEDU 0x038 -#define HPPA_OTHER_SPECFB 0x048 -#define HPPA_OTHER_SPECCTL 0x049 -#define HPPA_BCPORT_PHANTOM 0x000 -#define HPPA_BCPORT_PORT 0x00c -#define HPPA_CIO_CIO 0x010 -#define HPPA_CONSOLE_CHEETAH 0x01c -#define HPPA_CONSOLE_NULL 0x01f -#define HPPA_FIO_A_X25 0x02e -#define HPPA_FIO_8X25 0x04f -#define HPPA_FIO_SCSI 0x071 -#define HPPA_FIO_LAN 0x072 -#define HPPA_FIO_HIL 0x073 -#define HPPA_FIO_CENT 0x074 -#define HPPA_FIO_RS232 0x075 -#define HPPA_FIO_SGC 0x077 -#define HPPA_FIO_A1 0x07a -#define HPPA_FIO_A2NB 0x07b -#define HPPA_FIO_FWSCSI 0x07c -#define HPPA_FIO_FDDI 0x07d -#define HPPA_FIO_A1NB 0x07e -#define HPPA_FIO_A2 0x07f -#define HPPA_FIO_HPIB 0x080 -#define HPPA_FIO_TR9000 0x086 -#define HPPA_FIO_VMENET 0x088 -#define HPPA_FIO_BOOTROM 0x08f -#define HPPA_FIO_DINOPCK 0x096 -#define HPPA_FIO_EISALAN 0x097 -#define HPPA_FIO_WHPIB 0x099 -#define HPPA_FIO_SPPCON 0x0a1 -#define HPPA_FIO_PCILAN 0x0a2 -#define HPPA_FIO_PCIDSK 0x0a3 -#define HPPA_FIO_SPPCORE 0x0a4 -#define HPPA_FIO_SONICET 0x0a6 -#define HPPA_FIO_PCIMISC 0x0a9 -#define HPPA_FIO_METHEUS 0x320 -#define HPPA_FIO_BARCO 0x340 -#define HPPA_FIO_HUGHES 0x360 -#define HPPA_FIO_GSCSI 0x082 -#define HPPA_FIO_GPCFD 0x083 -#define HPPA_FIO_GPCIO 0x084 -#define HPPA_FIO_GSGC 0x085 -#define HPPA_FIO_GISDN 0x087 -#define HPPA_FIO_GSCSCSI 0x089 -#define HPPA_FIO_GLAN 0x08a -#define HPPA_FIO_GRS232 0x08c -#define HPPA_FIO_GRJ16 0x08d -#define HPPA_BHA_DIO 0x003 -#define HPPA_BHA_SGC 0x005 -#define HPPA_BHA_GSC 0x007 -#define HPPA_BHA_ASP 0x070 -#define HPPA_BHA_EISA 0x076 -#define HPPA_BHA_VME 0x078 -#define HPPA_BHA_LASI 0x081 -#define HPPA_BHA_PCMCIA 0x08b -#define HPPA_BHA_WAX 0x08e -#define HPPA_BHA_WEISA 0x090 -#define HPPA_BHA_TIMI 0x093 -#define HPPA_BHA_EPIC 0x0a5 -#define HPPA_IOA_UTURN 0x00b -#define HPPA_IOA_PLUTO 0x00c -#define HPPA_BRIDGE_DINO 0x00a -#define HPPA_BRIDGE_SAGA 0x0a5 -#define HPPA_FABRIC_DNACA 0x0aa -#define HPPA_FABRIC_TOGO 0x0ab -#define HPPA_FABRIC_SAKURA 0x0ac diff --git a/sys/arch/hppa/dev/cpudevs_data.h b/sys/arch/hppa/dev/cpudevs_data.h deleted file mode 100644 index 7be4f69f3..000000000 --- a/sys/arch/hppa/dev/cpudevs_data.h +++ /dev/null @@ -1,354 +0,0 @@ -/* - * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. - * generated from: - * OpenBSD: cpudevs,v 1.44 2007/05/18 15:57:35 kettenis Exp - */ - -{HPPA_TYPE_BOARD, HPPA_BOARD_HP840, "840/930 (Indigo)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP825, "825/925 (FireFox)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP835, "83[45]/[69]35 (TopGun)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP845, "845/645 (Technical ShoGun)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP850, "850/950 (Cheetah)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP949, "949 (Commercial ShoGun)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP950S, "950S (Cheetah)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP855, "855/955 (Jaguar)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP860, "860/960 (Cougar)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP870, "865/870/980 (Panther)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP810, "810 (Burgundy)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP822, "822/922 (SilverFox Low)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP832, "832/932 (SilverFox High)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP808, "808/815/920 (Lego, SilverLite)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP842, "842/948 (SilverBullet Low)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP852, "852/958 (SilverBullet High)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HPOBOE, "(Oboe)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HPDRAGON, "(Dragon)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP890, "890/990/992 (Chimera)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP891, "891/T500 (TNT 100)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP892, "892/T520 (TNT 120)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP893_T540, "893/T540/T600 (Jade 180 U)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HPHXPROC, "Hitachi X Processor" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP720, "720 (Cobra)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP750_66, "750/66 (Coral)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP730_66, "730/66 (King Cobra)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP735_99, "735/99 (Hardball)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP755_99, "755/99 (Coral II)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP755_125, "755/125 (Coral II)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP735_130, "735/130 (Snake Cheetah)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP817, "817/827/957/957LX/FH20 (Nova Low)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP837, "837/847/857/967/967LX/FGHI30 (Nova High)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP807, "807/917/917LX/927/927LX/937/937LX/947/947LX/F10 (Nova8)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP867, "867/877/977/GHI40 (Nova64)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP887T, "887/897/987/GHI50 (TNova)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP887, "887/897/GHI70 (Hydra96 (Nova))" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP887T96, "887/897/GHI60 (TNova96)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP710, "710/50 (Bushmaster)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP705, "705/35 (Flounder)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715_50, "715/50 (Scorpio)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715_33, "715/33 (Scorpio Jr.)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715S_50, "715S/50 (Spider-50)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715S_33, "715S/33 (Spider-33)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715T_50, "715T/50 (Trailways-50)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715T_33, "715T/33 (Trailways-33)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715_75, "715/75 (Scorpio Sr.)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715_99, "715/99 (Scorpio 100)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP725_50, "725/50 (Spectra)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP725_75, "725/75 (Spectra)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP725_99, "725/99 (Spectra)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP745I_50, "745i/747i/50 (Pace)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP742I_50, "742i/50 (Sidewinder)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP747I_100, "745i/747i/100 (Fast Pace)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HPE23, "806/E23 (Orville)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HPE25, "806/E25 (Wilbur)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HPE35, "816/E35 (Wright Brothers 80)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HPE45, "826/E45 (Wright Brothers 96)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HPD210, "811/D210/D310 (UltraLight L 100)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HPD200, "801/D200/D300 (UltraLight L 75)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP778_B132L, "778/B132L (Merlin L2 132)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP778_B160L, "778/B160L (Merlin L2 160)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP778_B132LP, "778/B132L+ (Merlin L2+ 132)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP778_B180L, "778/B180L+ (Merlin L2+ 180)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP779_C132L, "779/C132L (Raven L2 132)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP779_C160L, "779/C160L (Raven L2 160)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP779_C180L, "779/C180L (Raven L2 180)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP779_C160L1, "779/C160L (Raven L2 160)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP712_132L2, "712/132 (L2 Upgrade)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP712_160L2, "712/160 (L2 Upgrade)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP712_132L21, "712/132 (L2 Upgrade)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP712_160L21, "712/160 (L2 Upgrade)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP744_132L, "744/132L (Anole-132L)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP744_165L, "744/165L (Anole-165L)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP803, "803/D220 (UltraLight L2 132)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP813, "813/D320 (UltraLight L2 160)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP778_B132, "778/B132 (Merlin Jr. L2 132)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_A132, "800/A132 (Staccato L2 132)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_A180C, "800/A180C (Staccato L2 180)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP809, "809/K100 (KittyHawk DC2-100)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP839, "839/K210 (KittyHawk DC3-120)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP829, "829/K400 (KittyHawk DC3-100)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP849, "849/K410 (KittyHawk DC3-120)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP770_J210XC, "770/J210XC (LighteningHawk)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP770_J200, "770/J200 (SkyHawk 100)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP770_J210, "770/J210 (SkyHawk 120)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP841, "841/D210/D410 (UltraLight Proc 1-way T'120)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP851, "851/D210-2/D410-2 (UltraLight Proc 2-way T'120)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP821_1, "821/D200/D400 (UltraLight Proc 1-way T'100)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP831, "831/D200-2/D400-2 (UltraLight Proc 2-way T'100)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP819, "819/K200 (KittyHawk DC2 100)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP859, "859/K220 (ThunderHawk DC3- 120 1M)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP869, "869/K420 (ThunderHawk DC3 120 1M)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP780_C110, "780/C110 (Raven 120 T')" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP804, "804/K450 (Mohawk 160 U 1M DC3)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP889, "889/K460 (Mohawk 180 U 1M DC3)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP780_C100, "780/C100 (Raven 100 T')" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP780_J282, "780/J282 (FireHawk 180 U)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800V, "800/V2200/V2500 (SPP2000)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP780_C230, "780/C230 (Raven U 230)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP780_C240, "780/C240 (Raven U 240)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP780_C160, "780/C160 (Raven U 160)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP780_C180XP, "780/C180XP (Raven U 180)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP780_C200, "780/C200 (Raven U 200)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP780_C180P, "780/C180+ (Raven U 180+)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP841_1, "841/D260/D360 (UltraLight 1-way T120 1MB)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP851_1, "851/D260/D360 (UltraLight 2-way T120 1MB)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP861, "861/D270/D370 (UltraLight 1-way U160 512K)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP871, "871/D270/D370 (UltraLight 2-way U160 512K)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP802, "802/K250 (MoHawk U160 1M DC3-)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP879, "879/K260 (MoHawk U180 1M DC3-)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP810D, "810/D380/R380 (UltraLight 1-way U180 1M)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP820, "820/D280 (UltraLight 2-way U180 1M)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP898, "898/K370 (BraveHawk 200 DC3-)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP899, "899/K570 (BraveHawk 200 DC3)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800V2, "800/V2500 (SPP2500)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP782_J2240, "782/J2240 (SummitHawk U+)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800K, "800/K580 (DragonHawk U+ 240 DC3)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP821, "821/D350/R350 (UltraLight 1w U+/240)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800D, "800/D390/R390 (UltraLight 2w U+/240)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_C3000, "785/C3000 (AllegroHigh W)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_B1000, "785/B1000 (AllegroLow W)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_J5000, "785/J5000 (Forte W 2w)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_N400036, "800/N4000-36/rp7400 (Prelude W)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_J7000, "785/J7000 (Forte W 4w)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_L200044, "800/L2000-44/rp5450 (Rhapsody 440)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_L200036, "800/L2000-36/rp5450 (Rhapsody 360)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_C360, "780/C360 (Raven W 360)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_L100044, "800/L1000-44/rp5400 (Rhapsody DC-440)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_L100036, "800/L1000-36/rp5400 (Rhapsody DC-360)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP897_A50044, "897/A500-44/rp2450 (Crescendo 440)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_N400044, "800/N4000-44/rp7400 (Prelude W 440)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_C3600, "785/C3600 (Allegro)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP786_B2000, "786/B2000 (Kazoo W+)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_J5600, "785/J5600 (Forte W+ 2w)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_J7600, "785/J7600 (Forte W+ 4w)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_N400055, "800/N4000-55/rp7400 (Prelude W+ 550)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_J6000, "785/J6000 (Duet W+)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP897_A5005X, "897/A500-5X/rp2450 (Crescendo 550)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP897_A40044, "897/A400-44/rp2400 (Crescendo 440)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_N40005X, "800/N4000-5X/rp7410 (Keystone W+ 550)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_L150044, "800/L1500-44/rp5430 (Rhapsody wave 2 W+)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_L150036, "800/L1500-36/rp5430 (Rhapsody wave 2 W+)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_L30005X, "800/L3000-5X/rp5470 (Marcato W+)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_C3700, "785/C3700" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_J6700, "785/J6700 (Duet W2)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_B2600, "785/B2600 (Piccolo W+)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP897_A4006X, "897/A400-6X/rp2430 (Crescendo DC-W2)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP897_A5006X, "897/A500-6X/rp2470 (Crescendo 650 W2)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP897_A5007X, "897/A500-7X/rp2470 (Crescendo 750 W2)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_N40007X, "800/N4000-7X/rp7410 (Keystone/Matterhorn W2 750)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP800_N40006X, "800/N4000-6X/rp7410 (Keystone/Matterhorn W2 650)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HITACHIW, "(Hitachi W)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP785_C8000, "785/C8000" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP712_60, "712/60 (Gecko)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP712_80, "712/80 (King Gecko)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP712_100, "712/100 (King Gecko)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP743I_64, "743i/64 (Anole-64)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP743I_100, "743i/100 (Anole-100)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP712_120, "712/120 (King Gecko)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715_80, "715/80 (Scorpio-L)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715_64, "715/64 (Mirage Jr.)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715_100, "715/100 (Mirage Sr.)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715_100XC, "715/100XC (Turnip)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP725_100, "725/100 (Electra)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP725_120, "725/120 (Electra)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715_100L, "715/100L (Scorpio-L)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715_120L, "715/120L (Scorpio-L)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP725_80L, "725/80L (Spectra-L)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP725_100L, "725/100L (Spectra-L)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP725_120L, "725/120L (Spectra-L)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP743_50, "743/50 (Jason)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP743_100, "743/100 (Jason)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP715_80M, "715/80 (Mirage)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP811, "811/DX5 (SAIC L-80)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP801, "801/DX0 (Rocky1 L-80)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HP743T, "743T (Anole T)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HITACHIT80, "(Hitachi Tiny 80)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_HITACHIT64, "(Hitachi Tiny 64)" }, -{HPPA_TYPE_BOARD, HPPA_BOARD_NEC, "(NEC Aska)" }, -{HPPA_TYPE_BUS, HPPA_BUS_MID_BUS, "MID_BUS" }, -{HPPA_TYPE_BUS, HPPA_BUS_SMB, "SMB" }, -{HPPA_TYPE_BUS, HPPA_BUS_HPPB, "HP-PB" }, -{HPPA_TYPE_BUS, HPPA_BUS_SUMMIT, "Summit" }, -{HPPA_TYPE_BUS, HPPA_BUS_VVSC, "Viper-VSC" }, -{HPPA_TYPE_BUS, HPPA_BUS_VHPPB, "Viper-HPPB" }, -{HPPA_TYPE_BUS, HPPA_BUS_K9KSC, "K9-KSC" }, -{HPPA_TYPE_BUS, HPPA_BUS_SPSSC, "Spider-SSC" }, -{HPPA_TYPE_BUS, HPPA_BUS_STSSC, "Stiletto-SSC" }, -{HPPA_TYPE_BUS, HPPA_BUS_GSCHPPB, "GSC-HPPB" }, -{HPPA_TYPE_BUS, HPPA_BUS_GSCHSC, "GSC+(HSC)" }, -{HPPA_TYPE_BUS, HPPA_BUS_RUNWAY, "Runway" }, -{HPPA_TYPE_BUS, HPPA_BUS_GSC, "GSC" }, -{HPPA_TYPE_BUS, HPPA_BUS_GSCP, "GSC++" }, -{HPPA_TYPE_BUS, HPPA_BUS_NECSB, "NEC System Bus" }, -{HPPA_TYPE_BUS, HPPA_BUS_ROPES, "Ropes" }, -{HPPA_TYPE_BUS, HPPA_BUS_MERCED, "Merced" }, -{HPPA_TYPE_CPU, HPPA_CPU_SOFTEMU, "Software Emulation" }, -{HPPA_TYPE_CPU, HPPA_CPU_PCXT2, "PCXT' (Thunderbird')" }, -{HPPA_TYPE_CPU, HPPA_CPU_PCXL, "PCXL (Hummingbird)" }, -{HPPA_TYPE_CPU, HPPA_CPU_PCXU, "PCXU (Onyx)" }, -{HPPA_TYPE_CPU, HPPA_CPU_PCXL2, "PCXL2 (Velociraptor)" }, -{HPPA_TYPE_CPU, HPPA_CPU_PCXUP, "PCXU+ (Vulcan)" }, -{HPPA_TYPE_CPU, HPPA_CPU_PCXW, "PCXW (Vulcan)" }, -{HPPA_TYPE_CPU, HPPA_CPU_PCXW2, "PCXW2 (Piranha)" }, -{HPPA_TYPE_FPU, HPPA_FPU_SOFTEMU, "Software Emulation" }, -{HPPA_TYPE_FPU, HPPA_FPU_INDIGO, "Indigo" }, -{HPPA_TYPE_FPU, HPPA_FPU_TYCO, "Sterling I MIU (TYCO)" }, -{HPPA_TYPE_FPU, HPPA_FPU_ROC, "Sterling I MIU (ROC w/Weitek)" }, -{HPPA_TYPE_FPU, HPPA_FPU_FPCW, "FPC (NMOS-III w/Weitek)" }, -{HPPA_TYPE_FPU, HPPA_FPU_FPCB, "FPC (NMOS-III w/Bit)" }, -{HPPA_TYPE_FPU, HPPA_FPU_PCXS, "PCXS (Timex-II)" }, -{HPPA_TYPE_FPU, HPPA_FPU_PCXT, "PCXT (Rolex - CMOS-26B)" }, -{HPPA_TYPE_FPU, HPPA_FPU_HARP, "HARP-I" }, -{HPPA_TYPE_FPU, HPPA_FPU_PCXT2, "PCXT' (Tornado)" }, -{HPPA_TYPE_FPU, HPPA_FPU_PA50, "PA-50 (Hitachi)" }, -{HPPA_TYPE_FPU, HPPA_FPU_PCXL, "PCXL (CMOS-26B)" }, -{HPPA_TYPE_FPU, HPPA_FPU_PCXU, "PCXU/PCXU+" }, -{HPPA_TYPE_FPU, HPPA_FPU_VR, "VR" }, -{HPPA_TYPE_FPU, HPPA_FPU_PCXW, "PCXW" }, -{HPPA_TYPE_FPU, HPPA_FPU_PCXW2, "PCXW2" }, -{HPPA_TYPE_NPROC, HPPA_NPROC_HPPA, "PA-RISC" }, -{HPPA_TYPE_MEMORY, HPPA_MEMORY_ARCH, "architected memory module" }, -{HPPA_TYPE_MEMORY, HPPA_MEMORY_PDEP, "pdep memory module" }, -{HPPA_TYPE_BDMA, HPPA_BDMA_PARALLEL, "Parallel I/O" }, -{HPPA_TYPE_BDMA, HPPA_BDMA_PRDB, "Parallel RDB" }, -{HPPA_TYPE_BDMA, HPPA_BDMA_MIDBUSPSI, "MID_BUS PSI" }, -{HPPA_TYPE_BDMA, HPPA_BDMA_HPPBTPSI, "HP-PB Transit PSI" }, -{HPPA_TYPE_BDMA, HPPA_BDMA_HPPBT8023, "HP-PB Transit 802.3" }, -{HPPA_TYPE_BDMA, HPPA_BDMA_HPPBLANCON, "Miura LAN/Console (J2146A)" }, -{HPPA_TYPE_BDMA, HPPA_BDMA_HPPB8024, "HP-PB Transit 802.4" }, -{HPPA_TYPE_BDMA, HPPA_BDMA_LANCONS, "LAN/Console" }, -{HPPA_TYPE_BDMA, HPPA_BDMA_EXERCISER, "GSC+ Exerciser" }, -{HPPA_TYPE_BDMA, HPPA_BDMA_HPPBHFI, "HP-PB HF Interface" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_SCSI, "SCSI" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_FWSCSI0, "Wizard FW SCSI" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_HPIB, "HP-IB" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_HPPBFL, "HP-PB HP-FL" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_HPPBIB, "HP-PB LoQuix HP-IB" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_HPPBCL, "HP-PB Crypt LoQuix" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_HPPBGPS, "HP-PB Shazam GPIO" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_HPPBGPL, "HP-PB LoQuix GPIO" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_2X25, "2-Port X.25 NIO_ACC" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_4X25, "4-Port X.25 NIO_ACC" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_NIMBFB, "Nimbus Frame Buffer" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_NIMBCL, "Nimbus Control" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_MRTI, "Martian RTI" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_ACCMUX, "ACC Mux" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_L8023, "Lanbrusca 802.3" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_LQFDDI, "HP-PB LoQuix FDDI" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_LQFDDI1, "HP-PB LoQuix FDDI (28670A)" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_GTR, "TI TokenRing" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_FWSCSI, "FW SCSI" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_NETFC, "Net FC" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_YATM, "GSC+ YLIASTER ATM" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_MYRI, "Hamlyn GSC+ Network Card" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_LFEMU, "Lo-fat Emulator" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_VATM, "GSC+ Venus ATM" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_HSCPCI, "HP HSC-PCI Cards" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_ATMGSC, "Alaxis GSC+ ATM" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_SHUSB, "SummitHawk 230 USB" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_SHFETH, "SummitHawk 230 100BaseT" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_MASSFC, "Add-on mass FC" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_IPFC, "Interphase NIO-FC" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_IPATM, "Interphase NIO-ATM" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_IP100T, "Interphase NIO-100BaseT" }, -{HPPA_TYPE_ADMA, HPPA_ADMA_IPNIOVG, "Interphase NIO-100VG" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_APMUX, "AP/MUX" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_RS232, "RS-232" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_PEACOCK, "Peacock Graphics" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_HIL, "HIL" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_LEONARDO, "Leonardo" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_HRM, "HP-PB HRM" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_HRC, "HP-PB HRC" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_LPT, "Centronics interface" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_ATTDK, "AT&T DataKit" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_HPIB, "Test&Meas GSC HPIB" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_ROCKYKBD, "Rocky2 Front Keyboard" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_HICONS, "Hitachi Console Module" }, -{HPPA_TYPE_ADIRECT, HPPA_ADIRECT_HIBOOT, "Hitachi Boot Module" }, -{HPPA_TYPE_OTHER, HPPA_OTHER_MIDBVM, "MID_BUS Verification Master" }, -{HPPA_TYPE_OTHER, HPPA_OTHER_MIDBVS, "MID_BUS Verification Slave" }, -{HPPA_TYPE_OTHER, HPPA_OTHER_MIDBEDU, "MID_BUS Verification EDU" }, -{HPPA_TYPE_OTHER, HPPA_OTHER_SPECFB, "Spectograph frame buffer" }, -{HPPA_TYPE_OTHER, HPPA_OTHER_SPECCTL, "Spectograph control" }, -{HPPA_TYPE_BCPORT, HPPA_BCPORT_PHANTOM, "Phantom Port" }, -{HPPA_TYPE_BCPORT, HPPA_BCPORT_PORT, "Bus Converter Port" }, -{HPPA_TYPE_CIO, HPPA_CIO_CIO, "CIO" }, -{HPPA_TYPE_CONSOLE, HPPA_CONSOLE_CHEETAH, "Cheetah Console" }, -{HPPA_TYPE_CONSOLE, HPPA_CONSOLE_NULL, "Jason/Anole Null Console" }, -{HPPA_TYPE_FIO, HPPA_FIO_A_X25, "Armyknife Optional X.25" }, -{HPPA_TYPE_FIO, HPPA_FIO_8X25, "8-Port X.25 EISA-ACC" }, -{HPPA_TYPE_FIO, HPPA_FIO_SCSI, "NCR 53C700 SCSI" }, -{HPPA_TYPE_FIO, HPPA_FIO_LAN, "Core LAN" }, -{HPPA_TYPE_FIO, HPPA_FIO_HIL, "Core HIL" }, -{HPPA_TYPE_FIO, HPPA_FIO_CENT, "Core Centronics" }, -{HPPA_TYPE_FIO, HPPA_FIO_RS232, "Core RS-232C" }, -{HPPA_TYPE_FIO, HPPA_FIO_SGC, "SGC Graphics" }, -{HPPA_TYPE_FIO, HPPA_FIO_A1, "Core audio (int.)" }, -{HPPA_TYPE_FIO, HPPA_FIO_A2NB, "Advanced audio (ext.)" }, -{HPPA_TYPE_FIO, HPPA_FIO_FWSCSI, "NCR 53C720 FW-SCSI" }, -{HPPA_TYPE_FIO, HPPA_FIO_FDDI, "Core FDDI" }, -{HPPA_TYPE_FIO, HPPA_FIO_A1NB, "Core audio (ext.)" }, -{HPPA_TYPE_FIO, HPPA_FIO_A2, "Advanced audio (int.)" }, -{HPPA_TYPE_FIO, HPPA_FIO_HPIB, "Core HPIB" }, -{HPPA_TYPE_FIO, HPPA_FIO_TR9000, "GSC IBM TokenRing" }, -{HPPA_TYPE_FIO, HPPA_FIO_VMENET, "VME Networking" }, -{HPPA_TYPE_FIO, HPPA_FIO_BOOTROM, "BOOT ROM" }, -{HPPA_TYPE_FIO, HPPA_FIO_DINOPCK, "Dino PC Keyboard" }, -{HPPA_TYPE_FIO, HPPA_FIO_EISALAN, "Cascade EISA 100VG lan" }, -{HPPA_TYPE_FIO, HPPA_FIO_WHPIB, "Wax/Clark/Dino HPIB" }, -{HPPA_TYPE_FIO, HPPA_FIO_SPPCON, "SPP2000 Console TTY" }, -{HPPA_TYPE_FIO, HPPA_FIO_PCILAN, "PCI Plug-In LAN" }, -{HPPA_TYPE_FIO, HPPA_FIO_PCIDSK, "PCI Plug-In Disk" }, -{HPPA_TYPE_FIO, HPPA_FIO_SPPCORE, "SPP2000 Core BA" }, -{HPPA_TYPE_FIO, HPPA_FIO_SONICET, "Sonic Ethernet" }, -{HPPA_TYPE_FIO, HPPA_FIO_PCIMISC, "Misc PCI Plug-in" }, -{HPPA_TYPE_FIO, HPPA_FIO_METHEUS, "Metheus Frame Buffer" }, -{HPPA_TYPE_FIO, HPPA_FIO_BARCO, "BARCO CX4500 VME Graphics Console" }, -{HPPA_TYPE_FIO, HPPA_FIO_HUGHES, "Hughes TOG VME FDDI" }, -{HPPA_TYPE_FIO, HPPA_FIO_GSCSI, "NCR 53C710 SCSI" }, -{HPPA_TYPE_FIO, HPPA_FIO_GPCFD, "floppy controller" }, -{HPPA_TYPE_FIO, HPPA_FIO_GPCIO, "PS/2 port" }, -{HPPA_TYPE_FIO, HPPA_FIO_GSGC, "GIO Graphics" }, -{HPPA_TYPE_FIO, HPPA_FIO_GISDN, "Core ISDN" }, -{HPPA_TYPE_FIO, HPPA_FIO_GSCSCSI, "GSC SCSI" }, -{HPPA_TYPE_FIO, HPPA_FIO_GLAN, "Core LAN" }, -{HPPA_TYPE_FIO, HPPA_FIO_GRS232, "Core RS-232C" }, -{HPPA_TYPE_FIO, HPPA_FIO_GRJ16, "Optional RJ-16" }, -{HPPA_TYPE_BHA, HPPA_BHA_DIO, "DIO Bus Adapter" }, -{HPPA_TYPE_BHA, HPPA_BHA_SGC, "SGC Bus Adapter" }, -{HPPA_TYPE_BHA, HPPA_BHA_GSC, "GSC Bus Adapter" }, -{HPPA_TYPE_BHA, HPPA_BHA_ASP, "Core Bus Adapter (ASP)" }, -{HPPA_TYPE_BHA, HPPA_BHA_EISA, "EISA Bus Adapter" }, -{HPPA_TYPE_BHA, HPPA_BHA_VME, "VME Bus Adapter" }, -{HPPA_TYPE_BHA, HPPA_BHA_LASI, "LASI Bus Adapter" }, -{HPPA_TYPE_BHA, HPPA_BHA_PCMCIA, "PCMCIA Bus Adapter" }, -{HPPA_TYPE_BHA, HPPA_BHA_WAX, "WAX Bus Adapter" }, -{HPPA_TYPE_BHA, HPPA_BHA_WEISA, "WAX EISA Bus Adapter" }, -{HPPA_TYPE_BHA, HPPA_BHA_TIMI, "TIMI Bus Adapter" }, -{HPPA_TYPE_BHA, HPPA_BHA_EPIC, "Epic PCI Bus Adapter" }, -{HPPA_TYPE_IOA, HPPA_IOA_UTURN, "U2/UTurn Runway BC Port" }, -{HPPA_TYPE_IOA, HPPA_IOA_PLUTO, "Pluto BC Port" }, -{HPPA_TYPE_BRIDGE, HPPA_BRIDGE_DINO, "PCI Bridge" }, -{HPPA_TYPE_BRIDGE, HPPA_BRIDGE_SAGA, "Saga PCI Bridge" }, -{HPPA_TYPE_FABRIC, HPPA_FABRIC_DNACA, "Halfdome DNA Central Agent" }, -{HPPA_TYPE_FABRIC, HPPA_FABRIC_TOGO, "Halfdome TOGO Fabric Crossbar" }, -{HPPA_TYPE_FABRIC, HPPA_FABRIC_SAKURA, "Halfdome Sakura Fabric Router" }, -{ -1 } diff --git a/sys/arch/hppa/dev/devlist2h.awk b/sys/arch/hppa/dev/devlist2h.awk deleted file mode 100644 index f5684f040..000000000 --- a/sys/arch/hppa/dev/devlist2h.awk +++ /dev/null @@ -1,119 +0,0 @@ -# $OpenBSD: devlist2h.awk,v 1.6 2004/04/07 18:24:19 mickey Exp $ - -# -# Copyright (c) 1998-2003 Michael Shalayeff -# 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 OR HIS RELATIVES 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 MIND, 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. -# - -BEGIN { - ncpu = 0; - cpuh="cpudevs.h"; - cpud="cpudevs_data.h"; - SUBSEP = "_"; -} - -/^[ \t]*$/ {next} - -/^[ \t]*\/\*/ {busted++} - -/^[ \t]*#/ {next} - -busted { - cp = match($0, /\*\//); - if(!cp) { - next; - } else if (cp + 1 == length($0)) { - busted = 0; - next; - } else { - sub(/.*\*\//, ""); - busted = 0; - } -} - -# first line is rcsid, beware -NR == 1 { - VERSION = $0; - gsub("\\$", "", VERSION); - - printf("/*\n * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n" \ - " * generated from:\n *\t%s\n */\n\n", VERSION) > cpud; - printf("/*\n * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT.\n" \ - " * generated from:\n *\t%s\n */\n\n", VERSION) > cpuh; -} - -$1 == "type" { - printf("#define\tHPPA_TYPE_%s\t%s\n", toupper($2), $3) > cpuh; - types[tolower($2)] = toupper($2); - next; -} - -NR > 1 { - if (tolower($1) in types) { - printf("#define\tHPPA_%s_%s\t%s\n", toupper($1), - toupper($2), $3) > cpuh; - printf("{HPPA_TYPE_%s,\tHPPA_%s_%s,\t\"", toupper($1), - toupper($1), toupper($2), $3) > cpud; - f = 4; - while (f <= NF) { - sub(/[ \t]*/, "", $f); - ep = match($f, /\*\//); - if (busted && !ep) { - f++; - continue; - } - if (match($f, /\/\*/)) { - if (ep) { - sub(/\/\*/, "", $f); - } else { - sub(/\/\*.*$/, "", $f); - busted++; - } - } - if (ep) { - gsub(/^.*\*\//, "", $f); - busted = 0; - } - if (length($f)) { - if (f > 4) - printf (" ") > cpud; - printf ("%s", $f) > cpud; - } - f++; - } - printf("\" },\n") > cpud; - } else { - printf("WHA at line %d\n", NR); - exit(1); - } -} - -END { - if (busted) { - print("unterminated comment at the EOF\n"); - exit(1); - } - printf("{ -1 }\n") > cpud; -} - diff --git a/sys/arch/hppa/dev/dino.c b/sys/arch/hppa/dev/dino.c deleted file mode 100644 index dd52d9583..000000000 --- a/sys/arch/hppa/dev/dino.c +++ /dev/null @@ -1,1840 +0,0 @@ -/* $OpenBSD: dino.c,v 1.33 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2003-2005 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 "cardbus.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#if NCARDBUS > 0 -#include -#endif - -#include -#include -#include - -#include -#include - -#define DINO_MEM_CHUNK 0x800000 -#define DINO_MEM_WINDOW (2 * DINO_MEM_CHUNK) - -struct dino_regs { - u_int32_t pad0; /* 0x000 */ - u_int32_t iar0; /* 0x004 rw intr addr reg 0 */ - u_int32_t iodc; /* 0x008 rw iodc data/addr */ - u_int32_t irr0; /* 0x00c r intr req reg 0 */ - u_int32_t iar1; /* 0x010 rw intr addr reg 1 */ - u_int32_t irr1; /* 0x014 r intr req reg 1 */ - u_int32_t imr; /* 0x018 rw intr mask reg */ - u_int32_t ipr; /* 0x01c rw intr pending reg */ - u_int32_t toc_addr; /* 0x020 rw TOC addr reg */ - u_int32_t icr; /* 0x024 rw intr control reg */ - u_int32_t ilr; /* 0x028 r intr level reg */ - u_int32_t pad1; /* 0x02c */ - u_int32_t io_command; /* 0x030 w command register */ - u_int32_t io_status; /* 0x034 r status register */ - u_int32_t io_control; /* 0x038 rw control register */ - u_int32_t pad2; /* 0x03c AUX registers follow */ - u_int32_t io_gsc_err_addr;/* 0x040 GSC error address */ - u_int32_t io_err_info; /* 0x044 error info register */ - u_int32_t io_pci_err_addr;/* 0x048 PCI error address */ - u_int32_t pad3[4]; /* 0x04c */ - u_int32_t io_fbb_en; /* 0x05c fast back2back enable reg */ - u_int32_t io_addr_en; /* 0x060 address enable reg */ - u_int32_t pci_addr; /* 0x064 PCI conf/io/mem addr reg */ - u_int32_t pci_conf_data; /* 0x068 PCI conf data reg */ - u_int32_t pci_io_data; /* 0x06c PCI io data reg */ - u_int32_t pci_mem_data; /* 0x070 PCI memory data reg */ - u_int32_t pad4[0x740/4]; /* 0x074 */ - u_int32_t gsc2x_config; /* 0x7b4 GSC2X config reg */ - u_int32_t pad5[0x48/4]; /* 0x7b8: BSRS registers follow */ - u_int32_t gmask; /* 0x800 GSC arbitration mask */ - u_int32_t pamr; /* 0x804 PCI arbitration mask */ - u_int32_t papr; /* 0x808 PCI arbitration priority */ - u_int32_t damode; /* 0x80c PCI arbitration mode */ - u_int32_t pcicmd; /* 0x810 PCI command register */ - u_int32_t pcists; /* 0x814 PCI status register */ - u_int32_t pad6; /* 0x818 */ - u_int32_t mltim; /* 0x81c PCI master latency timer */ - u_int32_t brdg_feat; /* 0x820 PCI bridge feature enable */ - u_int32_t pciror; /* 0x824 PCI read optimization reg */ - u_int32_t pciwor; /* 0x828 PCI write optimization reg */ - u_int32_t pad7; /* 0x82c */ - u_int32_t tltim; /* 0x830 PCI target latency reg */ -}; - -struct dino_softc { - struct device sc_dv; - - int sc_ver; - void *sc_ih; - u_int32_t sc_imr; - bus_space_tag_t sc_bt; - bus_space_handle_t sc_bh; - bus_dma_tag_t sc_dmat; - volatile struct dino_regs *sc_regs; - - struct hppa_pci_chipset_tag sc_pc; - struct hppa_bus_space_tag sc_iot; - char sc_ioexname[20]; - struct extent *sc_ioex; - struct hppa_bus_space_tag sc_memt; - char sc_memexname[20]; - struct extent *sc_memex; - struct hppa_bus_dma_tag sc_dmatag; - - u_int32_t io_shadow; -}; - -int dinomatch(struct device *, void *, void *); -void dinoattach(struct device *, struct device *, void *); -int dino_intr(void *); - -const struct cfattach dino_ca = { - sizeof(struct dino_softc), dinomatch, dinoattach -}; - -struct cfdriver dino_cd = { - NULL, "dino", DV_DULL -}; - -int -dinomatch(parent, cfdata, aux) - struct device *parent; - void *cfdata; - void *aux; -{ - struct confargs *ca = aux; - /* struct cfdata *cf = cfdata; */ - - /* there will be only one */ - if (ca->ca_type.iodc_type != HPPA_TYPE_BRIDGE || - ca->ca_type.iodc_sv_model != HPPA_BRIDGE_DINO) - return (0); - - /* do not match on the elroy family */ - if (ca->ca_type.iodc_model == 0x78) - return (0); - - return (1); -} - -void dino_attach_hook(struct device *, struct device *, - struct pcibus_attach_args *); -int dino_maxdevs(void *, int); -pcitag_t dino_make_tag(void *, int, int, int); -void dino_decompose_tag(void *, pcitag_t, int *, int *, int *); -int dino_conf_size(void *, pcitag_t); -pcireg_t dino_conf_read(void *, pcitag_t, int); -void dino_conf_write(void *, pcitag_t, int, pcireg_t); -int dino_intr_map(struct pci_attach_args *, pci_intr_handle_t *); -const char *dino_intr_string(void *, pci_intr_handle_t); -void * dino_intr_establish(void *, pci_intr_handle_t, int, int (*)(void *), - void *, const char *); -void dino_intr_disestablish(void *, void *); -int dino_iomap(void *, bus_addr_t, bus_size_t, int, bus_space_handle_t *); -int dino_memmap(void *, bus_addr_t, bus_size_t, int, bus_space_handle_t *); -int dino_subregion(void *, bus_space_handle_t, bus_size_t, bus_size_t, - bus_space_handle_t *); -int dino_ioalloc(void *, bus_addr_t, bus_addr_t, bus_size_t, bus_size_t, - bus_size_t, int, bus_addr_t *, bus_space_handle_t *); -int dino_memalloc(void *, bus_addr_t, bus_addr_t, bus_size_t, bus_size_t, - bus_size_t, int, bus_addr_t *, bus_space_handle_t *); -void dino_unmap(void *, bus_space_handle_t, bus_size_t); -void dino_free(void *, bus_space_handle_t, bus_size_t); -void dino_barrier(void *, bus_space_handle_t, bus_size_t, bus_size_t, int); -void * dino_alloc_parent(struct device *, struct pci_attach_args *, int); -void * dino_vaddr(void *, bus_space_handle_t); -u_int8_t dino_r1(void *, bus_space_handle_t, bus_size_t); -u_int16_t dino_r2(void *, bus_space_handle_t, bus_size_t); -u_int32_t dino_r4(void *, bus_space_handle_t, bus_size_t); -u_int64_t dino_r8(void *, bus_space_handle_t, bus_size_t); -void dino_w1(void *, bus_space_handle_t, bus_size_t, u_int8_t); -void dino_w2(void *, bus_space_handle_t, bus_size_t, u_int16_t); -void dino_w4(void *, bus_space_handle_t, bus_size_t, u_int32_t); -void dino_w8(void *, bus_space_handle_t, bus_size_t, u_int64_t); -void dino_rm_1(void *, bus_space_handle_t, bus_size_t, u_int8_t *, - bus_size_t); -void dino_rm_2(void *, bus_space_handle_t, bus_size_t, u_int16_t *, - bus_size_t); -void dino_rm_4(void *, bus_space_handle_t, bus_size_t, u_int32_t *, - bus_size_t); -void dino_rm_8(void *, bus_space_handle_t, bus_size_t, u_int64_t *, - bus_size_t); -void dino_wm_1(void *, bus_space_handle_t, bus_size_t, const u_int8_t *, - bus_size_t); -void dino_wm_2(void *, bus_space_handle_t, bus_size_t, const u_int16_t *, - bus_size_t); -void dino_wm_4(void *, bus_space_handle_t, bus_size_t, const u_int32_t *, - bus_size_t); -void dino_wm_8(void *, bus_space_handle_t, bus_size_t, const u_int64_t *, - bus_size_t); -void dino_sm_1(void *, bus_space_handle_t, bus_size_t, u_int8_t, bus_size_t); -void dino_sm_2(void *, bus_space_handle_t, bus_size_t, u_int16_t, - bus_size_t); -void dino_sm_4(void *, bus_space_handle_t, bus_size_t, u_int32_t, - bus_size_t); -void dino_sm_8(void *, bus_space_handle_t, bus_size_t, u_int64_t, - bus_size_t); -void dino_rrm_2(void *, bus_space_handle_t, bus_size_t, u_int8_t *, - bus_size_t); -void dino_rrm_4(void *, bus_space_handle_t, bus_size_t, u_int8_t *, - bus_size_t); -void dino_rrm_8(void *, bus_space_handle_t, bus_size_t, u_int8_t *, - bus_size_t); -void dino_wrm_2(void *, bus_space_handle_t, bus_size_t, const u_int8_t *, - bus_size_t); -void dino_wrm_4(void *, bus_space_handle_t, bus_size_t, const u_int8_t *, - bus_size_t); -void dino_wrm_8(void *, bus_space_handle_t, bus_size_t, const u_int8_t *, - bus_size_t); -void dino_rr_1(void *, bus_space_handle_t, bus_size_t, u_int8_t *, - bus_size_t); -void dino_rr_2(void *, bus_space_handle_t, bus_size_t, u_int16_t *, - bus_size_t); -void dino_rr_4(void *, bus_space_handle_t, bus_size_t, u_int32_t *, - bus_size_t); -void dino_rr_8(void *, bus_space_handle_t, bus_size_t, u_int64_t *, - bus_size_t); -void dino_wr_1(void *, bus_space_handle_t, bus_size_t, const u_int8_t *, - bus_size_t); -void dino_wr_2(void *, bus_space_handle_t, bus_size_t, const u_int16_t *, - bus_size_t); -void dino_wr_4(void *, bus_space_handle_t, bus_size_t, const u_int32_t *, - bus_size_t); -void dino_wr_8(void *, bus_space_handle_t, bus_size_t, const u_int64_t *, - bus_size_t); -void dino_rrr_2(void *, bus_space_handle_t, bus_size_t, u_int8_t *, - bus_size_t); -void dino_rrr_4(void *, bus_space_handle_t, bus_size_t, u_int8_t *, - bus_size_t); -void dino_rrr_8(void *, bus_space_handle_t, bus_size_t, u_int8_t *, - bus_size_t); -void dino_wrr_2(void *, bus_space_handle_t, bus_size_t, const u_int8_t *, - bus_size_t); -void dino_wrr_4(void *, bus_space_handle_t, bus_size_t, const u_int8_t *, - bus_size_t); -void dino_wrr_8(void *, bus_space_handle_t, bus_size_t, const u_int8_t *, - bus_size_t); -void dino_sr_1(void *, bus_space_handle_t, bus_size_t, u_int8_t, bus_size_t); -void dino_sr_2(void *, bus_space_handle_t, bus_size_t, u_int16_t, - bus_size_t); -void dino_sr_4(void *, bus_space_handle_t, bus_size_t, u_int32_t, - bus_size_t); -void dino_sr_8(void *, bus_space_handle_t, bus_size_t, u_int64_t, - bus_size_t); -void dino_cp_1(void *, bus_space_handle_t, bus_size_t, bus_space_handle_t, - bus_size_t, bus_size_t); -void dino_cp_2(void *, bus_space_handle_t, bus_size_t, bus_space_handle_t, - bus_size_t, bus_size_t); -void dino_cp_4(void *, bus_space_handle_t, bus_size_t, bus_space_handle_t, - bus_size_t, bus_size_t); -void dino_cp_8(void *, bus_space_handle_t, bus_size_t, bus_space_handle_t, - bus_size_t, bus_size_t); -int dino_dmamap_create(void *, bus_size_t, int, bus_size_t, bus_size_t, int, - bus_dmamap_t *); -void dino_dmamap_destroy(void *, bus_dmamap_t); -int dino_dmamap_load(void *, bus_dmamap_t, void *, bus_size_t, - struct proc *, int); -int dino_dmamap_load_mbuf(void *, bus_dmamap_t, struct mbuf *, int); -int dino_dmamap_load_uio(void *, bus_dmamap_t, struct uio *, int); -int dino_dmamap_load_raw(void *, bus_dmamap_t, bus_dma_segment_t *, int, - bus_size_t, int); -void dino_dmamap_unload(void *, bus_dmamap_t); -void dino_dmamap_sync(void *, bus_dmamap_t, bus_addr_t, bus_size_t, int); -int dino_dmamem_alloc(void *, bus_size_t, bus_size_t, bus_size_t, - bus_dma_segment_t *, int, int *, int); -void dino_dmamem_free(void *, bus_dma_segment_t *, int); -int dino_dmamem_map(void *, bus_dma_segment_t *, int, size_t, caddr_t *, - int); -void dino_dmamem_unmap(void *, caddr_t, size_t); -paddr_t dino_dmamem_mmap(void *, bus_dma_segment_t *, int, off_t, int, int); -int dinoprint(void *, const char *); -void dino_clear_pdc_mappings(void *); - -void -dino_attach_hook(struct device *parent, struct device *self, - struct pcibus_attach_args *pba) -{ - -} - -int -dino_maxdevs(void *v, int bus) -{ - return (32); -} - -pcitag_t -dino_make_tag(void *v, int bus, int dev, int func) -{ - if (bus > 255 || dev > 31 || func > 7) - panic("dino_make_tag: bad request"); - - return ((bus << 16) | (dev << 11) | (func << 8)); -} - -void -dino_decompose_tag(void *v, pcitag_t tag, int *bus, int *dev, int *func) -{ - if (bus) - *bus = (tag >> 16) & 0xff; - if (dev) - *dev = (tag >> 11) & 0x1f; - if (func) - *func= (tag >> 8) & 0x07; -} - -int -dino_conf_size(void *v, pcitag_t tag) -{ - return PCI_CONFIG_SPACE_SIZE; -} - -pcireg_t -dino_conf_read(void *v, pcitag_t tag, int reg) -{ - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - pcireg_t data; - u_int32_t pamr; - - /* fix arbitration errata by disabling all pci devs on config read */ - pamr = r->pamr; - r->pamr = 0; - - r->pci_addr = tag | reg; - data = r->pci_conf_data; - - /* restore arbitration */ - r->pamr = pamr; - - return (letoh32(data)); -} - -void -dino_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data) -{ - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - pcireg_t data1; - u_int32_t pamr; - - /* fix arbitration errata by disabling all pci devs on config read */ - pamr = r->pamr; - r->pamr = 0; - - r->pci_addr = tag | reg; - r->pci_conf_data = htole32(data); - - /* fix coalescing config and io writes by interleaving w/ a read */ - r->pci_addr = tag | PCI_ID_REG; - data1 = r->pci_conf_data; - - /* restore arbitration */ - r->pamr = pamr; -} - -int -dino_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp) -{ - /* struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; */ - pci_chipset_tag_t pc = pa->pa_pc; - pcitag_t tag = pa->pa_tag; - pcireg_t reg; - - reg = pci_conf_read(pc, tag, PCI_INTERRUPT_REG); - - if (PCI_INTERRUPT_LINE(reg) == 0xff) - return (1); - - *ihp = PCI_INTERRUPT_LINE(reg) + 1; - return (0); -} - -const char * -dino_intr_string(void *v, pci_intr_handle_t ih) -{ - static char buf[32]; - - snprintf(buf, 32, "dino irq %ld", ih); - - return (buf); -} - -void * -dino_intr_establish(void *v, pci_intr_handle_t ih, - int pri, int (*handler)(void *), void *arg, const char *name) -{ - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - void *iv; - - /* no mapping or bogus */ - if (ih <= 0 || ih > 11) - return (NULL); - - if ((iv = cpu_intr_map(sc->sc_ih, pri, ih - 1, handler, arg, name))) { - if (cold) - sc->sc_imr |= (1 << (ih - 1)); - else - r->imr = sc->sc_imr |= (1 << (ih - 1)); - } - - return (iv); -} - -void -dino_intr_disestablish(void *v, void *cookie) -{ -#if 0 - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->imr &= ~(1 << (ih - 1)); - - TODO cpu_intr_unmap(sc->sc_ih, cookie); -#endif -} - -int -dino_iomap(void *v, bus_addr_t bpa, bus_size_t size, - int flags, bus_space_handle_t *bshp) -{ - struct dino_softc *sc = v; - int error; - - if ((error = extent_alloc_region(sc->sc_ioex, bpa, size, EX_NOWAIT))) - return (error); - - if (bshp) - *bshp = bpa; - - return (0); -} - -int -dino_memmap(void *v, bus_addr_t bpa, bus_size_t size, - int flags, bus_space_handle_t *bshp) -{ - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - bus_addr_t sbpa; - bus_space_handle_t bush; - u_int32_t reg; - int first = 1; - int error; - - while (size != 0) { - sbpa = bpa & 0xff800000; - reg = sc->io_shadow; - reg |= 1 << ((bpa >> 23) & 0x1f); - if (reg & 0x80000001) { -#ifdef DEBUG - panic("mapping outside the mem extent range"); -#endif - return (EINVAL); - } - /* map into the upper bus space, if not yet mapped this 8M */ - if (reg != sc->io_shadow) { - - if ((error = bus_space_map(sc->sc_bt, sbpa, - DINO_MEM_CHUNK, flags, &bush))) { - return (error); - } - r->io_addr_en |= reg; - sc->io_shadow = reg; - - if (first) { - if (bshp) - *bshp = bush + (bpa - sbpa); - } - } else { - if (first) { - if (bshp) - *bshp = bpa; - } - } - - if (first) { - size += (bpa - sbpa); - first = 0; - } - - if (size < DINO_MEM_CHUNK) - size = 0; - else { - size -= DINO_MEM_CHUNK; - bpa = sbpa + DINO_MEM_CHUNK; - } - } - - return (0); -} - -int -dino_subregion(void *v, bus_space_handle_t bsh, bus_size_t offset, - bus_size_t size, bus_space_handle_t *nbshp) -{ - *nbshp = bsh + offset; - return (0); -} - -int -dino_ioalloc(void *v, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, - bus_size_t align, bus_size_t boundary, int flags, bus_addr_t *addrp, - bus_space_handle_t *bshp) -{ - struct dino_softc *sc = v; - struct extent *ex = sc->sc_ioex; - bus_addr_t bpa; - int error; - - if (rstart < ex->ex_start || rend > ex->ex_end) - panic("dino_ioalloc: bad region start/end"); - - if ((error = extent_alloc_subregion(ex, rstart, rend, size, - align, 0, boundary, EX_NOWAIT, &bpa))) - return (error); - - if (addrp) - *addrp = bpa; - if (bshp) - *bshp = bpa; - - return (0); -} - -int -dino_memalloc(void *v, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, - bus_size_t align, bus_size_t boundary, int flags, bus_addr_t *addrp, - bus_space_handle_t *bshp) -{ - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - u_int32_t reg; - - if (bus_space_alloc(sc->sc_bt, rstart, rend, size, - align, boundary, flags, addrp, bshp)) - return (ENOMEM); - - reg = sc->io_shadow; - reg |= 1 << ((*addrp >> 23) & 0x1f); - if (reg & 0x80000001) { -#ifdef DEBUG - panic("mapping outside the mem extent range"); -#endif - return (EINVAL); - } - r->io_addr_en |= reg; - sc->io_shadow = reg; - - return (0); -} - -void -dino_unmap(void *v, bus_space_handle_t bsh, bus_size_t size) -{ - struct dino_softc *sc = v; - struct extent *ex; - bus_addr_t bpa; - - bpa = bsh; - if (bsh & 0xf0000000) { - /* TODO dino_unmap mem */ - /* TODO unmap from the upper bus if the last use in this 8M */ - return; - } else - ex = sc->sc_ioex; - - if (extent_free(ex, bpa, size, EX_NOWAIT)) - printf("dino_unmap: ps 0x%lx, size 0x%lx\n" - "dino_unmap: can't free region\n", bpa, size); -} - -void -dino_free(void *v, bus_space_handle_t bh, bus_size_t size) -{ - /* should be enough */ - dino_unmap(v, bh, size); -} - -void -dino_barrier(void *v, bus_space_handle_t h, bus_size_t o, bus_size_t l, int op) -{ - sync_caches(); -} - -#if NCARDBUS > 0 -void * -dino_alloc_parent(struct device *self, struct pci_attach_args *pa, int io) -{ - struct dino_softc *sc = pa->pa_pc->_cookie; - struct extent *ex; - bus_space_tag_t tag; - bus_addr_t start; - bus_size_t size; - - if (io) { - ex = sc->sc_ioex; - tag = pa->pa_iot; - start = 0xa000; - size = 0x1000; - } else { - if (!sc->sc_memex) { - bus_space_handle_t memh; - bus_addr_t mem_start; - - if (dino_memalloc(sc, 0xf0800000, 0xff7fffff, - DINO_MEM_WINDOW, DINO_MEM_WINDOW, EX_NOBOUNDARY, - 0, &mem_start, &memh)) - return (NULL); - - snprintf(sc->sc_memexname, sizeof(sc->sc_memexname), - "%s_mem", sc->sc_dv.dv_xname); - if ((sc->sc_memex = extent_create(sc->sc_memexname, - mem_start, mem_start + DINO_MEM_WINDOW, M_DEVBUF, - NULL, 0, EX_NOWAIT | EX_MALLOCOK)) == NULL) { - extent_destroy(sc->sc_ioex); - bus_space_free(sc->sc_bt, memh, - DINO_MEM_WINDOW); - return (NULL); - } - } - ex = sc->sc_memex; - tag = pa->pa_memt; - start = ex->ex_start; - size = DINO_MEM_CHUNK; - } - - if (extent_alloc_subregion(ex, start, ex->ex_end, size, size, 0, - EX_NOBOUNDARY, EX_NOWAIT, &start)) - return (NULL); - - extent_free(ex, start, size, EX_NOWAIT); - return rbus_new_root_share(tag, ex, start, size); -} -#endif - -void * -dino_vaddr(void *v, bus_space_handle_t h) -{ - if (h & 0xf0000000) - return ((void *)h); - else - return (NULL); -} - -u_int8_t -dino_r1(void *v, bus_space_handle_t h, bus_size_t o) -{ - h += o; - if (h & 0xf0000000) - return *(volatile u_int8_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - u_int8_t data; - - r->pci_addr = h; - data = *((volatile u_int8_t *)&r->pci_io_data + (h & 3)); - return (data); - } -} - -u_int16_t -dino_r2(void *v, bus_space_handle_t h, bus_size_t o) -{ - volatile u_int16_t *p; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int16_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int16_t *)&r->pci_io_data; - if (h & 2) - p++; - } - - return (letoh16(*p)); -} - -u_int32_t -dino_r4(void *v, bus_space_handle_t h, bus_size_t o) -{ - u_int32_t data; - - h += o; - if (h & 0xf0000000) - data = *(volatile u_int32_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - data = r->pci_io_data; - } - - return (letoh32(data)); -} - -u_int64_t -dino_r8(void *v, bus_space_handle_t h, bus_size_t o) -{ - u_int64_t data; - - h += o; - if (h & 0xf0000000) - data = *(volatile u_int64_t *)h; - else - panic("dino_r8: not implemented"); - - return (letoh64(data)); -} - -void -dino_w1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv) -{ - h += o; - if (h & 0xf0000000) - *(volatile u_int8_t *)h = vv; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - *((volatile u_int8_t *)&r->pci_io_data + (h & 3)) = vv; - } -} - -void -dino_w2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv) -{ - volatile u_int16_t *p; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int16_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int16_t *)&r->pci_io_data; - if (h & 2) - p++; - } - - *p = htole16(vv); -} - -void -dino_w4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv) -{ - h += o; - vv = htole32(vv); - if (h & 0xf0000000) - *(volatile u_int32_t *)h = vv; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - r->pci_io_data = vv; - } -} - -void -dino_w8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv) -{ - h += o; - if (h & 0xf0000000) - *(volatile u_int64_t *)h = htole64(vv); - else - panic("dino_w8: not implemented"); -} - - -void -dino_rm_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t *a, bus_size_t c) -{ - volatile u_int8_t *p; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int8_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int8_t *)&r->pci_io_data + (h & 3); - } - - while (c--) - *a++ = *p; -} - -void -dino_rm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t c) -{ - volatile u_int16_t *p; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int16_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int16_t *)&r->pci_io_data; - if (h & 2) - p++; - } - - while (c--) - *a++ = letoh16(*p); -} - -void -dino_rm_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t *a, bus_size_t c) -{ - volatile u_int32_t *p; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int32_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int32_t *)&r->pci_io_data; - } - - while (c--) - *a++ = letoh32(*p); -} - -void -dino_rm_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t *a, bus_size_t c) -{ - panic("dino_rm_8: not implemented"); -} - -void -dino_wm_1(void *v, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, bus_size_t c) -{ - volatile u_int8_t *p; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int8_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int8_t *)&r->pci_io_data + (h & 3); - } - - while (c--) - *p = *a++; -} - -void -dino_wm_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_size_t c) -{ - volatile u_int16_t *p; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int16_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int16_t *)&r->pci_io_data; - if (h & 2) - p++; - } - - while (c--) - *p = htole16(*a++); -} - -void -dino_wm_4(void *v, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, bus_size_t c) -{ - volatile u_int32_t *p; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int32_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int32_t *)&r->pci_io_data; - } - - while (c--) - *p = htole32(*a++); -} - -void -dino_wm_8(void *v, bus_space_handle_t h, bus_size_t o, const u_int64_t *a, bus_size_t c) -{ - panic("dino_wm_8: not implemented"); -} - -void -dino_sm_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv, bus_size_t c) -{ - volatile u_int8_t *p; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int8_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int8_t *)&r->pci_io_data + (h & 3); - } - - while (c--) - *p = vv; -} - -void -dino_sm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, bus_size_t c) -{ - volatile u_int16_t *p; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int16_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int16_t *)&r->pci_io_data; - if (h & 2) - p++; - } - - vv = htole16(vv); - while (c--) - *p = vv; -} - -void -dino_sm_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv, bus_size_t c) -{ - volatile u_int32_t *p; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int32_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int32_t *)&r->pci_io_data; - } - - vv = htole32(vv); - while (c--) - *p = vv; -} - -void -dino_sm_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv, bus_size_t c) -{ - panic("dino_sm_8: not implemented"); -} - -void -dino_rrm_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c) -{ - volatile u_int16_t *p, *q = (u_int16_t *)a; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int16_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int16_t *)&r->pci_io_data; - if (h & 2) - p++; - } - - c /= 2; - while (c--) - *q++ = *p; -} - -void -dino_rrm_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c) -{ - volatile u_int32_t *p, *q = (u_int32_t *)a; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int32_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int32_t *)&r->pci_io_data; - } - - c /= 4; - while (c--) - *q++ = *p; -} - -void -dino_rrm_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c) -{ - panic("dino_rrm_8: not implemented"); -} - -void -dino_wrm_2(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c) -{ - volatile u_int16_t *p; - const u_int16_t *q = (const u_int16_t *)a; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int16_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int16_t *)&r->pci_io_data; - if (h & 2) - p++; - } - - c /= 2; - while (c--) - *p = *q++; -} - -void -dino_wrm_4(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c) -{ - volatile u_int32_t *p; - const u_int32_t *q = (const u_int32_t *)a; - - h += o; - if (h & 0xf0000000) - p = (volatile u_int32_t *)h; - else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - r->pci_addr = h; - p = (volatile u_int32_t *)&r->pci_io_data; - } - - c /= 4; - while (c--) - *p = *q++; -} - -void -dino_wrm_8(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c) -{ - panic("dino_wrm_8: not implemented"); -} - -void -dino_rr_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t *a, bus_size_t c) -{ - volatile u_int8_t *p; - - h += o; - if (h & 0xf0000000) { - p = (volatile u_int8_t *)h; - while (c--) - *a++ = *p++; - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h++) { - r->pci_addr = h; - p = (volatile u_int8_t *)&r->pci_io_data + (h & 3); - *a++ = *p; - } - } -} - -void -dino_rr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t c) -{ - volatile u_int16_t *p, data; - - h += o; - if (h & 0xf0000000) { - p = (volatile u_int16_t *)h; - while (c--) { - data = *p++; - *a++ = letoh16(data); - } - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h += 2) { - r->pci_addr = h; - p = (volatile u_int16_t *)&r->pci_io_data; - if (h & 2) - p++; - data = *p; - *a++ = letoh16(data); - } - } -} - -void -dino_rr_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t *a, bus_size_t c) -{ - volatile u_int32_t *p, data; - - h += o; - if (h & 0xf0000000) { - p = (volatile u_int32_t *)h; - while (c--) { - data = *p++; - *a++ = letoh32(data); - } - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h += 4) { - r->pci_addr = h; - data = r->pci_io_data; - *a++ = letoh32(data); - } - } -} - -void -dino_rr_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t *a, bus_size_t c) -{ - panic("dino_rr_8: not implemented"); -} - -void -dino_wr_1(void *v, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, bus_size_t c) -{ - volatile u_int8_t *p; - - h += o; - if (h & 0xf0000000) { - p = (volatile u_int8_t *)h; - while (c--) - *p++ = *a++; - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h++) { - r->pci_addr = h; - p = (volatile u_int8_t *)&r->pci_io_data + (h & 3); - *p = *a++; - } - } -} - -void -dino_wr_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_size_t c) -{ - volatile u_int16_t *p, data; - - h += o; - if (h & 0xf0000000) { - p = (volatile u_int16_t *)h; - while (c--) { - data = *a++; - *p++ = htole16(data); - } - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h += 2) { - r->pci_addr = h; - p = (volatile u_int16_t *)&r->pci_io_data; - if (h & 2) - p++; - data = *a++; - *p = htole16(data); - } - } -} - -void -dino_wr_4(void *v, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, bus_size_t c) -{ - volatile u_int32_t *p, data; - - h += o; - if (h & 0xf0000000) { - p = (volatile u_int32_t *)h; - while (c--) { - data = *a++; - *p++ = htole32(data); - } - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h += 4) { - r->pci_addr = h; - data = *a++; - r->pci_io_data = htole32(data); - } - } -} - -void -dino_wr_8(void *v, bus_space_handle_t h, bus_size_t o, const u_int64_t *a, bus_size_t c) -{ - panic("dino_wr_8: not implemented"); -} - -void -dino_rrr_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c) -{ - volatile u_int16_t *p, *q = (u_int16_t *)a; - - c /= 2; - h += o; - if (h & 0xf0000000) { - p = (volatile u_int16_t *)h; - while (c--) - *q++ = *p++; - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h += 2) { - r->pci_addr = h; - p = (volatile u_int16_t *)&r->pci_io_data; - if (h & 2) - p++; - *q++ = *p; - } - } -} - -void -dino_rrr_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c) -{ - volatile u_int32_t *p, *q = (u_int32_t *)a; - - c /= 4; - h += o; - if (h & 0xf0000000) { - p = (volatile u_int32_t *)h; - while (c--) - *q++ = *p++; - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h += 4) { - r->pci_addr = h; - *q++ = r->pci_io_data; - } - } -} - -void -dino_rrr_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c) -{ - panic("dino_rrr_8: not implemented"); -} - -void -dino_wrr_2(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c) -{ - volatile u_int16_t *p; - const u_int16_t *q = (u_int16_t *)a; - - c /= 2; - h += o; - if (h & 0xf0000000) { - p = (volatile u_int16_t *)h; - while (c--) - *p++ = *q++; - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h += 2) { - r->pci_addr = h; - p = (volatile u_int16_t *)&r->pci_io_data; - if (h & 2) - p++; - *p = *q++; - } - } -} - -void -dino_wrr_4(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c) -{ - volatile u_int32_t *p; - const u_int32_t *q = (u_int32_t *)a; - - c /= 4; - h += o; - if (h & 0xf0000000) { - p = (volatile u_int32_t *)h; - while (c--) - *p++ = *q++; - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h += 4) { - r->pci_addr = h; - r->pci_io_data = *q++; - } - } -} - -void -dino_wrr_8(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c) -{ - panic("dino_wrr_8: not implemented"); -} - -void -dino_sr_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv, bus_size_t c) -{ - volatile u_int8_t *p; - - h += o; - if (h & 0xf0000000) { - p = (volatile u_int8_t *)h; - while (c--) - *p++ = vv; - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h++) { - r->pci_addr = h; - p = (volatile u_int8_t *)&r->pci_io_data + (h & 3); - *p = vv; - } - } -} - -void -dino_sr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, bus_size_t c) -{ - volatile u_int16_t *p; - - h += o; - vv = htole16(vv); - if (h & 0xf0000000) { - p = (volatile u_int16_t *)h; - while (c--) - *p++ = vv; - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h += 2) { - r->pci_addr = h; - p = (volatile u_int16_t *)&r->pci_io_data; - if (h & 2) - p++; - *p = vv; - } - } -} - -void -dino_sr_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv, bus_size_t c) -{ - volatile u_int32_t *p; - - h += o; - vv = htole32(vv); - if (h & 0xf0000000) { - p = (volatile u_int32_t *)h; - while (c--) - *p++ = vv; - } else { - struct dino_softc *sc = v; - volatile struct dino_regs *r = sc->sc_regs; - - for (; c--; h += 4) { - r->pci_addr = h; - r->pci_io_data = vv; - } - } -} - -void -dino_sr_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv, bus_size_t c) -{ - panic("dino_sr_8: not implemented"); -} - -void -dino_cp_1(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - while (c--) - dino_w1(v, h1, o1++, dino_r1(v, h2, o2++)); -} - -void -dino_cp_2(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - while (c--) { - dino_w2(v, h1, o1, dino_r2(v, h2, o2)); - o1 += 2; - o2 += 2; - } -} - -void -dino_cp_4(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - while (c--) { - dino_w4(v, h1, o1, dino_r4(v, h2, o2)); - o1 += 4; - o2 += 4; - } -} - -void -dino_cp_8(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - while (c--) { - dino_w8(v, h1, o1, dino_r8(v, h2, o2)); - o1 += 8; - o2 += 8; - } -} - - -const struct hppa_bus_space_tag dino_iomemt = { - NULL, - - NULL, dino_unmap, dino_subregion, NULL, dino_free, - dino_barrier, dino_vaddr, - dino_r1, dino_r2, dino_r4, dino_r8, - dino_w1, dino_w2, dino_w4, dino_w8, - dino_rm_1, dino_rm_2, dino_rm_4, dino_rm_8, - dino_wm_1, dino_wm_2, dino_wm_4, dino_wm_8, - dino_sm_1, dino_sm_2, dino_sm_4, dino_sm_8, - dino_rrm_2, dino_rrm_4, dino_rrm_8, - dino_wrm_2, dino_wrm_4, dino_wrm_8, - dino_rr_1, dino_rr_2, dino_rr_4, dino_rr_8, - dino_wr_1, dino_wr_2, dino_wr_4, dino_wr_8, - dino_rrr_2, dino_rrr_4, dino_rrr_8, - dino_wrr_2, dino_wrr_4, dino_wrr_8, - dino_sr_1, dino_sr_2, dino_sr_4, dino_sr_8, - dino_cp_1, dino_cp_2, dino_cp_4, dino_cp_8 -}; - -int -dino_dmamap_create(void *v, bus_size_t size, int nsegments, - bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp) -{ - struct dino_softc *sc = v; - - /* TODO check the addresses, boundary, enable dma */ - - return (bus_dmamap_create(sc->sc_dmat, size, nsegments, - maxsegsz, boundary, flags, dmamp)); -} - -void -dino_dmamap_destroy(void *v, bus_dmamap_t map) -{ - struct dino_softc *sc = v; - - bus_dmamap_destroy(sc->sc_dmat, map); -} - -int -dino_dmamap_load(void *v, bus_dmamap_t map, void *addr, bus_size_t size, - struct proc *p, int flags) -{ - struct dino_softc *sc = v; - - return (bus_dmamap_load(sc->sc_dmat, map, addr, size, p, flags)); -} - -int -dino_dmamap_load_mbuf(void *v, bus_dmamap_t map, struct mbuf *m, int flags) -{ - struct dino_softc *sc = v; - - return (bus_dmamap_load_mbuf(sc->sc_dmat, map, m, flags)); -} - -int -dino_dmamap_load_uio(void *v, bus_dmamap_t map, struct uio *uio, int flags) -{ - struct dino_softc *sc = v; - - return (bus_dmamap_load_uio(sc->sc_dmat, map, uio, flags)); -} - -int -dino_dmamap_load_raw(void *v, bus_dmamap_t map, bus_dma_segment_t *segs, - int nsegs, bus_size_t size, int flags) -{ - struct dino_softc *sc = v; - - return (bus_dmamap_load_raw(sc->sc_dmat, map, segs, nsegs, size, flags)); -} - -void -dino_dmamap_unload(void *v, bus_dmamap_t map) -{ - struct dino_softc *sc = v; - - bus_dmamap_unload(sc->sc_dmat, map); -} - -void -dino_dmamap_sync(void *v, bus_dmamap_t map, bus_addr_t off, - bus_size_t len, int ops) -{ - struct dino_softc *sc = v; - - return (bus_dmamap_sync(sc->sc_dmat, map, off, len, ops)); -} - -int -dino_dmamem_alloc(void *v, bus_size_t size, bus_size_t alignment, - bus_size_t boundary, bus_dma_segment_t *segs, - int nsegs, int *rsegs, int flags) -{ - struct dino_softc *sc = v; - - return (bus_dmamem_alloc(sc->sc_dmat, size, alignment, boundary, - segs, nsegs, rsegs, flags)); -} - -void -dino_dmamem_free(void *v, bus_dma_segment_t *segs, int nsegs) -{ - struct dino_softc *sc = v; - - bus_dmamem_free(sc->sc_dmat, segs, nsegs); -} - -int -dino_dmamem_map(void *v, bus_dma_segment_t *segs, int nsegs, size_t size, - caddr_t *kvap, int flags) -{ - struct dino_softc *sc = v; - - return (bus_dmamem_map(sc->sc_dmat, segs, nsegs, size, kvap, flags)); -} - -void -dino_dmamem_unmap(void *v, caddr_t kva, size_t size) -{ - struct dino_softc *sc = v; - - bus_dmamem_unmap(sc->sc_dmat, kva, size); -} - -paddr_t -dino_dmamem_mmap(void *v, bus_dma_segment_t *segs, int nsegs, off_t off, - int prot, int flags) -{ - struct dino_softc *sc = v; - - return (bus_dmamem_mmap(sc->sc_dmat, segs, nsegs, off, prot, flags)); -} - -const struct hppa_bus_dma_tag dino_dmat = { - NULL, - dino_dmamap_create, dino_dmamap_destroy, - dino_dmamap_load, dino_dmamap_load_mbuf, - dino_dmamap_load_uio, dino_dmamap_load_raw, - dino_dmamap_unload, dino_dmamap_sync, - - dino_dmamem_alloc, dino_dmamem_free, dino_dmamem_map, - dino_dmamem_unmap, dino_dmamem_mmap -}; - -const struct hppa_pci_chipset_tag dino_pc = { - NULL, - dino_attach_hook, dino_maxdevs, dino_make_tag, dino_decompose_tag, - dino_conf_size, dino_conf_read, dino_conf_write, - dino_intr_map, dino_intr_string, - dino_intr_establish, dino_intr_disestablish, -#if NCARDBUS > 0 - dino_alloc_parent -#else - NULL -#endif -}; - -int -dinoprint(void *aux, const char *pnp) -{ - struct pcibus_attach_args *pba = aux; - - if (pnp) - printf("%s at %s\n", pba->pba_busname, pnp); - return (UNCONF); -} - -void -dinoattach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -{ - struct dino_softc *sc = (struct dino_softc *)self; - struct confargs *ca = (struct confargs *)aux; - struct pcibus_attach_args pba; - volatile struct dino_regs *r; - const char *p = NULL; - u_int data; - int s, irqbit; - - sc->sc_bt = ca->ca_iot; - sc->sc_dmat = ca->ca_dmatag; - if (bus_space_map(sc->sc_bt, ca->ca_hpa, PAGE_SIZE, 0, &sc->sc_bh)) { - printf(": can't map space\n"); - return; - } - - sc->sc_regs = r = (volatile struct dino_regs *)sc->sc_bh; - r->pciror = 0; - r->pciwor = 0; - - /* - * Do not reset enabled io mappings mask if we are still running - * with PDC console - we'll do it after autoconf. - */ - if (cn_tab->cn_putc != pdccnputc) - r->io_addr_en = 0; - sc->io_shadow = 0; - - r->gmask &= ~1; /* allow GSC bus req */ - r->brdg_feat &= ~0xf00; - r->brdg_feat |= 3; -#ifdef notyet_card_mode - r->io_control = 0x80; - r->pamr = 0; - r->papr = 0; - r->io_fbb_en |= 1; - r->damode = 0; - r->brdg_feat = 0xc0000000 XXX; - r->mltim = 0x40; /* 64 clocks */ - r->tltim = 0x8c; /* 12 clocks */ - - /* PCI reset */ - r->pcicmd = 0x6f; - DELAY(10000); /* 10ms for reset to settle */ -#endif - - snprintf(sc->sc_ioexname, sizeof(sc->sc_ioexname), - "%s_io", sc->sc_dv.dv_xname); - if ((sc->sc_ioex = extent_create(sc->sc_ioexname, 0, 0xffff, - M_DEVBUF, NULL, 0, EX_NOWAIT | EX_MALLOCOK)) == NULL) { - printf(": cannot allocate I/O extent map\n"); - bus_space_unmap(sc->sc_bt, sc->sc_bh, PAGE_SIZE); - return; - } - - /* TODO reserve dino's pci space ? */ - - sc->sc_ver = ca->ca_type.iodc_revision; - switch ((ca->ca_type.iodc_model << 4) | - (ca->ca_type.iodc_revision >> 4)) { - case 0x05d: /* j2240 */ - p = "Dino(card)"; - case 0x680: - if (!p) - p = "Dino"; - switch (ca->ca_type.iodc_revision & 0xf) { - case 0: sc->sc_ver = 0x20; break; - case 1: sc->sc_ver = 0x21; break; - case 2: sc->sc_ver = 0x30; break; - case 3: sc->sc_ver = 0x31; break; - } - break; - - case 0x682: - p = "Cujo"; - switch (ca->ca_type.iodc_revision & 0xf) { - case 0: sc->sc_ver = 0x10; break; - case 1: sc->sc_ver = 0x20; break; - } - break; - - default: - p = "Mojo"; - break; - } - - irqbit = cpu_intr_findirq(); - if (irqbit >= 0) - printf(" irq %d", irqbit); - - printf(": %s V%d.%d\n", p, sc->sc_ver >> 4, sc->sc_ver & 0xf); - - s = splhigh(); - r->imr = ~0; - data = r->irr0; - data = r->irr1; - r->imr = 0; - __asm volatile ("" ::: "memory"); - r->icr = 0; - if (irqbit >= 0) - r->iar0 = cpu_gethpa(0) | (31 - irqbit); - splx(s); - - if (irqbit < 0) - sc->sc_ih = NULL; - else - sc->sc_ih = cpu_intr_establish(IPL_NESTED, irqbit, - dino_intr, (void *)sc->sc_regs, sc->sc_dv.dv_xname); - if (sc->sc_ih == NULL) { - printf("%s: can't establish interrupt\n", sc->sc_dv.dv_xname); - return; - } - - /* TODO establish the bus error interrupt */ - - /* scan for ps2 kbd/ms, serial, and flying toasters */ - ca->ca_hpamask = -1; - pdc_scanbus(self, ca, MAXMODBUS, 0, 0); - - sc->sc_iot = dino_iomemt; - sc->sc_iot.hbt_cookie = sc; - sc->sc_iot.hbt_map = dino_iomap; - sc->sc_iot.hbt_alloc = dino_ioalloc; - sc->sc_memt = dino_iomemt; - sc->sc_memt.hbt_cookie = sc; - sc->sc_memt.hbt_map = dino_memmap; - sc->sc_memt.hbt_alloc = dino_memalloc; - sc->sc_pc = dino_pc; - sc->sc_pc._cookie = sc; - sc->sc_dmatag = dino_dmat; - sc->sc_dmatag._cookie = sc; - - bzero(&pba, sizeof(pba)); - pba.pba_busname = "pci"; - pba.pba_iot = &sc->sc_iot; - pba.pba_memt = &sc->sc_memt; - pba.pba_dmat = &sc->sc_dmatag; - pba.pba_pc = &sc->sc_pc; - pba.pba_domain = pci_ndomains++; - pba.pba_bus = 0; - config_found(self, &pba, dinoprint); - - /* postpone cleanup if necessary */ - if (r->io_addr_en != sc->io_shadow) - startuphook_establish(dino_clear_pdc_mappings, sc); - - /* enable interrupts now that all the devices are there */ - r->imr = sc->sc_imr; -} - -void -dino_clear_pdc_mappings(void *v) -{ - struct dino_softc *sc = (struct dino_softc *)v; - volatile struct dino_regs *r; - - if (cn_tab->cn_putc == pdccnputc) { - /* damn! */ - return; - } - - r = sc->sc_regs; - r->io_addr_en = sc->io_shadow; -} diff --git a/sys/arch/hppa/dev/elroy.c b/sys/arch/hppa/dev/elroy.c deleted file mode 100644 index 4b389dfb2..000000000 --- a/sys/arch/hppa/dev/elroy.c +++ /dev/null @@ -1,1351 +0,0 @@ -/* $OpenBSD: elroy.c,v 1.12 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2005 Michael Shalayeff - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "cardbus.h" - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include - -#if NCARDBUS > 0 -#include -#endif - -#include -#include -#include - -#include -#include - -#define ELROY_MEM_CHUNK 0x800000 -#define ELROY_MEM_WINDOW (2 * ELROY_MEM_CHUNK) - -int elroy_match(struct device *, void *, void *); -void elroy_attach(struct device *, struct device *, void *); -int elroy_intr(void *); - -const struct cfattach elroy_ca = { - sizeof(struct elroy_softc), elroy_match, elroy_attach -}; - -struct cfdriver elroy_cd = { - NULL, "elroy", DV_DULL -}; - -void elroy_attach_hook(struct device *parent, struct device *self, - struct pcibus_attach_args *pba); -int elroy_maxdevs(void *v, int bus); -pcitag_t elroy_make_tag(void *v, int bus, int dev, int func); -void elroy_decompose_tag(void *v, pcitag_t tag, int *bus, - int *dev, int *func); -int elroy_conf_size(void *v, pcitag_t tag); -pcireg_t elroy_conf_read(void *v, pcitag_t tag, int reg); -void elroy_conf_write(void *v, pcitag_t tag, int reg, - pcireg_t data); -int elroy_iomap(void *v, bus_addr_t bpa, bus_size_t size, - int flags, bus_space_handle_t *bshp); -int elroy_memmap(void *v, bus_addr_t bpa, bus_size_t size, - int flags, bus_space_handle_t *bshp); -int elroy_subregion(void *v, bus_space_handle_t bsh, - bus_size_t offset, bus_size_t size, - bus_space_handle_t *nbshp); -int elroy_ioalloc(void *v, bus_addr_t rstart, bus_addr_t rend, - bus_size_t size, bus_size_t align, bus_size_t boundary, - int flags, bus_addr_t *addrp, bus_space_handle_t *bshp); -int elroy_memalloc(void *v, bus_addr_t rstart, bus_addr_t rend, - bus_size_t size, bus_size_t align, bus_size_t boundary, - int flags, bus_addr_t *addrp, bus_space_handle_t *bshp); -void elroy_unmap(void *v, bus_space_handle_t bsh, - bus_size_t size); -void elroy_free(void *v, bus_space_handle_t bh, bus_size_t size); -void elroy_barrier(void *v, bus_space_handle_t h, bus_size_t o, - bus_size_t l, int op); -void * elroy_alloc_parent(struct device *self, - struct pci_attach_args *pa, int io); -void * elroy_vaddr(void *v, bus_space_handle_t h); -u_int8_t elroy_r1(void *v, bus_space_handle_t h, bus_size_t o); -u_int16_t elroy_r2(void *v, bus_space_handle_t h, bus_size_t o); -u_int32_t elroy_r4(void *v, bus_space_handle_t h, bus_size_t o); -u_int64_t elroy_r8(void *v, bus_space_handle_t h, bus_size_t o); -void elroy_w1(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t vv); -void elroy_w2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t vv); -void elroy_w4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t vv); -void elroy_w8(void *v, bus_space_handle_t h, bus_size_t o, - u_int64_t vv); -void elroy_rm_1(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c); -void elroy_rm_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t *a, bus_size_t c); -void elroy_rm_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t *a, bus_size_t c); -void elroy_rm_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int64_t *a, bus_size_t c); -void elroy_wm_1(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c); -void elroy_wm_2(void *v, bus_space_handle_t h, bus_size_t o, - const u_int16_t *a, bus_size_t c); -void elroy_wm_4(void *v, bus_space_handle_t h, bus_size_t o, - const u_int32_t *a, bus_size_t c); -void elroy_wm_8(void *v, bus_space_handle_t h, bus_size_t o, - const u_int64_t *a, bus_size_t c); -void elroy_sm_1(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t vv, bus_size_t c); -void elroy_sm_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t vv, bus_size_t c); -void elroy_sm_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t vv, bus_size_t c); -void elroy_sm_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int64_t vv, bus_size_t c); -void elroy_rrm_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c); -void elroy_rrm_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c); -void elroy_rrm_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c); -void elroy_wrm_2(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c); -void elroy_wrm_4(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c); -void elroy_wrm_8(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c); -void elroy_rr_1(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c); -void elroy_rr_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t *a, bus_size_t c); -void elroy_rr_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t *a, bus_size_t c); -void elroy_rr_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int64_t *a, bus_size_t c); -void elroy_wr_1(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c); -void elroy_wr_2(void *v, bus_space_handle_t h, bus_size_t o, - const u_int16_t *a, bus_size_t c); -void elroy_wr_4(void *v, bus_space_handle_t h, bus_size_t o, - const u_int32_t *a, bus_size_t c); -void elroy_wr_8(void *v, bus_space_handle_t h, bus_size_t o, - const u_int64_t *a, bus_size_t c); -void elroy_rrr_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c); -void elroy_rrr_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c); -void elroy_rrr_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c); -void elroy_wrr_2(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c); -void elroy_wrr_4(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c); -void elroy_wrr_8(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c); -void elroy_sr_1(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t vv, bus_size_t c); -void elroy_sr_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t vv, bus_size_t c); -void elroy_sr_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t vv, bus_size_t c); -void elroy_sr_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int64_t vv, bus_size_t c); -void elroy_cp_1(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c); -void elroy_cp_2(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c); -void elroy_cp_4(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c); -void elroy_cp_8(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c); - -int -elroy_match(struct device *parent, void *cfdata, void *aux) -{ - struct confargs *ca = aux; - /* struct cfdata *cf = cfdata; */ - - if ((ca->ca_name && !strcmp(ca->ca_name, "lba")) || - (ca->ca_type.iodc_type == HPPA_TYPE_BRIDGE && - ca->ca_type.iodc_sv_model == HPPA_BRIDGE_DINO && - ca->ca_type.iodc_model == 0x78)) - return (1); - - return (0); -} - -void -elroy_write32(volatile u_int32_t *p, u_int32_t v) -{ - *p = v; -} - -u_int32_t -elroy_read32(volatile u_int32_t *p) -{ - return *p; -} - -void -elroy_attach_hook(struct device *parent, struct device *self, - struct pcibus_attach_args *pba) -{ - -} - -int -elroy_maxdevs(void *v, int bus) -{ - return (32); -} - -pcitag_t -elroy_make_tag(void *v, int bus, int dev, int func) -{ - if (bus > 255 || dev > 31 || func > 7) - panic("elroy_make_tag: bad request"); - - return ((bus << 16) | (dev << 11) | (func << 8)); -} - -void -elroy_decompose_tag(void *v, pcitag_t tag, int *bus, int *dev, int *func) -{ - if (bus) - *bus = (tag >> 16) & 0xff; - if (dev) - *dev = (tag >> 11) & 0x1f; - if (func) - *func= (tag >> 8) & 0x07; -} - -int -elroy_conf_size(void *v, pcitag_t tag) -{ - return PCI_CONFIG_SPACE_SIZE; -} - -pcireg_t -elroy_conf_read(void *v, pcitag_t tag, int reg) -{ - struct elroy_softc *sc = v; - volatile struct elroy_regs *r = sc->sc_regs; - u_int32_t arb_mask, err_cfg, control; - pcireg_t data, data1; - -/* printf("elroy_conf_read(%p, 0x%08x, 0x%x)", v, tag, reg); */ - arb_mask = elroy_read32(&r->arb_mask); - err_cfg = elroy_read32(&r->err_cfg); - control = elroy_read32(&r->control); - if (!arb_mask) - elroy_write32(&r->arb_mask, htole32(ELROY_ARB_ENABLE)); - elroy_write32(&r->err_cfg, err_cfg | - htole32(ELROY_ERRCFG_SMART | ELROY_ERRCFG_CM)); - elroy_write32(&r->control, (control | htole32(ELROY_CONTROL_CE)) & - ~htole32(ELROY_CONTROL_HF)); - - elroy_write32(&r->pci_conf_addr, htole32(tag | reg)); - data1 = elroy_read32(&r->pci_conf_addr); - data = elroy_read32(&r->pci_conf_data); - - elroy_write32(&r->control, control | - htole32(ELROY_CONTROL_CE|ELROY_CONTROL_CL)); - elroy_write32(&r->control, control); - elroy_write32(&r->err_cfg, err_cfg); - if (!arb_mask) - elroy_write32(&r->arb_mask, arb_mask); - - data = letoh32(data); -/* printf("=0x%08x (@ 0x%08x)\n", data, letoh32(data1)); */ - return (data); -} - -void -elroy_conf_write(void *v, pcitag_t tag, int reg, pcireg_t data) -{ - struct elroy_softc *sc = v; - volatile struct elroy_regs *r = sc->sc_regs; - u_int32_t arb_mask, err_cfg, control; - pcireg_t data1; - -/* printf("elroy_conf_write(%p, 0x%08x, 0x%x, 0x%x)\n", v, tag, reg, data); */ - arb_mask = elroy_read32(&r->arb_mask); - err_cfg = elroy_read32(&r->err_cfg); - control = elroy_read32(&r->control); - if (!arb_mask) - elroy_write32(&r->arb_mask, htole32(ELROY_ARB_ENABLE)); - elroy_write32(&r->err_cfg, err_cfg | - htole32(ELROY_ERRCFG_SMART | ELROY_ERRCFG_CM)); - elroy_write32(&r->control, (control | htole32(ELROY_CONTROL_CE)) & - ~htole32(ELROY_CONTROL_HF)); - - /* fix coalescing config writes errata by interleaving w/ a read */ - elroy_write32(&r->pci_conf_addr, htole32(tag | PCI_ID_REG)); - data1 = elroy_read32(&r->pci_conf_addr); - data1 = elroy_read32(&r->pci_conf_data); - - elroy_write32(&r->pci_conf_addr, htole32(tag | reg)); - data1 = elroy_read32(&r->pci_conf_addr); - elroy_write32(&r->pci_conf_data, htole32(data)); - data1 = elroy_read32(&r->pci_conf_addr); - - elroy_write32(&r->control, control | - htole32(ELROY_CONTROL_CE|ELROY_CONTROL_CL)); - elroy_write32(&r->control, control); - elroy_write32(&r->err_cfg, err_cfg); - if (!arb_mask) - elroy_write32(&r->arb_mask, arb_mask); -} - -int -elroy_iomap(void *v, bus_addr_t bpa, bus_size_t size, - int flags, bus_space_handle_t *bshp) -{ - struct elroy_softc *sc = v; - /* volatile struct elroy_regs *r = sc->sc_regs; */ - int error; - - if ((error = bus_space_map(sc->sc_bt, bpa + sc->sc_iobase, size, - flags, bshp))) - return (error); - - return (0); -} - -int -elroy_memmap(void *v, bus_addr_t bpa, bus_size_t size, - int flags, bus_space_handle_t *bshp) -{ - struct elroy_softc *sc = v; - /* volatile struct elroy_regs *r = sc->sc_regs; */ - int error; - - if ((error = bus_space_map(sc->sc_bt, bpa, size, flags, bshp))) - return (error); - - return (0); -} - -int -elroy_subregion(void *v, bus_space_handle_t bsh, bus_size_t offset, - bus_size_t size, bus_space_handle_t *nbshp) -{ - *nbshp = bsh + offset; - return (0); -} - -int -elroy_ioalloc(void *v, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, - bus_size_t align, bus_size_t boundary, int flags, bus_addr_t *addrp, - bus_space_handle_t *bshp) -{ - struct elroy_softc *sc = v; - volatile struct elroy_regs *r = sc->sc_regs; - bus_addr_t iostart, ioend; - - iostart = r->io_base & ~htole32(ELROY_BASE_RE); - ioend = iostart + ~htole32(r->io_mask) + 1; - if (rstart < iostart || rend > ioend) - panic("elroy_ioalloc: bad region start/end"); - - rstart += sc->sc_iobase; - rend += sc->sc_iobase; - if (bus_space_alloc(sc->sc_bt, rstart, rend, size, - align, boundary, flags, addrp, bshp)) - return (ENOMEM); - - return (0); -} - -int -elroy_memalloc(void *v, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, - bus_size_t align, bus_size_t boundary, int flags, bus_addr_t *addrp, - bus_space_handle_t *bshp) -{ - struct elroy_softc *sc = v; - /* volatile struct elroy_regs *r = sc->sc_regs; */ - - if (bus_space_alloc(sc->sc_bt, rstart, rend, size, - align, boundary, flags, addrp, bshp)) - return (ENOMEM); - - return (0); -} - -void -elroy_unmap(void *v, bus_space_handle_t bsh, bus_size_t size) -{ - struct elroy_softc *sc = v; - - bus_space_free(sc->sc_bt, bsh, size); -} - -void -elroy_free(void *v, bus_space_handle_t bh, bus_size_t size) -{ - /* should be enough */ - elroy_unmap(v, bh, size); -} - -void -elroy_barrier(void *v, bus_space_handle_t h, bus_size_t o, bus_size_t l, int op) -{ - struct elroy_softc *sc = v; - volatile struct elroy_regs *r = sc->sc_regs; - u_int32_t data; - - sync_caches(); - if (op & BUS_SPACE_BARRIER_WRITE) { - data = r->pci_id; /* flush write fifo */ - sync_caches(); - } -} - -#if NCARDBUS > 0 -void * -elroy_alloc_parent(struct device *self, struct pci_attach_args *pa, int io) -{ -#if 0 /* TODO */ - - struct elroy_softc *sc = pa->pa_pc->_cookie; - struct extent *ex; - bus_space_tag_t tag; - bus_addr_t start; - bus_size_t size; - - if (io) { - ex = sc->sc_ioex; - tag = pa->pa_iot; - start = 0xa000; - size = 0x1000; - } else { - if (!sc->sc_memex) { - bus_space_handle_t memh; - bus_addr_t mem_start; - - if (elroy_memalloc(sc, 0xf0800000, 0xff7fffff, - ELROY_MEM_WINDOW, ELROY_MEM_WINDOW, EX_NOBOUNDARY, - 0, &mem_start, &memh)) - return (NULL); - - snprintf(sc->sc_memexname, sizeof(sc->sc_memexname), - "%s_mem", sc->sc_dv.dv_xname); - if ((sc->sc_memex = extent_create(sc->sc_memexname, - mem_start, mem_start + ELROY_MEM_WINDOW, M_DEVBUF, - NULL, 0, EX_NOWAIT | EX_MALLOCOK)) == NULL) { - extent_destroy(sc->sc_ioex); - bus_space_free(sc->sc_bt, memh, - ELROY_MEM_WINDOW); - return (NULL); - } - } - ex = sc->sc_memex; - tag = pa->pa_memt; - start = ex->ex_start; - size = ELROY_MEM_CHUNK; - } - - if (extent_alloc_subregion(ex, start, ex->ex_end, size, size, 0, - EX_NOBOUNDARY, EX_NOWAIT, &start)) - return (NULL); - - extent_free(ex, start, size, EX_NOWAIT); - return rbus_new_root_share(tag, ex, start, size); -#else - return (NULL); -#endif -} -#endif - -void * -elroy_vaddr(void *v, bus_space_handle_t h) -{ - return ((void *)h); -} - -u_int8_t -elroy_r1(void *v, bus_space_handle_t h, bus_size_t o) -{ - h += o; - return *(volatile u_int8_t *)h; -} - -u_int16_t -elroy_r2(void *v, bus_space_handle_t h, bus_size_t o) -{ - volatile u_int16_t *p; - - h += o; - p = (volatile u_int16_t *)h; - return (letoh16(*p)); -} - -u_int32_t -elroy_r4(void *v, bus_space_handle_t h, bus_size_t o) -{ - u_int32_t data; - - h += o; - data = *(volatile u_int32_t *)h; - return (letoh32(data)); -} - -u_int64_t -elroy_r8(void *v, bus_space_handle_t h, bus_size_t o) -{ - u_int64_t data; - - h += o; - data = *(volatile u_int64_t *)h; - return (letoh64(data)); -} - -void -elroy_w1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv) -{ - h += o; - *(volatile u_int8_t *)h = vv; -} - -void -elroy_w2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv) -{ - volatile u_int16_t *p; - - h += o; - p = (volatile u_int16_t *)h; - *p = htole16(vv); -} - -void -elroy_w4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv) -{ - h += o; - vv = htole32(vv); - *(volatile u_int32_t *)h = vv; -} - -void -elroy_w8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv) -{ - h += o; - *(volatile u_int64_t *)h = htole64(vv); -} - - -void -elroy_rm_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t *a, bus_size_t c) -{ - volatile u_int8_t *p; - - h += o; - p = (volatile u_int8_t *)h; - while (c--) - *a++ = *p; -} - -void -elroy_rm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t c) -{ - volatile u_int16_t *p; - - h += o; - p = (volatile u_int16_t *)h; - while (c--) - *a++ = letoh16(*p); -} - -void -elroy_rm_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t *a, bus_size_t c) -{ - volatile u_int32_t *p; - - h += o; - p = (volatile u_int32_t *)h; - while (c--) - *a++ = letoh32(*p); -} - -void -elroy_rm_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t *a, bus_size_t c) -{ - volatile u_int64_t *p; - - h += o; - p = (volatile u_int64_t *)h; - while (c--) - *a++ = letoh64(*p); -} - -void -elroy_wm_1(void *v, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, bus_size_t c) -{ - volatile u_int8_t *p; - - h += o; - p = (volatile u_int8_t *)h; - while (c--) - *p = *a++; -} - -void -elroy_wm_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_size_t c) -{ - volatile u_int16_t *p; - - h += o; - p = (volatile u_int16_t *)h; - while (c--) - *p = htole16(*a++); -} - -void -elroy_wm_4(void *v, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, bus_size_t c) -{ - volatile u_int32_t *p; - - h += o; - p = (volatile u_int32_t *)h; - while (c--) - *p = htole32(*a++); -} - -void -elroy_wm_8(void *v, bus_space_handle_t h, bus_size_t o, const u_int64_t *a, bus_size_t c) -{ - volatile u_int64_t *p; - - h += o; - p = (volatile u_int64_t *)h; - while (c--) - *p = htole64(*a++); -} - -void -elroy_sm_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv, bus_size_t c) -{ - volatile u_int8_t *p; - - h += o; - p = (volatile u_int8_t *)h; - while (c--) - *p = vv; -} - -void -elroy_sm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, bus_size_t c) -{ - volatile u_int16_t *p; - - h += o; - p = (volatile u_int16_t *)h; - vv = htole16(vv); - while (c--) - *p = vv; -} - -void -elroy_sm_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv, bus_size_t c) -{ - volatile u_int32_t *p; - - h += o; - p = (volatile u_int32_t *)h; - vv = htole32(vv); - while (c--) - *p = vv; -} - -void -elroy_sm_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv, bus_size_t c) -{ - volatile u_int64_t *p; - - h += o; - p = (volatile u_int64_t *)h; - vv = htole64(vv); - while (c--) - *p = vv; -} - -void -elroy_rrm_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c) -{ - volatile u_int16_t *p, *q = (u_int16_t *)a; - - h += o; - p = (volatile u_int16_t *)h; - c /= 2; - while (c--) - *q++ = *p; -} - -void -elroy_rrm_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c) -{ - volatile u_int32_t *p, *q = (u_int32_t *)a; - - h += o; - p = (volatile u_int32_t *)h; - c /= 4; - while (c--) - *q++ = *p; -} - -void -elroy_rrm_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c) -{ - volatile u_int64_t *p, *q = (u_int64_t *)a; - - h += o; - p = (volatile u_int64_t *)h; - c /= 8; - while (c--) - *q++ = *p; -} - -void -elroy_wrm_2(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c) -{ - volatile u_int16_t *p; - const u_int16_t *q = (const u_int16_t *)a; - - h += o; - p = (volatile u_int16_t *)h; - c /= 2; - while (c--) - *p = *q++; -} - -void -elroy_wrm_4(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c) -{ - volatile u_int32_t *p; - const u_int32_t *q = (const u_int32_t *)a; - - h += o; - p = (volatile u_int32_t *)h; - c /= 4; - while (c--) - *p = *q++; -} - -void -elroy_wrm_8(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c) -{ - volatile u_int64_t *p; - const u_int64_t *q = (const u_int64_t *)a; - - h += o; - p = (volatile u_int64_t *)h; - c /= 8; - while (c--) - *p = *q++; -} - -void -elroy_rr_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t *a, bus_size_t c) -{ - volatile u_int8_t *p; - - h += o; - p = (volatile u_int8_t *)h; - while (c--) - *a++ = *p++; -} - -void -elroy_rr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t c) -{ - volatile u_int16_t *p, data; - - h += o; - p = (volatile u_int16_t *)h; - while (c--) { - data = *p++; - *a++ = letoh16(data); - } -} - -void -elroy_rr_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t *a, bus_size_t c) -{ - volatile u_int32_t *p, data; - - h += o; - p = (volatile u_int32_t *)h; - while (c--) { - data = *p++; - *a++ = letoh32(data); - } -} - -void -elroy_rr_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t *a, bus_size_t c) -{ - volatile u_int64_t *p, data; - - h += o; - p = (volatile u_int64_t *)h; - while (c--) { - data = *p++; - *a++ = letoh64(data); - } -} - -void -elroy_wr_1(void *v, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, bus_size_t c) -{ - volatile u_int8_t *p; - - h += o; - p = (volatile u_int8_t *)h; - while (c--) - *p++ = *a++; -} - -void -elroy_wr_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_size_t c) -{ - volatile u_int16_t *p, data; - - h += o; - p = (volatile u_int16_t *)h; - while (c--) { - data = *a++; - *p++ = htole16(data); - } -} - -void -elroy_wr_4(void *v, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, bus_size_t c) -{ - volatile u_int32_t *p, data; - - h += o; - p = (volatile u_int32_t *)h; - while (c--) { - data = *a++; - *p++ = htole32(data); - } -} - -void -elroy_wr_8(void *v, bus_space_handle_t h, bus_size_t o, const u_int64_t *a, bus_size_t c) -{ - volatile u_int64_t *p, data; - - h += o; - p = (volatile u_int64_t *)h; - while (c--) { - data = *a++; - *p++ = htole64(data); - } -} - -void -elroy_rrr_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c) -{ - volatile u_int16_t *p, *q = (u_int16_t *)a; - - c /= 2; - h += o; - p = (volatile u_int16_t *)h; - while (c--) - *q++ = *p++; -} - -void -elroy_rrr_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c) -{ - volatile u_int32_t *p, *q = (u_int32_t *)a; - - c /= 4; - h += o; - p = (volatile u_int32_t *)h; - while (c--) - *q++ = *p++; -} - -void -elroy_rrr_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c) -{ - volatile u_int64_t *p, *q = (u_int64_t *)a; - - c /= 8; - h += o; - p = (volatile u_int64_t *)h; - while (c--) - *q++ = *p++; -} - -void -elroy_wrr_2(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c) -{ - volatile u_int16_t *p; - const u_int16_t *q = (u_int16_t *)a; - - c /= 2; - h += o; - p = (volatile u_int16_t *)h; - while (c--) - *p++ = *q++; -} - -void -elroy_wrr_4(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c) -{ - volatile u_int32_t *p; - const u_int32_t *q = (u_int32_t *)a; - - c /= 4; - h += o; - p = (volatile u_int32_t *)h; - while (c--) - *p++ = *q++; -} - -void -elroy_wrr_8(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c) -{ - volatile u_int64_t *p; - const u_int64_t *q = (u_int64_t *)a; - - c /= 8; - h += o; - p = (volatile u_int64_t *)h; - while (c--) - *p++ = *q++; -} - -void -elroy_sr_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv, bus_size_t c) -{ - volatile u_int8_t *p; - - h += o; - p = (volatile u_int8_t *)h; - while (c--) - *p++ = vv; -} - -void -elroy_sr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, bus_size_t c) -{ - volatile u_int16_t *p; - - h += o; - vv = htole16(vv); - p = (volatile u_int16_t *)h; - while (c--) - *p++ = vv; -} - -void -elroy_sr_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv, bus_size_t c) -{ - volatile u_int32_t *p; - - h += o; - vv = htole32(vv); - p = (volatile u_int32_t *)h; - while (c--) - *p++ = vv; -} - -void -elroy_sr_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv, bus_size_t c) -{ - volatile u_int64_t *p; - - h += o; - vv = htole64(vv); - p = (volatile u_int64_t *)h; - while (c--) - *p++ = vv; -} - -void -elroy_cp_1(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - while (c--) - elroy_w1(v, h1, o1++, elroy_r1(v, h2, o2++)); -} - -void -elroy_cp_2(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - while (c--) { - elroy_w2(v, h1, o1, elroy_r2(v, h2, o2)); - o1 += 2; - o2 += 2; - } -} - -void -elroy_cp_4(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - while (c--) { - elroy_w4(v, h1, o1, elroy_r4(v, h2, o2)); - o1 += 4; - o2 += 4; - } -} - -void -elroy_cp_8(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - while (c--) { - elroy_w8(v, h1, o1, elroy_r8(v, h2, o2)); - o1 += 8; - o2 += 8; - } -} - -const struct hppa_bus_space_tag elroy_iomemt = { - NULL, - - NULL, elroy_unmap, elroy_subregion, NULL, elroy_free, - elroy_barrier, elroy_vaddr, - elroy_r1, elroy_r2, elroy_r4, elroy_r8, - elroy_w1, elroy_w2, elroy_w4, elroy_w8, - elroy_rm_1, elroy_rm_2, elroy_rm_4, elroy_rm_8, - elroy_wm_1, elroy_wm_2, elroy_wm_4, elroy_wm_8, - elroy_sm_1, elroy_sm_2, elroy_sm_4, elroy_sm_8, - elroy_rrm_2, elroy_rrm_4, elroy_rrm_8, - elroy_wrm_2, elroy_wrm_4, elroy_wrm_8, - elroy_rr_1, elroy_rr_2, elroy_rr_4, elroy_rr_8, - elroy_wr_1, elroy_wr_2, elroy_wr_4, elroy_wr_8, - elroy_rrr_2, elroy_rrr_4, elroy_rrr_8, - elroy_wrr_2, elroy_wrr_4, elroy_wrr_8, - elroy_sr_1, elroy_sr_2, elroy_sr_4, elroy_sr_8, - elroy_cp_1, elroy_cp_2, elroy_cp_4, elroy_cp_8 -}; - -int elroy_dmamap_create(void *v, bus_size_t size, - int nsegments, bus_size_t maxsegsz, - bus_size_t boundary, int flags, - bus_dmamap_t *dmamp); -void elroy_dmamap_destroy(void *v, bus_dmamap_t map); -int elroy_dmamap_load(void *v, bus_dmamap_t map, - void *addr, bus_size_t size, - struct proc *p, int flags); -int elroy_dmamap_load_mbuf(void *v, bus_dmamap_t map, - struct mbuf *m, int flags); -int elroy_dmamap_load_uio(void *v, bus_dmamap_t map, - struct uio *uio, int flags); -int elroy_dmamap_load_raw(void *v, bus_dmamap_t map, - bus_dma_segment_t *segs, - int nsegs, bus_size_t size, int flags); -void elroy_dmamap_unload(void *v, bus_dmamap_t map); -void elroy_dmamap_sync(void *v, bus_dmamap_t map, bus_addr_t off, - bus_size_t len, int ops); -int elroy_dmamem_alloc(void *v, bus_size_t size, - bus_size_t alignment, bus_size_t boundary, - bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags); -void elroy_dmamem_free(void *v, bus_dma_segment_t *segs, - int nsegs); -int elroy_dmamem_map(void *v, bus_dma_segment_t *segs, int nsegs, - size_t size, caddr_t *kvap, int flags); -void elroy_dmamem_unmap(void *v, caddr_t kva, size_t size); -paddr_t elroy_dmamem_mmap(void *v, bus_dma_segment_t *segs, - int nsegs, off_t off, int prot, int flags); - -int -elroy_dmamap_create(void *v, bus_size_t size, int nsegments, - bus_size_t maxsegsz, bus_size_t boundary, int flags, bus_dmamap_t *dmamp) -{ - struct elroy_softc *sc = v; - - /* TODO check the addresses, boundary, enable dma */ - - return (bus_dmamap_create(sc->sc_dmat, size, nsegments, - maxsegsz, boundary, flags, dmamp)); -} - -void -elroy_dmamap_destroy(void *v, bus_dmamap_t map) -{ - struct elroy_softc *sc = v; - - bus_dmamap_destroy(sc->sc_dmat, map); -} - -int -elroy_dmamap_load(void *v, bus_dmamap_t map, void *addr, bus_size_t size, - struct proc *p, int flags) -{ - struct elroy_softc *sc = v; - - return (bus_dmamap_load(sc->sc_dmat, map, addr, size, p, flags)); -} - -int -elroy_dmamap_load_mbuf(void *v, bus_dmamap_t map, struct mbuf *m, int flags) -{ - struct elroy_softc *sc = v; - - return (bus_dmamap_load_mbuf(sc->sc_dmat, map, m, flags)); -} - -int -elroy_dmamap_load_uio(void *v, bus_dmamap_t map, struct uio *uio, int flags) -{ - struct elroy_softc *sc = v; - - return (bus_dmamap_load_uio(sc->sc_dmat, map, uio, flags)); -} - -int -elroy_dmamap_load_raw(void *v, bus_dmamap_t map, bus_dma_segment_t *segs, - int nsegs, bus_size_t size, int flags) -{ - struct elroy_softc *sc = v; - - return (bus_dmamap_load_raw(sc->sc_dmat, map, segs, nsegs, size, flags)); -} - -void -elroy_dmamap_unload(void *v, bus_dmamap_t map) -{ - struct elroy_softc *sc = v; - - bus_dmamap_unload(sc->sc_dmat, map); -} - -void -elroy_dmamap_sync(void *v, bus_dmamap_t map, bus_addr_t off, - bus_size_t len, int ops) -{ - struct elroy_softc *sc = v; - - bus_dmamap_sync(sc->sc_dmat, map, off, len, ops); -} - -int -elroy_dmamem_alloc(void *v, bus_size_t size, bus_size_t alignment, - bus_size_t boundary, bus_dma_segment_t *segs, - int nsegs, int *rsegs, int flags) -{ - struct elroy_softc *sc = v; - - return (bus_dmamem_alloc(sc->sc_dmat, size, alignment, boundary, - segs, nsegs, rsegs, flags)); -} - -void -elroy_dmamem_free(void *v, bus_dma_segment_t *segs, int nsegs) -{ - struct elroy_softc *sc = v; - - bus_dmamem_free(sc->sc_dmat, segs, nsegs); -} - -int -elroy_dmamem_map(void *v, bus_dma_segment_t *segs, int nsegs, size_t size, - caddr_t *kvap, int flags) -{ - struct elroy_softc *sc = v; - - return (bus_dmamem_map(sc->sc_dmat, segs, nsegs, size, kvap, flags)); -} - -void -elroy_dmamem_unmap(void *v, caddr_t kva, size_t size) -{ - struct elroy_softc *sc = v; - - bus_dmamem_unmap(sc->sc_dmat, kva, size); -} - -paddr_t -elroy_dmamem_mmap(void *v, bus_dma_segment_t *segs, int nsegs, off_t off, - int prot, int flags) -{ - struct elroy_softc *sc = v; - - return (bus_dmamem_mmap(sc->sc_dmat, segs, nsegs, off, prot, flags)); -} - -const struct hppa_bus_dma_tag elroy_dmat = { - NULL, - elroy_dmamap_create, elroy_dmamap_destroy, - elroy_dmamap_load, elroy_dmamap_load_mbuf, - elroy_dmamap_load_uio, elroy_dmamap_load_raw, - elroy_dmamap_unload, elroy_dmamap_sync, - - elroy_dmamem_alloc, elroy_dmamem_free, elroy_dmamem_map, - elroy_dmamem_unmap, elroy_dmamem_mmap -}; - -const struct hppa_pci_chipset_tag elroy_pc = { - NULL, - elroy_attach_hook, elroy_maxdevs, elroy_make_tag, elroy_decompose_tag, - elroy_conf_size, elroy_conf_read, elroy_conf_write, - apic_intr_map, apic_intr_string, - apic_intr_establish, apic_intr_disestablish, -#if NCARDBUS > 0 - elroy_alloc_parent -#else - NULL -#endif -}; - -int elroy_print(void *aux, const char *pnp); - -int -elroy_print(void *aux, const char *pnp) -{ - struct pcibus_attach_args *pba = aux; - - if (pnp) - printf("%s at %s\n", pba->pba_busname, pnp); - return (UNCONF); -} - -void -elroy_attach(struct device *parent, struct device *self, void *aux) -{ - struct elroy_softc *sc = (struct elroy_softc *)self; - struct confargs *ca = (struct confargs *)aux; - struct pcibus_attach_args pba; - volatile struct elroy_regs *r; - const char *p = NULL, *q; - int i; - - sc->sc_hpa = ca->ca_hpa; - sc->sc_bt = ca->ca_iot; - sc->sc_dmat = ca->ca_dmatag; - if (bus_space_map(sc->sc_bt, ca->ca_hpa, ca->ca_hpasz, 0, &sc->sc_bh)) { - printf(": can't map space\n"); - return; - } - - sc->sc_regs = r = bus_space_vaddr(sc->sc_bt, sc->sc_bh); - elroy_write32(&r->pci_cmdstat, htole32(PCI_COMMAND_IO_ENABLE | - PCI_COMMAND_MEM_ENABLE | PCI_COMMAND_MASTER_ENABLE)); - - elroy_write32(&r->control, elroy_read32(&r->control) & - ~htole32(ELROY_CONTROL_RF)); - for (i = 5000; i-- && - elroy_read32(&r->status) & htole32(ELROY_STATUS_RC); DELAY(10)); - if (i < 0) { - printf(": reset failed; status %b\n", - htole32(r->status), ELROY_STATUS_BITS); - return; - } - - q = ""; - sc->sc_ver = PCI_REVISION(letoh32(elroy_read32(&r->pci_class))); - switch ((ca->ca_type.iodc_model << 4) | - (ca->ca_type.iodc_revision >> 4)) { - case 0x782: - p = "Elroy"; - switch (sc->sc_ver) { - default: - q = "+"; - case 5: sc->sc_ver = 0x40; break; - case 4: sc->sc_ver = 0x30; break; - case 3: sc->sc_ver = 0x22; break; - case 2: sc->sc_ver = 0x21; break; - case 1: sc->sc_ver = 0x20; break; - case 0: sc->sc_ver = 0x10; break; - } - break; - - case 0x783: - p = "Mercury"; - break; - - case 0x784: - p = "Quicksilver"; - break; - - default: - p = "Mojo"; - break; - } - - printf(": %s TR%d.%d%s", p, sc->sc_ver >> 4, sc->sc_ver & 0xf, q); - apic_attach(sc); - printf("\n"); - - elroy_write32(&r->imask, htole32(0xffffffff << 30)); - elroy_write32(&r->ibase, htole32(ELROY_BASE_RE)); - - /* TODO reserve elroy's pci space ? */ - -#if 0 -printf("lmm %llx/%llx gmm %llx/%llx wlm %llx/%llx wgm %llx/%llx io %llx/%llx eio %llx/%llx\n", -letoh64(r->lmmio_base), letoh64(r->lmmio_mask), -letoh64(r->gmmio_base), letoh64(r->gmmio_mask), -letoh64(r->wlmmio_base), letoh64(r->wlmmio_mask), -letoh64(r->wgmmio_base), letoh64(r->wgmmio_mask), -letoh64(r->io_base), letoh64(r->io_mask), -letoh64(r->eio_base), letoh64(r->eio_mask)); -#endif - - /* XXX evil hack! */ - sc->sc_iobase = 0xfee00000; - - sc->sc_iot = elroy_iomemt; - sc->sc_iot.hbt_cookie = sc; - sc->sc_iot.hbt_map = elroy_iomap; - sc->sc_iot.hbt_alloc = elroy_ioalloc; - sc->sc_memt = elroy_iomemt; - sc->sc_memt.hbt_cookie = sc; - sc->sc_memt.hbt_map = elroy_memmap; - sc->sc_memt.hbt_alloc = elroy_memalloc; - sc->sc_pc = elroy_pc; - sc->sc_pc._cookie = sc; - sc->sc_dmatag = elroy_dmat; - sc->sc_dmatag._cookie = sc; - - bzero(&pba, sizeof(pba)); - pba.pba_busname = "pci"; - pba.pba_iot = &sc->sc_iot; - pba.pba_memt = &sc->sc_memt; - pba.pba_dmat = &sc->sc_dmatag; - pba.pba_pc = &sc->sc_pc; - pba.pba_domain = pci_ndomains++; - pba.pba_bus = 0; /* (letoh32(elroy_read32(&r->busnum)) & 0xff) >> 4; */ - config_found(self, &pba, elroy_print); -} diff --git a/sys/arch/hppa/dev/elroyreg.h b/sys/arch/hppa/dev/elroyreg.h deleted file mode 100644 index ed28e9fb0..000000000 --- a/sys/arch/hppa/dev/elroyreg.h +++ /dev/null @@ -1,148 +0,0 @@ -/* $OpenBSD: elroyreg.h,v 1.1 2007/05/21 22:43:38 kettenis Exp $ */ - -/* - * Copyright (c) 2005 Michael Shalayeff - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -struct elroy_regs { - /* std PCI bridge header */ - u_int32_t pci_id; /* 0x000 rw PCI_ID */ - u_int32_t pci_cmdstat; /* 0x004 rw PCI_COMMAND_STATUS_REG */ - u_int32_t pci_class; /* 0x008 ro PCI_CLASS_REG */ - u_int32_t pci_bhlc; /* 0x00c rw PCI_BHLC_REG */ - u_int32_t res0[0x30/4]; /* 0x010 */ - - /* HW Bridge registers */ - u_int32_t pci_conf_addr; /* 0x040 rw config space address */ - u_int32_t pad040; - u_int32_t pci_conf_data; /* 0x048 rw config space data */ - u_int32_t pad048; - u_int64_t elroy_mtlt; /* 0x050 */ - u_int32_t busnum; /* 0x058 bus number/scratch */ - u_int32_t par058; - u_int64_t res1; /* 0x060 */ - u_int64_t rope; /* 0x068 rope parity, loopback */ - u_int64_t err_addr; /* 0x070 error log: address */ - u_int64_t suspend; /* 0x078 rw suspend control */ - u_int32_t arb_mask; /* 0x080 rw arbitration mask */ - u_int32_t pad080; -#define ELROY_ARB_ENABLE 0x01 /* enable arbitration */ -#define ELROY_ARB_PCIDEVA 0x02 /* PCI device A allow */ -#define ELROY_ARB_PCIDEVB 0x04 /* PCI device A allow */ -#define ELROY_ARB_PCIDEVC 0x08 /* PCI device A allow */ -#define ELROY_ARB_PCIDEVD 0x10 /* PCI device A allow */ -#define ELROY_ARB_PCIDEVE 0x20 /* PCI device A allow */ -#define ELROY_ARB_PCIDEVF 0x40 /* PCI device A allow */ -#define ELROY_ARB_PCIDEVG 0x80 /* PCI device A allow */ - u_int64_t arb_pri; /* 0x088 arbitration priority */ - u_int64_t arb_mode; /* 0x090 arbitration mode */ - u_int64_t mtlt; /* 0x098 */ - u_int64_t res2[12]; /* 0x0a0 */ - u_int64_t mod_info; /* 0x100 */ - u_int32_t control; /* 0x108 */ -#define ELROY_CONTROL_RF 0x01 /* reset pci */ -#define ELROY_CONTROL_VE 0x08 /* VGA enable */ -#define ELROY_CONTROL_CL 0x10 /* clear error log */ -#define ELROY_CONTROL_CE 0x20 /* clear error log enable */ -#define ELROY_CONTROL_HF 0x40 /* hard fail enable */ - u_int32_t status; /* 0x10c */ -#define ELROY_STATUS_RC 0x01 /* reset complete */ -#define ELROY_STATUS_BITS "\020\01RC" - u_int64_t res3[30]; /* 0x110 */ - u_int64_t lmmio_base; /* 0x200 */ - u_int64_t lmmio_mask; /* 0x208 */ - u_int64_t gmmio_base; /* 0x210 */ - u_int64_t gmmio_mask; /* 0x218 */ - u_int64_t wlmmio_base; /* 0x220 */ - u_int64_t wlmmio_mask; /* 0x228 */ - u_int64_t wgmmio_base; /* 0x230 */ - u_int64_t wgmmio_mask; /* 0x238 */ - u_int32_t io_base; /* 0x240 */ - u_int32_t pad240; - u_int32_t io_mask; /* 0x248 */ - u_int32_t pad248; - u_int32_t res4[4]; /* 0x250 */ - u_int32_t eio_base; /* 0x260 */ - u_int32_t pad260; - u_int32_t eio_mask; /* 0x268 */ - u_int32_t pad268; -#define ELROY_BASE_RE 0x01 /* range enable */ - u_int64_t res5; /* 0x270 */ - u_int64_t dmac_ctrl; /* 0x278 DMA connection control */ - u_int64_t res6[16]; /* 0x280 */ - u_int32_t ibase; /* 0x300 */ - u_int32_t pad300; - u_int32_t imask; /* 0x308 */ - u_int32_t pad308; - u_int64_t hint_cfg; /* 0x310 */ - u_int64_t res7[13]; /* 0x318 */ - u_int64_t hints[14]; /* 0x380 */ - u_int64_t res8[2]; /* 0x3f0 */ - u_int64_t res9[64]; /* 0x400 */ - u_int64_t pad0; /* 0x600 */ - u_int64_t pci_drive; /* 0x608 */ - u_int64_t rope_cfg; /* 0x610 */ - u_int64_t clk_ctl; /* 0x618 */ - u_int32_t pad1; /* 0x620 */ - u_int32_t res10[23]; /* 0x624 */ - u_int32_t err_cfg; /* 0x680 error config */ - u_int32_t pad680; -#define ELROY_ERRCFG_PW 0x01 /* PIO writes parity errors */ -#define ELROY_ERRCFG_PR 0x02 /* PIO reads parity errors */ -#define ELROY_ERRCFG_DW 0x04 /* DMA writes parity errors */ -#define ELROY_ERRCFG_DR 0x08 /* DMA reads parity errors */ -#define ELROY_ERRCFG_CM 0x10 /* no fatal on config space */ -#define ELROY_ERRCFG_SMART 0x20 /* smart bus mode */ - u_int64_t err_stat; /* 0x688 error status */ - u_int64_t err_mid; /* 0x690 error log: master id */ - u_int64_t rope_estat; /* 0x698 rope error status */ - u_int64_t rope_eclr; /* 0x6a0 rope error clear */ - u_int64_t res11[42]; /* 0x6a8 */ - u_int64_t regbus; /* 0x7f8 reads 0x3ff */ - u_int32_t apic_addr; /* 0x800 APIC address register */ - u_int32_t pad800; - u_int64_t res12; - u_int32_t apic_data; /* 0x810 APIC data register */ - u_int32_t pad808; - u_int64_t res13[5]; - u_int32_t apic_eoi; /* 0x840 APIC interrupt ack */ - u_int32_t pad840; - u_int32_t apic_softint; /* 0x850 write generates softint */ - u_int32_t pad850; - u_int64_t res14[123]; /* 0x858 */ - /*0x1000 */ -} __packed; - -/* APIC registers */ -#define APIC_VERSION 0x01 -#define APIC_VERSION_MASK 0xff -#define APIC_VERSION_NENT 0xff0000 -#define APIC_VERSION_NENT_SHIFT 16 -#define APIC_ENT0(i) (0x10 + (i)*2) -#define APIC_ENT0_VEC 0x000ff -#define APIC_ENT0_MOD 0x00700 /* delivery mode */ -#define APIC_ENT0_FXD 0x00000 -#define APIC_ENT0_RDR 0x00100 -#define APIC_ENT0_PMI 0x00200 -#define APIC_ENT0_NMI 0x00400 -#define APIC_ENT0_INI 0x00500 -#define APIC_ENT0_EXT 0x00700 -#define APIC_ENT0_PEND 0x01000 /* int is pending */ -#define APIC_ENT0_LOW 0x02000 /* polarity */ -#define APIC_ENT0_LEV 0x08000 /* edge/level */ -#define APIC_ENT0_MASK 0x10000 /* mask int */ -#define APIC_ENT1(i) (0x11 + (i)*2) - diff --git a/sys/arch/hppa/dev/elroyvar.h b/sys/arch/hppa/dev/elroyvar.h deleted file mode 100644 index f7c6d5c9d..000000000 --- a/sys/arch/hppa/dev/elroyvar.h +++ /dev/null @@ -1,57 +0,0 @@ -/* $OpenBSD: elroyvar.h,v 1.4 2009/08/22 02:54:50 mk Exp $ */ - -/* - * Copyright (c) 2005 Michael Shalayeff - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -struct elroy_softc { - struct device sc_dv; - - int sc_ver; - hppa_hpa_t sc_hpa; - bus_space_tag_t sc_bt; - bus_space_handle_t sc_bh; - bus_dma_tag_t sc_dmat; - volatile struct elroy_regs *sc_regs; - bus_addr_t sc_iobase; - - u_int32_t sc_imr; - int sc_nints; - int *sc_irq; - - struct pdc_pat_pci_rt *sc_int_tbl; - int sc_int_tbl_sz; - - struct hppa_pci_chipset_tag sc_pc; - struct hppa_bus_space_tag sc_iot; - struct hppa_bus_space_tag sc_memt; - char sc_memexname[20]; - struct extent *sc_memex; - struct hppa_bus_dma_tag sc_dmatag; -}; - -void apic_attach(struct elroy_softc *sc); -int apic_intr(void *v); -int apic_intr_map(struct pci_attach_args *pa, pci_intr_handle_t *ihp); -const char *apic_intr_string(void *v, pci_intr_handle_t ih); -void *apic_intr_establish(void *v, pci_intr_handle_t ih, int pri, - int (*handler)(void *), void *arg, const char *name); -void apic_intr_disestablish(void *v, void *cookie); - -void elroy_write32(volatile u_int32_t *p, u_int32_t v); -u_int32_t elroy_read32(volatile u_int32_t *p); diff --git a/sys/arch/hppa/dev/gecko.c b/sys/arch/hppa/dev/gecko.c deleted file mode 100644 index 13ea4366f..000000000 --- a/sys/arch/hppa/dev/gecko.c +++ /dev/null @@ -1,91 +0,0 @@ -/* $OpenBSD: gecko.c,v 1.2 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2007 Mark Kettenis - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -struct gecko_softc { - struct device sc_dv; - - bus_space_tag_t sc_iot; - bus_space_handle_t sc_ioh; -}; - -int gecko_match(struct device *, void *, void *); -void gecko_attach(struct device *, struct device *, void *); - -const struct cfattach gecko_ca = { - sizeof(struct gecko_softc), gecko_match, gecko_attach -}; - -struct cfdriver gecko_cd = { - NULL, "gecko", DV_DULL -}; - -int -gecko_match(struct device *parent, void *match, void *aux) -{ - struct confargs *ca = aux; - - if (ca->ca_type.iodc_type != HPPA_TYPE_BCPORT || - ca->ca_type.iodc_sv_model != HPPA_BCPORT_PORT) - return (0); - - if (ca->ca_type.iodc_model == 0x50 && - ca->ca_type.iodc_revision == 0x00) - return (1); - - return (0); -} - -void -gecko_attach(struct device *parent, struct device *self, void *aux) -{ - struct gecko_softc *sc = (struct gecko_softc *)self; - struct confargs *ca = aux, nca; - bus_space_handle_t ioh; - volatile struct iomod *regs; - - sc->sc_iot = ca->ca_iot; - if (bus_space_map(sc->sc_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, - &sc->sc_ioh)) { - printf(": can't map IO space\n"); - return; - } - regs = bus_space_vaddr(ca->ca_iot, ioh); - -#if 1 - printf(": %x-%x", regs->io_io_low, regs->io_io_high); -#endif - - printf("\n"); - - nca = *ca; - nca.ca_hpamask = HPPA_IOBEGIN; - pdc_scanbus(self, &nca, MAXMODBUS, regs->io_io_low); -} diff --git a/sys/arch/hppa/dev/lasi.c b/sys/arch/hppa/dev/lasi.c deleted file mode 100644 index f93fc6acc..000000000 --- a/sys/arch/hppa/dev/lasi.c +++ /dev/null @@ -1,238 +0,0 @@ -/* $OpenBSD: lasi.c,v 1.23 2018/05/14 13:54:39 kettenis Exp $ */ - -/* - * Copyright (c) 1998-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#undef LASIDEBUG - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include - -#define LASI_IOMASK 0xfff00000 - -struct lasi_hwr { - u_int32_t lasi_power; -#define LASI_BLINK 0x01 -#define LASI_OFF 0x02 - u_int32_t lasi_error; - u_int32_t lasi_version; - u_int32_t lasi_reset; - u_int32_t lasi_arbmask; -}; - -struct lasi_softc { - struct device sc_dev; - - struct lasi_hwr volatile *sc_hw; - struct gsc_attach_args ga; /* for deferred attach */ -}; - -int lasimatch(struct device *, void *, void *); -void lasiattach(struct device *, struct device *, void *); - -const struct cfattach lasi_ca = { - sizeof(struct lasi_softc), lasimatch, lasiattach -}; - -struct cfdriver lasi_cd = { - NULL, "lasi", DV_DULL -}; - -void lasi_cold_hook(int on); -void lasi_gsc_attach(struct device *self); - -int -lasimatch(parent, cfdata, aux) - struct device *parent; - void *cfdata; - void *aux; -{ - struct confargs *ca = aux; - /* struct cfdata *cf = cfdata; */ - - if (ca->ca_type.iodc_type != HPPA_TYPE_BHA || - ca->ca_type.iodc_sv_model != HPPA_BHA_LASI) - return 0; - - return 1; -} - -void -lasiattach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -{ - struct lasi_softc *sc = (struct lasi_softc *)self; - struct confargs *ca = aux; - struct gscbus_ic *ic; - bus_space_handle_t ioh, ioh2; - int s; - - if (bus_space_map(ca->ca_iot, ca->ca_hpa, - IOMOD_HPASIZE, 0, &ioh)) { - printf(": can't map TRS space\n"); - return; - } - - if (bus_space_map(ca->ca_iot, ca->ca_hpa + 0xc000, - IOMOD_HPASIZE, 0, &ioh2)) { - bus_space_unmap(ca->ca_iot, ioh, IOMOD_HPASIZE); - printf(": can't map IO space\n"); - return; - } - - sc->sc_hw = (struct lasi_hwr *)(ca->ca_hpa + 0xc000); - ic = (struct gscbus_ic *)ca->ca_hpa; - - /* XXX should we reset the chip here? */ - - printf(": rev %d.%d\n", (sc->sc_hw->lasi_version & 0xf0) >> 4, - sc->sc_hw->lasi_version & 0xf); - - /* interrupts guts */ - s = splhigh(); - ic->iar = 0; /* will be set up by gsc when attaching */ - ic->icr = 0; - ic->imr = ~0U; - (void)ic->irr; - ic->imr = 0; - splx(s); - -#ifdef USELEDS - /* figure out the leds address */ - switch (cpu_hvers) { - case HPPA_BOARD_HP712_60: - case HPPA_BOARD_HP712_80: - case HPPA_BOARD_HP712_100: - case HPPA_BOARD_HP743I_64: - case HPPA_BOARD_HP743I_100: - case HPPA_BOARD_HP712_120: - break; /* only has one led. works different */ - - case HPPA_BOARD_HP715_64: - case HPPA_BOARD_HP715_80: - case HPPA_BOARD_HP715_100: - case HPPA_BOARD_HP715_100XC: - case HPPA_BOARD_HP725_100: - case HPPA_BOARD_HP725_120: - if (bus_space_map(ca->ca_iot, ca->ca_hpa - 0x20000, - 4, 0, (bus_space_handle_t *)&machine_ledaddr)) - machine_ledaddr = NULL; - machine_ledword = 1; - break; - - case HPPA_BOARD_HP800_A180C: - case HPPA_BOARD_HP778_B132L: - case HPPA_BOARD_HP778_B132LP: - case HPPA_BOARD_HP778_B160L: - case HPPA_BOARD_HP778_B180L: - case HPPA_BOARD_HP780_C100: - case HPPA_BOARD_HP780_C110: - case HPPA_BOARD_HP779_C132L: - case HPPA_BOARD_HP779_C160L: - case HPPA_BOARD_HP779_C180L: - case HPPA_BOARD_HP779_C160L1: - if (bus_space_map(ca->ca_iot, 0xf0190000, - 4, 0, (bus_space_handle_t *)&machine_ledaddr)) - machine_ledaddr = NULL; - machine_ledword = 1; - break; - - default: - machine_ledaddr = (u_int8_t *)sc->sc_hw; - machine_ledword = 1; - break; - } -#endif - - sc->ga.ga_ca = *ca; /* clone from us */ - if (!strcmp(parent->dv_xname, "mainbus0")) { - sc->ga.ga_dp.dp_bc[0] = sc->ga.ga_dp.dp_bc[1]; - sc->ga.ga_dp.dp_bc[1] = sc->ga.ga_dp.dp_bc[2]; - sc->ga.ga_dp.dp_bc[2] = sc->ga.ga_dp.dp_bc[3]; - sc->ga.ga_dp.dp_bc[3] = sc->ga.ga_dp.dp_bc[4]; - sc->ga.ga_dp.dp_bc[4] = sc->ga.ga_dp.dp_bc[5]; - sc->ga.ga_dp.dp_bc[5] = sc->ga.ga_dp.dp_mod; - sc->ga.ga_dp.dp_mod = 0; - } - sc->ga.ga_name = "gsc"; - sc->ga.ga_hpamask = LASI_IOMASK; - sc->ga.ga_parent = gsc_lasi; - sc->ga.ga_ic = ic; - if (sc->sc_dev.dv_unit) - config_defer(self, lasi_gsc_attach); - else { - extern void (*cold_hook)(int); - - lasi_gsc_attach(self); - /* could be already set by power(4) */ - if (!cold_hook) - cold_hook = lasi_cold_hook; - } -} - -void -lasi_gsc_attach(self) - struct device *self; -{ - struct lasi_softc *sc = (struct lasi_softc *)self; - - config_found(self, &sc->ga, gscprint); -} - -void -lasi_cold_hook(on) - int on; -{ - struct lasi_softc *sc = lasi_cd.cd_devs[0]; - - if (!sc) - return; - - switch (on) { - case HPPA_COLD_COLD: - sc->sc_hw->lasi_power = LASI_BLINK; - break; - case HPPA_COLD_HOT: - sc->sc_hw->lasi_power = 0; - break; - case HPPA_COLD_OFF: - sc->sc_hw->lasi_power = LASI_OFF; - break; - } -} diff --git a/sys/arch/hppa/dev/lcd.c b/sys/arch/hppa/dev/lcd.c deleted file mode 100644 index 335a14e85..000000000 --- a/sys/arch/hppa/dev/lcd.c +++ /dev/null @@ -1,156 +0,0 @@ -/* $OpenBSD: lcd.c,v 1.6 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2007 Mark Kettenis - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#define LCD_CLS 0x01 -#define LCD_HOME 0x02 -#define LCD_LOCATE(X, Y) (((Y) & 1 ? 0xc0 : 0x80) | ((X) & 0x0f)) - -struct lcd_softc { - struct device sc_dv; - - bus_space_tag_t sc_iot; - bus_space_handle_t sc_cmdh, sc_datah; - - u_int sc_delay; - u_int8_t sc_heartbeat[3]; - - struct timeout sc_to; - int sc_on; - struct blink_led sc_blink; -}; - -int lcd_match(struct device *, void *, void *); -void lcd_attach(struct device *, struct device *, void *); - -const struct cfattach lcd_ca = { - sizeof(struct lcd_softc), lcd_match, lcd_attach -}; - -struct cfdriver lcd_cd = { - NULL, "lcd", DV_DULL -}; - -void lcd_mountroot(struct device *); -void lcd_write(struct lcd_softc *, const char *); -void lcd_blink(void *, int); -void lcd_blink_finish(void *); - -int -lcd_match(struct device *parent, void *match, void *aux) -{ - struct confargs *ca = aux; - - if (strcmp(ca->ca_name, "lcd") == 0) - return (1); - - return (0); -} - -void -lcd_attach(struct device *parent, struct device *self, void *aux) -{ - struct lcd_softc *sc = (struct lcd_softc *)self; - struct confargs *ca = aux; - struct pdc_chassis_lcd *pdc_lcd = (void *)ca->ca_pdc_iodc_read; - int i; - - sc->sc_iot = ca->ca_iot; - if (bus_space_map(sc->sc_iot, pdc_lcd->cmd_addr, - 1, 0, &sc->sc_cmdh)) { - printf(": cannot map cmd register\n"); - return; - } - - if (bus_space_map(sc->sc_iot, pdc_lcd->data_addr, - 1, 0, &sc->sc_datah)) { - printf(": cannot map data register\n"); - bus_space_unmap(sc->sc_iot, sc->sc_cmdh, 1); - return; - } - - printf(": model %d\n", pdc_lcd->model); - - sc->sc_delay = pdc_lcd->delay; - for (i = 0; i < 3; i++) - sc->sc_heartbeat[i] = pdc_lcd->heartbeat[i]; - - timeout_set(&sc->sc_to, lcd_blink_finish, sc); - - sc->sc_blink.bl_func = lcd_blink; - sc->sc_blink.bl_arg = sc; - blink_led_register(&sc->sc_blink); - - config_mountroot(self, lcd_mountroot); -} - -void -lcd_mountroot(struct device *self) -{ - struct lcd_softc *sc = (struct lcd_softc *)self; - - bus_space_write_1(sc->sc_iot, sc->sc_cmdh, 0, LCD_CLS); - delay(100 * sc->sc_delay); - - bus_space_write_1(sc->sc_iot, sc->sc_cmdh, 0, LCD_LOCATE(0, 0)); - delay(sc->sc_delay); - lcd_write(sc, "OpenBSD/" MACHINE); -} - -void -lcd_write(struct lcd_softc *sc, const char *str) -{ - while (*str) { - bus_space_write_1(sc->sc_iot, sc->sc_datah, 0, *str++); - delay(sc->sc_delay); - } -} - -void -lcd_blink(void *v, int on) -{ - struct lcd_softc *sc = v; - - sc->sc_on = on; - bus_space_write_1(sc->sc_iot, sc->sc_cmdh, 0, sc->sc_heartbeat[0]); - timeout_add_usec(&sc->sc_to, sc->sc_delay); -} - -void -lcd_blink_finish(void *v) -{ - struct lcd_softc *sc = v; - u_int8_t data; - - if (sc->sc_on) - data = sc->sc_heartbeat[1]; - else - data = sc->sc_heartbeat[2]; - - bus_space_write_1(sc->sc_iot, sc->sc_datah, 0, data); -} diff --git a/sys/arch/hppa/dev/lpt_ssio.c b/sys/arch/hppa/dev/lpt_ssio.c deleted file mode 100644 index 3ed1e4a04..000000000 --- a/sys/arch/hppa/dev/lpt_ssio.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: lpt_ssio.c,v 1.2 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2007 Mark Kettenis - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -#include - -#include -#include - -#include - -int lpt_ssio_match(struct device *, void *, void *); -void lpt_ssio_attach(struct device *, struct device *, void *); - -const struct cfattach lpt_ssio_ca = { - sizeof(struct lpt_softc), lpt_ssio_match, lpt_ssio_attach -}; - -int -lpt_ssio_match(struct device *parent, void *match, void *aux) -{ - struct cfdata *cf = match; - struct ssio_attach_args *saa = aux; - - if (strcmp(saa->saa_name, "lpt") != 0) - return (0); - - /* Check locators. */ - if (cf->ssiocf_irq != SSIO_UNK_IRQ && cf->ssiocf_irq != saa->saa_irq) - return (0); - - return (1); -} - -void -lpt_ssio_attach(struct device *parent, struct device *self, void *aux) -{ - struct lpt_softc *sc = (void *)self; - struct ssio_attach_args *saa = aux; - - sc->sc_iot = saa->saa_iot; - if (bus_space_map(sc->sc_iot, saa->saa_iobase, LPT_NPORTS, - 0, &sc->sc_ioh)) { - printf(": cannot map io space\n"); - return; - } - - lpt_attach_common(sc); - - sc->sc_ih = ssio_intr_establish(IPL_TTY, saa->saa_irq, - lptintr, sc, sc->sc_dev.dv_xname); -} diff --git a/sys/arch/hppa/dev/mongoose.c b/sys/arch/hppa/dev/mongoose.c deleted file mode 100644 index 098c520c9..000000000 --- a/sys/arch/hppa/dev/mongoose.c +++ /dev/null @@ -1,594 +0,0 @@ -/* $OpenBSD: mongoose.c,v 1.23 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 1998-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include - -#include -#include - -void mgattach_gedoens(struct device *, struct device *, void *); -int mgmatch_gedoens(struct device *, void *, void *); - -const struct cfattach mg_gedoens_ca = { - sizeof(struct mongoose_softc), mgmatch_gedoens, mgattach_gedoens -}; - -struct cfdriver mongoose_cd = { - NULL, "mongoose", DV_DULL -}; - -void mg_eisa_attach_hook(struct device *parent, - struct device *self, - struct eisabus_attach_args *mg); -int mg_intr_map(void *v, u_int irq, eisa_intr_handle_t *ehp); -const char *mg_intr_string(void *v, int irq); -void mg_isa_attach_hook(struct device *parent, - struct device *self, - struct isabus_attach_args *iba); -void *mg_intr_establish(void *v, int irq, int type, int pri, - int (*handler)(void *), void *arg, const char *name); -void mg_intr_disestablish(void *v, void *cookie); -int mg_intr_check(void *v, int irq, int type); -int mg_eisa_iomap(void *v, bus_addr_t addr, bus_size_t size, - int flags, bus_space_handle_t *bshp); -int mg_eisa_memmap(void *v, bus_addr_t addr, bus_size_t size, - int flags, bus_space_handle_t *bshp); -void mg_eisa_memunmap(void *v, bus_space_handle_t bsh, - bus_size_t size); -void mg_isa_barrier(void *v, bus_space_handle_t h, bus_size_t o, - bus_size_t l, int op); -u_int16_t mg_isa_r2(void *v, bus_space_handle_t h, bus_size_t o); -u_int32_t mg_isa_r4(void *v, bus_space_handle_t h, bus_size_t o); -void mg_isa_w2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t vv); -void mg_isa_w4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t vv); -void mg_isa_rm_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t *a, bus_size_t c); -void mg_isa_rm_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t *a, bus_size_t c); -void mg_isa_wm_2(void *v, bus_space_handle_t h, bus_size_t o, - const u_int16_t *a, bus_size_t c); -void mg_isa_wm_4(void *v, bus_space_handle_t h, bus_size_t o, - const u_int32_t *a, bus_size_t c); -void mg_isa_sm_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t vv, bus_size_t c); -void mg_isa_sm_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t vv, bus_size_t c); -void mg_isa_rr_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t *a, bus_size_t c); -void mg_isa_rr_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t *a, bus_size_t c); -void mg_isa_wr_2(void *v, bus_space_handle_t h, bus_size_t o, - const u_int16_t *a, bus_size_t c); -void mg_isa_wr_4(void *v, bus_space_handle_t h, bus_size_t o, - const u_int32_t *a, bus_size_t c); -void mg_isa_sr_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t vv, bus_size_t c); -void mg_isa_sr_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t vv, bus_size_t c); - -/* TODO: DMA guts */ - -void -mg_eisa_attach_hook(struct device *parent, struct device *self, - struct eisabus_attach_args *mg) -{ -} - -int -mg_intr_map(void *v, u_int irq, eisa_intr_handle_t *ehp) -{ - *ehp = irq; - return 0; -} - -const char * -mg_intr_string(void *v, int irq) -{ - static char buf[16]; - - snprintf(buf, sizeof buf, "isa irq %d", irq); - return buf; -} - -void -mg_isa_attach_hook(struct device *parent, struct device *self, - struct isabus_attach_args *iba) -{ - -} - -void * -mg_intr_establish(void *v, int irq, int type, int pri, - int (*handler)(void *), void *arg, const char *name) -{ - struct hppa_isa_iv *iv; - struct mongoose_softc *sc = v; - volatile u_int8_t *imr, *pic; - - if (!sc || irq < 0 || irq >= MONGOOSE_NINTS || - (0 <= irq && irq < MONGOOSE_NINTS && sc->sc_iv[irq].iv_handler)) - return NULL; - - if (type != IST_LEVEL && type != IST_EDGE) { -#ifdef DEBUG - printf("%s: bad interrupt level (%d)\n", sc->sc_dev.dv_xname, - type); -#endif - return NULL; - } - - iv = &sc->sc_iv[irq]; - if (iv->iv_handler) { -#ifdef DEBUG - printf("%s: irq %d already established\n", sc->sc_dev.dv_xname, - irq); -#endif - return NULL; - } - - iv->iv_name = name; - iv->iv_pri = pri; - iv->iv_handler = handler; - iv->iv_arg = arg; - - if (irq < 8) { - imr = &sc->sc_ctrl->imr0; - pic = &sc->sc_ctrl->pic0; - } else { - imr = &sc->sc_ctrl->imr1; - pic = &sc->sc_ctrl->pic1; - irq -= 8; - } - - *imr |= 1 << irq; - *pic |= (type == IST_LEVEL) << irq; - - /* TODO: ack it? */ - - return iv; -} - -void -mg_intr_disestablish(void *v, void *cookie) -{ - struct hppa_isa_iv *iv = cookie; - struct mongoose_softc *sc = v; - int irq; - volatile u_int8_t *imr; - - if (!sc || !cookie) - return; - - irq = iv - sc->sc_iv; - if (irq < 8) - imr = &sc->sc_ctrl->imr0; - else - imr = &sc->sc_ctrl->imr1; - *imr &= ~(1 << irq); - /* TODO: ack it? */ - - iv->iv_handler = NULL; -} - -int -mg_intr_check(void *v, int irq, int type) -{ - return 0; -} - -int -mg_intr(void *v) -{ - struct mongoose_softc *sc = v; - struct hppa_isa_iv *iv; - int s, irq = 0; - - iv = &sc->sc_iv[irq]; - s = splraise(iv->iv_pri); - (iv->iv_handler)(iv->iv_arg); - splx(s); - - return 0; -} - -int -mg_eisa_iomap(void *v, bus_addr_t addr, bus_size_t size, int flags, - bus_space_handle_t *bshp) -{ - struct mongoose_softc *sc = v; - - /* see if it's ISA space we are mapping */ - if (0x100 <= addr && addr < 0x400) { -#define TOISA(a) ((((a) & 0x3f8) << 9) + ((a) & 7)) - size = TOISA(addr + size) - TOISA(addr); - addr = TOISA(addr); - } - - return (sc->sc_bt->hbt_map)(NULL, sc->sc_iomap + addr, size, - flags, bshp); -} - -int -mg_eisa_memmap(void *v, bus_addr_t addr, bus_size_t size, int flags, - bus_space_handle_t *bshp) -{ - /* TODO: eisa memory map */ - return -1; -} - -void -mg_eisa_memunmap(void *v, bus_space_handle_t bsh, bus_size_t size) -{ - /* TODO: eisa memory unmap */ -} - -void -mg_isa_barrier(void *v, bus_space_handle_t h, bus_size_t o, bus_size_t l, int op) -{ - sync_caches(); -} - -u_int16_t -mg_isa_r2(void *v, bus_space_handle_t h, bus_size_t o) -{ - register u_int16_t r = *((volatile u_int16_t *)(h + o)); - return letoh16(r); -} - -u_int32_t -mg_isa_r4(void *v, bus_space_handle_t h, bus_size_t o) -{ - register u_int32_t r = *((volatile u_int32_t *)(h + o)); - return letoh32(r); -} - -void -mg_isa_w2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv) -{ - *((volatile u_int16_t *)(h + o)) = htole16(vv); -} - -void -mg_isa_w4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv) -{ - *((volatile u_int32_t *)(h + o)) = htole32(vv); -} - -void -mg_isa_rm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t c) -{ - h += o; - while (c--) - *(a++) = letoh16(*(volatile u_int16_t *)h); -} - -void -mg_isa_rm_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t *a, bus_size_t c) -{ - h += o; - while (c--) - *(a++) = letoh32(*(volatile u_int32_t *)h); -} - -void -mg_isa_wm_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_size_t c) -{ - register u_int16_t r; - h += o; - while (c--) { - r = *(a++); - *(volatile u_int16_t *)h = htole16(r); - } -} - -void -mg_isa_wm_4(void *v, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, bus_size_t c) -{ - register u_int32_t r; - h += o; - while (c--) { - r = *(a++); - *(volatile u_int32_t *)h = htole32(r); - } -} - -void -mg_isa_sm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, bus_size_t c) -{ - vv = htole16(vv); - h += o; - while (c--) - *(volatile u_int16_t *)h = vv; -} - -void -mg_isa_sm_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv, bus_size_t c) -{ - vv = htole32(vv); - h += o; - while (c--) - *(volatile u_int32_t *)h = vv; -} - -void -mg_isa_rr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t c) -{ - volatile u_int16_t *p = (u_int16_t *)(h + o); - u_int32_t r; - - while (c--) { - r = *p++; - *a++ = letoh16(r); - } -} - -void -mg_isa_rr_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t *a, bus_size_t c) -{ - volatile u_int32_t *p = (u_int32_t *)(h + o); - u_int32_t r; - - while (c--) { - r = *p++; - *a++ = letoh32(r); - } -} - -void -mg_isa_wr_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_size_t c) -{ - volatile u_int16_t *p = (u_int16_t *)(h + o); - u_int32_t r; - - while (c--) { - r = *a++; - *p++ = htole16(r); - } -} - -void -mg_isa_wr_4(void *v, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, bus_size_t c) -{ - volatile u_int32_t *p = (u_int32_t *)(h + o); - u_int32_t r; - - while (c--) { - r = *a++; - *p++ = htole32(r); - } -} - -void -mg_isa_sr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, bus_size_t c) -{ - volatile u_int16_t *p = (u_int16_t *)(h + o); - - vv = htole16(vv); - while (c--) - *p++ = vv; -} - -void -mg_isa_sr_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv, bus_size_t c) -{ - volatile u_int32_t *p = (u_int32_t *)(h + o); - - vv = htole32(vv); - while (c--) - *p++ = vv; -} - -int -mgattach_common(sc) - struct mongoose_softc *sc; -{ - struct hppa_bus_space_tag *bt; - union mongoose_attach_args ea; - char brid[EISA_IDSTRINGLEN]; - - viper_eisa_en(); - - /* BUS RESET */ - sc->sc_ctrl->nmi_ext = MONGOOSE_NMI_BUSRESET; - DELAY(1); - sc->sc_ctrl->nmi_ext = 0; - DELAY(100); - - /* determine eisa board id */ - { - u_int8_t id[4], *p; - p = (u_int8_t *)(sc->sc_iomap + EISA_SLOTOFF_VID); - id[0] = *p++; - id[1] = *p++; - id[2] = *p++; - id[3] = *p++; - - brid[0] = EISA_VENDID_0(id); - brid[1] = EISA_VENDID_1(id); - brid[2] = EISA_VENDID_2(id); - brid[3] = EISA_PRODID_0(id + 2); - brid[4] = EISA_PRODID_1(id + 2); - brid[5] = EISA_PRODID_2(id + 2); - brid[6] = EISA_PRODID_3(id + 2); - brid[7] = '\0'; - } - - printf (": %s rev %d, %d MHz\n", brid, sc->sc_regs->version, - (sc->sc_regs->clock? 33 : 25)); - sc->sc_regs->liowait = 1; /* disable isa wait states */ - sc->sc_regs->lock = 1; /* bus unlock */ - - /* attach EISA */ - sc->sc_ec.ec_v = sc; - sc->sc_ec.ec_attach_hook = mg_eisa_attach_hook; - sc->sc_ec.ec_intr_establish = mg_intr_establish; - sc->sc_ec.ec_intr_disestablish = mg_intr_disestablish; - sc->sc_ec.ec_intr_string = mg_intr_string; - sc->sc_ec.ec_intr_map = mg_intr_map; - /* inherit the bus tags for eisa from the mainbus */ - bt = &sc->sc_eiot; - bcopy(sc->sc_bt, bt, sizeof(*bt)); - bt->hbt_cookie = sc; - bt->hbt_map = mg_eisa_iomap; -#define R(n) bt->__CONCAT(hbt_,n) = &__CONCAT(mg_isa_,n) - /* R(barrier); */ - R(r2); R(r4); R(w2); R(w4); - R(rm_2);R(rm_4);R(wm_2);R(wm_4);R(sm_2);R(sm_4); - R(rr_2);R(rr_4);R(wr_2);R(wr_4);R(sr_2);R(sr_4); - - bt = &sc->sc_ememt; - bcopy(sc->sc_bt, bt, sizeof(*bt)); - bt->hbt_cookie = sc; - bt->hbt_map = mg_eisa_memmap; - bt->hbt_unmap = mg_eisa_memunmap; - /* attachment guts */ - ea.mongoose_eisa.eba_busname = "eisa"; - ea.mongoose_eisa.eba_iot = &sc->sc_eiot; - ea.mongoose_eisa.eba_memt = &sc->sc_ememt; - ea.mongoose_eisa.eba_dmat = NULL /* &sc->sc_edmat */; - ea.mongoose_eisa.eba_ec = &sc->sc_ec; - config_found((struct device *)sc, &ea.mongoose_eisa, mgprint); - - sc->sc_ic.ic_v = sc; - sc->sc_ic.ic_attach_hook = mg_isa_attach_hook; - sc->sc_ic.ic_intr_establish = mg_intr_establish; - sc->sc_ic.ic_intr_disestablish = mg_intr_disestablish; - sc->sc_ic.ic_intr_check = mg_intr_check; - /* inherit the bus tags for isa from the eisa */ - bt = &sc->sc_imemt; - bcopy(&sc->sc_ememt, bt, sizeof(*bt)); - bt = &sc->sc_iiot; - bcopy(&sc->sc_eiot, bt, sizeof(*bt)); - /* TODO: DMA tags */ - /* attachment guts */ - ea.mongoose_isa.iba_busname = "isa"; - ea.mongoose_isa.iba_iot = &sc->sc_iiot; - ea.mongoose_isa.iba_memt = &sc->sc_imemt; -#if NISADMA > 0 - ea.mongoose_isa.iba_dmat = &sc->sc_idmat; -#endif - ea.mongoose_isa.iba_ic = &sc->sc_ic; - config_found((struct device *)sc, &ea.mongoose_isa, mgprint); -#undef R - - return (0); -} - -int -mgprint(aux, pnp) - void *aux; - const char *pnp; -{ - union mongoose_attach_args *ea = aux; - - if (pnp) - printf ("%s at %s", ea->mongoose_name, pnp); - - return (UNCONF); -} - -int -mgmatch_gedoens(parent, cfdata, aux) - struct device *parent; - void *cfdata; - void *aux; -{ - register struct confargs *ca = aux; - /* struct cfdata *cf = cfdata; */ - bus_space_handle_t ioh; - - if (ca->ca_type.iodc_type != HPPA_TYPE_BHA || - (ca->ca_type.iodc_sv_model != HPPA_BHA_EISA && - ca->ca_type.iodc_sv_model != HPPA_BHA_WEISA)) - return 0; - - if (bus_space_map(ca->ca_iot, ca->ca_hpa + MONGOOSE_MONGOOSE, - IOMOD_HPASIZE, 0, &ioh)) - return 0; - - /* XXX check EISA signature */ - - bus_space_unmap(ca->ca_iot, ioh, IOMOD_HPASIZE); - - return 1; -} - -void -mgattach_gedoens(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -{ - register struct confargs *ca = aux; - register struct mongoose_softc *sc = (struct mongoose_softc *)self; - bus_space_handle_t ioh; - - sc->sc_bt = ca->ca_iot; - sc->sc_iomap = ca->ca_hpa; - - if (bus_space_map(ca->ca_iot, ca->ca_hpa + MONGOOSE_MONGOOSE, - sizeof(struct mongoose_regs), 0, &ioh) != 0) { - printf(": can't map IO space\n"); - return; - } - sc->sc_regs = (struct mongoose_regs *)ioh; - - if (bus_space_map(ca->ca_iot, ca->ca_hpa + MONGOOSE_CTRL, - sizeof(struct mongoose_ctrl), 0, &ioh) != 0) { - printf(": can't map control registers\n"); - bus_space_unmap(ca->ca_iot, (bus_space_handle_t)sc->sc_regs, - sizeof(struct mongoose_regs)); - return; - } - sc->sc_ctrl = (struct mongoose_ctrl *)ioh; - - if (mgattach_common(sc) != 0) - return; - - /* attach interrupt */ - sc->sc_ih = cpu_intr_establish(IPL_HIGH, ca->ca_irq, - mg_intr, sc, sc->sc_dev.dv_xname); -} diff --git a/sys/arch/hppa/dev/mongoosereg.h b/sys/arch/hppa/dev/mongoosereg.h deleted file mode 100644 index 5d6a3a6ce..000000000 --- a/sys/arch/hppa/dev/mongoosereg.h +++ /dev/null @@ -1,130 +0,0 @@ -/* $OpenBSD: mongoosereg.h,v 1.2 2008/08/24 18:53:36 miod Exp $ */ - -/* - * Copyright (c) 1998-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -/* EISA Bus Adapter registers definitions */ -#define MONGOOSE_MONGOOSE 0x10000 -struct mongoose_regs { - u_int8_t version; - u_int8_t lock; - u_int8_t liowait; - u_int8_t clock; - u_int8_t reserved[0xf000 - 4]; - u_int8_t intack; -}; - -#define MONGOOSE_CTRL 0x00000 -#define MONGOOSE_NINTS 16 -struct mongoose_ctrl { - struct dma0 { - struct { - u_int16_t addr : 8; - u_int16_t count: 8; - } ch[4]; - u_int8_t command; - u_int8_t request; - u_int8_t mask_channel; - u_int8_t mode; - u_int8_t clr_byte_ptr; - u_int8_t master_clear; - u_int8_t mask_clear; - u_int8_t master_write; - u_int8_t pad[15]; - } dma0; - - u_int8_t irr0; /* 0x20 */ - u_int8_t imr0; - u_int8_t iack; /* 0x22 -- 2 b2b reads generate - (e)isa Iack cycle & returns int level */ - u_int8_t pad0[29]; - - struct timers { - u_int8_t sysclk; - u_int8_t refresh; - u_int8_t spkr; - u_int8_t ctrl; - u_int32_t pad; - } tmr[2]; /* 0x40 -- timers control */ - u_int8_t pad1[16]; - - u_int16_t inmi; /* 0x60 NMI control */ - u_int8_t pad2[30]; - struct { - u_int8_t pad0; - u_int8_t ch2; - u_int8_t ch3; - u_int8_t ch1; - u_int8_t pad1; - u_int8_t pad2[3]; - u_int8_t ch0; - u_int8_t pad4; - u_int8_t ch6; - u_int8_t ch7; - u_int8_t ch5; - u_int8_t pad5[3]; - u_int8_t pad6[16]; - } pr; /* 0x80 */ - - u_int8_t irr1; /* 0xa0 */ - u_int8_t imr1; - u_int8_t pad3[30]; - - struct dma1 { - struct { - u_int32_t addr : 16; - u_int32_t count: 16; - } ch[4]; - u_int16_t command; - u_int16_t request; - u_int16_t mask_channel; - u_int16_t mode; - u_int16_t clr_byte_ptr; - u_int16_t master_clear; - u_int16_t mask_clear; - u_int16_t master_write; - } dma1; /* 0xc0 */ - - u_int8_t master_req; /* 0xe0 master request register */ - u_int8_t pad4[31]; - - u_int8_t pad5[0x3d0]; /* 0x4d0 */ - u_int8_t pic0; /* 0 - edge, 1 - level */ - u_int8_t pic1; - u_int8_t pad6[0x460]; - u_int8_t nmi; - u_int8_t nmi_ext; -#define MONGOOSE_NMI_BUSRESET 0x01 -#define MONGOOSE_NMI_IOPORT_EN 0x02 -#define MONGOOSE_NMI_EN 0x04 -#define MONGOOSE_NMI_MTMO_EN 0x08 -#define MONGOOSE_NMI_RES4 0x10 -#define MONGOOSE_NMI_IOPORT_INT 0x20 -#define MONGOOSE_NMI_MASTER_INT 0x40 -#define MONGOOSE_NMI_INT 0x80 -}; - -#define MONGOOSE_IOMAP 0x100000 diff --git a/sys/arch/hppa/dev/mongoosevar.h b/sys/arch/hppa/dev/mongoosevar.h deleted file mode 100644 index 87c066054..000000000 --- a/sys/arch/hppa/dev/mongoosevar.h +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: mongoosevar.h,v 1.2 2007/05/10 17:59:24 deraadt Exp $ */ - -/* - * Copyright (c) 1998-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -struct hppa_isa_iv { - const char *iv_name; - int (*iv_handler)(void *arg); - void *iv_arg; - int iv_pri; - - /* don't do sharing, we won't have many slots anyway - struct hppa_isa_iv *iv_next; - */ -}; - -struct mongoose_softc { - struct device sc_dev; - void *sc_ih; - - bus_space_tag_t sc_bt; - volatile struct mongoose_regs *sc_regs; - volatile struct mongoose_ctrl *sc_ctrl; - bus_addr_t sc_iomap; - - /* interrupts section */ - struct hppa_eisa_chipset sc_ec; - struct hppa_isa_chipset sc_ic; - struct hppa_isa_iv sc_iv[MONGOOSE_NINTS]; - - /* isa/eisa bus guts */ - struct hppa_bus_space_tag sc_eiot; - struct hppa_bus_space_tag sc_ememt; - struct hppa_bus_dma_tag sc_edmat; - struct hppa_bus_space_tag sc_iiot; - struct hppa_bus_space_tag sc_imemt; - struct hppa_bus_dma_tag sc_idmat; -}; - -union mongoose_attach_args { - char *mongoose_name; - struct eisabus_attach_args mongoose_eisa; - struct isabus_attach_args mongoose_isa; -}; - -int mgattach_common(struct mongoose_softc *); -int mgprint(void *, const char *); -int mg_intr(void *); diff --git a/sys/arch/hppa/dev/pdc.c b/sys/arch/hppa/dev/pdc.c deleted file mode 100644 index 896075bbd..000000000 --- a/sys/arch/hppa/dev/pdc.c +++ /dev/null @@ -1,447 +0,0 @@ -/* $OpenBSD: pdc.c,v 1.41 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 1998-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 "com.h" - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -typedef -struct pdc_softc { - struct device sc_dv; - struct tty *sc_tty; - struct timeout sc_to; -} pdcsoftc_t; - -pdcio_t pdc; -int pdcret[32] PDC_ALIGNMENT; -char pdc_consbuf[IODC_MINIOSIZ] PDC_ALIGNMENT; -iodcio_t pdc_cniodc, pdc_kbdiodc; -pz_device_t *pz_kbd, *pz_cons; - -int pdcngetc(dev_t); -void pdcnputc(dev_t, char *); - -struct consdev pdccons = { NULL, NULL, pdccngetc, pdccnputc, - nullcnpollc, NULL, makedev(22, 0), CN_LOWPRI }; - -int pdcmatch(struct device *, void *, void *); -void pdcattach(struct device *, struct device *, void *); - -const struct cfattach pdc_ca = { - sizeof(pdcsoftc_t), pdcmatch, pdcattach -}; - -struct cfdriver pdc_cd = { - NULL, "pdc", DV_DULL -}; - -void pdcstart(struct tty *tp); -void pdctimeout(void *v); -int pdcparam(struct tty *tp, struct termios *); -int pdccnlookc(dev_t dev, int *cp); - -#if NCOM > 0 -/* serial console speed table */ -static int pdc_speeds[] = { - B50, - B75, - B110, - B150, - B300, - B600, - B1200, - B2400, - B4800, - B7200, - B9600, - B19200, - B38400, - B57600, - B115200, - B230400, -}; -#endif - -void -pdc_init() -{ - static int kbd_iodc[IODC_MAXSIZE/sizeof(int)]; - static int cn_iodc[IODC_MAXSIZE/sizeof(int)]; - int err; - - /* XXX locore've done it XXX pdc = (pdcio_t)PAGE0->mem_pdc; */ - pz_kbd = &PAGE0->mem_kbd; - pz_cons = &PAGE0->mem_cons; - - /* XXX should we reset the console/kbd here? - well, /boot did that for us anyway */ - if ((err = pdc_call((iodcio_t)pdc, 0, PDC_IODC, PDC_IODC_READ, - pdcret, pz_cons->pz_hpa, IODC_IO, cn_iodc, IODC_MAXSIZE)) < 0 || - (err = pdc_call((iodcio_t)pdc, 0, PDC_IODC, PDC_IODC_READ, - pdcret, pz_kbd->pz_hpa, IODC_IO, kbd_iodc, IODC_MAXSIZE)) < 0) { -#ifdef DEBUG - printf("pdc_init: failed reading IODC (%d)\n", err); -#endif - } - - pdc_cniodc = (iodcio_t)cn_iodc; - pdc_kbdiodc = (iodcio_t)kbd_iodc; - - /* Start out with pdc as the console. */ - cn_tab = &pdccons; - - /* Figure out console settings. */ -#if NCOM > 0 - if (PAGE0->mem_cons.pz_class == PCL_DUPLEX) { - struct pz_device *pzd = &PAGE0->mem_cons; - extern int comdefaultrate; -#ifdef DEBUG - printf("console: class %d flags %b ", - pzd->pz_class, pzd->pz_flags, PZF_BITS); - printf("bc %d/%d/%d/%d/%d/%d ", - pzd->pz_bc[0], pzd->pz_bc[1], pzd->pz_bc[2], - pzd->pz_bc[3], pzd->pz_bc[4], pzd->pz_bc[5]); - printf("mod %x layers %x/%x/%x/%x/%x/%x hpa %x\n", pzd->pz_mod, - pzd->pz_layers[0], pzd->pz_layers[1], pzd->pz_layers[2], - pzd->pz_layers[3], pzd->pz_layers[4], pzd->pz_layers[5], - pzd->pz_hpa); - -#endif - - /* compute correct baud rate */ - if (PZL_SPEED(pzd->pz_layers[0]) < - sizeof(pdc_speeds) / sizeof(int)) - comdefaultrate = - pdc_speeds[PZL_SPEED(pzd->pz_layers[0])]; - else - comdefaultrate = B9600; /* XXX */ - } -#endif -} - -int -pdcmatch(parent, cfdata, aux) - struct device *parent; - void *cfdata; - void *aux; -{ - struct cfdata *cf = cfdata; - struct confargs *ca = aux; - - /* there could be only one */ - if (cf->cf_unit > 0 && !strcmp(ca->ca_name, "pdc")) - return 0; - - return 1; -} - -void -pdcattach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -{ - struct pdc_softc *sc = (struct pdc_softc *)self; - - if (!pdc) - pdc_init(); - - printf("\n"); - - timeout_set(&sc->sc_to, pdctimeout, sc); -} - -int -pdcopen(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; -{ - int unit = minor(dev); - struct pdc_softc *sc; - struct tty *tp; - int s; - int error = 0, setuptimeout = 0; - - if (unit >= pdc_cd.cd_ndevs || (sc = pdc_cd.cd_devs[unit]) == NULL) - return ENXIO; - - s = spltty(); - - if (sc->sc_tty) - tp = sc->sc_tty; - else { - tp = sc->sc_tty = ttymalloc(0); - } - - tp->t_oproc = pdcstart; - tp->t_param = pdcparam; - tp->t_dev = dev; - if ((tp->t_state & TS_ISOPEN) == 0) { - ttychars(tp); - tp->t_iflag = TTYDEF_IFLAG; - tp->t_oflag = TTYDEF_OFLAG; - tp->t_cflag = TTYDEF_CFLAG|CLOCAL; - tp->t_lflag = TTYDEF_LFLAG; - tp->t_ispeed = tp->t_ospeed = B9600; - ttsetwater(tp); - - setuptimeout = 1; - } else if (tp->t_state&TS_XCLUDE && suser(p) != 0) { - splx(s); - return (EBUSY); - } - tp->t_state |= TS_CARR_ON; - splx(s); - - error = (*linesw[tp->t_line].l_open)(dev, tp, p); - if (error == 0 && setuptimeout) - pdctimeout(sc); - - return error; -} - -int -pdcclose(dev, flag, mode, p) - dev_t dev; - int flag, mode; - struct proc *p; -{ - int unit = minor(dev); - struct tty *tp; - struct pdc_softc *sc; - - if (unit >= pdc_cd.cd_ndevs || (sc = pdc_cd.cd_devs[unit]) == NULL) - return ENXIO; - - tp = sc->sc_tty; - timeout_del(&sc->sc_to); - (*linesw[tp->t_line].l_close)(tp, flag, p); - ttyclose(tp); - return 0; -} - -int -pdcread(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int unit = minor(dev); - struct tty *tp; - struct pdc_softc *sc; - - if (unit >= pdc_cd.cd_ndevs || (sc = pdc_cd.cd_devs[unit]) == NULL) - return ENXIO; - - tp = sc->sc_tty; - return ((*linesw[tp->t_line].l_read)(tp, uio, flag)); -} - -int -pdcwrite(dev, uio, flag) - dev_t dev; - struct uio *uio; - int flag; -{ - int unit = minor(dev); - struct tty *tp; - struct pdc_softc *sc; - - if (unit >= pdc_cd.cd_ndevs || (sc = pdc_cd.cd_devs[unit]) == NULL) - return ENXIO; - - tp = sc->sc_tty; - return ((*linesw[tp->t_line].l_write)(tp, uio, flag)); -} - -int -pdcioctl(dev, cmd, data, flag, p) - dev_t dev; - u_long cmd; - caddr_t data; - int flag; - struct proc *p; -{ - int unit = minor(dev); - int error; - struct tty *tp; - struct pdc_softc *sc; - - if (unit >= pdc_cd.cd_ndevs || (sc = pdc_cd.cd_devs[unit]) == NULL) - return ENXIO; - - tp = sc->sc_tty; - error = (*linesw[tp->t_line].l_ioctl)(tp, cmd, data, flag, p); - if (error >= 0) - return error; - error = ttioctl(tp, cmd, data, flag, p); - if (error >= 0) - return error; - - return ENOTTY; -} - -int -pdcparam(tp, t) - struct tty *tp; - struct termios *t; -{ - - return 0; -} - -void -pdcstart(tp) - struct tty *tp; -{ - int s; - - s = spltty(); - if (tp->t_state & (TS_TTSTOP | TS_BUSY)) { - splx(s); - return; - } - ttwakeupwr(tp); - tp->t_state |= TS_BUSY; - while (tp->t_outq.c_cc != 0) - pdccnputc(tp->t_dev, getc(&tp->t_outq)); - tp->t_state &= ~TS_BUSY; - splx(s); -} - -int -pdcstop(tp, flag) - struct tty *tp; - int flag; -{ - int s; - - s = spltty(); - if (tp->t_state & TS_BUSY) - if ((tp->t_state & TS_TTSTOP) == 0) - tp->t_state |= TS_FLUSH; - splx(s); - return 0; -} - -void -pdctimeout(v) - void *v; -{ - struct pdc_softc *sc = v; - struct tty *tp = sc->sc_tty; - int c; - - while (pdccnlookc(tp->t_dev, &c)) { - if (tp->t_state & TS_ISOPEN) - (*linesw[tp->t_line].l_rint)(c, tp); - } - timeout_add(&sc->sc_to, 1); -} - -struct tty * -pdctty(dev) - dev_t dev; -{ - int unit = minor(dev); - struct pdc_softc *sc; - - if (unit >= pdc_cd.cd_ndevs || (sc = pdc_cd.cd_devs[unit]) == NULL) - return NULL; - - return sc->sc_tty; -} - -int -pdccnlookc(dev, cp) - dev_t dev; - int *cp; -{ - int err, l; - int s = splhigh(); - - err = pdc_call(pdc_kbdiodc, 0, pz_kbd->pz_hpa, IODC_IO_CONSIN, - pz_kbd->pz_spa, pz_kbd->pz_layers, pdcret, 0, pdc_consbuf, 1, 0); - - l = pdcret[0]; - *cp = pdc_consbuf[0]; - splx(s); -#ifdef DEBUG - if (err < 0) - printf("pdccnlookc: input error: %d\n", err); -#endif - - return l; -} - -int -pdccngetc(dev) - dev_t dev; -{ - int c; - - if (!pdc) - return 0; - - while(!pdccnlookc(dev, &c)) - ; - - return (c); -} - -void -pdccnputc(dev, c) - dev_t dev; - int c; -{ - register int err; - int s = splhigh(); - - *pdc_consbuf = c; - err = pdc_call(pdc_cniodc, 0, pz_cons->pz_hpa, IODC_IO_CONSOUT, - pz_cons->pz_spa, pz_cons->pz_layers, pdcret, 0, pdc_consbuf, 1, 0); - splx(s); - - if (err < 0) { -#ifdef DEBUG - printf("pdccnputc: output error: %d\n", err); -#endif - } -} diff --git a/sys/arch/hppa/dev/phantomas.c b/sys/arch/hppa/dev/phantomas.c deleted file mode 100644 index fb59d9b55..000000000 --- a/sys/arch/hppa/dev/phantomas.c +++ /dev/null @@ -1,77 +0,0 @@ -/* $OpenBSD: phantomas.c,v 1.6 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2002 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include - -#include -#include -#include - -#include - -struct cfdriver phantomas_cd = { - NULL, "phantomas", DV_DULL -}; - -struct phantomas_softc { - struct device sc_dev; - -}; - -int phantomasmatch(struct device *, void *, void *); -void phantomasattach(struct device *, struct device *, void *); - -const struct cfattach phantomas_ca = { - sizeof(struct phantomas_softc), phantomasmatch, phantomasattach -}; - -int -phantomasmatch(struct device *parent, void *cfdata, void *aux) -{ - struct confargs *ca = aux; - - if (ca->ca_type.iodc_type != HPPA_TYPE_BCPORT || - ca->ca_type.iodc_sv_model != HPPA_BCPORT_PHANTOM) - return (0); - - return (1); -} - -void -phantomasattach(struct device *parent, struct device *self, void *aux) -{ - struct confargs *ca = aux, nca; - - printf("\n"); - - nca = *ca; - nca.ca_hpamask = HPPA_IOBEGIN; - pdc_scanbus(self, &nca, MAXMODBUS, 0, 0); -} diff --git a/sys/arch/hppa/dev/power.c b/sys/arch/hppa/dev/power.c deleted file mode 100644 index 340859991..000000000 --- a/sys/arch/hppa/dev/power.c +++ /dev/null @@ -1,191 +0,0 @@ -/* $OpenBSD: power.c,v 1.11 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -struct power_softc { - struct device sc_dev; - void *sc_ih; - - struct proc *sc_thread; - void (*sc_kicker)(void *); - - int sc_dr_cnt; - paddr_t sc_pwr_reg; - volatile int sc_interrupted; -}; - -int powermatch(struct device *, void *, void *); -void powerattach(struct device *, struct device *, void *); - -const struct cfattach power_ca = { - sizeof(struct power_softc), powermatch, powerattach -}; - -struct cfdriver power_cd = { - NULL, "power", DV_DULL -}; - -void power_thread_create(void *v); -void power_thread_dr(void *v); -void power_thread_reg(void *v); -void power_cold_hook_reg(int); -int power_intr(void *); - -int -powermatch(struct device *parent, void *cfdata, void *aux) -{ - struct cfdata *cf = cfdata; - struct confargs *ca = aux; - - if (cf->cf_unit > 0 && !strcmp(ca->ca_name, "power")) - return (0); - - return (1); -} - -void -powerattach(struct device *parent, struct device *self, void *aux) -{ - struct power_softc *sc = (struct power_softc *)self; - struct confargs *ca = aux; - - switch (cpu_hvers) { - case HPPA_BOARD_HP712_60: - case HPPA_BOARD_HP712_80: - case HPPA_BOARD_HP712_100: - case HPPA_BOARD_HP712_120: - sc->sc_kicker = power_thread_dr; - printf(": DR25\n"); - break; - - default: - if (ca->ca_hpa) { - extern void (*cold_hook)(int); - - sc->sc_pwr_reg = ca->ca_hpa; - cold_hook = power_cold_hook_reg; - sc->sc_kicker = power_thread_reg; - printf("\n"); - } else - printf(": not available\n"); - break; - } - - if (ca->ca_irq >= 0) - sc->sc_ih = cpu_intr_establish(IPL_CLOCK, ca->ca_irq, - power_intr, sc, sc->sc_dev.dv_xname); - - if (sc->sc_kicker) - kthread_create_deferred(power_thread_create, sc); -} - -int -power_intr(void *v) -{ - struct power_softc *sc = v; - - sc->sc_interrupted = 1; - - return (1); -} - -void -power_thread_create(void *v) -{ - struct power_softc *sc = v; - - if (kthread_create(sc->sc_kicker, sc, &sc->sc_thread, - sc->sc_dev.dv_xname)) - printf("WARNING: failed to create kernel power thread\n"); -} - -void -power_thread_dr(void *v) -{ - struct power_softc *sc = v; - u_int32_t r; - - for (;;) { - mfcpu(DR0_PCXL_SHINT_EN, r); /* XXX don't ask */ - if (r & 0x80000000) - sc->sc_dr_cnt = 0; - else - sc->sc_dr_cnt++; - - /* - * the bit is undampened straight wire from the power - * switch and thus we have do dampen it ourselves. - */ - if (sc->sc_dr_cnt == hz / 10) - prsignal(initprocess, SIGUSR2); - - tsleep_nsec(v, PWAIT, "drpower", MSEC_TO_NSEC(100)); - } -} - -void -power_thread_reg(void *v) -{ - struct power_softc *sc = v; - u_int32_t r; - - for (;;) { - __asm volatile("ldwas 0(%1), %0" - : "=&r" (r) : "r" (sc->sc_pwr_reg)); - - if (!(r & 1)) - prsignal(initprocess, SIGUSR2); - - tsleep_nsec(v, PWAIT, "regpower", MSEC_TO_NSEC(100)); - } -} - -void -power_cold_hook_reg(int on) -{ - extern struct pdc_power_info pdc_power_info; /* machdep.c */ - int error; - - if ((error = pdc_call((iodcio_t)pdc, 0, PDC_SOFT_POWER, - PDC_SOFT_POWER_ENABLE, &pdc_power_info, - on == HPPA_COLD_HOT))) - printf("power_cold_hook_reg: failed (%d)\n", error); -} diff --git a/sys/arch/hppa/dev/siop_sgc.c b/sys/arch/hppa/dev/siop_sgc.c deleted file mode 100644 index d70543a3d..000000000 --- a/sys/arch/hppa/dev/siop_sgc.c +++ /dev/null @@ -1,166 +0,0 @@ -/* $OpenBSD: siop_sgc.c,v 1.2 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2007 Mark Kettenis - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include - -#define IO_II_INTEN 0x20000000 -#define IO_II_PACKEN 0x10000000 -#define IO_II_PREFETCHEN 0x08000000 - -int siop_sgc_match(struct device *, void *, void *); -void siop_sgc_attach(struct device *, struct device *, void *); -int siop_sgc_intr(void *); -void siop_sgc_reset(struct siop_common_softc *); - -u_int8_t siop_sgc_r1(void *, bus_space_handle_t, bus_size_t); -u_int16_t siop_sgc_r2(void *, bus_space_handle_t, bus_size_t); -void siop_sgc_w1(void *, bus_space_handle_t, bus_size_t, u_int8_t); -void siop_sgc_w2(void *, bus_space_handle_t, bus_size_t, u_int16_t); - -struct siop_sgc_softc { - struct siop_softc sc_siop; - bus_space_tag_t sc_iot; - bus_space_handle_t sc_ioh; - struct hppa_bus_space_tag sc_bustag; -}; - -const struct cfattach siop_gedoens_ca = { - sizeof(struct siop_sgc_softc), siop_sgc_match, siop_sgc_attach -}; - -int -siop_sgc_match(struct device *parent, void *match, void *aux) -{ - struct confargs *ca = aux; - - if (ca->ca_type.iodc_type != HPPA_TYPE_ADMA || - ca->ca_type.iodc_sv_model != HPPA_ADMA_FWSCSI) - return 0; - - return 1; -} - -void -siop_sgc_attach(struct device *parent, struct device *self, void *aux) -{ - struct siop_sgc_softc *sc = (struct siop_sgc_softc *)self; - struct confargs *ca = aux; - volatile struct iomod *regs; - - sc->sc_iot = ca->ca_iot; - if (bus_space_map(sc->sc_iot, ca->ca_hpa, - IOMOD_HPASIZE, 0, &sc->sc_ioh)) { - printf(": cannot map io space\n"); - return; - } - - sc->sc_bustag = *sc->sc_iot; - sc->sc_bustag.hbt_r1 = siop_sgc_r1; - sc->sc_bustag.hbt_r2 = siop_sgc_r2; - sc->sc_bustag.hbt_w1 = siop_sgc_w1; - sc->sc_bustag.hbt_w2 = siop_sgc_w2; - - sc->sc_siop.sc_c.features = SF_CHIP_PF | SF_CHIP_BE | SF_BUS_WIDE; - sc->sc_siop.sc_c.maxburst = 4; - sc->sc_siop.sc_c.maxoff = 8; - sc->sc_siop.sc_c.clock_div = 3; - sc->sc_siop.sc_c.clock_period = 250; - sc->sc_siop.sc_c.ram_size = 0; - - sc->sc_siop.sc_c.sc_reset = siop_sgc_reset; - sc->sc_siop.sc_c.sc_dmat = ca->ca_dmatag; - - sc->sc_siop.sc_c.sc_rt = &sc->sc_bustag; - bus_space_subregion(sc->sc_iot, sc->sc_ioh, IOMOD_DEVOFFSET, - IOMOD_HPASIZE - IOMOD_DEVOFFSET, &sc->sc_siop.sc_c.sc_rh); - - regs = bus_space_vaddr(sc->sc_iot, sc->sc_ioh); - regs->io_command = CMD_RESET; - while ((regs->io_status & IO_ERR_MEM_RY) == 0) - delay(100); - regs->io_ii_rw = IO_II_PACKEN | IO_II_PREFETCHEN; - - siop_sgc_reset(&sc->sc_siop.sc_c); - - regs->io_eim = cpu_gethpa(0) | (31 - ca->ca_irq); - regs->io_ii_rw |= IO_II_INTEN; - cpu_intr_establish(IPL_BIO, ca->ca_irq, siop_intr, sc, - sc->sc_siop.sc_c.sc_dev.dv_xname); - - printf(": NCR53C720 rev %d\n", bus_space_read_1(sc->sc_siop.sc_c.sc_rt, - sc->sc_siop.sc_c.sc_rh, SIOP_CTEST3) >> 4); - - siop_attach(&sc->sc_siop); -} - -void -siop_sgc_reset(struct siop_common_softc *sc) -{ - bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_DCNTL, DCNTL_EA); - bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_CTEST0, CTEST0_EHP); - bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_CTEST4, CTEST4_MUX); - - bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_STIME0, - (0xc << STIME0_SEL_SHIFT)); -} - -u_int8_t -siop_sgc_r1(void *v, bus_space_handle_t h, bus_size_t o) -{ - return *(volatile u_int8_t *)(h + (o ^ 3)); -} - -u_int16_t -siop_sgc_r2(void *v, bus_space_handle_t h, bus_size_t o) -{ - if (o == SIOP_SIST0) { - u_int16_t reg; - - reg = siop_sgc_r1(v, h, SIOP_SIST0); - reg |= siop_sgc_r1(v, h, SIOP_SIST1) << 8; - return reg; - } - return *(volatile u_int16_t *)(h + (o ^ 2)); -} - -void -siop_sgc_w1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv) -{ - *(volatile u_int8_t *)(h + (o ^ 3)) = vv; -} - -void -siop_sgc_w2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv) -{ - *(volatile u_int16_t *)(h + (o ^ 2)) = vv; -} diff --git a/sys/arch/hppa/dev/ssio.c b/sys/arch/hppa/dev/ssio.c deleted file mode 100644 index 760e8f3e4..000000000 --- a/sys/arch/hppa/dev/ssio.c +++ /dev/null @@ -1,364 +0,0 @@ -/* $OpenBSD: ssio.c,v 1.8 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2007 Mark Kettenis - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * Driver for the National Semiconductor PC87560 Legacy I/O chip. - */ - -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include - -#include "ukbd.h" -#if NUKBD > 0 -#include -#include -#endif - -/* PCI config space. */ -#define SSIO_PCI_DMA_RC2 0x64 -#define SSIO_PCI_INT_TC1 0x67 -#define SSIO_PCI_INT_TC2 0x68 -#define SSIO_PCI_INT_RC1 0x69 -#define SSIO_PCI_INT_RC2 0x6a -#define SSIO_PCI_INT_RC3 0x6b -#define SSIO_PCI_INT_RC4 0x6c -#define SSIO_PCI_INT_RC5 0x6d -#define SSIO_PCI_INT_RC6 0x6e -#define SSIO_PCI_INT_RC7 0x6f -#define SSIO_PCI_INT_RC8 0x70 -#define SSIO_PCI_INT_RC9 0x71 -#define SSIO_PCI_SP1BAR 0x94 -#define SSIO_PCI_SP2BAR 0x98 -#define SSIO_PCI_PPBAR 0x9c - -#define SSIO_PCI_INT_TC1_MASK 0xff -#define SSIO_PCI_INT_TC1_SHIFT 24 - -#define SSIO_PCI_INT_TC2_MASK 0xff -#define SSIO_PCI_INT_TC2_SHIFT 0 - -#define SSIO_PCI_INT_RC1_MASK 0xff -#define SSIO_PCI_INT_RC1_SHIFT 8 - -#define SSIO_PCI_INT_RC2_MASK 0xff -#define SSIO_PCI_INT_RC2_SHIFT 16 - -#define SSIO_PCI_INT_RC3_MASK 0xff -#define SSIO_PCI_INT_RC3_SHIFT 24 - -#define SSIO_PCI_INT_RC4_MASK 0xff -#define SSIO_PCI_INT_RC4_SHIFT 0 - -#define SSIO_PCI_INT_RC5_MASK 0xff -#define SSIO_PCI_INT_RC5_SHIFT 8 - -#define SSIO_PCI_INT_RC6_MASK 0xff -#define SSIO_PCI_INT_RC6_SHIFT 16 - -#define SSIO_PCI_INT_RC7_MASK 0xff -#define SSIO_PCI_INT_RC7_SHIFT 24 - -#define SSIO_PCI_INT_RC8_MASK 0xff -#define SSIO_PCI_INT_RC8_SHIFT 0 - -#define SSIO_PCI_INT_RC9_MASK 0xff -#define SSIO_PCI_INT_RC9_SHIFT 8 - -/* Cascaded i8259-compatible PICs. */ -#define SSIO_PIC1 0x20 -#define SSIO_PIC2 0xa0 -#define SSIO_NINTS 16 - -int ssio_match(struct device *, void *, void *); -void ssio_attach(struct device *, struct device *, void *); - -struct ssio_iv { - int (*handler)(void *); - void *arg; -}; - -struct ssio_iv ssio_intr_table[SSIO_NINTS]; - -struct ssio_softc { - struct device sc_dev; - - bus_space_tag_t sc_iot; - bus_space_handle_t sc_ic1h; - bus_space_handle_t sc_ic2h; - void *sc_ih; -}; - -const struct cfattach ssio_ca = { - sizeof(struct ssio_softc), ssio_match, ssio_attach -}; - -struct cfdriver ssio_cd = { - NULL, "ssio", DV_DULL -}; - -const struct pci_matchid ssio_devices[] = { - { PCI_VENDOR_NS, PCI_PRODUCT_NS_PC87560 } -}; - -int ssio_intr(void *); -int ssio_print(void *, const char *); - -int -ssio_match(struct device *parent, void *match, void *aux) -{ - struct pci_attach_args *pa = aux; - pcireg_t bhlc, id; - pcitag_t tag; - - /* - * The firmware doesn't always switch the IDE function into native - * mode. So we do that ourselves since it makes life much simpler. - * Note that we have to do this in the match function since the - * Legacy I/O function attaches after the IDE function. - */ - if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_NS && - PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_NS_PC87415) { - bhlc = pci_conf_read(pa->pa_pc, pa->pa_tag, PCI_BHLC_REG); - if (!PCI_HDRTYPE_MULTIFN(bhlc)) - return (0); - - tag = pci_make_tag(pa->pa_pc, pa->pa_bus, pa->pa_device, 1); - id = pci_conf_read(pa->pa_pc, tag, PCI_ID_REG); - if (PCI_VENDOR(id) != PCI_VENDOR_NS || - PCI_PRODUCT(id) != PCI_PRODUCT_NS_PC87560) - return (0); - - pa->pa_class |= PCIIDE_INTERFACE_PCI(0) << PCI_INTERFACE_SHIFT; - pa->pa_class |= PCIIDE_INTERFACE_PCI(1) << PCI_INTERFACE_SHIFT; - pci_conf_write(pa->pa_pc, pa->pa_tag, PCI_CLASS_REG, - pa->pa_class); - return (0); - } - - return (pci_matchbyid((struct pci_attach_args *)aux, ssio_devices, - sizeof(ssio_devices) / sizeof (ssio_devices[0]))); -} - -void -ssio_attach(struct device *parent, struct device *self, void *aux) -{ - struct ssio_softc *sc = (void *)self; - struct pci_attach_args *pa = aux; - struct ssio_attach_args saa; - pci_intr_handle_t ih; - const char *intrstr; - pcireg_t reg; -#if NUKBD > 0 - pcitag_t tag; -#endif - - sc->sc_iot = pa->pa_iot; - if (bus_space_map(sc->sc_iot, SSIO_PIC1, 2, 0, &sc->sc_ic1h)) { - printf(": unable to map PIC1 registers\n"); - return; - } - if (bus_space_map(sc->sc_iot, SSIO_PIC2, 2, 0, &sc->sc_ic2h)) { - printf(": unable to map PIC2 registers\n"); - goto unmap_ic1; - } - - if (pci_intr_map(pa, &ih)) { - printf(": unable to map interrupt\n"); - goto unmap_ic2; - } - intrstr = pci_intr_string(pa->pa_pc, ih); - /* XXX Probably should be IPL_NESTED. */ - sc->sc_ih = pci_intr_establish(pa->pa_pc, ih, IPL_TTY, ssio_intr, - sc, sc->sc_dev.dv_xname); - if (sc->sc_ih == NULL) { - printf(": couldn't establish interrupt\n"); - goto unmap_ic2; - } - - printf(": %s\n", intrstr); - - /* - * We use the following interrupt mapping: - * - * USB (INTD#) IRQ 1 - * IDE Channel 1 IRQ 5 - * Serial Port 1 IRQ 4 - * Serial Port 2 IRQ 3 - * Parallel Port IRQ 7 - * - * USB and IDE are set to level triggered, all others to edge - * triggered. - * - * We disable all other interrupts since we don't need them. - */ - reg = pci_conf_read(pa->pa_pc, pa->pa_tag, SSIO_PCI_DMA_RC2); - reg &= ~(SSIO_PCI_INT_TC1_MASK << SSIO_PCI_INT_TC1_SHIFT); - reg |= 0x22 << SSIO_PCI_INT_TC1_SHIFT; - pci_conf_write(pa->pa_pc, pa->pa_tag, SSIO_PCI_DMA_RC2, reg); - - reg = 0; - reg |= 0x34 << SSIO_PCI_INT_RC1_SHIFT; /* SP1, SP2 */ - reg |= 0x07 << SSIO_PCI_INT_RC2_SHIFT; /* PP */ - reg |= 0x05 << SSIO_PCI_INT_RC3_SHIFT; /* IDE1 */ - pci_conf_write(pa->pa_pc, pa->pa_tag, SSIO_PCI_INT_TC2, reg); - - reg = 0; - reg |= 0x10 << SSIO_PCI_INT_RC5_SHIFT; /* INTD# (USB) */ - pci_conf_write(pa->pa_pc, pa->pa_tag, SSIO_PCI_INT_RC4, reg); - - /* Program PIC1. */ - bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 0, 0x11); - bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 1, 0x00); - bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 1, 0x04); - bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 1, 0x01); - - /* Priority (3-7,0-2). */ - bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 0, 0xc2); - - /* Program PIC2. */ - bus_space_write_1(sc->sc_iot, sc->sc_ic2h, 0, 0x11); - bus_space_write_1(sc->sc_iot, sc->sc_ic2h, 1, 0x00); - bus_space_write_1(sc->sc_iot, sc->sc_ic2h, 1, 0x02); - bus_space_write_1(sc->sc_iot, sc->sc_ic2h, 1, 0x01); - - /* Unmask all interrupts. */ - bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 1, 0x00); - bus_space_write_1(sc->sc_iot, sc->sc_ic2h, 1, 0x00); - - /* Serial Port 1. */ - saa.saa_name = "com"; - saa.saa_iot = sc->sc_iot; - saa.saa_iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, SSIO_PCI_SP1BAR); - saa.saa_iobase &= 0xfffffffe; - saa.saa_irq = 4; - config_found(self, &saa, ssio_print); - - /* Serial Port 2. */ - saa.saa_name = "com"; - saa.saa_iot = sc->sc_iot; - saa.saa_iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, SSIO_PCI_SP2BAR); - saa.saa_iobase &= 0xfffffffe; - saa.saa_irq = 3; - config_found(self, &saa, ssio_print); - - /* Parallel Port. */ - saa.saa_name = "lpt"; - saa.saa_iot = sc->sc_iot; - saa.saa_iobase = pci_conf_read(pa->pa_pc, pa->pa_tag, SSIO_PCI_PPBAR); - saa.saa_iobase &= 0xfffffffe; - saa.saa_irq = 7; - config_found(self, &saa, ssio_print); - -#if NUKBD > 0 - /* - * If a USB keybard is used for console input, the firmware passes - * the mmio address of the USB controller the keyboard is attached - * to. Since we know the USB controller is function 2 on the same - * device and comes right after us (we're function 1 remember), - * this is a convenient spot to mark the USB keyboard as console - * if the address matches. - */ - tag = pci_make_tag(pa->pa_pc, pa->pa_bus, pa->pa_device, 2); - reg = pci_conf_read(pa->pa_pc, tag, PCI_CBMEM); - - if (PAGE0->mem_kbd.pz_class == PCL_KEYBD && - PAGE0->mem_kbd.pz_hpa == reg) - ukbd_cnattach(); -#endif - - return; - -unmap_ic2: - bus_space_unmap(sc->sc_iot, sc->sc_ic2h, 2); -unmap_ic1: - bus_space_unmap(sc->sc_iot, sc->sc_ic1h, 2); -} - -int -ssio_intr(void *v) -{ - struct ssio_softc *sc = v; - struct ssio_iv *iv; - int claimed = 0; - int irq, isr; - - /* Poll for interrupt. */ - bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 0, 0x0c); - irq = bus_space_read_1(sc->sc_iot, sc->sc_ic1h, 0); - irq &= 0x07; - - if (irq == 7) { - bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 0, 0x0b); - isr = bus_space_read_1(sc->sc_iot, sc->sc_ic1h, 0); - if ((isr & 0x80) == 0) - /* Spurious interrupt. */ - return (0); - } - - iv = &ssio_intr_table[irq]; - if (iv->handler) - claimed = iv->handler(iv->arg); - - /* Signal EOI. */ - bus_space_write_1(sc->sc_iot, sc->sc_ic1h, 0, 0x60 | (irq & 0x0f)); - - return (claimed); -} - -void * -ssio_intr_establish(int pri, int irq, int (*handler)(void *), void *arg, - const char *name) -{ - struct ssio_iv *iv; - - if (irq < 0 || irq >= SSIO_NINTS || ssio_intr_table[irq].handler) - return (NULL); - - iv = &ssio_intr_table[irq]; - iv->handler = handler; - iv->arg = arg; - - return (iv); -} - -int -ssio_print(void *aux, const char *pnp) -{ - struct ssio_attach_args *saa = aux; - - if (pnp) - printf("%s at %s", saa->saa_name, pnp); - if (saa->saa_iobase) { - printf(" offset %lx", saa->saa_iobase); - if (!pnp && saa->saa_irq >= 0) - printf(" irq %d", saa->saa_irq); - } - - return (UNCONF); -} diff --git a/sys/arch/hppa/dev/ssiovar.h b/sys/arch/hppa/dev/ssiovar.h deleted file mode 100644 index dfbf5c137..000000000 --- a/sys/arch/hppa/dev/ssiovar.h +++ /dev/null @@ -1,29 +0,0 @@ -/* $OpenBSD: ssiovar.h,v 1.1 2007/06/19 22:51:26 kettenis Exp $ */ - -/* - * Copyright (c) 2007 Mark Kettenis - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -struct ssio_attach_args { - const char *saa_name; - bus_space_tag_t saa_iot; - bus_addr_t saa_iobase; - int saa_irq; -}; - -#define ssiocf_irq cf_loc[0] -#define SSIO_UNK_IRQ -1 - -void *ssio_intr_establish(int, int, int (*)(void *), void *, const char *); diff --git a/sys/arch/hppa/dev/sti_pci_machdep.c b/sys/arch/hppa/dev/sti_pci_machdep.c deleted file mode 100644 index 4071535e0..000000000 --- a/sys/arch/hppa/dev/sti_pci_machdep.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $OpenBSD: sti_pci_machdep.c,v 1.3 2023/04/13 15:07:43 miod Exp $ */ - -/* - * Copyright (c) 2007, 2009 Miodrag Vallat. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice, this permission notice, and the disclaimer below - * appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -#include -#include - -#include - -int sti_pci_is_console(struct pci_attach_args *, bus_addr_t *); - -int -sti_pci_is_console(struct pci_attach_args *paa, bus_addr_t *bases) -{ - u_int32_t cf; - bus_addr_t addr; - int bar; - int rc; - - /* - * PAGE0 console information will point to one of our BARs, - * but depending on the particular sti model, this might not - * be the BAR mapping the rom (region #0). - * - * For example, on Visualize FXe, regions #0, #2 and #3 are - * mapped by BAR 0x18, while region #1 is mapped by BAR 0x10, - * which matches PAGE0 console address. - * - * Rather than trying to be smart, reread the region->BAR array - * again, and compare the BAR mapping region #1 against PAGE0 - * values, we simply try all the valid BARs; if any of them - * matches what PAGE0 says, then we are the console, and it - * doesn't matter which BAR matched. - */ - for (bar = PCI_MAPREG_START; bar <= PCI_MAPREG_PPB_END; bar += 4) { - cf = pci_conf_read(paa->pa_pc, paa->pa_tag, bar); - rc = pci_mapreg_info(paa->pa_pc, paa->pa_tag, bar, - _PCI_MAPREG_TYPEBITS(cf), &addr, NULL, NULL); - if (PCI_MAPREG_TYPE(cf) == PCI_MAPREG_TYPE_MEM && - PCI_MAPREG_MEM_TYPE(cf) == PCI_MAPREG_MEM_TYPE_64BIT) - bar += 4; - - if (rc == 0 && - (hppa_hpa_t)addr == (hppa_hpa_t)PAGE0->mem_cons.pz_hpa) - return 1; - } - - return 0; -} diff --git a/sys/arch/hppa/dev/sti_sgc.c b/sys/arch/hppa/dev/sti_sgc.c deleted file mode 100644 index 6ecfe44ae..000000000 --- a/sys/arch/hppa/dev/sti_sgc.c +++ /dev/null @@ -1,223 +0,0 @@ -/* $OpenBSD: sti_sgc.c,v 1.41 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2000-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ -/* - * These cards has to be known to work so far: - * - HPA1991AGrayscale rev 0.02 (705/35) (byte-wide) - * - HPA1991AC19 rev 0.02 (715/33) (byte-wide) - * - HPA208LC1280 rev 8.04 (712/80) just works - */ - -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#define STI_ROMSIZE (sizeof(struct sti_dd) * 4) -#define STI_ID_FDDI 0x280b31af /* Medusa FDDI ROM id */ - -/* gecko optional graphics (these share the onboard's prom) */ -const char sti_sgc_opt[] = { 0x17, 0x20, 0x30, 0x40, 0x70, 0xc0, 0xd0 }; - -extern struct cfdriver sti_cd; - -int sti_sgc_probe(struct device *, void *, void *); -void sti_sgc_attach(struct device *, struct device *, void *); -paddr_t sti_sgc_getrom(int, struct confargs *); - -const struct cfattach sti_gedoens_ca = { - sizeof(struct sti_softc), sti_sgc_probe, sti_sgc_attach -}; - -/* - * Locate STI ROM. - * On some machines it may not be part of the HPA space. - */ -paddr_t -sti_sgc_getrom(int unit, struct confargs *ca) -{ - paddr_t rom = PAGE0->pd_resv2[1]; - int i; - - if (unit) { - i = -1; - if (ca->ca_type.iodc_sv_model == HPPA_FIO_GSGC) - for (i = sizeof(sti_sgc_opt); i-- && - sti_sgc_opt[i] != ca->ca_type.iodc_revision; ) - ; - if (i < 0) - rom = 0; - } - - if (rom < HPPA_IOBEGIN) { - if (ca->ca_naddrs > 0) - rom = ca->ca_addrs[0].addr; - else - rom = ca->ca_hpa; - } - - return (rom); -} - -int -sti_sgc_probe(struct device *parent, void *match, void *aux) -{ - struct cfdata *cf = match; - struct confargs *ca = aux; - bus_space_handle_t romh; - paddr_t rom; - u_int32_t id; - u_char devtype; - int rv = 0, romunmapped = 0; - - /* due to the graphic nature of this program do probe only one */ - if (cf->cf_unit > sti_cd.cd_ndevs) - return (0); - - if (ca->ca_type.iodc_type != HPPA_TYPE_FIO) - return (0); - - /* these need further checking for the graphics id */ - if (ca->ca_type.iodc_sv_model != HPPA_FIO_GSGC && - ca->ca_type.iodc_sv_model != HPPA_FIO_SGC) - return 0; - - rom = sti_sgc_getrom(cf->cf_unit, ca); -#ifdef STIDEBUG - printf ("sti: hpa=%lx, rom=%lx\n", ca->ca_hpa, rom); -#endif - - /* if it does not map, probably part of the lasi space */ - if ((rv = bus_space_map(ca->ca_iot, rom, STI_ROMSIZE, 0, &romh))) { -#ifdef STIDEBUG - printf ("sti: cannot map rom space (%d)\n", rv); -#endif - if ((rom & HPPA_IOBEGIN) == HPPA_IOBEGIN) { - romh = rom; - romunmapped++; - } else { - /* in this case nobody has no freaking idea */ - return 0; - } - } - - devtype = bus_space_read_1(ca->ca_iot, romh, 3); - -#ifdef STIDEBUG - printf("sti: devtype=%d\n", devtype); -#endif - rv = 1; - switch (devtype) { - case STI_DEVTYPE4: - id = bus_space_read_4(ca->ca_iot, romh, 0x8); - break; - case STI_DEVTYPE1: - id = (bus_space_read_1(ca->ca_iot, romh, 0x10 + 3) << 24) | - (bus_space_read_1(ca->ca_iot, romh, 0x10 + 7) << 16) | - (bus_space_read_1(ca->ca_iot, romh, 0x10 + 11) << 8) | - (bus_space_read_1(ca->ca_iot, romh, 0x10 + 15)); - break; - default: -#ifdef STIDEBUG - printf("sti: unknown type (%x)\n", devtype); -#endif - rv = 0; - } - - if (rv && - ca->ca_type.iodc_sv_model == HPPA_FIO_SGC && id == STI_ID_FDDI) { -#ifdef STIDEBUG - printf("sti: not a graphics device\n"); -#endif - rv = 0; - } - - if (ca->ca_naddrs >= sizeof(ca->ca_addrs)/sizeof(ca->ca_addrs[0])) { - printf("sti: address list overflow\n"); - return (0); - } - - ca->ca_addrs[ca->ca_naddrs].addr = rom; - ca->ca_addrs[ca->ca_naddrs].size = sti_rom_size(ca->ca_iot, romh); - ca->ca_naddrs++; - - if (!romunmapped) - bus_space_unmap(ca->ca_iot, romh, STI_ROMSIZE); - return (rv); -} - -void -sti_sgc_attach(struct device *parent, struct device *self, void *aux) -{ - struct sti_softc *sc = (void *)self; - struct confargs *ca = aux; - bus_space_handle_t romh; - paddr_t rom; - u_int32_t romlen; - int rv; - int i; - - /* we stashed rom addr/len into the last slot during probe */ - rom = ca->ca_addrs[ca->ca_naddrs - 1].addr; - romlen = ca->ca_addrs[ca->ca_naddrs - 1].size; - if ((rv = bus_space_map(ca->ca_iot, rom, romlen, 0, &romh))) { - if ((rom & HPPA_IOBEGIN) == HPPA_IOBEGIN) - romh = rom; - else { - printf (": cannot map rom space (%d)\n", rv); - return; - } - } - - sc->bases[0] = romh; - for (i = 1; i < STI_REGION_MAX; i++) - sc->bases[i] = ca->ca_hpa; - -#ifdef HP7300LC_CPU - /* PCXL2: enable accel i/o for this space */ - if (cpu_type == hpcxl2) - eaio_l2(0x8 >> (((ca->ca_hpa >> 25) & 3) - 2)); -#endif - - if (ca->ca_hpa == (hppa_hpa_t)PAGE0->mem_cons.pz_hpa) - sc->sc_flags |= STI_CONSOLE; - if (sti_attach_common(sc, ca->ca_iot, ca->ca_iot, romh, - STI_CODEBASE_PA) == 0) - startuphook_establish(sti_end_attach, sc); -} diff --git a/sys/arch/hppa/dev/uturn.c b/sys/arch/hppa/dev/uturn.c deleted file mode 100644 index a8985908f..000000000 --- a/sys/arch/hppa/dev/uturn.c +++ /dev/null @@ -1,136 +0,0 @@ -/* $OpenBSD: uturn.c,v 1.8 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -/* TODO IOA programming */ - -#include -#include -#include -#include - -#include -#include - -#include - -struct uturn_regs { - u_int64_t resv0[2]; - u_int64_t status; /* 0x10: */ - u_int64_t resv1[5]; - u_int64_t debug; /* 0x40: */ -}; - -struct uturn_softc { - struct device sc_dv; - - struct uturn_regs volatile *sc_regs; -}; - -int uturnmatch(struct device *, void *, void *); -void uturnattach(struct device *, struct device *, void *); - -const struct cfattach uturn_ca = { - sizeof(struct uturn_softc), uturnmatch, uturnattach -}; - -struct cfdriver uturn_cd = { - NULL, "uturn", DV_DULL -}; - -int -uturnmatch(parent, cfdata, aux) - struct device *parent; - void *cfdata; - void *aux; -{ - struct confargs *ca = aux; - /* struct cfdata *cf = cfdata; */ - - /* there will be only one */ - if (ca->ca_type.iodc_type != HPPA_TYPE_IOA || - ca->ca_type.iodc_sv_model != HPPA_IOA_UTURN) - return 0; - - if (ca->ca_type.iodc_model == 0x58 && - ca->ca_type.iodc_revision >= 0x20) - return 0; - - return 1; -} - -void -uturnattach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -{ - struct confargs *ca = aux, nca; - struct uturn_softc *sc = (struct uturn_softc *)self; - bus_space_handle_t ioh; - hppa_hpa_t hpa; - - if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) { - printf(": can't map IO space\n"); - return; - } - sc->sc_regs = (struct uturn_regs *)ca->ca_hpa; - - printf(": %s rev %d\n", - ca->ca_type.iodc_revision < 0x10? "U2" : "UTurn", - ca->ca_type.iodc_revision & 0xf); - - /* keep it real */ - ((struct iomod *)ioh)->io_control = 0x80; - - /* - * U2/UTurn is actually a combination of an Upper Bus - * Converter (UBC) and a Lower Bus Converter (LBC). This - * driver attaches to the UBC; the LBC isn't very interesting, - * so we skip it. This is easy, since it always is module 63, - * hence the MAXMODBUS - 1 below. - */ - nca = *ca; - nca.ca_hpamask = HPPA_IOBEGIN; - pdc_scanbus(self, &nca, MAXMODBUS - 1, 0, 0); - - /* XXX On some machines, PDC doesn't tell us about all devices. */ - switch (cpu_hvers) { - case HPPA_BOARD_HP809: - case HPPA_BOARD_HP819: - case HPPA_BOARD_HP829: - case HPPA_BOARD_HP839: - case HPPA_BOARD_HP849: - case HPPA_BOARD_HP859: - case HPPA_BOARD_HP869: - hpa = ((struct iomod *)ioh)->io_io_low << 16; - pdc_scanbus(self, &nca, MAXMODBUS - 1, hpa, 0); - break; - default: - break; - } -} diff --git a/sys/arch/hppa/dev/viper.h b/sys/arch/hppa/dev/viper.h deleted file mode 100644 index 17c28fa2e..000000000 --- a/sys/arch/hppa/dev/viper.h +++ /dev/null @@ -1,215 +0,0 @@ -/* $OpenBSD: viper.h,v 1.7 2021/03/11 11:16:56 jsg Exp $ */ - -/* - * Copyright (c) 1991,1994 The University of Utah and - * the Computer Systems Laboratory (CSL). All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: viper.h 1.8 94/12/14$ - */ - -/* - * Viper control register. - * - * With respect to arbitration preference (*_prf), only one of these may be - * set at any one time. "preference" means that a particular device will - * be granted the bus on every other arbitration cycle; these bits default - * to unset (0). Similarly, a device may be denied the bus (*_den); these - * bits default to *set* (1). - * - * The macros V_CTRL_ANYPRF or V_CTRL_ANYDEN should be used to determine - * if any preference or deny bits are set. - */ - -#define VI_CTRL_EISA_DEN 0x00000001 /* EISA denied bus grants */ -#define VI_CTRL_EISA_PRF 0x00000002 /* EISA bus has arbitration preference */ -#define VI_CTRL_CORE_DEN 0x00000004 /* CORE denied bus grants */ -#define VI_CTRL_CORE_PRF 0x00000008 /* CORE bus has arbitration preference */ -#define VI_CTRL_SGC0_DEN 0x00000010 /* SGC0 denied bus grants */ -#define VI_CTRL_SGC0_PRF 0x00000020 /* SGC0 has arbitration preference */ -#define VI_CTRL_SGC1_DEN 0x00000040 /* SGC1 denied bus grants */ -#define VI_CTRL_SGC1_PRF 0x00000080 /* SGC1 has arbitration preference */ -#define VI_CTRL_CPU_PRF 0x00000200 /* CPU has arbitration preference */ -#define VI_CTRL_LPMC_EN 0x00010000 /* enable Low Priority Machine Checks */ -#define VI_CTRL_IPREF_EN 0x00020000 /* enable instruction prefetching */ -#define VI_CTRL_VSC_TOUT 0xfff80000 /* VSC clocks to wait before buserr tmo */ - -#define VI_CTRL_ANYPRF 0x02AA -#define VI_CTRL_ANYDEN 0x0055 -#define VI_CTRL PAGE0->pz_Pdep.pd_Viper.v_Ctrlcpy -#define VI_CTRL_BITS "\020\001eisa_den\002eisa_prf\003core_den\004core_prf" \ - "\005sgc1_den\006sgc1_prf\007sgc0_den\010sgc0_prf" \ - "\012cpu_prf\021lpmc_en\022ipref_en" - -#define VI_STAT_BITS "\020\001grf_buserr\002cpu_buserr\003ven_tmo" \ - "\004ven_buserr\005toc\006hardecc\007softecc\010cmdrst" -struct vi_stat { /* (RO) */ - u_int hw_rev :24, /* Viper hardware revision (24 bits!) */ - cmdreset: 1, /* set if last chip reset caused by CMD_RESET */ - softecc : 1, /* correctable memory error (lpmc_en set) */ - hardecc : 1, /* uncorrectable memory error (HPMC) */ - toc : 1, /* Transfer Of Control signaled */ - vn_ader : 1, /* Venom address error (lpmc_en set) */ - vn_vscto: 1, /* Venom VSC timeout (lpmc_en set) */ - cpu_ader: 1, /* CPU address error or timeout (HPMC) */ - grf_ader: 1; /* Graphics address error */ -}; - - -/* - * Viper TRS. The structures have been defined above; the remaining - * fields are described here. - * - * vi_intrwd (WO) - * If a high to low transition of the interrupt line occurs, - * Viper will send this to the CPU to be or'd into its EIR. - * In general, this is an ASP interrupt request. - * - * vi_mem_ctrl (WO) - * Set various DRAM attributes (row, cols, refresh, etc). - * - * vi_mem_wrchk (WO), vi_mem_rdchk (RO) - * read/write data to be for copyin/memtest. - * - * vi_mem_limit (WO) - * Set an upper limit for non-IO memory accesses; this must - * be less than the actual memory size, low 22 bits ignored. - * - * vi_merr_w0, vi_merr_w1, vi_merr_ckbyte, vi_merr_addr (RO) - * If memory error detection enabled and soft/hard ECC error, - * raw double word is stored here (w0: most significant word). - * The raw checkbyte data is stored in "vi_merr_ckbyte". - * The address of last logged error is in "vi_merr_addr". - * - */ -struct vi_trs { - u_int vi_control; /* PAGE0->pz_Pdep.pd_Viper.v_Ctrlcpy */ - struct vi_stat vi_status; - u_int vi_intrwd; - u_int vi_resv1[13]; - u_int vi_mem_ctrl; - u_int vi_mem_wrchk; - u_int vi_mem_limit; - u_int vi_resv2[1]; - u_int vi_merr_w1; - u_int vi_merr_w2; - u_int vi_merr_ckbyte; - u_int vi_mem_rdchk; - u_int vi_merr_addr; - u_int vi_resv3[135]; -}; - - -/* -** Viper also creates HPA registers for the graphics accelerator (Venom). -** Venom has two sets of resisters; the User HPA contains registers that -** users are allowed to access, while the Supervisor HPA is only accessible -** by code running at the most privileged level. Both sets of registers -** are defined below. -*/ - -#define VENOM_USER ((struct vn_user *)0xFFFBC000) -#define VENOM_SUPR ((struct vn_supr *)0xFFFBD000) - -/* - * Define bits in the Venom "User Control" register. - */ -struct vnu_ctl { - u_int sdt_msk :16, /* screen door transparency mask */ - : 6, - d_z_intp: 1, /* disable Z Interpolation when set */ - d_c_intp: 1, /* disable Color Interpolation when set */ - d_ad_inc: 1, /* disable I/O Addr Incrementing when set */ - : 1, - z_fast : 1, /* enable Fast Z Interpolation when set */ - c_pseudo: 1, /* enable Pseudo Color when set (disable RG) */ - z_prec24: 1, /* enable 24-bit Z integer precision (o/w 16) */ - cmp_intp: 3; /* enable cond: Z intp owrites old Z (<,>,=) */ -}; - -/* - * When vnu_ctl's "z_prec24" is set, 24-bit Z integer precision is enabled - * (otherwise 16-bit integer precision is used). When enabled, the format - * of various User Control registers is changed; `vnu_prec' (defined below) - * should make this format more clear. - */ -union vnu_prec { /* 16 or 24 bit precision */ - struct { - u_int zero1; /* must be zero */ - u_int intg :16, /* integer part (16 bits) */ - frac :12, /* fractional part (12 bits) */ - zero2 : 4; /* must be zero */ - } prec16; - struct { - u_int frac_lo : 4, /* fractional part (lower 4 bits) */ - zero1 :28; /* must be zero */ - u_int intg :24, /* integer part (24 bits) */ - frac_hi : 8; /* fractional part (upper 8 bits) */ - } prec24; -}; -#define vnu_p16i prec16.intg -#define vnu_p16f prec16.frac -#define vnu_p24i prec24.intg -#define vnu_p24f ((prec24.frac_hi << 4) | prec24.frac_lo) -#define vnu_p24fh prec24.frac_hi -#define vnu_p24fl prec24.frac_lo - -/* - * Venom User HPA registers. - */ -struct vn_user { - u_int vnu_resv1[32]; - struct vnu_ctl vnu_uctl; /* user control */ - u_int vnu_spancnt; /* span count (13 bits, signed) */ - u_int vnu_graddr; /* graphics address (24 bits: 6-29) */ - u_int vnu_resv2; - union vnu_prec vnu_zslope; /* Z Slope */ - union vnu_prec vnu_z; /* Z */ - u_int vnu_resv3[8]; - u_int vnu_bslope; /* Blue Slope (12-19:int, 20-31:fra) */ - u_int vnu_bcolor; /* Blue Color (12-19:int, 20-31:fra) */ - u_int vnu_resv4[2]; - u_int vnu_rslope; /* Red Slope (12-19:int, 20-31:fra) */ - u_int vnu_rcolor; /* Red Color (12-19:int, 20-31:fra) */ - u_int vnu_resv5[2]; - u_int vnu_gslope; /* Green Slope (12-19:int, 20-31:fra) */ - u_int vnu_gcolor; /* Green Color (12-19:int, 20-31:fra) */ -}; - - -/* - * Define bits in Venom "Supervisor Control" register. - */ -struct vns_ctl { - u_int : 4, - ioaddr : 2, /* graphics addr (bits 4 & 5 of `vnu_graddr') */ - d_venom : 1, /* disable Venom operation processing */ - :25; -}; - -/* - * Venom Supervisor HPA registers. - */ -struct vn_supr { - u_int vns_resv1[32]; - struct vns_ctl vns_sctl; /* supervisor control */ - u_int vns_zaddr; /* Z Buffer Address (RO) */ -}; - -void viper_setintrwnd(u_int32_t mask); -void viper_eisa_en(void); - diff --git a/sys/arch/hppa/dev/wax.c b/sys/arch/hppa/dev/wax.c deleted file mode 100644 index 4167660fe..000000000 --- a/sys/arch/hppa/dev/wax.c +++ /dev/null @@ -1,119 +0,0 @@ -/* $OpenBSD: wax.c,v 1.11 2018/05/14 13:54:39 kettenis Exp $ */ - -/* - * Copyright (c) 1998-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include - -#include -#include - -#include - -#include - -#define WAX_IOMASK 0xfff00000 - -int waxmatch(struct device *, void *, void *); -void waxattach(struct device *, struct device *, void *); -void wax_gsc_attach(struct device *); - -const struct cfattach wax_ca = { - sizeof(struct device), waxmatch, waxattach -}; - -struct cfdriver wax_cd = { - NULL, "wax", DV_DULL -}; - -int -waxmatch(parent, cfdata, aux) - struct device *parent; - void *cfdata; - void *aux; -{ - struct confargs *ca = aux; - struct cfdata *cf = cfdata; - - /* there will be only one */ - if (cf->cf_unit > 0 || - ca->ca_type.iodc_type != HPPA_TYPE_BHA || - ca->ca_type.iodc_sv_model != HPPA_BHA_WAX) - return 0; - - return 1; -} - -void -waxattach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -{ - struct confargs *ca = aux; - struct gsc_attach_args ga; - struct gscbus_ic *ic; - bus_space_handle_t ioh; - int s; - - if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) { - printf(": can't map IO space\n"); - return; - } - - printf("\n"); - - /* interrupts guts */ - ic = (struct gscbus_ic *)ca->ca_hpa; - s = splhigh(); - ic->iar = 0; /* will be set up by gsc when attaching */ - ic->icr = 0; - ic->imr = ~0U; - (void)ic->irr; - ic->imr = 0; - splx(s); - - ga.ga_ca = *ca; /* clone from us */ - if (!strcmp(parent->dv_xname, "mainbus0")) { - ga.ga_dp.dp_bc[0] = ga.ga_dp.dp_bc[1]; - ga.ga_dp.dp_bc[1] = ga.ga_dp.dp_bc[2]; - ga.ga_dp.dp_bc[2] = ga.ga_dp.dp_bc[3]; - ga.ga_dp.dp_bc[3] = ga.ga_dp.dp_bc[4]; - ga.ga_dp.dp_bc[4] = ga.ga_dp.dp_bc[5]; - ga.ga_dp.dp_bc[5] = ga.ga_dp.dp_mod; - ga.ga_dp.dp_mod = 0; - } - - ga.ga_name = "gsc"; - ga.ga_hpamask = WAX_IOMASK; - ga.ga_parent = gsc_wax; - ga.ga_ic = ic; - - config_found(self, &ga, gscprint); -} diff --git a/sys/arch/hppa/gsc/arcofi_gsc.c b/sys/arch/hppa/gsc/arcofi_gsc.c deleted file mode 100644 index c9c0bea23..000000000 --- a/sys/arch/hppa/gsc/arcofi_gsc.c +++ /dev/null @@ -1,87 +0,0 @@ -/* $OpenBSD: arcofi_gsc.c,v 1.1 2011/12/21 23:12:03 miod Exp $ */ - -/* - * Copyright (c) 2011 Miodrag Vallat. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -int arcofi_gsc_match(struct device *, void *, void *); -void arcofi_gsc_attach(struct device *, struct device *, void *); - -const struct cfattach arcofi_gsc_ca = { - sizeof(struct arcofi_softc), - arcofi_gsc_match, - arcofi_gsc_attach -}; - -int -arcofi_gsc_match(struct device *parent, void *match, void *vaa) -{ - struct gsc_attach_args *ga = vaa; - - if (ga->ga_type.iodc_type == HPPA_TYPE_FIO && - (ga->ga_type.iodc_sv_model == HPPA_FIO_A1 || - ga->ga_type.iodc_sv_model == HPPA_FIO_A1NB)) - return 1; - - return 0; -} - -void -arcofi_gsc_attach(struct device *parent, struct device *self, void *vaa) -{ - struct arcofi_softc *sc = (struct arcofi_softc *)self; - struct gsc_attach_args *ga = vaa; - unsigned int u; - - for (u = 0; u < ARCOFI_NREGS; u++) - sc->sc_reg[u] = (u << 2) | 0x01; - - sc->sc_iot = ga->ga_iot; - if (bus_space_map(sc->sc_iot, ga->ga_hpa, ARCOFI_NREGS << 2, 0, - &sc->sc_ioh) != 0) { - printf(": can't map registers\n"); - return; - } - - /* XXX no generic IPL_SOFT level available */ - sc->sc_sih = softintr_establish(IPL_SOFTTTY, &arcofi_swintr, sc); - if (sc->sc_sih == NULL) { - printf(": can't register soft interrupt\n"); - return; - } - gsc_intr_establish((struct gsc_softc *)parent, ga->ga_irq, - IPL_AUDIO, arcofi_hwintr, sc, sc->sc_dev.dv_xname); - - printf("\n"); - - arcofi_attach(sc, "gsc"); -} diff --git a/sys/arch/hppa/gsc/com_gsc.c b/sys/arch/hppa/gsc/com_gsc.c deleted file mode 100644 index 06bcaf686..000000000 --- a/sys/arch/hppa/gsc/com_gsc.c +++ /dev/null @@ -1,106 +0,0 @@ -/* $OpenBSD: com_gsc.c,v 1.22 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 1998-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#define COM_GSC_FREQ 7372800 - -struct com_gsc_regs { - u_int8_t reset; -}; - -int com_gsc_probe(struct device *, void *, void *); -void com_gsc_attach(struct device *, struct device *, void *); - -const struct cfattach com_gsc_ca = { - sizeof(struct com_softc), com_gsc_probe, com_gsc_attach -}; - -int -com_gsc_probe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct gsc_attach_args *ga = aux; - - if (ga->ga_type.iodc_type != HPPA_TYPE_FIO || - (ga->ga_type.iodc_sv_model != HPPA_FIO_GRS232 && - ga->ga_type.iodc_sv_model != HPPA_FIO_RS232 && - ga->ga_type.iodc_sv_model != HPPA_FIO_GRJ16)) - return (0); - - return (1); - /* HOZER comprobe1(ga->ga_iot, ga->ga_hpa + IOMOD_DEVOFFSET); */ -} - -void -com_gsc_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct com_softc *sc = (void *)self; - struct gsc_attach_args *ga = aux; - - sc->sc_iot = ga->ga_iot; - sc->sc_iobase = (bus_addr_t)ga->ga_hpa; - if (ga->ga_type.iodc_sv_model != HPPA_FIO_GRJ16) - sc->sc_iobase += IOMOD_DEVOFFSET; - - if (bus_space_map(sc->sc_iot, sc->sc_iobase, COM_NPORTS, - 0, &sc->sc_ioh)) { - printf(": cannot map io space\n"); - return; - } - - if (PAGE0->mem_cons.pz_class == PCL_DUPLEX && - PAGE0->mem_cons.pz_hpa == ga->ga_hpa) { - bus_space_unmap(sc->sc_iot, sc->sc_ioh, COM_NPORTS); - comcnattach(sc->sc_iot, sc->sc_iobase, comdefaultrate, - COM_GSC_FREQ, comconscflag); - } - - sc->sc_frequency = COM_GSC_FREQ; - com_attach_subr(sc); - - sc->sc_ih = gsc_intr_establish((struct gsc_softc *)parent, - ga->ga_irq, IPL_TTY, comintr, sc, sc->sc_dev.dv_xname); -} diff --git a/sys/arch/hppa/gsc/fdc_gsc.c b/sys/arch/hppa/gsc/fdc_gsc.c deleted file mode 100644 index 70926ccc8..000000000 --- a/sys/arch/hppa/gsc/fdc_gsc.c +++ /dev/null @@ -1,95 +0,0 @@ -/* $OpenBSD: fdc_gsc.c,v 1.6 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 1998 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -/* controller driver configuration */ -int fdc_gsc_probe(struct device *, void *, void *); -void fdc_gsc_attach(struct device *, struct device *, void *); - -const struct cfattach fdc_gsc_ca = { - sizeof(struct fdc_softc), fdc_gsc_probe, fdc_gsc_attach -}; - -int -fdc_gsc_probe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct confargs *ca = aux; - bus_space_handle_t ioh; - int rv; - - if (ca->ca_type.iodc_type != HPPA_TYPE_FIO || - ca->ca_type.iodc_sv_model != HPPA_FIO_GPCFD) - return 0; - - /* Map the I/O space. */ - if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) - return 0; - - rv = fdcprobe1(ca->ca_iot, ioh | IOMOD_DEVOFFSET); - bus_space_unmap(ca->ca_iot, ioh, IOMOD_HPASIZE); - return rv; -} - -void -fdc_gsc_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct fdc_softc *sc = (void *)self; - bus_space_handle_t ioh; - struct confargs *ca = aux; - - /* Re-map the I/O space. */ - if (bus_space_map(ca->ca_iot, ca->ca_hpa, IOMOD_HPASIZE, 0, &ioh)) - panic("fdcattach: couldn't map I/O ports"); - - ioh |= IOMOD_DEVOFFSET; - sc->sc_iot = ca->ca_iot; - sc->sc_ioh = ioh; - sc->sc_ioh_ctl = ioh + FDCTL_OFFSET; - - fdc_attach_subr(sc); -} - - diff --git a/sys/arch/hppa/gsc/gscbus.c b/sys/arch/hppa/gsc/gscbus.c deleted file mode 100644 index 05a0657ac..000000000 --- a/sys/arch/hppa/gsc/gscbus.c +++ /dev/null @@ -1,159 +0,0 @@ -/* $OpenBSD: gscbus.c,v 1.31 2018/05/14 13:54:39 kettenis Exp $ */ - -/* - * Copyright (c) 1998 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -/* #define GSCDEBUG */ - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -int gscmatch(struct device *, void *, void *); -void gscattach(struct device *, struct device *, void *); - -const struct cfattach gsc_ca = { - sizeof(struct gsc_softc), gscmatch, gscattach -}; - -struct cfdriver gsc_cd = { - NULL, "gsc", DV_DULL -}; - -int -gscmatch(parent, cfdata, aux) - struct device *parent; - void *cfdata; - void *aux; -{ - struct confargs *ca = aux; - - return !strcmp(ca->ca_name, "gsc"); -} - -void -gscattach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -{ - struct gsc_softc *sc = (struct gsc_softc *)self; - struct gsc_attach_args *ga = aux; - int s, irqbit; - - sc->sc_iot = ga->ga_iot; - sc->sc_ic = ga->ga_ic; - - irqbit = cpu_intr_findirq(); - if (irqbit >= 0) - printf(" irq %d", irqbit); - -#ifdef USELEDS - if (machine_ledaddr) - printf(": %sleds", machine_ledword? "word" : ""); -#endif - printf ("\n"); - - if (irqbit < 0) - sc->sc_ih = NULL; - else - sc->sc_ih = cpu_intr_establish(IPL_NESTED, irqbit, - gsc_intr, (void *)sc->sc_ic, sc->sc_dev.dv_xname); - if (sc->sc_ih == NULL) { - printf("%s: can't establish interrupt\n", sc->sc_dev.dv_xname); - return; - } - - /* - * On ASP, the IAR register is not writable; we need to go through - * the memory controller to achieve proper routing. - */ - s = splhigh(); - if (ga->ga_parent == gsc_asp) - viper_setintrwnd(1 << irqbit); - else - sc->sc_ic->iar = cpu_gethpa(0) | (31 - irqbit); - splx(s); - - pdc_scanbus(self, &ga->ga_ca, MAXMODBUS, 0, 0); -} - -int -gscprint(aux, pnp) - void *aux; - const char *pnp; -{ - struct gsc_attach_args *ga = aux; - - if (pnp) - printf("%s at %s", ga->ga_name, pnp); - return (UNCONF); -} - -void * -gsc_intr_establish(sc, irq, pri, handler, arg, name) - struct gsc_softc *sc; - int pri; - int irq; - int (*handler)(void *v); - void *arg; - const char *name; -{ - void *iv; - - if ((iv = cpu_intr_map(sc->sc_ih, pri, irq, handler, arg, name))) - sc->sc_ic->imr |= (1 << irq); - else { -#ifdef GSCDEBUG - printf("%s: attaching irq %d, already occupied\n", - sc->sc_dev.dv_xname, irq); -#endif - } - - return (iv); -} - -void -gsc_intr_disestablish(sc, v) - struct gsc_softc *sc; - void *v; -{ -#if notyet - sc->sc_ic->imr &= ~(1 << irq); - - cpu_intr_unmap(sc->sc_ih, v); -#endif -} diff --git a/sys/arch/hppa/gsc/gscbusvar.h b/sys/arch/hppa/gsc/gscbusvar.h deleted file mode 100644 index c2c0687a9..000000000 --- a/sys/arch/hppa/gsc/gscbusvar.h +++ /dev/null @@ -1,69 +0,0 @@ -/* $OpenBSD: gscbusvar.h,v 1.15 2018/05/14 13:54:39 kettenis Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -/* - * Layout of the interrupt registers, part of the parent bus. - */ -struct gscbus_ic { - volatile u_int32_t irr; /* int request register */ - volatile u_int32_t imr; /* int mask register */ - volatile u_int32_t ipr; /* int pending register */ - volatile u_int32_t icr; /* int control register */ - volatile u_int32_t iar; /* int address register */ - volatile u_int32_t rsvd[3]; -}; - -struct gsc_attach_args { - struct confargs ga_ca; -#define ga_name ga_ca.ca_name -#define ga_iot ga_ca.ca_iot -#define ga_dp ga_ca.ca_dp -#define ga_type ga_ca.ca_type -#define ga_hpa ga_ca.ca_hpa -#define ga_hpamask ga_ca.ca_hpamask -#define ga_dmatag ga_ca.ca_dmatag -#define ga_irq ga_ca.ca_irq -#define ga_pdc_iodc_read ga_ca.ca_pdc_iodc_read - enum { gsc_unknown = 0, gsc_asp, gsc_lasi, gsc_wax } ga_parent; - struct gscbus_ic *ga_ic; /* IC pointer */ -}; - -struct gsc_softc { - struct device sc_dev; - void *sc_ih; - - bus_space_tag_t sc_iot; - struct gscbus_ic *sc_ic; -}; - -void *gsc_intr_establish(struct gsc_softc *sc, int irq, int pri, - int (*handler)(void *v), void *arg, const char *name); -void gsc_intr_disestablish(struct gsc_softc *sc, void *v); -int gsc_intr(void *); - -int gscprint(void *, const char *); diff --git a/sys/arch/hppa/gsc/gsckbc.c b/sys/arch/hppa/gsc/gsckbc.c deleted file mode 100644 index 439316477..000000000 --- a/sys/arch/hppa/gsc/gsckbc.c +++ /dev/null @@ -1,1021 +0,0 @@ -/* $OpenBSD: gsckbc.c,v 1.21 2022/03/13 08:04:38 mpi Exp $ */ -/* - * Copyright (c) 2003, Miodrag Vallat. - * 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 MIND, - * 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. - */ - -/* - * Derived from /sys/dev/ic/pckbd.c under the following terms: - * OpenBSD: pckbc.c,v 1.5 2002/06/09 00:58:03 nordin Exp - * NetBSD: pckbc.c,v 1.5 2000/06/09 04:58:35 soda Exp - */ -/* - * Copyright (c) 1998 - * Matthias Drochner. 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project - * by Matthias Drochner. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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. - */ - -/* - * Driver for the PS/2-like keyboard and mouse ports found on 712 and 715 - * models, among others. - * - * Contrary to the ``pckbc'' port set found on other arches, the - * keyboard and mouse port are two separate entities on the snakes, and - * they are driven by a custom chip not 8042-compatible. - */ - -#include "pckbd.h" - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include /* constants for probe magic */ -#include - -int gsckbc_match(struct device *, void *, void *); -void gsckbc_attach(struct device *, struct device *, void *); - -struct gsckbc_softc { - struct pckbc_softc sc_pckbc; - - void *sc_ih; - int sc_type; -}; - -const struct cfattach gsckbc_ca = { - sizeof(struct gsckbc_softc), gsckbc_match, gsckbc_attach -}; - -struct cfdriver gsckbc_cd = { - NULL, "gsckbc", DV_DULL -}; - -/* descriptor for one device command */ -struct pckbc_devcmd { - TAILQ_ENTRY(pckbc_devcmd) next; - int flags; -#define KBC_CMDFLAG_SYNC 1 /* give descriptor back to caller */ -#define KBC_CMDFLAG_SLOW 2 - u_char cmd[4]; - int cmdlen, cmdidx, retries; - u_char response[4]; - int status, responselen, responseidx; -}; - -/* data per slave device */ -struct pckbc_slotdata { - int polling; /* don't read data port in interrupt handler */ - TAILQ_HEAD(, pckbc_devcmd) cmdqueue; /* active commands */ - TAILQ_HEAD(, pckbc_devcmd) freequeue; /* free commands */ -#define NCMD 5 - struct pckbc_devcmd cmds[NCMD]; -}; - -#define CMD_IN_QUEUE(q) (TAILQ_FIRST(&(q)->cmdqueue) != NULL) -/* Force polling mode behaviour for boot -a XXX */ -#define IS_POLLING(q) ((q)->polling || cold) - -void pckbc_init_slotdata(struct pckbc_slotdata *); -int pckbc_attach_slot(struct pckbc_softc *, pckbc_slot_t); -int pckbc_submatch(struct device *, void *, void *); -int pckbcprint(void *, const char *); - -int pckbc_wait_output(bus_space_tag_t, bus_space_handle_t); -int pckbc_send_devcmd(struct pckbc_internal *, pckbc_slot_t, - u_char); -void pckbc_poll_cmd1(struct pckbc_internal *, pckbc_slot_t, - struct pckbc_devcmd *); - -void pckbc_cleanqueue(struct pckbc_slotdata *); -void pckbc_cleanup(void *); -int pckbc_cmdresponse(struct pckbc_internal *, pckbc_slot_t, u_char); -void pckbc_start(struct pckbc_internal *, pckbc_slot_t); -int gsckbcintr(void *); - -const char *pckbc_slot_names[] = { "kbd", "mouse" }; - -#define KBC_DEVCMD_ACK 0xfa -#define KBC_DEVCMD_RESEND 0xfe - -#define KBD_DELAY DELAY(8) - -int -gsckbc_match(struct device *parent, void *match, void *aux) -{ - struct gsc_attach_args *ga = aux; - bus_space_handle_t ioh; - u_int8_t rv; - - if (ga->ga_type.iodc_type != HPPA_TYPE_FIO || - ga->ga_type.iodc_sv_model != HPPA_FIO_GPCIO) - return (0); - - /* Map the i/o space. */ - if (bus_space_map(ga->ga_ca.ca_iot, ga->ga_ca.ca_hpa, - KBMAPSIZE, 0, &ioh)) - return 0; - - rv = bus_space_read_1(ga->ga_ca.ca_iot, ioh, KBIDP); - bus_space_unmap(ga->ga_ca.ca_iot, ioh, KBMAPSIZE); - - if (rv == PCKBC_KBD_SLOT || rv == PCKBC_AUX_SLOT) - return (1); /* keyboard or mouse port */ - - return (0); -} - -/* - * Attachment helper functions - */ - -/* state machine values */ -#define PROBE_SUCCESS 0 -#define PROBE_TIMEOUT 1 -#define PROBE_RETRANS 2 -#define PROBE_NOACK 3 - -int probe_readtmo(bus_space_tag_t iot, bus_space_handle_t ioh, int *reply); -int probe_readretry(bus_space_tag_t iot, bus_space_handle_t ioh, int *reply); -int probe_sendtmo(bus_space_tag_t iot, bus_space_handle_t ioh, int cmdbyte); -int probe_sendack(bus_space_tag_t iot, bus_space_handle_t ioh, int cmdbyte); -int probe_ident(bus_space_tag_t iot, bus_space_handle_t ioh); - -#define PROBE_TRIES 1000 - -int -probe_readtmo(bus_space_tag_t iot, bus_space_handle_t ioh, int *reply) -{ - int numtries = PROBE_TRIES; - - while (numtries--) { - if (bus_space_read_1(iot, ioh, KBSTATP) & - (KBS_DIB | KBS_TERR | KBS_PERR)) - break; - DELAY(500); - } - - if (numtries <= 0) - return (PROBE_TIMEOUT); - - if (bus_space_read_1(iot, ioh, KBSTATP) & (KBS_PERR | KBS_TERR)) { - if (!(bus_space_read_1(iot, ioh, KBSTATP) & KBS_DIB)) { - bus_space_write_1(iot, ioh, KBRESETP, 0xff); - bus_space_write_1(iot, ioh, KBRESETP, 0x00); - bus_space_write_1(iot, ioh, KBCMDP, - bus_space_read_1(iot, ioh, KBCMDP) | KBCP_ENABLE); - return (PROBE_TIMEOUT); - } - - *reply = bus_space_read_1(iot, ioh, KBDATAP); - if (!(bus_space_read_1(iot, ioh, KBSTATP) & KBS_DIB)) { - bus_space_write_1(iot, ioh, KBRESETP, 0xff); - bus_space_write_1(iot, ioh, KBRESETP, 0x00); - bus_space_write_1(iot, ioh, KBCMDP, - bus_space_read_1(iot, ioh, KBCMDP) | KBCP_ENABLE); - if (probe_sendtmo(iot, ioh, KBR_RESEND)) - return (PROBE_TIMEOUT); - else - return (PROBE_RETRANS); - } else - return (PROBE_SUCCESS); - } else { - *reply = bus_space_read_1(iot, ioh, KBDATAP); - return (PROBE_SUCCESS); - } -} - -int -probe_readretry(bus_space_tag_t iot, bus_space_handle_t ioh, int *reply) -{ - int read_status; - int retrans = KB_MAX_RETRANS; - - do { - read_status = probe_readtmo(iot, ioh, reply); - } while ((read_status == PROBE_RETRANS) && retrans--); - - return (read_status); -} - -int -probe_sendtmo(bus_space_tag_t iot, bus_space_handle_t ioh, int cmdbyte) -{ - int numtries = PROBE_TRIES; - - while (numtries--) { - if ((bus_space_read_1(iot, ioh, KBSTATP) & KBS_OCMD) == 0) - break; - DELAY(500); - } - - if (numtries <= 0) - return (1); - - bus_space_write_1(iot, ioh, KBDATAP, cmdbyte); - bus_space_write_1(iot, ioh, KBCMDP, KBCP_ENABLE); - return (0); -} - -int -probe_sendack(bus_space_tag_t iot, bus_space_handle_t ioh, int cmdbyte) -{ - int retranscount; - int reply; - - for (retranscount = 0; retranscount < KB_MAX_RETRANS; retranscount++) { - if (probe_sendtmo(iot, ioh, cmdbyte)) - return (PROBE_TIMEOUT); - if (probe_readretry(iot, ioh, &reply)) - return (PROBE_TIMEOUT); - - switch (reply) { - case KBR_ACK: - return (PROBE_SUCCESS); - case KBR_RESEND: - break; - default: - return (PROBE_NOACK); - } - } - return (PROBE_TIMEOUT); - -} - -int -probe_ident(bus_space_tag_t iot, bus_space_handle_t ioh) -{ - int status; - - bus_space_write_1(iot, ioh, KBRESETP, 0); - bus_space_write_1(iot, ioh, KBCMDP, KBCP_ENABLE); - DELAY(0x20000); /* XXX why 0x? */ - bus_space_write_1(iot, ioh, KBCMDP, 0); - DELAY(20000); - bus_space_write_1(iot, ioh, KBRESETP, 0); - bus_space_write_1(iot, ioh, KBCMDP, KBCP_DIAG); - DELAY(20000); - - status = probe_sendack(iot, ioh, KBC_DISABLE); - switch (status) { - case PROBE_TIMEOUT: - if (bus_space_read_1(iot, ioh, KBSTATP) & KBS_OCMD) { - bus_space_write_1(iot, ioh, KBRESETP, 0); - bus_space_write_1(iot, ioh, KBCMDP, KBCP_ENABLE); - } - return (-1); - case PROBE_NOACK: - return (-1); - } - - if (probe_sendack(iot, ioh, KBC_ID) != PROBE_SUCCESS) - return (-1); - - if (probe_readretry(iot, ioh, &status)) - return (-1); - - switch (status) { - case KBR_MOUSE_ID: - return PCKBC_AUX_SLOT; - case KBR_KBD_ID1: - if (probe_readretry(iot, ioh, &status)) - return (-1); - if (status == KBR_KBD_ID2) { - if (probe_sendack(iot, ioh, KBC_ENABLE) == - PROBE_TIMEOUT) { - bus_space_write_1(iot, ioh, KBRESETP, 0); - bus_space_write_1(iot, ioh, KBCMDP, - KBCP_ENABLE); - } - return PCKBC_KBD_SLOT; - } - } - return (-1); -} - -void -gsckbc_attach(struct device *parent, struct device *self, void *aux) -{ - struct gsc_attach_args *ga = aux; - struct gsckbc_softc *gsc = (void *)self; - struct pckbc_softc *sc = &gsc->sc_pckbc; - struct pckbc_internal *t; - bus_space_tag_t iot; - bus_space_handle_t ioh; - int ident; - - iot = ga->ga_ca.ca_iot; - - if (bus_space_map(iot, ga->ga_ca.ca_hpa, KBMAPSIZE, 0, &ioh)) - panic("gsckbc_attach: couldn't map port"); - - gsc->sc_type = bus_space_read_1(iot, ioh, KBIDP); - - switch (gsc->sc_type) { - case PCKBC_KBD_SLOT: - case PCKBC_AUX_SLOT: - break; - default: - printf(": unknown port type %x\n", gsc->sc_type); - /* play nice and don't really attach. */ - bus_space_unmap(iot, ioh, KBMAPSIZE); - return; - } - - gsc->sc_ih = gsc_intr_establish((struct gsc_softc *)parent, - ga->ga_ca.ca_irq, IPL_TTY, gsckbcintr, sc, sc->sc_dv.dv_xname); - if (gsc->sc_ih == NULL) { - printf(": can't establish interrupt\n"); - bus_space_unmap(iot, ioh, KBMAPSIZE); - return; - } - - printf("\n"); - - t = malloc(sizeof(*t), M_DEVBUF, M_WAITOK | M_ZERO); - t->t_iot = iot; - /* XXX it does not make sense to only map two ports here */ - t->t_ioh_d = t->t_ioh_c = ioh; - t->t_addr = ga->ga_ca.ca_hpa; - t->t_sc = sc; - timeout_set(&t->t_cleanup, pckbc_cleanup, t); - sc->id = t; - - /* - * Reset port and probe device, if plugged - */ - ident = probe_ident(iot, ioh); - if (ident != gsc->sc_type) { - /* don't whine for unplugged ports */ - if (ident != -1) - printf("%s: expecting device type %d, got %d\n", - sc->sc_dv.dv_xname, gsc->sc_type, ident); - } else { -#if (NPCKBD > 0) - if (gsc->sc_type == PCKBC_KBD_SLOT && - ga->ga_dp.dp_mod == PAGE0->mem_kbd.pz_dp.dp_mod && - bcmp(ga->ga_dp.dp_bc, PAGE0->mem_kbd.pz_dp.dp_bc, 6) == 0) - pckbd_cnattach(t); -#endif - pckbc_attach_slot(sc, gsc->sc_type); - } -} - -/* - * pckbc-like interfaces - */ - -int -pckbc_wait_output(iot, ioh) - bus_space_tag_t iot; - bus_space_handle_t ioh; -{ - u_int i; - - for (i = 100000; i; i--) { - if ((bus_space_read_1(iot, ioh, KBSTATP) & KBS_OCMD)) { - KBD_DELAY; - } else - return (1); - } - return (0); -} - -int -pckbc_send_cmd(iot, ioh, val) - bus_space_tag_t iot; - bus_space_handle_t ioh; - u_char val; -{ - if (!pckbc_wait_output(iot, ioh)) - return (0); - bus_space_write_1(iot, ioh, KBOUTP, val); - bus_space_write_1(iot, ioh, KBCMDP, KBCP_ENABLE); - return (1); -} - -/* XXX logic */ -int -pckbc_poll_data1(iot, ioh, ioh_c, slot, checkaux) - bus_space_tag_t iot; - bus_space_handle_t ioh, ioh_c; - pckbc_slot_t slot; - int checkaux; /* ignored on hppa */ -{ - int i; - u_char stat; - - /* if 1 port read takes 1us (?), this polls for 100ms */ - for (i = 100000; i; i--) { - stat = bus_space_read_1(iot, ioh, KBSTATP); - if (stat & KBS_DIB) { - KBD_DELAY; - return bus_space_read_1(iot, ioh, KBDATAP); - } - } - return (-1); -} - -int -pckbc_send_devcmd(t, slot, val) - struct pckbc_internal *t; - pckbc_slot_t slot; - u_char val; -{ - return pckbc_send_cmd(t->t_iot, t->t_ioh_d, val); -} - -int -pckbc_submatch(parent, match, aux) - struct device *parent; - void *match; - void *aux; -{ - struct cfdata *cf = match; - struct pckbc_attach_args *pa = aux; - - if (cf->cf_loc[PCKBCCF_SLOT] != PCKBCCF_SLOT_DEFAULT && - cf->cf_loc[PCKBCCF_SLOT] != pa->pa_slot) - return (0); - return ((*cf->cf_attach->ca_match)(parent, cf, aux)); -} - -int -pckbc_attach_slot(sc, slot) - struct pckbc_softc *sc; - pckbc_slot_t slot; -{ - struct pckbc_internal *t = sc->id; - struct pckbc_attach_args pa; - int found; - - pa.pa_tag = t; - pa.pa_slot = slot; - found = (config_found_sm((struct device *)sc, &pa, - pckbcprint, pckbc_submatch) != NULL); - - if (found && !t->t_slotdata[slot]) { - t->t_slotdata[slot] = malloc(sizeof(struct pckbc_slotdata), - M_DEVBUF, M_NOWAIT); - if (t->t_slotdata[slot] == NULL) - return 0; - pckbc_init_slotdata(t->t_slotdata[slot]); - } - return (found); -} - -int -pckbcprint(aux, pnp) - void *aux; - const char *pnp; -{ -#if 0 /* hppa having devices for each slot, this is barely useful */ - struct pckbc_attach_args *pa = aux; - - if (!pnp) - printf(" (%s slot)", pckbc_slot_names[pa->pa_slot]); -#endif - return (QUIET); -} - -void -pckbc_init_slotdata(q) - struct pckbc_slotdata *q; -{ - int i; - TAILQ_INIT(&q->cmdqueue); - TAILQ_INIT(&q->freequeue); - - for (i = 0; i < NCMD; i++) { - TAILQ_INSERT_TAIL(&q->freequeue, &(q->cmds[i]), next); - } - q->polling = 0; -} - -void -pckbc_flush(self, slot) - pckbc_tag_t self; - pckbc_slot_t slot; -{ - struct pckbc_internal *t = self; - - pckbc_poll_data1(t->t_iot, t->t_ioh_d, t->t_ioh_d, slot, 0); -} - -int -pckbc_poll_data(self, slot) - pckbc_tag_t self; - pckbc_slot_t slot; -{ - struct pckbc_internal *t = self; - struct pckbc_slotdata *q = t->t_slotdata[slot]; - int c; - - c = pckbc_poll_data1(t->t_iot, t->t_ioh_d, t->t_ioh_d, slot, 0); - if (c != -1 && q && CMD_IN_QUEUE(q)) { - /* we jumped into a running command - try to - deliver the response */ - if (pckbc_cmdresponse(t, slot, c)) - return (-1); - } - return (c); -} - -int -pckbc_xt_translation(self) - pckbc_tag_t self; -{ - /* Translation isn't supported... */ - return (-1); -} - -void -pckbc_slot_enable(self, slot, on) - pckbc_tag_t self; - pckbc_slot_t slot; - int on; -{ - /* can't enable slots here as they are different devices */ -} - -void -pckbc_set_poll(self, slot, on) - pckbc_tag_t self; - pckbc_slot_t slot; - int on; -{ - struct pckbc_internal *t = (struct pckbc_internal *)self; - - t->t_slotdata[slot]->polling = on; - - if (!on) { - int s; - - /* - * If disabling polling on a device that's been configured, - * make sure there are no bytes left in the FIFO, holding up - * the interrupt line. Otherwise we won't get any further - * interrupts. - */ - if (t->t_sc) { - s = spltty(); - gsckbcintr(t->t_sc); - splx(s); - } - } -} - -/* - * Pass command to device, poll for ACK and data. - * to be called at spltty() - */ -void -pckbc_poll_cmd1(t, slot, cmd) - struct pckbc_internal *t; - pckbc_slot_t slot; - struct pckbc_devcmd *cmd; -{ - bus_space_tag_t iot = t->t_iot; - bus_space_handle_t ioh = t->t_ioh_d; - int i, c = 0; - - while (cmd->cmdidx < cmd->cmdlen) { - if (!pckbc_send_devcmd(t, slot, cmd->cmd[cmd->cmdidx])) { - printf("pckbc_cmd: send error\n"); - cmd->status = EIO; - return; - } - for (i = 10; i; i--) { /* 1s ??? */ - c = pckbc_poll_data1(iot, ioh, ioh, slot, 0); - if (c != -1) - break; - } - - if (c == KBC_DEVCMD_ACK) { - cmd->cmdidx++; - continue; - } - if (c == KBC_DEVCMD_RESEND) { -#ifdef PCKBCDEBUG - printf("pckbc_cmd: RESEND\n"); -#endif - if (cmd->retries++ < KB_MAX_RETRANS) - continue; - else { -#ifdef PCKBCDEBUG - printf("pckbc: cmd failed\n"); -#endif - cmd->status = EIO; - return; - } - } - if (c == -1) { -#ifdef PCKBCDEBUG - printf("pckbc_cmd: timeout\n"); -#endif - cmd->status = EIO; - return; - } -#ifdef PCKBCDEBUG - printf("pckbc_cmd: lost 0x%x\n", c); -#endif - } - - while (cmd->responseidx < cmd->responselen) { - if (cmd->flags & KBC_CMDFLAG_SLOW) - i = 100; /* 10s ??? */ - else - i = 10; /* 1s ??? */ - while (i--) { - c = pckbc_poll_data1(iot, ioh, ioh, slot, 0); - if (c != -1) - break; - } - if (c == -1) { -#ifdef PCKBCDEBUG - printf("pckbc_cmd: no data\n"); -#endif - cmd->status = ETIMEDOUT; - return; - } else - cmd->response[cmd->responseidx++] = c; - } -} - -/* for use in autoconfiguration */ -int -pckbc_poll_cmd(self, slot, cmd, len, responselen, respbuf, slow) - pckbc_tag_t self; - pckbc_slot_t slot; - u_char *cmd; - int len, responselen; - u_char *respbuf; - int slow; -{ - struct pckbc_devcmd nc; - - if ((len > 4) || (responselen > 4)) - return (EINVAL); - - bzero(&nc, sizeof(nc)); - bcopy(cmd, nc.cmd, len); - nc.cmdlen = len; - nc.responselen = responselen; - nc.flags = (slow ? KBC_CMDFLAG_SLOW : 0); - - pckbc_poll_cmd1(self, slot, &nc); - - if (nc.status == 0 && respbuf) - bcopy(nc.response, respbuf, responselen); - - return (nc.status); -} - -/* - * Clean up a command queue, throw away everything. - */ -void -pckbc_cleanqueue(q) - struct pckbc_slotdata *q; -{ - struct pckbc_devcmd *cmd; -#ifdef PCKBCDEBUG - int i; -#endif - - while ((cmd = TAILQ_FIRST(&q->cmdqueue))) { - TAILQ_REMOVE(&q->cmdqueue, cmd, next); -#ifdef PCKBCDEBUG - printf("pckbc_cleanqueue: removing"); - for (i = 0; i < cmd->cmdlen; i++) - printf(" %02x", cmd->cmd[i]); - printf("\n"); -#endif - TAILQ_INSERT_TAIL(&q->freequeue, cmd, next); - } -} - -/* - * Timeout error handler: clean queues and data port. - * XXX could be less invasive. - */ -void -pckbc_cleanup(self) - void *self; -{ - struct pckbc_internal *t = self; - int s; - - printf("pckbc: command timeout\n"); - - s = spltty(); - - if (t->t_slotdata[PCKBC_KBD_SLOT]) - pckbc_cleanqueue(t->t_slotdata[PCKBC_KBD_SLOT]); - if (t->t_slotdata[PCKBC_AUX_SLOT]) - pckbc_cleanqueue(t->t_slotdata[PCKBC_AUX_SLOT]); - - while (bus_space_read_1(t->t_iot, t->t_ioh_d, KBSTATP) & KBS_DIB) { - KBD_DELAY; - (void) bus_space_read_1(t->t_iot, t->t_ioh_d, KBDATAP); - } - - /* reset KBC? */ - - splx(s); -} - -/* - * Pass command to device during normal operation. - * to be called at spltty() - */ -void -pckbc_start(t, slot) - struct pckbc_internal *t; - pckbc_slot_t slot; -{ - struct pckbc_slotdata *q = t->t_slotdata[slot]; - struct pckbc_devcmd *cmd = TAILQ_FIRST(&q->cmdqueue); - - if (IS_POLLING(q)) { - do { - pckbc_poll_cmd1(t, slot, cmd); - if (cmd->status) - printf("pckbc_start: command error\n"); - - TAILQ_REMOVE(&q->cmdqueue, cmd, next); - if (cmd->flags & KBC_CMDFLAG_SYNC) - wakeup(cmd); - else { - timeout_del(&t->t_cleanup); - TAILQ_INSERT_TAIL(&q->freequeue, cmd, next); - } - cmd = TAILQ_FIRST(&q->cmdqueue); - } while (cmd); - return; - } - - if (!pckbc_send_devcmd(t, slot, cmd->cmd[cmd->cmdidx])) { - printf("pckbc_start: send error\n"); - /* XXX what now? */ - return; - } -} - -/* - * Handle command responses coming in asynchronously, - * return nonzero if valid response. - * to be called at spltty() - */ -int -pckbc_cmdresponse(t, slot, data) - struct pckbc_internal *t; - pckbc_slot_t slot; - u_char data; -{ - struct pckbc_slotdata *q = t->t_slotdata[slot]; - struct pckbc_devcmd *cmd = TAILQ_FIRST(&q->cmdqueue); - -#ifdef DIAGNOSTIC - if (!cmd) - panic("pckbc_cmdresponse: no active command"); -#endif - if (cmd->cmdidx < cmd->cmdlen) { - if (data != KBC_DEVCMD_ACK && data != KBC_DEVCMD_RESEND) - return (0); - - if (data == KBC_DEVCMD_RESEND) { - if (cmd->retries++ < KB_MAX_RETRANS) { - /* try again last command */ - goto restart; - } else { -#ifdef PCKBCDEBUG - printf("pckbc: cmd failed\n"); -#endif - cmd->status = EIO; - /* dequeue */ - } - } else { - if (++cmd->cmdidx < cmd->cmdlen) - goto restart; - if (cmd->responselen) - return (1); - /* else dequeue */ - } - } else if (cmd->responseidx < cmd->responselen) { - cmd->response[cmd->responseidx++] = data; - if (cmd->responseidx < cmd->responselen) - return (1); - /* else dequeue */ - } else - return (0); - - /* dequeue: */ - TAILQ_REMOVE(&q->cmdqueue, cmd, next); - if (cmd->flags & KBC_CMDFLAG_SYNC) - wakeup(cmd); - else { - timeout_del(&t->t_cleanup); - TAILQ_INSERT_TAIL(&q->freequeue, cmd, next); - } - if (!CMD_IN_QUEUE(q)) - return (1); -restart: - pckbc_start(t, slot); - return (1); -} - -/* - * Put command into the device's command queue, return zero or errno. - */ -int -pckbc_enqueue_cmd(self, slot, cmd, len, responselen, sync, respbuf) - pckbc_tag_t self; - pckbc_slot_t slot; - u_char *cmd; - int len, responselen, sync; - u_char *respbuf; -{ - struct pckbc_internal *t = self; - struct pckbc_slotdata *q = t->t_slotdata[slot]; - struct pckbc_devcmd *nc; - int s, isactive, res = 0; - - if ((len > 4) || (responselen > 4)) - return (EINVAL); - s = spltty(); - nc = TAILQ_FIRST(&q->freequeue); - if (nc) { - TAILQ_REMOVE(&q->freequeue, nc, next); - } - splx(s); - if (!nc) - return (ENOMEM); - - bzero(nc, sizeof(*nc)); - bcopy(cmd, nc->cmd, len); - nc->cmdlen = len; - nc->responselen = responselen; - nc->flags = (sync ? KBC_CMDFLAG_SYNC : 0); - - s = spltty(); - - if (IS_POLLING(q) && sync) { - /* - * XXX We should poll until the queue is empty. - * But we don't come here normally, so make - * it simple and throw away everything. - */ - pckbc_cleanqueue(q); - } - - isactive = CMD_IN_QUEUE(q); - TAILQ_INSERT_TAIL(&q->cmdqueue, nc, next); - if (!isactive) - pckbc_start(t, slot); - - if (IS_POLLING(q)) - res = (sync ? nc->status : 0); - else if (sync) { - if ((res = tsleep_nsec(nc, 0, "kbccmd", SEC_TO_NSEC(1)))) { - TAILQ_REMOVE(&q->cmdqueue, nc, next); - pckbc_cleanup(t); - } else - res = nc->status; - } else - timeout_add_sec(&t->t_cleanup, 1); - - if (sync) { - if (respbuf) - bcopy(nc->response, respbuf, responselen); - TAILQ_INSERT_TAIL(&q->freequeue, nc, next); - } - - splx(s); - - return (res); -} - -void -pckbc_set_inputhandler(self, slot, func, arg, name) - pckbc_tag_t self; - pckbc_slot_t slot; - pckbc_inputfcn func; - void *arg; - char *name; -{ - struct pckbc_internal *t = (struct pckbc_internal *)self; - struct pckbc_softc *sc = t->t_sc; - - if (slot >= PCKBC_NSLOTS) - panic("pckbc_set_inputhandler: bad slot %d", slot); - - sc->inputhandler[slot] = func; - sc->inputarg[slot] = arg; - sc->subname[slot] = name; -} - -int -gsckbcintr(void *v) -{ - struct gsckbc_softc *gsc = v; - struct pckbc_softc *sc = (struct pckbc_softc *)gsc; - struct pckbc_internal *t = sc->id; - pckbc_slot_t slot; - struct pckbc_slotdata *q; - int served = 0, data; - - while (bus_space_read_1(t->t_iot, t->t_ioh_d, KBSTATP) & KBS_DIB) { - served = 1; - - slot = gsc->sc_type; - q = t->t_slotdata[slot]; - - if (!q) { - /* XXX do something for live insertion? */ -#ifdef PCKBCDEBUG - printf("gsckbcintr: no dev for slot %d\n", slot); -#endif - KBD_DELAY; - (void) bus_space_read_1(t->t_iot, t->t_ioh_d, KBDATAP); - continue; - } - - if (IS_POLLING(q)) - break; /* pckbc_poll_data() will get it */ - - KBD_DELAY; - data = bus_space_read_1(t->t_iot, t->t_ioh_d, KBDATAP); - - if (CMD_IN_QUEUE(q) && pckbc_cmdresponse(t, slot, data)) - continue; - - if (sc->inputhandler[slot]) - (*sc->inputhandler[slot])(sc->inputarg[slot], data); -#ifdef PCKBCDEBUG - else - printf("gsckbcintr: slot %d lost %d\n", slot, data); -#endif - } - - return (served); -} diff --git a/sys/arch/hppa/gsc/gsckbcreg.h b/sys/arch/hppa/gsc/gsckbcreg.h deleted file mode 100644 index b682f98a5..000000000 --- a/sys/arch/hppa/gsc/gsckbcreg.h +++ /dev/null @@ -1,64 +0,0 @@ -/* $OpenBSD: gsckbcreg.h,v 1.1 2003/01/31 22:50:19 miod Exp $ */ -/* - * Copyright (c) 2003, Miodrag Vallat. - * 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 MIND, - * 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. - */ - -/* - * Register definitions for the GSC PS/2 compatible keyboard/mouse ports. - * - * These definitions attempt to match names although the - * actual wiring is different. - */ - -#define KBSTATP 12 /* controller status port (I) */ -#define KBS_DIB 0x01 /* data in buffer */ -#define KBS_OCMD 0x02 /* output buffer has command */ -#define KBS_PERR 0x04 /* parity error */ -#define KBS_TERR 0x08 /* transmission error */ - -#define KBCMDP 8 /* controller port (O) */ -#define KBCP_ENABLE 0x01 /* enable device */ -#define KBCP_DIAG 0x20 /* diagnostic mode control */ - -#define KBDATAP 4 /* data port (I) */ -#define KBOUTP 4 /* data port (O) */ - -#define KBIDP 0 /* id port (I) */ -#define ID_KBD 0 /* slot is a keyboard port */ -#define ID_MOUSE 1 /* slot is a mouse port */ - -#define KBRESETP 0 /* reset port (O) */ - -#define KBMAPSIZE 16 /* size to bus_space_map() */ - -/* - * Various command definitions not provided by the existing pckbc code. - */ - -#define KBC_ID 0xF2 /* get device identifier */ -#define KBR_MOUSE_ID 0x00 /* mouse type */ -#define KBR_KBD_ID1 0xAB /* keyboard type */ -#define KBR_KBD_ID2 0x83 - -#define KB_MAX_RETRANS 5 /* maximum number of command retrans attempts */ diff --git a/sys/arch/hppa/gsc/harmony.c b/sys/arch/hppa/gsc/harmony.c deleted file mode 100644 index e0ee7de1a..000000000 --- a/sys/arch/hppa/gsc/harmony.c +++ /dev/null @@ -1,1150 +0,0 @@ -/* $OpenBSD: harmony.c,v 1.40 2022/10/26 20:19:06 kn Exp $ */ - -/* - * Copyright (c) 2003 Jason L. Wright (jason@thought.net) - * 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. - */ - -/* - * Harmony (CS4215/AD1849 LASI) audio interface. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -int harmony_open(void *, int); -void harmony_close(void *); -int harmony_set_params(void *, int, int, struct audio_params *, - struct audio_params *); -int harmony_round_blocksize(void *, int); -int harmony_commit_settings(void *); -int harmony_halt_output(void *); -int harmony_halt_input(void *); -int harmony_set_port(void *, mixer_ctrl_t *); -int harmony_get_port(void *, mixer_ctrl_t *); -int harmony_query_devinfo(void *addr, mixer_devinfo_t *); -void * harmony_allocm(void *, int, size_t, int, int); -void harmony_freem(void *, void *, int); -size_t harmony_round_buffersize(void *, int, size_t); -int harmony_trigger_output(void *, void *, void *, int, - void (*intr)(void *), void *, struct audio_params *); -int harmony_trigger_input(void *, void *, void *, int, - void (*intr)(void *), void *, struct audio_params *); - -const struct audio_hw_if harmony_sa_hw_if = { - .open = harmony_open, - .close = harmony_close, - .set_params = harmony_set_params, - .round_blocksize = harmony_round_blocksize, - .commit_settings = harmony_commit_settings, - .halt_output = harmony_halt_output, - .halt_input = harmony_halt_input, - .set_port = harmony_set_port, - .get_port = harmony_get_port, - .query_devinfo = harmony_query_devinfo, - .allocm = harmony_allocm, - .freem = harmony_freem, - .round_buffersize = harmony_round_buffersize, - .trigger_output = harmony_trigger_output, - .trigger_input = harmony_trigger_input, -}; - -int harmony_match(struct device *, void *, void *); -void harmony_attach(struct device *, struct device *, void *); -int harmony_intr(void *); -void harmony_intr_enable(struct harmony_softc *); -void harmony_intr_disable(struct harmony_softc *); -u_int32_t harmony_speed_bits(struct harmony_softc *, u_long *); -int harmony_set_gainctl(struct harmony_softc *); -void harmony_reset_codec(struct harmony_softc *); -void harmony_start_cp(struct harmony_softc *); -void harmony_tick_pb(void *); -void harmony_tick_cp(void *); -void harmony_try_more(struct harmony_softc *); - -void harmony_acc_tmo(void *); -#define ADD_CLKALLICA(sc) do { \ - (sc)->sc_acc <<= 1; \ - (sc)->sc_acc |= READ_REG((sc), HARMONY_DIAG) & DIAG_CO; \ - if ((sc)->sc_acc_cnt++ && !((sc)->sc_acc_cnt % 32)) \ - enqueue_randomness((sc)->sc_acc_num ^= (sc)->sc_acc); \ -} while(0) - -int -harmony_match(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct gsc_attach_args *ga = aux; - bus_space_handle_t bh; - u_int32_t cntl; - - if (ga->ga_type.iodc_type == HPPA_TYPE_FIO) { - if (ga->ga_type.iodc_sv_model == HPPA_FIO_A1 || - ga->ga_type.iodc_sv_model == HPPA_FIO_A2NB || - ga->ga_type.iodc_sv_model == HPPA_FIO_A1NB || - ga->ga_type.iodc_sv_model == HPPA_FIO_A2) { - if (bus_space_map(ga->ga_iot, ga->ga_hpa, - HARMONY_NREGS, 0, &bh) != 0) - return (0); - cntl = bus_space_read_4(ga->ga_iot, bh, HARMONY_ID) & - ID_REV_MASK; - bus_space_unmap(ga->ga_iot, bh, HARMONY_NREGS); - if (cntl == ID_REV_TS || cntl == ID_REV_NOTS) - return (1); - } - } - return (0); -} - -void -harmony_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct harmony_softc *sc = (struct harmony_softc *)self; - struct gsc_attach_args *ga = aux; - u_int8_t rev; - u_int32_t cntl; - int i; - - sc->sc_bt = ga->ga_iot; - sc->sc_dmat = ga->ga_dmatag; - - if (bus_space_map(sc->sc_bt, ga->ga_hpa, HARMONY_NREGS, 0, - &sc->sc_bh) != 0) { - printf(": couldn't map registers\n"); - return; - } - - cntl = READ_REG(sc, HARMONY_ID); - sc->sc_teleshare = (cntl & ID_REV_MASK) == ID_REV_TS; - - if (bus_dmamem_alloc(sc->sc_dmat, sizeof(struct harmony_empty), - PAGE_SIZE, 0, &sc->sc_empty_seg, 1, &sc->sc_empty_rseg, - BUS_DMA_NOWAIT) != 0) { - printf(": couldn't alloc DMA memory\n"); - bus_space_unmap(sc->sc_bt, sc->sc_bh, HARMONY_NREGS); - return; - } - if (bus_dmamem_map(sc->sc_dmat, &sc->sc_empty_seg, 1, - sizeof(struct harmony_empty), (caddr_t *)&sc->sc_empty_kva, - BUS_DMA_NOWAIT) != 0) { - printf(": couldn't map DMA memory\n"); - bus_dmamem_free(sc->sc_dmat, &sc->sc_empty_seg, - sc->sc_empty_rseg); - bus_space_unmap(sc->sc_bt, sc->sc_bh, HARMONY_NREGS); - return; - } - if (bus_dmamap_create(sc->sc_dmat, sizeof(struct harmony_empty), 1, - sizeof(struct harmony_empty), 0, BUS_DMA_NOWAIT, - &sc->sc_empty_map) != 0) { - printf(": can't create DMA map\n"); - bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->sc_empty_kva, - sizeof(struct harmony_empty)); - bus_dmamem_free(sc->sc_dmat, &sc->sc_empty_seg, - sc->sc_empty_rseg); - bus_space_unmap(sc->sc_bt, sc->sc_bh, HARMONY_NREGS); - return; - } - if (bus_dmamap_load(sc->sc_dmat, sc->sc_empty_map, sc->sc_empty_kva, - sizeof(struct harmony_empty), NULL, BUS_DMA_NOWAIT) != 0) { - printf(": can't load DMA map\n"); - bus_dmamap_destroy(sc->sc_dmat, sc->sc_empty_map); - bus_dmamem_unmap(sc->sc_dmat, (caddr_t)sc->sc_empty_kva, - sizeof(struct harmony_empty)); - bus_dmamem_free(sc->sc_dmat, &sc->sc_empty_seg, - sc->sc_empty_rseg); - bus_space_unmap(sc->sc_bt, sc->sc_bh, HARMONY_NREGS); - return; - } - - sc->sc_playback_empty = 0; - for (i = 0; i < PLAYBACK_EMPTYS; i++) - sc->sc_playback_paddrs[i] = - sc->sc_empty_map->dm_segs[0].ds_addr + - offsetof(struct harmony_empty, playback[i][0]); - - sc->sc_capture_empty = 0; - for (i = 0; i < CAPTURE_EMPTYS; i++) - sc->sc_capture_paddrs[i] = - sc->sc_empty_map->dm_segs[0].ds_addr + - offsetof(struct harmony_empty, playback[i][0]); - - bus_dmamap_sync(sc->sc_dmat, sc->sc_empty_map, - offsetof(struct harmony_empty, playback[0][0]), - PLAYBACK_EMPTYS * HARMONY_BUFSIZE, BUS_DMASYNC_PREWRITE); - - (void)gsc_intr_establish((struct gsc_softc *)parent, ga->ga_irq, - IPL_AUDIO, harmony_intr, sc, sc->sc_dv.dv_xname); - - /* set defaults */ - sc->sc_in_port = HARMONY_IN_LINE; - sc->sc_out_port = HARMONY_OUT_SPEAKER; - sc->sc_input_lvl.left = sc->sc_input_lvl.right = 240; - sc->sc_output_lvl.left = sc->sc_output_lvl.right = 244; - sc->sc_monitor_lvl.left = sc->sc_monitor_lvl.right = 208; - sc->sc_outputgain = 0; - - /* reset chip, and push default gain controls */ - harmony_reset_codec(sc); - - cntl = READ_REG(sc, HARMONY_CNTL); - rev = (cntl & CNTL_CODEC_REV_MASK) >> CNTL_CODEC_REV_SHIFT; - printf(": rev %u", rev); - - if (sc->sc_teleshare) - printf(", teleshare"); - printf("\n"); - - if ((rev & CS4215_REV_VER) >= CS4215_REV_VER_E) - sc->sc_hasulinear8 = 1; - - audio_attach_mi(&harmony_sa_hw_if, sc, NULL, &sc->sc_dv); - - timeout_set(&sc->sc_acc_tmo, harmony_acc_tmo, sc); - sc->sc_acc_num = 0xa5a5a5a5; -} - -void -harmony_reset_codec(struct harmony_softc *sc) -{ - /* silence */ - WRITE_REG(sc, HARMONY_GAINCTL, GAINCTL_OUTPUT_LEFT_M | - GAINCTL_OUTPUT_RIGHT_M | GAINCTL_MONITOR_M); - - /* start reset */ - WRITE_REG(sc, HARMONY_RESET, RESET_RST); - - DELAY(100000); /* wait at least 0.05 sec */ - - harmony_set_gainctl(sc); - WRITE_REG(sc, HARMONY_RESET, 0); -} - -void -harmony_acc_tmo(void *v) -{ - struct harmony_softc *sc = v; - - ADD_CLKALLICA(sc); - timeout_add(&sc->sc_acc_tmo, 1); -} - -/* - * interrupt handler - */ -int -harmony_intr(vsc) - void *vsc; -{ - struct harmony_softc *sc = vsc; - struct harmony_channel *c; - u_int32_t dstatus; - int r = 0; - - mtx_enter(&audio_lock); - ADD_CLKALLICA(sc); - - harmony_intr_disable(sc); - - dstatus = READ_REG(sc, HARMONY_DSTATUS); - - if (dstatus & DSTATUS_PN) { - struct harmony_dma *d; - bus_addr_t nextaddr; - bus_size_t togo; - - r = 1; - c = &sc->sc_playback; - d = c->c_current; - togo = c->c_segsz - c->c_cnt; - if (togo == 0) { - nextaddr = d->d_map->dm_segs[0].ds_addr; - c->c_cnt = togo = c->c_blksz; - } else { - nextaddr = c->c_lastaddr; - if (togo > c->c_blksz) - togo = c->c_blksz; - c->c_cnt += togo; - } - - bus_dmamap_sync(sc->sc_dmat, d->d_map, - nextaddr - d->d_map->dm_segs[0].ds_addr, - c->c_blksz, BUS_DMASYNC_PREWRITE); - - WRITE_REG(sc, HARMONY_PNXTADD, nextaddr); - SYNC_REG(sc, HARMONY_PNXTADD, BUS_SPACE_BARRIER_WRITE); - c->c_lastaddr = nextaddr + togo; - harmony_try_more(sc); - } - - dstatus = READ_REG(sc, HARMONY_DSTATUS); - - if (dstatus & DSTATUS_RN) { - c = &sc->sc_capture; - r = 1; - harmony_start_cp(sc); - if (sc->sc_capturing && c->c_intr != NULL) - (*c->c_intr)(c->c_intrarg); - } - - if (READ_REG(sc, HARMONY_OV) & OV_OV) { - sc->sc_ov = 1; - WRITE_REG(sc, HARMONY_OV, 0); - } else - sc->sc_ov = 0; - - harmony_intr_enable(sc); - mtx_leave(&audio_lock); - return (r); -} - -void -harmony_intr_enable(struct harmony_softc *sc) -{ - WRITE_REG(sc, HARMONY_DSTATUS, DSTATUS_IE); - SYNC_REG(sc, HARMONY_DSTATUS, BUS_SPACE_BARRIER_WRITE); -} - -void -harmony_intr_disable(struct harmony_softc *sc) -{ - WRITE_REG(sc, HARMONY_DSTATUS, 0); - SYNC_REG(sc, HARMONY_DSTATUS, BUS_SPACE_BARRIER_WRITE); -} - -int -harmony_open(void *vsc, int flags) -{ - struct harmony_softc *sc = vsc; - - if (sc->sc_open) - return (EBUSY); - sc->sc_open = 1; - return (0); -} - -void -harmony_close(void *vsc) -{ - struct harmony_softc *sc = vsc; - - /* XXX: not useful, halt_*() already called */ - harmony_halt_input(sc); - harmony_halt_output(sc); - harmony_intr_disable(sc); - sc->sc_open = 0; -} - -int -harmony_set_params(void *vsc, int setmode, int usemode, - struct audio_params *p, struct audio_params *r) -{ - struct harmony_softc *sc = vsc; - u_int32_t bits; - - switch (p->encoding) { - case AUDIO_ENCODING_ULAW: - bits = CNTL_FORMAT_ULAW; - p->precision = 8; - break; - case AUDIO_ENCODING_ALAW: - bits = CNTL_FORMAT_ALAW; - p->precision = 8; - break; - case AUDIO_ENCODING_SLINEAR_BE: - if (p->precision == 16) { - bits = CNTL_FORMAT_SLINEAR16BE; - break; - } - return (EINVAL); - case AUDIO_ENCODING_ULINEAR_LE: - case AUDIO_ENCODING_ULINEAR_BE: - if (p->precision == 8) { - bits = CNTL_FORMAT_ULINEAR8; - break; - } - return (EINVAL); - default: - return (EINVAL); - } - - if (sc->sc_outputgain) - bits |= CNTL_OLB; - - if (p->channels == 1) - bits |= CNTL_CHANS_MONO; - else if (p->channels == 2) - bits |= CNTL_CHANS_STEREO; - else - return (EINVAL); - - r->sample_rate = p->sample_rate; - r->encoding = p->encoding; - r->precision = p->precision; - p->bps = AUDIO_BPS(p->precision); - r->bps = AUDIO_BPS(r->precision); - p->msb = r->msb = 1; - - bits |= harmony_speed_bits(sc, &p->sample_rate); - sc->sc_cntlbits = bits; - sc->sc_need_commit = 1; - - return (0); -} - -int -harmony_round_blocksize(void *vsc, int blk) -{ - return (HARMONY_BUFSIZE); -} - -int -harmony_commit_settings(void *vsc) -{ - struct harmony_softc *sc = vsc; - u_int32_t reg; - u_int8_t quietchar; - int i; - - if (sc->sc_need_commit == 0) - return (0); - - harmony_intr_disable(sc); - - for (;;) { - reg = READ_REG(sc, HARMONY_DSTATUS); - if ((reg & (DSTATUS_PC | DSTATUS_RC)) == 0) - break; - } - - /* Setting some bits in gainctl requires a reset */ - harmony_reset_codec(sc); - - /* set the silence character based on the encoding type */ - bus_dmamap_sync(sc->sc_dmat, sc->sc_empty_map, - offsetof(struct harmony_empty, playback[0][0]), - PLAYBACK_EMPTYS * HARMONY_BUFSIZE, BUS_DMASYNC_POSTWRITE); - switch (sc->sc_cntlbits & CNTL_FORMAT_MASK) { - case CNTL_FORMAT_ULAW: - quietchar = 0x7f; - break; - case CNTL_FORMAT_ALAW: - quietchar = 0x55; - break; - case CNTL_FORMAT_SLINEAR16BE: - case CNTL_FORMAT_ULINEAR8: - default: - quietchar = 0; - break; - } - for (i = 0; i < PLAYBACK_EMPTYS; i++) - memset(&sc->sc_empty_kva->playback[i][0], - quietchar, HARMONY_BUFSIZE); - bus_dmamap_sync(sc->sc_dmat, sc->sc_empty_map, - offsetof(struct harmony_empty, playback[0][0]), - PLAYBACK_EMPTYS * HARMONY_BUFSIZE, BUS_DMASYNC_PREWRITE); - - for (;;) { - /* Wait for it to come out of control mode */ - reg = READ_REG(sc, HARMONY_CNTL); - if ((reg & CNTL_C) == 0) - break; - } - - bus_space_write_4(sc->sc_bt, sc->sc_bh, HARMONY_CNTL, - sc->sc_cntlbits | CNTL_C); - - for (;;) { - /* Wait for it to come out of control mode */ - reg = READ_REG(sc, HARMONY_CNTL); - if ((reg & CNTL_C) == 0) - break; - } - - sc->sc_need_commit = 0; - - if (sc->sc_playing || sc->sc_capturing) - harmony_intr_enable(sc); - - return (0); -} - -int -harmony_halt_output(void *vsc) -{ - struct harmony_softc *sc = vsc; - - /* XXX: disable interrupts */ - sc->sc_playing = 0; - return (0); -} - -int -harmony_halt_input(void *vsc) -{ - struct harmony_softc *sc = vsc; - - /* XXX: disable interrupts */ - sc->sc_capturing = 0; - return (0); -} - -int -harmony_set_port(void *vsc, mixer_ctrl_t *cp) -{ - struct harmony_softc *sc = vsc; - int err = EINVAL; - - switch (cp->dev) { - case HARMONY_PORT_INPUT_LVL: - if (cp->type != AUDIO_MIXER_VALUE) - break; - if (cp->un.value.num_channels == 1) - sc->sc_input_lvl.left = sc->sc_input_lvl.right = - cp->un.value.level[AUDIO_MIXER_LEVEL_MONO]; - else if (cp->un.value.num_channels == 2) { - sc->sc_input_lvl.left = - cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT]; - sc->sc_input_lvl.right = - cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT]; - } else - break; - sc->sc_need_commit = 1; - err = 0; - break; - case HARMONY_PORT_OUTPUT_LVL: - if (cp->type != AUDIO_MIXER_VALUE) - break; - if (cp->un.value.num_channels == 1) - sc->sc_output_lvl.left = sc->sc_output_lvl.right = - cp->un.value.level[AUDIO_MIXER_LEVEL_MONO]; - else if (cp->un.value.num_channels == 2) { - sc->sc_output_lvl.left = - cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT]; - sc->sc_output_lvl.right = - cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT]; - } else - break; - sc->sc_need_commit = 1; - err = 0; - break; - case HARMONY_PORT_OUTPUT_GAIN: - if (cp->type != AUDIO_MIXER_ENUM) - break; - sc->sc_outputgain = cp->un.ord ? 1 : 0; - err = 0; - break; - case HARMONY_PORT_MONITOR_LVL: - if (cp->type != AUDIO_MIXER_VALUE) - break; - if (cp->un.value.num_channels != 1) - break; - sc->sc_monitor_lvl.left = sc->sc_input_lvl.right = - cp->un.value.level[AUDIO_MIXER_LEVEL_MONO]; - sc->sc_need_commit = 1; - err = 0; - break; - case HARMONY_PORT_RECORD_SOURCE: - if (cp->type != AUDIO_MIXER_ENUM) - break; - if (cp->un.ord != HARMONY_IN_LINE && - cp->un.ord != HARMONY_IN_MIC) - break; - sc->sc_in_port = cp->un.ord; - err = 0; - sc->sc_need_commit = 1; - break; - case HARMONY_PORT_OUTPUT_SOURCE: - if (cp->type != AUDIO_MIXER_ENUM) - break; - if (cp->un.ord != HARMONY_OUT_LINE && - cp->un.ord != HARMONY_OUT_SPEAKER && - cp->un.ord != HARMONY_OUT_HEADPHONE) - break; - sc->sc_out_port = cp->un.ord; - err = 0; - sc->sc_need_commit = 1; - break; - } - - return (err); -} - -int -harmony_get_port(void *vsc, mixer_ctrl_t *cp) -{ - struct harmony_softc *sc = vsc; - int err = EINVAL; - - switch (cp->dev) { - case HARMONY_PORT_INPUT_LVL: - if (cp->type != AUDIO_MIXER_VALUE) - break; - if (cp->un.value.num_channels == 1) { - cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = - sc->sc_input_lvl.left; - } else if (cp->un.value.num_channels == 2) { - cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = - sc->sc_input_lvl.left; - cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = - sc->sc_input_lvl.right; - } else - break; - err = 0; - break; - case HARMONY_PORT_INPUT_OV: - if (cp->type != AUDIO_MIXER_ENUM) - break; - cp->un.ord = sc->sc_ov ? 1 : 0; - err = 0; - break; - case HARMONY_PORT_OUTPUT_LVL: - if (cp->type != AUDIO_MIXER_VALUE) - break; - if (cp->un.value.num_channels == 1) { - cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = - sc->sc_output_lvl.left; - } else if (cp->un.value.num_channels == 2) { - cp->un.value.level[AUDIO_MIXER_LEVEL_LEFT] = - sc->sc_output_lvl.left; - cp->un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = - sc->sc_output_lvl.right; - } else - break; - err = 0; - break; - case HARMONY_PORT_OUTPUT_GAIN: - if (cp->type != AUDIO_MIXER_ENUM) - break; - cp->un.ord = sc->sc_outputgain ? 1 : 0; - err = 0; - break; - case HARMONY_PORT_MONITOR_LVL: - if (cp->type != AUDIO_MIXER_VALUE) - break; - if (cp->un.value.num_channels != 1) - break; - cp->un.value.level[AUDIO_MIXER_LEVEL_MONO] = - sc->sc_monitor_lvl.left; - err = 0; - break; - case HARMONY_PORT_RECORD_SOURCE: - if (cp->type != AUDIO_MIXER_ENUM) - break; - cp->un.ord = sc->sc_in_port; - err = 0; - break; - case HARMONY_PORT_OUTPUT_SOURCE: - if (cp->type != AUDIO_MIXER_ENUM) - break; - cp->un.ord = sc->sc_out_port; - err = 0; - break; - } - return (0); -} - -int -harmony_query_devinfo(void *vsc, mixer_devinfo_t *dip) -{ - int err = 0; - - switch (dip->index) { - case HARMONY_PORT_INPUT_LVL: - dip->type = AUDIO_MIXER_VALUE; - dip->mixer_class = HARMONY_PORT_INPUT_CLASS; - dip->prev = dip->next = AUDIO_MIXER_LAST; - strlcpy(dip->label.name, AudioNinput, sizeof dip->label.name); - dip->un.v.num_channels = 2; - strlcpy(dip->un.v.units.name, AudioNvolume, - sizeof dip->un.v.units.name); - break; - case HARMONY_PORT_INPUT_OV: - dip->type = AUDIO_MIXER_ENUM; - dip->mixer_class = HARMONY_PORT_INPUT_CLASS; - dip->prev = dip->next = AUDIO_MIXER_LAST; - strlcpy(dip->label.name, "overrange", sizeof dip->label.name); - dip->un.e.num_mem = 2; - strlcpy(dip->un.e.member[0].label.name, AudioNoff, - sizeof dip->un.e.member[0].label.name); - dip->un.e.member[0].ord = 0; - strlcpy(dip->un.e.member[1].label.name, AudioNon, - sizeof dip->un.e.member[1].label.name); - dip->un.e.member[1].ord = 1; - break; - case HARMONY_PORT_OUTPUT_LVL: - dip->type = AUDIO_MIXER_VALUE; - dip->mixer_class = HARMONY_PORT_OUTPUT_CLASS; - dip->prev = dip->next = AUDIO_MIXER_LAST; - strlcpy(dip->label.name, AudioNoutput, sizeof dip->label.name); - dip->un.v.num_channels = 2; - strlcpy(dip->un.v.units.name, AudioNvolume, - sizeof dip->un.v.units.name); - break; - case HARMONY_PORT_OUTPUT_GAIN: - dip->type = AUDIO_MIXER_ENUM; - dip->mixer_class = HARMONY_PORT_OUTPUT_CLASS; - dip->prev = dip->next = AUDIO_MIXER_LAST; - strlcpy(dip->label.name, "gain", sizeof dip->label.name); - dip->un.e.num_mem = 2; - strlcpy(dip->un.e.member[0].label.name, AudioNoff, - sizeof dip->un.e.member[0].label.name); - dip->un.e.member[0].ord = 0; - strlcpy(dip->un.e.member[1].label.name, AudioNon, - sizeof dip->un.e.member[1].label.name); - dip->un.e.member[1].ord = 1; - break; - case HARMONY_PORT_MONITOR_LVL: - dip->type = AUDIO_MIXER_VALUE; - dip->mixer_class = HARMONY_PORT_MONITOR_CLASS; - dip->prev = dip->next = AUDIO_MIXER_LAST; - strlcpy(dip->label.name, AudioNmonitor, sizeof dip->label.name); - dip->un.v.num_channels = 1; - strlcpy(dip->un.v.units.name, AudioNvolume, - sizeof dip->un.v.units.name); - break; - case HARMONY_PORT_RECORD_SOURCE: - dip->type = AUDIO_MIXER_ENUM; - dip->mixer_class = HARMONY_PORT_RECORD_CLASS; - dip->prev = dip->next = AUDIO_MIXER_LAST; - strlcpy(dip->label.name, AudioNsource, sizeof dip->label.name); - dip->un.e.num_mem = 2; - strlcpy(dip->un.e.member[0].label.name, AudioNmicrophone, - sizeof dip->un.e.member[0].label.name); - dip->un.e.member[0].ord = HARMONY_IN_MIC; - strlcpy(dip->un.e.member[1].label.name, AudioNline, - sizeof dip->un.e.member[1].label.name); - dip->un.e.member[1].ord = HARMONY_IN_LINE; - break; - case HARMONY_PORT_OUTPUT_SOURCE: - dip->type = AUDIO_MIXER_ENUM; - dip->mixer_class = HARMONY_PORT_MONITOR_CLASS; - dip->prev = dip->next = AUDIO_MIXER_LAST; - strlcpy(dip->label.name, AudioNoutput, sizeof dip->label.name); - dip->un.e.num_mem = 3; - strlcpy(dip->un.e.member[0].label.name, AudioNline, - sizeof dip->un.e.member[0].label.name); - dip->un.e.member[0].ord = HARMONY_OUT_LINE; - strlcpy(dip->un.e.member[1].label.name, AudioNspeaker, - sizeof dip->un.e.member[1].label.name); - dip->un.e.member[1].ord = HARMONY_OUT_SPEAKER; - strlcpy(dip->un.e.member[2].label.name, AudioNheadphone, - sizeof dip->un.e.member[2].label.name); - dip->un.e.member[2].ord = HARMONY_OUT_HEADPHONE; - break; - case HARMONY_PORT_INPUT_CLASS: - dip->type = AUDIO_MIXER_CLASS; - dip->mixer_class = HARMONY_PORT_INPUT_CLASS; - dip->prev = dip->next = AUDIO_MIXER_LAST; - strlcpy(dip->label.name, AudioCinputs, sizeof dip->label.name); - break; - case HARMONY_PORT_OUTPUT_CLASS: - dip->type = AUDIO_MIXER_CLASS; - dip->mixer_class = HARMONY_PORT_INPUT_CLASS; - dip->prev = dip->next = AUDIO_MIXER_LAST; - strlcpy(dip->label.name, AudioCoutputs, sizeof dip->label.name); - break; - case HARMONY_PORT_MONITOR_CLASS: - dip->type = AUDIO_MIXER_CLASS; - dip->mixer_class = HARMONY_PORT_INPUT_CLASS; - dip->prev = dip->next = AUDIO_MIXER_LAST; - strlcpy(dip->label.name, AudioCmonitor, sizeof dip->label.name); - break; - case HARMONY_PORT_RECORD_CLASS: - dip->type = AUDIO_MIXER_CLASS; - dip->mixer_class = HARMONY_PORT_RECORD_CLASS; - dip->prev = dip->next = AUDIO_MIXER_LAST; - strlcpy(dip->label.name, AudioCrecord, sizeof dip->label.name); - break; - default: - err = ENXIO; - break; - } - - return (err); -} - -void * -harmony_allocm(void *vsc, int dir, size_t size, int pool, int flags) -{ - struct harmony_softc *sc = vsc; - struct harmony_dma *d; - int rseg; - - d = (struct harmony_dma *)malloc(sizeof(struct harmony_dma), pool, flags); - if (d == NULL) - goto fail; - - if (bus_dmamap_create(sc->sc_dmat, size, 1, size, 0, BUS_DMA_NOWAIT, - &d->d_map) != 0) - goto fail1; - - if (bus_dmamem_alloc(sc->sc_dmat, size, PAGE_SIZE, 0, &d->d_seg, 1, - &rseg, BUS_DMA_NOWAIT) != 0) - goto fail2; - - if (bus_dmamem_map(sc->sc_dmat, &d->d_seg, 1, size, &d->d_kva, - BUS_DMA_NOWAIT) != 0) - goto fail3; - - if (bus_dmamap_load(sc->sc_dmat, d->d_map, d->d_kva, size, NULL, - BUS_DMA_NOWAIT) != 0) - goto fail4; - - d->d_next = sc->sc_dmas; - sc->sc_dmas = d; - d->d_size = size; - return (d->d_kva); - -fail4: - bus_dmamem_unmap(sc->sc_dmat, d->d_kva, size); -fail3: - bus_dmamem_free(sc->sc_dmat, &d->d_seg, 1); -fail2: - bus_dmamap_destroy(sc->sc_dmat, d->d_map); -fail1: - free(d, pool, sizeof *d); -fail: - return (NULL); -} - -void -harmony_freem(void *vsc, void *ptr, int pool) -{ - struct harmony_softc *sc = vsc; - struct harmony_dma *d, **dd; - - for (dd = &sc->sc_dmas; (d = *dd) != NULL; dd = &(*dd)->d_next) { - if (d->d_kva != ptr) - continue; - bus_dmamap_unload(sc->sc_dmat, d->d_map); - bus_dmamem_unmap(sc->sc_dmat, d->d_kva, d->d_size); - bus_dmamem_free(sc->sc_dmat, &d->d_seg, 1); - bus_dmamap_destroy(sc->sc_dmat, d->d_map); - free(d, pool, sizeof *d); - return; - } - printf("%s: free rogue pointer\n", sc->sc_dv.dv_xname); -} - -size_t -harmony_round_buffersize(void *vsc, int direction, size_t size) -{ - return ((size + HARMONY_BUFSIZE - 1) & (size_t)(-HARMONY_BUFSIZE)); -} - -int -harmony_trigger_output(void *vsc, void *start, void *end, int blksize, - void (*intr)(void *), void *intrarg, struct audio_params *param) -{ - struct harmony_softc *sc = vsc; - struct harmony_channel *c = &sc->sc_playback; - struct harmony_dma *d; - bus_addr_t nextaddr; - bus_size_t togo; - - for (d = sc->sc_dmas; d->d_kva != start; d = d->d_next) - /*EMPTY*/; - if (d == NULL) { - printf("%s: trigger_output: bad addr: %p\n", - sc->sc_dv.dv_xname, start); - return (EINVAL); - } - - c->c_intr = intr; - c->c_intrarg = intrarg; - c->c_blksz = blksize; - c->c_current = d; - c->c_segsz = (caddr_t)end - (caddr_t)start; - c->c_cnt = 0; - c->c_lastaddr = d->d_map->dm_segs[0].ds_addr; - - sc->sc_playing = 1; - - togo = c->c_segsz - c->c_cnt; - if (togo == 0) { - nextaddr = d->d_map->dm_segs[0].ds_addr; - c->c_cnt = togo = c->c_blksz; - } else { - nextaddr = c->c_lastaddr; - if (togo > c->c_blksz) - togo = c->c_blksz; - c->c_cnt += togo; - } - - bus_dmamap_sync(sc->sc_dmat, d->d_map, - nextaddr - d->d_map->dm_segs[0].ds_addr, - c->c_blksz, BUS_DMASYNC_PREWRITE); - - mtx_enter(&audio_lock); - WRITE_REG(sc, HARMONY_PNXTADD, nextaddr); - c->c_theaddr = nextaddr; - SYNC_REG(sc, HARMONY_PNXTADD, BUS_SPACE_BARRIER_WRITE); - c->c_lastaddr = nextaddr + togo; - - harmony_start_cp(sc); - harmony_intr_enable(sc); - mtx_leave(&audio_lock); - return (0); -} - -void -harmony_start_cp(struct harmony_softc *sc) -{ - struct harmony_channel *c = &sc->sc_capture; - struct harmony_dma *d; - bus_addr_t nextaddr; - bus_size_t togo; - - if (sc->sc_capturing == 0) { - WRITE_REG(sc, HARMONY_RNXTADD, - sc->sc_capture_paddrs[sc->sc_capture_empty]); - if (++sc->sc_capture_empty == CAPTURE_EMPTYS) - sc->sc_capture_empty = 0; - } else { - d = c->c_current; - togo = c->c_segsz - c->c_cnt; - if (togo == 0) { - nextaddr = d->d_map->dm_segs[0].ds_addr; - c->c_cnt = togo = c->c_blksz; - } else { - nextaddr = c->c_lastaddr; - if (togo > c->c_blksz) - togo = c->c_blksz; - c->c_cnt += togo; - } - - bus_dmamap_sync(sc->sc_dmat, d->d_map, - nextaddr - d->d_map->dm_segs[0].ds_addr, - c->c_blksz, BUS_DMASYNC_PREWRITE); - - WRITE_REG(sc, HARMONY_RNXTADD, nextaddr); - SYNC_REG(sc, HARMONY_RNXTADD, BUS_SPACE_BARRIER_WRITE); - c->c_lastaddr = nextaddr + togo; - } - - timeout_add(&sc->sc_acc_tmo, 1); -} - -int -harmony_trigger_input(void *vsc, void *start, void *end, int blksize, - void (*intr)(void *), void *intrarg, struct audio_params *param) -{ - struct harmony_softc *sc = vsc; - struct harmony_channel *c = &sc->sc_capture; - struct harmony_dma *d; - - for (d = sc->sc_dmas; d->d_kva != start; d = d->d_next) - /*EMPTY*/; - if (d == NULL) { - printf("%s: trigger_input: bad addr: %p\n", - sc->sc_dv.dv_xname, start); - return (EINVAL); - } - - c->c_intr = intr; - c->c_intrarg = intrarg; - c->c_blksz = blksize; - c->c_current = d; - c->c_segsz = (caddr_t)end - (caddr_t)start; - c->c_cnt = 0; - c->c_lastaddr = d->d_map->dm_segs[0].ds_addr; - mtx_enter(&audio_lock); - sc->sc_capturing = 1; - harmony_start_cp(sc); - harmony_intr_enable(sc); - mtx_leave(&audio_lock); - return (0); -} - -static const struct speed_struct { - u_int32_t speed; - u_int32_t bits; -} harmony_speeds[] = { - { 5125, CNTL_RATE_5125 }, - { 6615, CNTL_RATE_6615 }, - { 8000, CNTL_RATE_8000 }, - { 9600, CNTL_RATE_9600 }, - { 11025, CNTL_RATE_11025 }, - { 16000, CNTL_RATE_16000 }, - { 18900, CNTL_RATE_18900 }, - { 22050, CNTL_RATE_22050 }, - { 27428, CNTL_RATE_27428 }, - { 32000, CNTL_RATE_32000 }, - { 33075, CNTL_RATE_33075 }, - { 37800, CNTL_RATE_37800 }, - { 44100, CNTL_RATE_44100 }, - { 48000, CNTL_RATE_48000 }, -}; - -u_int32_t -harmony_speed_bits(struct harmony_softc *sc, u_long *speedp) -{ - int i, n, selected = -1; - - n = sizeof(harmony_speeds) / sizeof(harmony_speeds[0]); - - if ((*speedp) <= harmony_speeds[0].speed) - selected = 0; - else if ((*speedp) >= harmony_speeds[n - 1].speed) - selected = n - 1; - else { - for (i = 1; selected == -1 && i < n; i++) { - if ((*speedp) == harmony_speeds[i].speed) - selected = i; - else if ((*speedp) < harmony_speeds[i].speed) { - int diff1, diff2; - - diff1 = (*speedp) - harmony_speeds[i - 1].speed; - diff2 = harmony_speeds[i].speed - (*speedp); - if (diff1 < diff2) - selected = i - 1; - else - selected = i; - } - } - } - - if (selected == -1) - selected = 2; - - *speedp = harmony_speeds[selected].speed; - return (harmony_speeds[selected].bits); -} - -int -harmony_set_gainctl(struct harmony_softc *sc) -{ - u_int32_t bits, mask, val, old; - - /* XXX leave these bits alone or the chip will not come out of CNTL */ - bits = GAINCTL_LE | GAINCTL_HE | GAINCTL_SE | GAINCTL_IS_MASK; - - /* input level */ - bits |= ((sc->sc_input_lvl.left >> (8 - GAINCTL_INPUT_BITS)) << - GAINCTL_INPUT_LEFT_S) & GAINCTL_INPUT_LEFT_M; - bits |= ((sc->sc_input_lvl.right >> (8 - GAINCTL_INPUT_BITS)) << - GAINCTL_INPUT_RIGHT_S) & GAINCTL_INPUT_RIGHT_M; - - /* output level (inverted) */ - mask = (1 << GAINCTL_OUTPUT_BITS) - 1; - val = mask - (sc->sc_output_lvl.left >> (8 - GAINCTL_OUTPUT_BITS)); - bits |= (val << GAINCTL_OUTPUT_LEFT_S) & GAINCTL_OUTPUT_LEFT_M; - val = mask - (sc->sc_output_lvl.right >> (8 - GAINCTL_OUTPUT_BITS)); - bits |= (val << GAINCTL_OUTPUT_RIGHT_S) & GAINCTL_OUTPUT_RIGHT_M; - - /* monitor level (inverted) */ - mask = (1 << GAINCTL_MONITOR_BITS) - 1; - val = mask - (sc->sc_monitor_lvl.left >> (8 - GAINCTL_MONITOR_BITS)); - bits |= (val << GAINCTL_MONITOR_S) & GAINCTL_MONITOR_M; - - /* XXX messing with these causes CNTL_C to get stuck... grr. */ - bits &= ~GAINCTL_IS_MASK; - if (sc->sc_in_port == HARMONY_IN_MIC) - bits |= GAINCTL_IS_LINE; - else - bits |= GAINCTL_IS_MICROPHONE; - - /* XXX messing with these causes CNTL_C to get stuck... grr. */ - bits &= ~(GAINCTL_LE | GAINCTL_HE | GAINCTL_SE); - if (sc->sc_out_port == HARMONY_OUT_LINE) - bits |= GAINCTL_LE; - else if (sc->sc_out_port == HARMONY_OUT_SPEAKER) - bits |= GAINCTL_SE; - else - bits |= GAINCTL_HE; - - mask = GAINCTL_LE | GAINCTL_HE | GAINCTL_SE | GAINCTL_IS_MASK; - old = bus_space_read_4(sc->sc_bt, sc->sc_bh, HARMONY_GAINCTL); - bus_space_write_4(sc->sc_bt, sc->sc_bh, HARMONY_GAINCTL, bits); - if ((old & mask) != (bits & mask)) - return (1); - return (0); -} - -void -harmony_try_more(struct harmony_softc *sc) -{ - struct harmony_channel *c = &sc->sc_playback; - struct harmony_dma *d = c->c_current; - u_int32_t cur; - int i, nsegs; - - cur = bus_space_read_4(sc->sc_bt, sc->sc_bh, HARMONY_PCURADD); - cur &= PCURADD_BUFMASK; - nsegs = 0; - -#ifdef DIAGNOSTIC - if (cur < d->d_map->dm_segs[0].ds_addr || - cur >= (d->d_map->dm_segs[0].ds_addr + c->c_segsz)) - panic("%s: bad current %x < %lx || %x > %lx", - sc->sc_dv.dv_xname, cur, d->d_map->dm_segs[0].ds_addr, cur, - d->d_map->dm_segs[0].ds_addr + c->c_segsz); -#endif /* DIAGNOSTIC */ - - if (cur > c->c_theaddr) { - nsegs = (cur - c->c_theaddr) / HARMONY_BUFSIZE; - } else if (cur < c->c_theaddr) { - nsegs = (d->d_map->dm_segs[0].ds_addr + c->c_segsz - - c->c_theaddr) / HARMONY_BUFSIZE; - nsegs += (cur - d->d_map->dm_segs[0].ds_addr) / - HARMONY_BUFSIZE; - } - - if (nsegs != 0 && c->c_intr != NULL) { - for (i = 0; i < nsegs; i++) - (*c->c_intr)(c->c_intrarg); - c->c_theaddr = cur; - } -} - -struct cfdriver harmony_cd = { - NULL, "harmony", DV_DULL -}; - -const struct cfattach harmony_ca = { - sizeof(struct harmony_softc), harmony_match, harmony_attach -}; diff --git a/sys/arch/hppa/gsc/harmonyreg.h b/sys/arch/hppa/gsc/harmonyreg.h deleted file mode 100644 index bb8915478..000000000 --- a/sys/arch/hppa/gsc/harmonyreg.h +++ /dev/null @@ -1,152 +0,0 @@ -/* $OpenBSD: harmonyreg.h,v 1.5 2003/06/02 19:54:29 jason Exp $ */ - -/* - * Copyright (c) 2003 Jason L. Wright (jason@thought.net) - * 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. - */ - -/* - * Harmony CS4215/AD1849 register definitions based on: - * "712 I/O Subsystem ERS", Revision 1.1, 12 February 1993 - */ - -/* harmony always uses a 4K buffer */ -#define HARMONY_BUFSIZE 4096 - -#define HARMONY_NREGS 0x40 - -#define HARMONY_ID 0x00 /* identification */ -#define HARMONY_RESET 0x04 /* reset */ -#define HARMONY_CNTL 0x08 /* control */ -#define HARMONY_GAINCTL 0x0c /* gain control */ -#define HARMONY_PNXTADD 0x10 /* play next address */ -#define HARMONY_PCURADD 0x14 /* play current address */ -#define HARMONY_RNXTADD 0x18 /* record next address */ -#define HARMONY_RCURADD 0x1c /* record current address */ -#define HARMONY_DSTATUS 0x20 /* device status */ -#define HARMONY_OV 0x24 /* overrange input */ -#define HARMONY_PIO 0x28 /* general purpose i/o */ -#define HARMONY_DIAG 0x3c /* chi diagnostic */ - -/* HARMONY_ID */ -#define ID_REV_MASK 0x00ff0000 /* revision mask: */ -#define ID_REV_SHIFT 16 -#define ID_REV_TS 0x00150000 /* teleshare installed */ -#define ID_REV_NOTS 0x00140000 /* teleshare not installed */ -#define ID_CHIID 0x0000f000 /* CHI identification */ -#define ID_CHIID_SHIFT 12 - -/* HARMONY_RESET */ -#define RESET_RST 0x00000001 /* reset codec */ - -/* HARMONY_CNTL */ -#define CNTL_C 0x80000000 /* control mode */ -#define CNTL_CODEC_REV_MASK 0x0ff00000 /* codec revision */ -#define CNTL_CODEC_REV_SHIFT 20 -#define CNTL_EXP_3 0x00020000 /* expansion bit 3 */ -#define CNTL_EXP_2 0x00010000 /* expansion bit 2 */ -#define CNTL_EXP_1 0x00008000 /* expansion bit 1 */ -#define CNTL_EXP_0 0x00004000 /* expansion bit 0 */ -#define CNTL_AC 0x00002000 /* autocalibration ad1849 */ -#define CNTL_AD 0x00001000 /* ad1849 compat? */ -#define CNTL_OLB 0x00000800 /* output level */ -#define CNTL_ITS 0x00000400 /* codec immediate tristate */ -#define CNTL_LS_MASK 0x00000300 /* loopback select: */ -#define CNTL_LS_NONE 0x00000000 /* none */ -#define CNTL_LS_INTERNAL 0x00000100 /* internal */ -#define CNTL_LS_DIGITAL 0x00000200 /* digital */ -#define CNTL_LS_ANALOG 0x00000300 /* analog */ -#define CNTL_FORMAT_MASK 0x000000c0 /* encoding format: */ -#define CNTL_FORMAT_SLINEAR16BE 0x00000000 /* 16 bit signed linear be */ -#define CNTL_FORMAT_ULAW 0x00000040 /* 8 bit ulaw */ -#define CNTL_FORMAT_ALAW 0x00000080 /* 8 bit alaw */ -#define CNTL_FORMAT_ULINEAR8 0x000000c0 /* 8 bit unsigned linear */ -#define CNTL_CHANS_MASK 0x00000020 /* number of channels: */ -#define CNTL_CHANS_MONO 0x00000000 /* mono */ -#define CNTL_CHANS_STEREO 0x00000020 /* stereo */ -#define CNTL_RATE_MASK 0x0000001f /* sample rate (kHz): */ -#define CNTL_RATE_5125 0x00000010 /* 5.5125 */ -#define CNTL_RATE_6615 0x00000017 /* 6.615 */ -#define CNTL_RATE_8000 0x00000008 /* 8 */ -#define CNTL_RATE_9600 0x0000000f /* 9.6 */ -#define CNTL_RATE_11025 0x00000011 /* 11.025 */ -#define CNTL_RATE_16000 0x00000009 /* 16 */ -#define CNTL_RATE_18900 0x00000012 /* 18.9 */ -#define CNTL_RATE_22050 0x00000013 /* 22.05 */ -#define CNTL_RATE_27428 0x0000000a /* 27.42857 */ -#define CNTL_RATE_32000 0x0000000b /* 32 */ -#define CNTL_RATE_33075 0x00000016 /* 33.075 */ -#define CNTL_RATE_37800 0x00000014 /* 37.8 */ -#define CNTL_RATE_44100 0x00000015 /* 44.1 */ -#define CNTL_RATE_48000 0x0000000e /* 48 */ - -/* HARMONY_GAINCTL */ -#define GAINCTL_HE 0x08000000 /* headphones enable */ -#define GAINCTL_LE 0x04000000 /* line output enable */ -#define GAINCTL_SE 0x02000000 /* speaker enable */ -#define GAINCTL_IS_MASK 0x01000000 /* input select: */ -#define GAINCTL_IS_LINE 0x00000000 /* line input */ -#define GAINCTL_IS_MICROPHONE 0x01000000 /* microphone */ -#define GAINCTL_INPUT_LEFT_M 0x0000f000 /* left input gain */ -#define GAINCTL_INPUT_LEFT_S 12 -#define GAINCTL_INPUT_RIGHT_M 0x000f0000 /* left input gain */ -#define GAINCTL_INPUT_RIGHT_S 16 -#define GAINCTL_INPUT_BITS 4 -#define GAINCTL_MONITOR_M 0x00f00000 /* monitor gain (inverted) */ -#define GAINCTL_MONITOR_S 20 -#define GAINCTL_MONITOR_BITS 4 -#define GAINCTL_OUTPUT_LEFT_M 0x00000fc0 /* left out gain (inverted) */ -#define GAINCTL_OUTPUT_LEFT_S 6 -#define GAINCTL_OUTPUT_RIGHT_M 0x0000003f /* right out gain (inverted) */ -#define GAINCTL_OUTPUT_RIGHT_S 0 -#define GAINCTL_OUTPUT_BITS 6 - -/* HARMONY_PCURADD */ -#define PCURADD_BUFMASK (~(HARMONY_BUFSIZE - 1)) - -/* HARMONY_RCURADD */ -#define PCURADD_BUFMASK (~(HARMONY_BUFSIZE - 1)) - -/* HARMONY_DSTATUS */ -#define DSTATUS_IE 0x80000000 /* interrupt enable */ -#define DSTATUS_PN 0x00000200 /* playback next empty */ -#define DSTATUS_PC 0x00000100 /* playback dma active */ -#define DSTATUS_RN 0x00000002 /* record next empty */ -#define DSTATUS_RC 0x00000001 /* record dma active */ - -/* HARMONY_OV */ -#define OV_OV 0x00000001 /* input over range */ - -/* HARMONY_PIO */ -#define PIO_PO 0x00000002 /* parallel output */ -#define PIO_PI 0x00000001 /* parallel input */ - -/* HARMONY_DIAG */ -#define DIAG_CO 0x00000001 /* sclk from codec */ - -/* CS4215_REV */ -#define CS4215_REV_VER 0x0f -#define CS4215_REV_VER_C 0x00 /* CS4215 rev C */ -#define CS4215_REV_VER_D 0x01 /* CS4215 rev D */ -#define CS4215_REV_VER_E 0x02 /* CS4215 rev E/AD1849K */ diff --git a/sys/arch/hppa/gsc/harmonyvar.h b/sys/arch/hppa/gsc/harmonyvar.h deleted file mode 100644 index d1a024332..000000000 --- a/sys/arch/hppa/gsc/harmonyvar.h +++ /dev/null @@ -1,114 +0,0 @@ -/* $OpenBSD: harmonyvar.h,v 1.9 2016/09/19 06:46:43 ratchov Exp $ */ - -/* - * Copyright (c) 2003 Jason L. Wright (jason@thought.net) - * 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. - */ - -#define HARMONY_PORT_INPUT_LVL 0 -#define HARMONY_PORT_INPUT_OV 1 -#define HARMONY_PORT_OUTPUT_LVL 2 -#define HARMONY_PORT_OUTPUT_GAIN 3 -#define HARMONY_PORT_MONITOR_LVL 4 -#define HARMONY_PORT_RECORD_SOURCE 5 -#define HARMONY_PORT_OUTPUT_SOURCE 6 -#define HARMONY_PORT_INPUT_CLASS 7 -#define HARMONY_PORT_OUTPUT_CLASS 8 -#define HARMONY_PORT_MONITOR_CLASS 9 -#define HARMONY_PORT_RECORD_CLASS 10 - -#define HARMONY_IN_MIC 0 -#define HARMONY_IN_LINE 1 - -#define HARMONY_OUT_LINE 0 -#define HARMONY_OUT_SPEAKER 1 -#define HARMONY_OUT_HEADPHONE 2 - -#define PLAYBACK_EMPTYS 3 /* playback empty buffers */ -#define CAPTURE_EMPTYS 3 /* capture empty buffers */ - -struct harmony_volume { - u_char left, right; -}; - -struct harmony_empty { - u_int8_t playback[PLAYBACK_EMPTYS][HARMONY_BUFSIZE]; - u_int8_t capture[CAPTURE_EMPTYS][HARMONY_BUFSIZE]; -}; - -struct harmony_dma { - struct harmony_dma *d_next; - bus_dmamap_t d_map; - bus_dma_segment_t d_seg; - caddr_t d_kva; - size_t d_size; -}; - -struct harmony_channel { - struct harmony_dma *c_current; - bus_size_t c_segsz; - bus_size_t c_cnt; - bus_size_t c_blksz; - bus_addr_t c_lastaddr; - void (*c_intr)(void *); - void *c_intrarg; - bus_addr_t c_theaddr; -}; - -struct harmony_softc { - struct device sc_dv; - - bus_dma_tag_t sc_dmat; - bus_space_tag_t sc_bt; - bus_space_handle_t sc_bh; - int sc_open; - u_int32_t sc_cntlbits; - int sc_need_commit; - int sc_playback_empty; - bus_addr_t sc_playback_paddrs[PLAYBACK_EMPTYS]; - int sc_capture_empty; - bus_addr_t sc_capture_paddrs[CAPTURE_EMPTYS]; - bus_dmamap_t sc_empty_map; - bus_dma_segment_t sc_empty_seg; - int sc_empty_rseg; - struct harmony_empty *sc_empty_kva; - struct harmony_dma *sc_dmas; - int sc_playing, sc_capturing; - struct harmony_channel sc_playback, sc_capture; - struct harmony_volume sc_monitor_lvl, sc_input_lvl, sc_output_lvl; - int sc_in_port, sc_out_port, sc_hasulinear8; - int sc_micpreamp, sc_ov, sc_outputgain; - int sc_teleshare; - - struct timeout sc_acc_tmo; - u_int32_t sc_acc, sc_acc_num, sc_acc_cnt; -}; - -#define READ_REG(sc, reg) \ - bus_space_read_4((sc)->sc_bt, (sc)->sc_bh, (reg)) -#define WRITE_REG(sc, reg, val) \ - bus_space_write_4((sc)->sc_bt, (sc)->sc_bh, (reg), (val)) -#define SYNC_REG(sc, reg, flags) \ - bus_space_barrier((sc)->sc_bt, (sc)->sc_bh, (reg), sizeof(u_int32_t), \ - (flags)) diff --git a/sys/arch/hppa/gsc/hil_gsc.c b/sys/arch/hppa/gsc/hil_gsc.c deleted file mode 100644 index 6854b9256..000000000 --- a/sys/arch/hppa/gsc/hil_gsc.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $OpenBSD: hil_gsc.c,v 1.6 2022/03/13 08:04:38 mpi Exp $ */ -/* - * Copyright (c) 2003, Miodrag Vallat. - * 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 -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - -int hil_gsc_match(struct device *, void *, void *); -void hil_gsc_attach(struct device *, struct device *, void *); - -struct hil_gsc_softc { - struct hil_softc sc_hs; - int sc_hil_console; -}; - -const struct cfattach hil_gsc_ca = { - sizeof(struct hil_gsc_softc), hil_gsc_match, hil_gsc_attach -}; - -int -hil_gsc_match(struct device *parent, void *match, void *aux) -{ - struct gsc_attach_args *ga = aux; - - if (ga->ga_type.iodc_type != HPPA_TYPE_FIO || - ga->ga_type.iodc_sv_model != HPPA_FIO_HIL) - return (0); - - return (1); -} - -void -hil_gsc_attach(struct device *parent, struct device *self, void *aux) -{ - struct hil_gsc_softc *gsc = (void *)self; - struct hil_softc *sc = &gsc->sc_hs; - struct gsc_attach_args *ga = aux; - - sc->sc_bst = ga->ga_iot; - if (bus_space_map(ga->ga_iot, ga->ga_hpa, - HILMAPSIZE, 0, &sc->sc_bsh)) { - printf(": couldn't map hil controller\n"); - return; - } - - gsc->sc_hil_console = ga->ga_dp.dp_mod == PAGE0->mem_kbd.pz_dp.dp_mod && - bcmp(ga->ga_dp.dp_bc, PAGE0->mem_kbd.pz_dp.dp_bc, 6) == 0; - - hil_attach(sc, &gsc->sc_hil_console); - - gsc_intr_establish((struct gsc_softc *)parent, ga->ga_irq, IPL_TTY, - hil_intr, sc, sc->sc_dev.dv_xname); - - startuphook_establish(hil_attach_deferred, sc); -} diff --git a/sys/arch/hppa/gsc/if_ie_gsc.c b/sys/arch/hppa/gsc/if_ie_gsc.c deleted file mode 100644 index 068cd0c7b..000000000 --- a/sys/arch/hppa/gsc/if_ie_gsc.c +++ /dev/null @@ -1,396 +0,0 @@ -/* $OpenBSD: if_ie_gsc.c,v 1.30 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -/* - * References: - * 1. 82596DX and 82596SX High-Performance 32-bit Local Area Network Coprocessor - * Intel Corporation, November 1996, Order Number: 290219-006 - * - * 2. 712 I/O Subsystem ERS Rev 1.0 - * Hewlett-Packard, June 17 1992, Dwg No. A-A2263-66510-31 - */ -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include -#include - -#define IEGSC_GECKO IEMD_FLAG0 - -struct ie_gsc_regs { - u_int32_t ie_reset; - u_int32_t ie_port; - u_int32_t ie_attn; -}; - -#define IE_SIZE 0x8000 - -int ie_gsc_probe(struct device *, void *, void *); -void ie_gsc_attach(struct device *, struct device *, void *); - -const struct cfattach ie_gsc_ca = { - sizeof(struct ie_softc), ie_gsc_probe, ie_gsc_attach -}; - -static uint64_t ie_gsc_media[] = { - IFM_ETHER | IFM_10_2, -}; -#define IE_NMEDIA (sizeof(ie_gsc_media) / sizeof(ie_gsc_media[0])) - -char *ie_mem; - -void ie_gsc_reset(struct ie_softc *sc, int what); -void ie_gsc_attend(struct ie_softc *sc); -void ie_gsc_run(struct ie_softc *sc); -void ie_gsc_port(struct ie_softc *sc, u_int); -#ifdef USELEDS -int ie_gsc_intrhook(struct ie_softc *sc, int what); -#endif -u_int16_t ie_gsc_read16(struct ie_softc *sc, int offset); -void ie_gsc_write16(struct ie_softc *sc, int offset, u_int16_t v); -void ie_gsc_write24(struct ie_softc *sc, int offset, int addr); -void ie_gsc_memcopyin(struct ie_softc *sc, void *p, int offset, size_t); -void ie_gsc_memcopyout(struct ie_softc *sc, const void *p, int, size_t); - - -void -ie_gsc_reset(sc, what) - struct ie_softc *sc; - int what; -{ - volatile struct ie_gsc_regs *r = (struct ie_gsc_regs *)sc->ioh; - int i; - - r->ie_reset = 0; - /* - * per [2] 4.6.2.1 - * delay for 10 system clocks + 5 transmit clocks, - * NB: works for system clocks over 10MHz - */ - DELAY(1000); - - switch (what) { - case IE_CHIP_PROBE: - break; - - case IE_CARD_RESET: - /* - * after the hardware reset: - * inform i825[89]6 about new SCP address, - * maddr must be at least 16-byte aligned - */ - ie_gsc_port(sc, IE_PORT_SCP); - ie_gsc_attend(sc); - - for (i = 9000; i-- && ie_gsc_read16(sc, IE_ISCP_BUSY(sc->iscp)); - DELAY(100)) - pdcache(0, sc->sc_maddr + sc->iscp, IE_ISCP_SZ); - -#ifdef I82596_DEBUG - if (i < 0) { - printf("timeout for PORT command (%x)%s\n", - ie_gsc_read16(sc, IE_ISCP_BUSY(sc->iscp)), - (sc->sc_flags & IEGSC_GECKO)? " on gecko":""); - return; - } -#endif - break; - } -} - -void -ie_gsc_attend(sc) - struct ie_softc *sc; -{ - volatile struct ie_gsc_regs *r = (struct ie_gsc_regs *)sc->ioh; - - fdcache(0, (vaddr_t)ie_mem, IE_SIZE); - DELAY(1); - r->ie_attn = 0; - DELAY(1); -} - -void -ie_gsc_run(sc) - struct ie_softc *sc; -{ -} - -void -ie_gsc_port(sc, cmd) - struct ie_softc *sc; - u_int cmd; -{ - switch (cmd) { - case IE_PORT_RESET: - cmd = 0; - break; - case IE_PORT_TEST: - cmd = ((u_int)sc->sc_maddr + sc->scp) | 1; - break; - case IE_PORT_SCP: - cmd = ((u_int)sc->sc_maddr + sc->scp) | 2; - break; - case IE_PORT_DUMP: - cmd = 3; - break; - } - - if (sc->sc_flags & IEGSC_GECKO) { - volatile struct ie_gsc_regs *r = (struct ie_gsc_regs *)sc->ioh; - r->ie_port = cmd & 0xffff; - DELAY(1000); - r->ie_port = cmd >> 16; - DELAY(1000); - } else { - volatile struct ie_gsc_regs *r = (struct ie_gsc_regs *)sc->ioh; - r->ie_port = cmd >> 16; - DELAY(1000); - r->ie_port = cmd & 0xffff; - DELAY(1000); - } -} - -#ifdef USELEDS -int -ie_gsc_intrhook(sc, where) - struct ie_softc *sc; - int where; -{ - switch (where) { - case IE_INTR_ENRCV: - ledctl(PALED_NETRCV, 0, 0); - break; - case IE_INTR_ENSND: - ledctl(PALED_NETSND, 0, 0); - break; - case IE_INTR_EXIT: - case IE_INTR_LOOP: - fdcache(0, (vaddr_t)ie_mem, IE_SIZE); - break; - } - return 0; -} -#endif - -u_int16_t -ie_gsc_read16(sc, offset) - struct ie_softc *sc; - int offset; -{ - volatile u_int16_t *addr = (volatile u_int16_t *)(sc->bh + offset); - - asm volatile ("fdc %%r0(%%sr0, %0)" :: "r" (addr)); - return *addr; -} - -void -ie_gsc_write16(sc, offset, v) - struct ie_softc *sc; - int offset; - u_int16_t v; -{ - volatile u_int16_t *addr = (volatile u_int16_t *)(sc->bh + offset); - - *addr = v; - asm volatile ("fdc %%r0(%%sr0, %0)" :: "r" (addr)); -} - -void -ie_gsc_write24(sc, offset, v) - struct ie_softc *sc; - int offset; - int v; -{ - volatile u_int16_t *addr = (volatile u_int16_t *)(sc->bh + offset); - - addr[0] = (v ) & 0xffff; - addr[1] = (v >> 16) & 0xffff; - asm volatile ("fdc %%r0(%%sr0, %0)" :: "r" (addr+0)); - asm volatile ("fdc %%r0(%%sr0, %0)" :: "r" (addr+1)); -} - -void -ie_gsc_memcopyin(sc, p, offset, size) - struct ie_softc *sc; - void *p; - int offset; - size_t size; -{ - pdcache(0, sc->bh + offset, size); - bcopy ((void *)((u_long)sc->bh + offset), p, size); -} - -void -ie_gsc_memcopyout(sc, p, offset, size) - struct ie_softc *sc; - const void *p; - int offset; - size_t size; -{ - bcopy (p, (void *)((u_long)sc->bh + offset), size); - fdcache(0, sc->bh + offset, size); -} - -int -ie_gsc_probe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct gsc_attach_args *ga = aux; - - if (ga->ga_type.iodc_type != HPPA_TYPE_FIO || - (ga->ga_type.iodc_sv_model != HPPA_FIO_LAN && - ga->ga_type.iodc_sv_model != HPPA_FIO_GLAN)) - return 0; - - return 1; -} - -void -ie_gsc_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct pdc_lan_station_id pdc_mac PDC_ALIGNMENT; - struct ie_softc *sc = (struct ie_softc *)self; - struct gsc_attach_args *ga = aux; - /*bus_dma_segment_t seg; - int rseg;*/ - int rv; -#ifdef PMAPDEBUG - extern int pmapdebug; - int opmapdebug = pmapdebug; - pmapdebug = 0; -#endif - - sc->iot = sc->bt = ga->ga_iot; - if (bus_space_map(sc->iot, ga->ga_hpa, IOMOD_HPASIZE, 0, &sc->ioh)) { - printf(": can't map IO space\n"); - return; - } - - if (ga->ga_type.iodc_sv_model == HPPA_FIO_GLAN) - sc->sc_flags |= IEGSC_GECKO; - - sc->sc_msize = IE_SIZE; - /* XXX memory must be under 16M until the mi part is fixed */ -#if 0 - if (bus_dmamem_alloc(ga->ga_dmatag, sc->sc_msize, NBPG, 0, - &seg, 1, &rseg, BUS_DMA_NOWAIT)) { - printf (": cannot allocate %d bytes of DMA memory\n", - sc->sc_msize); - return; - } - if (bus_dmamem_map(ga->ga_dmatag, &seg, rseg, sc->sc_msize, - (caddr_t *)&sc->bh, BUS_DMA_NOWAIT)) { - printf (": cannot map DMA memory\n"); - bus_dmamem_free(ga->ga_dmatag, &seg, rseg); - return; - } - - bzero((void *)sc->bh, sc->sc_msize); - sc->sc_maddr = kvtop((caddr_t)sc->bh); - -#else - sc->bh = (u_int)ie_mem; - sc->sc_maddr = sc->bh; -#endif - sc->sysbus = 0x40 | IE_SYSBUS_82586 | IE_SYSBUS_INTLOW | IE_SYSBUS_TRG | IE_SYSBUS_BE; - - sc->do_xmitnopchain = 0; - sc->hwreset = ie_gsc_reset; - sc->chan_attn = ie_gsc_attend; - sc->port = ie_gsc_port; - sc->hwinit = ie_gsc_run; - sc->memcopyout = ie_gsc_memcopyout; - sc->memcopyin = ie_gsc_memcopyin; - sc->ie_bus_read16 = ie_gsc_read16; - sc->ie_bus_write16 = ie_gsc_write16; - sc->ie_bus_write24 = ie_gsc_write24; -#ifdef USELEDS - sc->intrhook = ie_gsc_intrhook; -#else - sc->intrhook = NULL; -#endif - -#ifdef I82596_DEBUG - printf(" mem %x[%p]/%x", sc->bh, sc->sc_maddr, sc->sc_msize); - sc->sc_debug = IED_ALL; -#endif - rv = i82596_probe(sc); - if (!rv) { - /*bus_dmamem_free(ga->ga_dmatag, &seg, sc->sc_msize);*/ - } -#ifdef PMAPDEBUG - pmapdebug = opmapdebug; -#endif - if (!rv) { - printf("\n"); - return; - } - - if (pdc_call((iodcio_t)pdc, 0, PDC_LAN_STATION_ID, - PDC_LAN_STATION_ID_READ, &pdc_mac, ga->ga_hpa) < 0) - bcopy((void *)ASP_PROM, sc->sc_arpcom.ac_enaddr, - ETHER_ADDR_LEN); - else - bcopy(pdc_mac.addr, sc->sc_arpcom.ac_enaddr, ETHER_ADDR_LEN); - - printf(":"); - - sc->iscp = 0; - sc->scp = 32; - sc->scb = 94; - sc->buf_area = 256; - sc->buf_area_sz = sc->sc_msize - sc->buf_area; - sc->sc_type = sc->sc_flags & IEGSC_GECKO? "LASI/i82596CA" : "i82596DX"; - sc->sc_vers = ga->ga_type.iodc_model * 10 + ga->ga_type.iodc_sv_rev; - i82596_attach(sc, sc->sc_type, (char *)sc->sc_arpcom.ac_enaddr, - ie_gsc_media, IE_NMEDIA, ie_gsc_media[0]); - - sc->sc_ih = gsc_intr_establish((struct gsc_softc *)parent, - ga->ga_irq, IPL_NET, i82596_intr, sc, sc->sc_dev.dv_xname); -} diff --git a/sys/arch/hppa/gsc/lpt_gsc.c b/sys/arch/hppa/gsc/lpt_gsc.c deleted file mode 100644 index e6e43be89..000000000 --- a/sys/arch/hppa/gsc/lpt_gsc.c +++ /dev/null @@ -1,187 +0,0 @@ -/* $OpenBSD: lpt_gsc.c,v 1.13 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 1998 Michael Shalayeff - * Copyright (c) 1993, 1994 Charles Hannum. - * Copyright (c) 1990 William F. Jolitz, TeleMuse - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This software is a component of "386BSD" developed by - * William F. Jolitz, TeleMuse. - * 4. Neither the name of the developer nor the name "386BSD" - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS A COMPONENT OF 386BSD DEVELOPED BY WILLIAM F. JOLITZ - * AND IS INTENDED FOR RESEARCH AND EDUCATIONAL PURPOSES ONLY. THIS - * SOFTWARE SHOULD NOT BE CONSIDERED TO BE A COMMERCIAL PRODUCT. - * THE DEVELOPER URGES THAT USERS WHO REQUIRE A COMMERCIAL PRODUCT - * NOT MAKE USE OF THIS WORK. - * - * FOR USERS WHO WISH TO UNDERSTAND THE 386BSD SYSTEM DEVELOPED - * BY WILLIAM F. JOLITZ, WE RECOMMEND THE USER STUDY WRITTEN - * REFERENCES SUCH AS THE "PORTING UNIX TO THE 386" SERIES - * (BEGINNING JANUARY 1991 "DR. DOBBS JOURNAL", USA AND BEGINNING - * JUNE 1991 "UNIX MAGAZIN", GERMANY) BY WILLIAM F. JOLITZ AND - * LYNNE GREER JOLITZ, AS WELL AS OTHER BOOKS ON UNIX AND THE - * ON-LINE 386BSD USER MANUAL BEFORE USE. A BOOK DISCUSSING THE INTERNALS - * OF 386BSD ENTITLED "386BSD FROM THE INSIDE OUT" WILL BE AVAILABLE LATE 1992. - * - * THIS SOFTWARE IS PROVIDED BY THE DEVELOPER ``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 DEVELOPER 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 -#include -#include - -#include -#include -#include -#include - -#include -#include - -#include - -#include - -#define LPTGSC_OFFSET 0x800 - -int lpt_gsc_probe(struct device *, void *, void *); -void lpt_gsc_attach(struct device *, struct device *, void *); - -const struct cfattach lpt_gsc_ca = { - sizeof(struct lpt_softc), lpt_gsc_probe, lpt_gsc_attach -}; - -/* - * Logic: - * 1) You should be able to write to and read back the same value - * to the data port. Do an alternating zeros, alternating ones, - * walking zero, and walking one test to check for stuck bits. - * - * 2) You should be able to write to and read back the same value - * to the control port lower 5 bits, the upper 3 bits are reserved - * per the IBM PC technical reference manuals and different boards - * do different things with them. Do an alternating zeros, alternating - * ones, walking zero, and walking one test to check for stuck bits. - * - * Some printers drag the strobe line down when the are powered off - * so this bit has been masked out of the control port test. - * - * XXX Some printers may not like a fast pulse on init or strobe, I - * don't know at this point, if that becomes a problem these bits - * should be turned off in the mask byte for the control port test. - * - * 3) Set the data and control ports to a value of 0 - */ -int -lpt_gsc_probe(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct gsc_attach_args *ga = aux; - bus_space_handle_t ioh; - bus_addr_t base; - u_int8_t mask, data; - int i, rv; - - if (ga->ga_type.iodc_type != HPPA_TYPE_FIO || - ga->ga_type.iodc_sv_model != HPPA_FIO_CENT) - return 0; - -#ifdef DEBUG -#define ABORT \ - do { \ - printf("lpt_gsc_probe: mask %x data %x failed\n", mask, \ - data); \ - return 0; \ - } while (0) -#else -#define ABORT do { \ - bus_space_unmap(ga->ga_iot, ioh, LPT_NPORTS); \ - return 0; \ - } while (0) -#endif - - base = ga->ga_hpa + LPTGSC_OFFSET; - if (bus_space_map(ga->ga_iot, base, LPT_NPORTS, 0, &ioh)) { - printf("lpt_gsc_probe: cannot map io space\n"); - return 0; - } - - rv = 0; - mask = 0xff; - - data = 0x55; /* Alternating zeros */ - if (!lpt_port_test(ga->ga_iot, ioh, base, lpt_data, data, mask)) - ABORT; - - data = 0xaa; /* Alternating ones */ - if (!lpt_port_test(ga->ga_iot, ioh, base, lpt_data, data, mask)) - ABORT; - - for (i = 0; i < CHAR_BIT; i++) { /* Walking zero */ - data = ~(1 << i); - if (!lpt_port_test(ga->ga_iot, ioh, base, lpt_data, data, mask)) - ABORT; - } - - for (i = 0; i < CHAR_BIT; i++) { /* Walking one */ - data = (1 << i); - if (!lpt_port_test(ga->ga_iot, ioh, base, lpt_data, data, mask)) - ABORT; - } - - bus_space_write_1(ga->ga_iot, ioh, lpt_data, 0); - bus_space_write_1(ga->ga_iot, ioh, lpt_control, 0); - bus_space_unmap(ga->ga_iot, ioh, LPT_NPORTS); - - return 1; -} - -void -lpt_gsc_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct lpt_softc *sc = (void *)self; - struct gsc_attach_args *ga = aux; - bus_addr_t base; - - /* sc->sc_flags |= LPT_POLLED; */ - - sc->sc_state = 0; - sc->sc_iot = ga->ga_iot; - base = ga->ga_hpa + LPTGSC_OFFSET; - if (bus_space_map(ga->ga_iot, base, LPT_NPORTS, 0, &sc->sc_ioh)) { - printf(": cannot map io space\n"); - return; - } - - lpt_attach_common(sc); - - sc->sc_ih = gsc_intr_establish((struct gsc_softc *)parent, - ga->ga_irq, IPL_TTY, lptintr, sc, sc->sc_dev.dv_xname); -} diff --git a/sys/arch/hppa/gsc/mongoose_gsc.c b/sys/arch/hppa/gsc/mongoose_gsc.c deleted file mode 100644 index 0bcbe831e..000000000 --- a/sys/arch/hppa/gsc/mongoose_gsc.c +++ /dev/null @@ -1,95 +0,0 @@ -/* $OpenBSD: mongoose_gsc.c,v 1.2 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2004, Miodrag Vallat. - * - * 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 -#include -#include - -#include -#include - -#include - -#include -#include - -#include -#include - -#include - -void mgattach_gsc(struct device *, struct device *, void *); -int mgmatch_gsc(struct device *, void *, void *); - -const struct cfattach mg_gsc_ca = { - sizeof(struct mongoose_softc), mgmatch_gsc, mgattach_gsc -}; - -int -mgmatch_gsc(struct device *parent, void *cfdata, void *aux) -{ - struct gsc_attach_args *ga = aux; - - if (ga->ga_type.iodc_type != HPPA_TYPE_BHA || - ga->ga_type.iodc_sv_model != HPPA_BHA_WEISA) - return (0); - - return (1); -} - -void -mgattach_gsc(struct device *parent, struct device *self, void *aux) -{ - struct mongoose_softc *sc = (struct mongoose_softc *)self; - struct gsc_attach_args *ga = aux; - bus_space_handle_t ioh; - - sc->sc_bt = ga->ga_iot; - sc->sc_iomap = ga->ga_hpa; - - if (bus_space_map(ga->ga_iot, ga->ga_hpa + MONGOOSE_MONGOOSE, - sizeof(struct mongoose_regs), 0, &ioh) != 0) { - printf(": can't map IO space\n"); - return; - } - sc->sc_regs = (struct mongoose_regs *)ioh; - - if (bus_space_map(ga->ga_iot, ga->ga_hpa + MONGOOSE_CTRL, - sizeof(struct mongoose_ctrl), 0, &ioh) != 0) { - printf(": can't map control registers\n"); - bus_space_unmap(ga->ga_iot, (bus_space_handle_t)sc->sc_regs, - sizeof(struct mongoose_regs)); - return; - } - sc->sc_ctrl = (struct mongoose_ctrl *)ioh; - - if (mgattach_common(sc) != 0) - return; - - sc->sc_ih = gsc_intr_establish((struct gsc_softc *)parent, - ga->ga_irq, IPL_HIGH, mg_intr, sc, sc->sc_dev.dv_xname); -} diff --git a/sys/arch/hppa/gsc/oosiop_gsc.c b/sys/arch/hppa/gsc/oosiop_gsc.c deleted file mode 100644 index fddbf66f1..000000000 --- a/sys/arch/hppa/gsc/oosiop_gsc.c +++ /dev/null @@ -1,172 +0,0 @@ -/* $OpenBSD: oosiop_gsc.c,v 1.4 2022/03/13 08:04:38 mpi Exp $ */ -/* $NetBSD: oosiop_gsc.c,v 1.2 2003/07/15 02:29:25 lukem Exp $ */ - -/* - * Copyright (c) 2001 Matt Fredette. All rights reserved. - * Copyright (c) 2001,2002 Izumi Tsutsui. 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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) 1998 Michael Shalayeff - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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 -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#define OOSIOP_GSC_RESET 0x0000 -#define OOSIOP_GSC_OFFSET 0x0100 - -int oosiop_gsc_match(struct device *, void *, void *); -void oosiop_gsc_attach(struct device *, struct device *, void *); -int oosiop_gsc_intr(void *); - -const struct cfattach oosiop_gsc_ca = { - sizeof(struct oosiop_softc), oosiop_gsc_match, oosiop_gsc_attach -}; - -int -oosiop_gsc_match(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct gsc_attach_args *ga = aux; - - if (ga->ga_type.iodc_type != HPPA_TYPE_FIO || - ga->ga_type.iodc_sv_model != HPPA_FIO_SCSI) - return 0; - - return 1; -} - -void -oosiop_gsc_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct oosiop_softc *sc = (void *)self; - struct gsc_attach_args *ga = aux; - bus_space_handle_t ioh; - - sc->sc_bst = ga->ga_iot; - sc->sc_dmat = ga->ga_dmatag; - if (bus_space_map(sc->sc_bst, ga->ga_hpa, - OOSIOP_GSC_OFFSET + OOSIOP_NREGS, 0, &ioh)) - panic("oosiop_gsc_attach: couldn't map I/O ports"); - if (bus_space_subregion(sc->sc_bst, ioh, - OOSIOP_GSC_OFFSET, OOSIOP_NREGS, &sc->sc_bsh)) - panic("oosiop_gsc_attach: couldn't get chip ports"); - - sc->sc_freq = ga->ga_ca.ca_pdc_iodc_read->filler2[14]; - if (!sc->sc_freq) - sc->sc_freq = 50 * 1000000; - - sc->sc_chip = OOSIOP_700; - sc->sc_id = 7; /* XXX */ - - /* default values */ - sc->sc_scntl0 = OOSIOP_SCNTL0_EPG; - sc->sc_dmode = OOSIOP_DMODE_BL_8; - sc->sc_dwt = 0xff; /* Enable DMA timeout */ - sc->sc_ctest7 = 0; - - /* - * Reset the SCSI subsystem. - */ - bus_space_write_1(sc->sc_bst, ioh, OOSIOP_GSC_RESET, 0); - DELAY(1000); - - /* - * Call common attachment - */ -#ifdef OOSIOP_DEBUG - { - extern int oosiop_debug; - oosiop_debug = -1; - } -#endif /* OOSIOP_DEBUG */ - oosiop_attach(sc); - - (void)gsc_intr_establish((struct gsc_softc *)parent, - ga->ga_irq, IPL_BIO, oosiop_gsc_intr, sc, sc->sc_dev.dv_xname); -} - -/* - * interrupt handler - */ -int -oosiop_gsc_intr(arg) - void *arg; -{ - struct oosiop_softc *sc = arg; - int rv; - - rv = oosiop_intr(sc); - -#ifdef USELEDS - ledctl(PALED_DISK, 0, 0); -#endif - - return (rv); -} diff --git a/sys/arch/hppa/gsc/osiop_gsc.c b/sys/arch/hppa/gsc/osiop_gsc.c deleted file mode 100644 index d30478a6d..000000000 --- a/sys/arch/hppa/gsc/osiop_gsc.c +++ /dev/null @@ -1,193 +0,0 @@ -/* $OpenBSD: osiop_gsc.c,v 1.13 2022/03/13 08:04:38 mpi Exp $ */ -/* $NetBSD: osiop_gsc.c,v 1.6 2002/10/02 05:17:50 thorpej Exp $ */ - -/* - * Copyright (c) 2001 Matt Fredette. All rights reserved. - * Copyright (c) 2001 Izumi Tsutsui. 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``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 AUTHORS 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) 1998 Michael Shalayeff - * 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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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 -#include -#include -#include -#include - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include -/* #include */ - -#define OSIOP_GSC_RESET 0x0000 -#define OSIOP_GSC_OFFSET 0x0100 - -int osiop_gsc_match(struct device *, void *, void *); -void osiop_gsc_attach(struct device *, struct device *, void *); -int osiop_gsc_intr(void *); - -const struct cfattach osiop_gsc_ca = { - sizeof(struct osiop_softc), osiop_gsc_match, osiop_gsc_attach -}; - -int -osiop_gsc_match(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct gsc_attach_args *ga = aux; - - if (ga->ga_type.iodc_type != HPPA_TYPE_FIO || - ga->ga_type.iodc_sv_model != HPPA_FIO_GSCSI) - return 0; - - return 1; -} - -void -osiop_gsc_attach(parent, self, aux) - struct device *parent, *self; - void *aux; -{ - struct osiop_softc *sc = (void *)self; - struct gsc_attach_args *ga = aux; - bus_space_handle_t ioh; - - sc->sc_bst = ga->ga_iot; - sc->sc_dmat = ga->ga_dmatag; - if (bus_space_map(sc->sc_bst, ga->ga_hpa, - OSIOP_GSC_OFFSET + OSIOP_NREGS, 0, &ioh)) - panic("osiop_gsc_attach: couldn't map I/O ports"); - if (bus_space_subregion(sc->sc_bst, ioh, - OSIOP_GSC_OFFSET, OSIOP_NREGS, &sc->sc_reg)) - panic("osiop_gsc_attach: couldn't get chip ports"); - - sc->sc_clock_freq = ga->ga_ca.ca_pdc_iodc_read->filler2[14] / 1000000; - if (!sc->sc_clock_freq) - sc->sc_clock_freq = 50; - - sc->sc_dcntl = OSIOP_DCNTL_EA; - /* XXX set burst mode to 8 words (32 bytes) */ - sc->sc_ctest7 = OSIOP_CTEST7_CDIS; - sc->sc_dmode = OSIOP_DMODE_BL8; /* | OSIOP_DMODE_FC2 */ - sc->sc_flags = 0; - sc->sc_id = 7; /* XXX */ - - /* - * Reset the SCSI subsystem. - */ - bus_space_write_1(sc->sc_bst, ioh, OSIOP_GSC_RESET, 0); - DELAY(1000); - - /* - * Call common attachment - */ -#ifdef OSIOP_DEBUG - { - extern int osiop_debug; - osiop_debug = -1; - } -#endif /* OSIOP_DEBUG */ - osiop_attach(sc); - - (void)gsc_intr_establish((struct gsc_softc *)parent, - ga->ga_irq, IPL_BIO, osiop_gsc_intr, sc, sc->sc_dev.dv_xname); -} - -/* - * interrupt handler - */ -int -osiop_gsc_intr(arg) - void *arg; -{ - struct osiop_softc *sc = arg; - u_int8_t istat; - - /* This is potentially nasty, since the IRQ is level triggered... */ - if (sc->sc_flags & OSIOP_INTSOFF) - return (0); - - istat = osiop_read_1(sc, OSIOP_ISTAT); - - if ((istat & (OSIOP_ISTAT_SIP | OSIOP_ISTAT_DIP)) == 0) - return (0); - - /* Save interrupt details for the back-end interrupt handler */ - sc->sc_sstat0 = osiop_read_1(sc, OSIOP_SSTAT0); - sc->sc_istat = istat; - /* - * Per page 4-18 of the LSI 53C710 Technical Manual, - * "insert a delay equivalent to 12 BCLK periods between - * the reads [of DSTAT and SSTAT0] to ensure that the - * interrupts clear properly." 1 BCLK = 40ns. Pg. 6-10. - */ - DELAY(25); - sc->sc_dstat = osiop_read_1(sc, OSIOP_DSTAT); - - /* Deal with the interrupt */ - osiop_intr(sc); - -#ifdef USELEDS - ledctl(PALED_DISK, 0, 0); -#endif - - return (1); -} diff --git a/sys/arch/hppa/gsc/siop_gsc.c b/sys/arch/hppa/gsc/siop_gsc.c deleted file mode 100644 index 2bff40dd4..000000000 --- a/sys/arch/hppa/gsc/siop_gsc.c +++ /dev/null @@ -1,162 +0,0 @@ -/* $OpenBSD: siop_gsc.c,v 1.5 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 2007 Mark Kettenis - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include -#include -#include - -#include -#include - -#define SIOP_GSC_RESET 0x0000 -#define SIOP_GSC_OFFSET 0x0100 - -int siop_gsc_match(struct device *, void *, void *); -void siop_gsc_attach(struct device *, struct device *, void *); -int siop_gsc_intr(void *); -void siop_gsc_reset(struct siop_common_softc *); - -u_int8_t siop_gsc_r1(void *, bus_space_handle_t, bus_size_t); -u_int16_t siop_gsc_r2(void *, bus_space_handle_t, bus_size_t); -void siop_gsc_w1(void *, bus_space_handle_t, bus_size_t, u_int8_t); -void siop_gsc_w2(void *, bus_space_handle_t, bus_size_t, u_int16_t); - -struct siop_gsc_softc { - struct siop_softc sc_siop; - bus_space_tag_t sc_iot; - bus_space_handle_t sc_ioh; - struct hppa_bus_space_tag sc_bustag; -}; - -const struct cfattach siop_gsc_ca = { - sizeof(struct siop_gsc_softc), siop_gsc_match, siop_gsc_attach -}; - -int -siop_gsc_match(struct device *parent, void *match, void *aux) -{ - struct gsc_attach_args *ga = aux; - - if (ga->ga_type.iodc_type != HPPA_TYPE_FIO || - ga->ga_type.iodc_sv_model != HPPA_FIO_FWSCSI) - return 0; - - return 1; -} - -void -siop_gsc_attach(struct device *parent, struct device *self, void *aux) -{ - struct siop_gsc_softc *sc = (struct siop_gsc_softc *)self; - struct gsc_attach_args *ga = aux; - - sc->sc_iot = ga->ga_iot; - if (bus_space_map(sc->sc_iot, ga->ga_hpa, - IOMOD_HPASIZE, 0, &sc->sc_ioh)) { - printf(": cannot map io space\n"); - return; - } - - sc->sc_bustag = *sc->sc_iot; - sc->sc_bustag.hbt_r1 = siop_gsc_r1; - sc->sc_bustag.hbt_r2 = siop_gsc_r2; - sc->sc_bustag.hbt_w1 = siop_gsc_w1; - sc->sc_bustag.hbt_w2 = siop_gsc_w2; - - sc->sc_siop.sc_c.features = SF_CHIP_PF | SF_CHIP_BE | SF_BUS_WIDE; - sc->sc_siop.sc_c.maxburst = 4; - sc->sc_siop.sc_c.maxoff = 8; - sc->sc_siop.sc_c.clock_div = 3; - sc->sc_siop.sc_c.clock_period = 250; - sc->sc_siop.sc_c.ram_size = 0; - - sc->sc_siop.sc_c.sc_reset = siop_gsc_reset; - sc->sc_siop.sc_c.sc_dmat = ga->ga_dmatag; - - sc->sc_siop.sc_c.sc_rt = &sc->sc_bustag; - bus_space_subregion(sc->sc_iot, sc->sc_ioh, SIOP_GSC_OFFSET, - IOMOD_HPASIZE - SIOP_GSC_OFFSET, &sc->sc_siop.sc_c.sc_rh); - - /* - * Reset the SCSI subsystem. - */ - bus_space_write_1(sc->sc_iot, sc->sc_ioh, SIOP_GSC_RESET, 0); - DELAY(1000); - siop_gsc_reset(&sc->sc_siop.sc_c); - - gsc_intr_establish((struct gsc_softc *)parent, ga->ga_irq, - IPL_BIO, siop_intr, sc, sc->sc_siop.sc_c.sc_dev.dv_xname); - - printf(": NCR53C720 rev %d\n", bus_space_read_1(sc->sc_siop.sc_c.sc_rt, - sc->sc_siop.sc_c.sc_rh, SIOP_CTEST3) >> 4); - - siop_attach(&sc->sc_siop); -} - -void -siop_gsc_reset(struct siop_common_softc *sc) -{ - bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_DCNTL, DCNTL_EA); - bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_CTEST0, CTEST0_EHP); - bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_CTEST4, CTEST4_MUX); - - bus_space_write_1(sc->sc_rt, sc->sc_rh, SIOP_STIME0, - (0xc << STIME0_SEL_SHIFT)); -} - -u_int8_t -siop_gsc_r1(void *v, bus_space_handle_t h, bus_size_t o) -{ - return *(volatile u_int8_t *)(h + (o ^ 3)); -} - -u_int16_t -siop_gsc_r2(void *v, bus_space_handle_t h, bus_size_t o) -{ - if (o == SIOP_SIST0) { - u_int16_t reg; - - reg = siop_gsc_r1(v, h, SIOP_SIST0); - reg |= siop_gsc_r1(v, h, SIOP_SIST1) << 8; - return reg; - } - return *(volatile u_int16_t *)(h + (o ^ 2)); -} - -void -siop_gsc_w1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv) -{ - *(volatile u_int8_t *)(h + (o ^ 3)) = vv; -} - -void -siop_gsc_w2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv) -{ - *(volatile u_int16_t *)(h + (o ^ 2)) = vv; -} diff --git a/sys/arch/hppa/hppa/autoconf.c b/sys/arch/hppa/hppa/autoconf.c deleted file mode 100644 index ffbe9bea8..000000000 --- a/sys/arch/hppa/hppa/autoconf.c +++ /dev/null @@ -1,522 +0,0 @@ -/* $OpenBSD: autoconf.c,v 1.63 2022/09/02 20:06:55 miod Exp $ */ - -/* - * Copyright (c) 1998-2003 Michael Shalayeff - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)autoconf.c 8.4 (Berkeley) 10/1/93 - */ - -#include "pci.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#include - -#include - -#if NPCI > 0 -#include -#include -#endif - -/* device we booted from */ -struct device *bootdv; -void dumpconf(void); - -void (*cold_hook)(int); /* see below */ - -/* - * LED blinking thing - */ -#ifdef USELEDS -#include - -struct timeout heartbeat_tmo; -void heartbeat(void *); -#endif - -#include "cd.h" -#include "sd.h" -#include "st.h" -#include "mpath.h" - -#include -#include -#if NMPATH > 0 -#include -#endif - -#ifdef USELEDS -/* - * turn the heartbeat alive. - * right thing would be to pass counter to each subsequent timeout - * as an argument to heartbeat() incrementing every turn, - * i.e. avoiding the static hbcnt, but doing timeout_set() on each - * timeout_add() sounds ugly, guts of struct timeout looks ugly - * to ponder in even more. - */ -void -heartbeat(v) - void *v; -{ - static u_int hbcnt = 0, ocp_total, ocp_idle; - int toggle, cp_mask, cp_total, cp_idle; - struct schedstate_percpu *spc = &(curcpu()->ci_schedstate); - - timeout_add(&heartbeat_tmo, hz / 16); - - cp_idle = spc->spc_cp_time[CP_IDLE]; - cp_total = spc->spc_cp_time[CP_USER] + spc->spc_cp_time[CP_NICE] + - spc->spc_cp_time[CP_SYS] + spc->spc_cp_time[CP_INTR] + - spc->spc_cp_time[CP_IDLE]; - if (cp_total == ocp_total) - cp_total = ocp_total + 1; - if (cp_idle == ocp_idle) - cp_idle = ocp_idle + 1; - cp_mask = 0xf0 >> (cp_idle - ocp_idle) * 4 / (cp_total - ocp_total); - cp_mask &= 0xf0; - ocp_total = cp_total; - ocp_idle = cp_idle; - /* - * do this: - * - * |~| |~| - * _| |_| |_,_,_,_ - * 0 1 2 3 4 6 7 - */ - toggle = 0; - if (hbcnt++ < 8 && hbcnt & 1) - toggle = PALED_HEARTBEAT; - hbcnt &= 15; - ledctl(cp_mask, - (~cp_mask & 0xf0) | PALED_NETRCV | PALED_NETSND | PALED_DISK, - toggle); -} -#endif - -/* - * This is called by configure to set dumplo and dumpsize. - * Dumps always skip the first CLBYTES of disk space - * in case there might be a disk label stored there. - * If there is extra space, put dump at the end to - * reduce the chance that swapping trashes it. - */ -void -dumpconf(void) -{ - extern int dumpsize; - int nblks, dumpblks; /* size of dump area */ - - if (dumpdev == NODEV || - (nblks = (bdevsw[major(dumpdev)].d_psize)(dumpdev)) == 0) - return; - if (nblks <= ctod(1)) - return; - - dumpblks = cpu_dumpsize(); - if (dumpblks < 0) - return; - dumpblks += ctod(physmem); - - /* If dump won't fit (incl. room for possible label), punt. */ - if (dumpblks > (nblks - ctod(1))) - return; - - /* Put dump at end of partition */ - dumplo = nblks - dumpblks; - - /* dumpsize is in page units, and doesn't include headers. */ - dumpsize = physmem; -} - -void print_devpath(const char *label, struct pz_device *pz); - -void -print_devpath(const char *label, struct pz_device *pz) -{ - int i; - - printf("%s: ", label); - - for (i = 0; i < 6; i++) - if (pz->pz_bc[i] >= 0) - printf("%d/", pz->pz_bc[i]); - - printf("%d.%x", pz->pz_mod, pz->pz_layers[0]); - for (i = 1; i < 6 && pz->pz_layers[i]; i++) - printf(".%x", pz->pz_layers[i]); - - printf(" class=%d flags=%b hpa=0x%x spa=0x%x io=0x%x\n", pz->pz_class, - pz->pz_flags, PZF_BITS, pz->pz_hpa, pz->pz_spa, pz->pz_iodc_io); -} - -struct pdc_memmap pdc_memmap PDC_ALIGNMENT; -struct pdc_sysmap_find pdc_find PDC_ALIGNMENT; -struct pdc_sysmap_addrs pdc_addr PDC_ALIGNMENT; -struct pdc_iodc_read pdc_iodc_read PDC_ALIGNMENT; - -void -pdc_scanbus(struct device *self, struct confargs *ca, int maxmod, - hppa_hpa_t hpa, int cpu_scan) -{ - int start, end, incr, i; - - /* Scan forwards for CPUs, backwards for everything else. */ - if (cpu_scan) { - start = 0; - incr = 1; - end = maxmod; - } else { - start = maxmod - 1; - incr = -1; - end = -1; - } - - for (i = start; i != end; i += incr) { - struct confargs nca; - int error; - - bzero(&nca, sizeof(nca)); - nca.ca_iot = ca->ca_iot; - nca.ca_dmatag = ca->ca_dmatag; - nca.ca_dp.dp_bc[0] = ca->ca_dp.dp_bc[1]; - nca.ca_dp.dp_bc[1] = ca->ca_dp.dp_bc[2]; - nca.ca_dp.dp_bc[2] = ca->ca_dp.dp_bc[3]; - nca.ca_dp.dp_bc[3] = ca->ca_dp.dp_bc[4]; - nca.ca_dp.dp_bc[4] = ca->ca_dp.dp_bc[5]; - nca.ca_dp.dp_bc[5] = ca->ca_dp.dp_mod; - nca.ca_dp.dp_mod = i; - nca.ca_hpamask = ca->ca_hpamask; - nca.ca_naddrs = 0; - nca.ca_hpa = 0; - - if (hpa) { - nca.ca_hpa = hpa + IOMOD_HPASIZE * i; - nca.ca_dp.dp_mod = i; - } else if ((error = pdc_call((iodcio_t)pdc, 0, PDC_MEMMAP, - PDC_MEMMAP_HPA, &pdc_memmap, &nca.ca_dp)) == 0) - nca.ca_hpa = pdc_memmap.hpa; - else if ((error = pdc_call((iodcio_t)pdc, 0, PDC_SYSMAP, - PDC_SYSMAP_HPA, &pdc_memmap, &nca.ca_dp)) == 0) { - struct device_path path; - int im, ia; - - nca.ca_hpa = pdc_memmap.hpa; - - for (im = 0; !(error = pdc_call((iodcio_t)pdc, 0, - PDC_SYSMAP, PDC_SYSMAP_FIND, - &pdc_find, &path, im)) && - pdc_find.hpa != nca.ca_hpa; im++) - ; - - if (!error) - nca.ca_hpasz = pdc_find.size << PGSHIFT; - - if (!error && pdc_find.naddrs) { - nca.ca_naddrs = pdc_find.naddrs; - if (nca.ca_naddrs > 16) { - nca.ca_naddrs = 16; - printf("WARNING: too many (%d) addrs\n", - pdc_find.naddrs); - } - - if (autoconf_verbose) - printf(">> ADDRS:"); - - for (ia = 0; !(error = pdc_call((iodcio_t)pdc, - 0, PDC_SYSMAP, PDC_SYSMAP_ADDR, &pdc_addr, - im, ia + 1)) && ia < nca.ca_naddrs; ia++) { - nca.ca_addrs[ia].addr = pdc_addr.hpa; - nca.ca_addrs[ia].size = - pdc_addr.size << PGSHIFT; - - if (autoconf_verbose) - printf(" 0x%lx[0x%x]", - nca.ca_addrs[ia].addr, - nca.ca_addrs[ia].size); - } - if (autoconf_verbose) - printf("\n"); - } - } - - if (!nca.ca_hpa) - continue; - - if (autoconf_verbose) - printf(">> HPA 0x%lx[0x%x]\n", - nca.ca_hpa, nca.ca_hpasz); - - if ((error = pdc_call((iodcio_t)pdc, 0, PDC_IODC, - PDC_IODC_READ, &pdc_iodc_read, nca.ca_hpa, IODC_DATA, - &nca.ca_type, sizeof(nca.ca_type))) < 0) { - if (autoconf_verbose) - printf(">> iodc_data error %d\n", error); - continue; - } - - nca.ca_pdc_iodc_read = &pdc_iodc_read; - nca.ca_name = hppa_mod_info(nca.ca_type.iodc_type, - nca.ca_type.iodc_sv_model); - - if (autoconf_verbose) { - printf(">> probing: flags %b bc %d/%d/%d/%d/%d/%d ", - nca.ca_dp.dp_flags, PZF_BITS, - nca.ca_dp.dp_bc[0], nca.ca_dp.dp_bc[1], - nca.ca_dp.dp_bc[2], nca.ca_dp.dp_bc[3], - nca.ca_dp.dp_bc[4], nca.ca_dp.dp_bc[5]); - printf("mod %x hpa %lx type %x sv %x\n", - nca.ca_dp.dp_mod, nca.ca_hpa, - nca.ca_type.iodc_type, nca.ca_type.iodc_sv_model); - } - - if (cpu_scan && nca.ca_type.iodc_type == HPPA_TYPE_NPROC && - nca.ca_type.iodc_sv_model == HPPA_NPROC_HPPA) - ncpusfound++; - - if (cpu_scan && - ((nca.ca_type.iodc_type != HPPA_TYPE_NPROC || - nca.ca_type.iodc_sv_model != HPPA_NPROC_HPPA) && - (nca.ca_type.iodc_type != HPPA_TYPE_MEMORY || - nca.ca_type.iodc_sv_model != HPPA_MEMORY_PDEP))) - continue; - - if (!cpu_scan && - ((nca.ca_type.iodc_type == HPPA_TYPE_NPROC && - nca.ca_type.iodc_sv_model == HPPA_NPROC_HPPA) || - (nca.ca_type.iodc_type == HPPA_TYPE_MEMORY && - nca.ca_type.iodc_sv_model == HPPA_MEMORY_PDEP))) - continue; - - config_found_sm(self, &nca, mbprint, mbsubmatch); - } -} - -const struct hppa_mod_info hppa_knownmods[] = { -#include -}; - -const char * -hppa_mod_info(type, sv) - int type, sv; -{ - const struct hppa_mod_info *mi; - static char fakeid[32]; - - for (mi = hppa_knownmods; mi->mi_type >= 0 && - (mi->mi_type != type || mi->mi_sv != sv); mi++); - - if (mi->mi_type < 0) { - snprintf(fakeid, sizeof fakeid, "type %x, sv %x", type, sv); - return fakeid; - } else - return mi->mi_name; -} - -void -device_register(struct device *dev, void *aux) -{ -#if NPCI > 0 - extern struct cfdriver pci_cd; -#endif -#if NCD > 0 || NSD > 0 || NST > 0 - extern struct cfdriver scsibus_cd; -#endif - struct confargs *ca = aux; - static struct device *elder = NULL; - - if (bootdv != NULL) - return; /* We already have a winner */ - -#if NPCI > 0 - if (dev->dv_parent && - dev->dv_parent->dv_cfdata->cf_driver == &pci_cd) { - struct pci_attach_args *pa = aux; - pcireg_t addr; - int reg; - - for (reg = PCI_MAPREG_START; reg < PCI_MAPREG_END; reg += 4) { - addr = pci_conf_read(pa->pa_pc, pa->pa_tag, reg); - if (PCI_MAPREG_TYPE(addr) == PCI_MAPREG_TYPE_IO) - addr = PCI_MAPREG_IO_ADDR(addr); - else - addr = PCI_MAPREG_MEM_ADDR(addr); - - if (addr == (pcireg_t)PAGE0->mem_boot.pz_hpa) { - elder = dev; - break; - } - } - } else -#endif - if (ca->ca_hpa == (hppa_hpa_t)PAGE0->mem_boot.pz_hpa) { - /* - * If hpa matches, the only thing we know is that the - * booted device is either this one or one of its children. - * And the children will not necessarily have the correct - * hpa value. - * Save this elder for now. - */ - elder = dev; - } else if (elder == NULL) { - return; /* not the device we booted from */ - } - - /* - * Unfortunately, we can not match on pz_class vs dv_class on - * older snakes netbooting using the rbootd protocol. - * In this case, we'll end up with pz_class == PCL_RANDOM... - * Instead, trust the device class from what the kernel attached - * now... - */ - switch (dev->dv_class) { - case DV_IFNET: - /* - * Netboot is the top elder - */ - if (elder == dev) { - bootdv = dev; - } - return; - case DV_DISK: - case DV_DULL: - if ((PAGE0->mem_boot.pz_class & PCL_CLASS_MASK) != PCL_RANDOM) - return; - break; - case DV_TAPE: - if ((PAGE0->mem_boot.pz_class & PCL_CLASS_MASK) != PCL_SEQU) - return; - break; - default: - /* No idea what we were booted from, but better ask the user */ - return; - } - - /* - * If control goes here, we are booted from a block device and we - * matched a block device. - * - * We only grok SCSI boot currently. Match on proper device - * hierarchy and unit/lun values. - */ - -#if NCD > 0 || NSD > 0 || NST > 0 - if (dev->dv_parent && - dev->dv_parent->dv_cfdata->cf_driver == &scsibus_cd) { - struct scsi_attach_args *sa = aux; - struct scsi_link *sl = sa->sa_sc_link; - - /* - * sd/st/cd is attached to scsibus which is attached to - * the controller. Hence the grandparent here should be - * the elder. - */ - if (dev->dv_parent->dv_parent != elder) { - return; - } - - /* - * And now check for proper target and lun values - */ - if (sl->target == PAGE0->mem_boot.pz_layers[0] && - sl->lun == PAGE0->mem_boot.pz_layers[1]) { - bootdv = dev; - } - } -#endif -} - -/* - * cpu_configure: - * called at boot time, configure all devices on system - */ -void -cpu_configure(void) -{ - splhigh(); - if (config_rootfound("mainbus", "mainbus") == NULL) - panic("no mainbus found"); - - cpu_intr_init(); - spl0(); - - if (cold_hook) - (*cold_hook)(HPPA_COLD_HOT); - -#ifdef USELEDS - timeout_set(&heartbeat_tmo, heartbeat, NULL); - heartbeat(NULL); -#endif - cold = 0; -} - -void -diskconf(void) -{ - print_devpath("bootpath", &PAGE0->mem_boot); - -#if NMPATH > 0 - if (bootdv != NULL) - bootdv = mpath_bootdv(bootdv); -#endif - - setroot(bootdv, 0, RB_USERREQ); - dumpconf(); -} - -const struct nam2blk nam2blk[] = { - { "vnd", 2 }, - { "rd", 3 }, - { "sd", 4 }, - { "cd", 6 }, - { "fd", 7 }, - { "wd", 8 }, - { NULL, -1 } -}; diff --git a/sys/arch/hppa/hppa/conf.c b/sys/arch/hppa/hppa/conf.c deleted file mode 100644 index 51e9a2837..000000000 --- a/sys/arch/hppa/hppa/conf.c +++ /dev/null @@ -1,278 +0,0 @@ -/* $OpenBSD: conf.c,v 1.75 2022/10/15 10:12:13 jsg Exp $ */ - -/*- - * Copyright (c) 1991 The Regents of the University of California. - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)conf.c 7.9 (Berkeley) 5/28/91 - */ - -#include -#include -#include -#include -#include -#include - -#include - -#include "vnd.h" -#include "rd.h" -#include "sd.h" -#include "st.h" -#include "cd.h" -#include "ch.h" -#include "uk.h" -#include "wd.h" -bdev_decl(wd); -cdev_decl(wd); -#if 0 -#include "fd.h" -#else -#define NFD 0 -#endif -bdev_decl(fd); -cdev_decl(fd); - -struct bdevsw bdevsw[] = -{ - bdev_swap_init(1,sw), /* 0: swap pseudo-device */ - bdev_notdef(), /* 1: was: concatenated disk driver */ - bdev_disk_init(NVND,vnd), /* 2: vnode disk driver */ - bdev_disk_init(NRD,rd), /* 3: RAM disk */ - bdev_disk_init(NSD,sd), /* 4: SCSI disk */ - bdev_notdef(), /* 5: was: SCSI tape */ - bdev_disk_init(NCD,cd), /* 6: SCSI CD-ROM */ - bdev_disk_init(NFD,fd), /* 7: floppy drive */ - bdev_disk_init(NWD,wd), /* 8: ST506 drive */ - bdev_notdef(), /* 9: */ - bdev_notdef(), /* 10: */ - bdev_notdef(), /* 11: */ - bdev_notdef(), /* 12: */ - bdev_notdef(), /* 13: */ - bdev_notdef(), /* 14: */ -}; -int nblkdev = nitems(bdevsw); - -#include "audio.h" -#include "video.h" -#include "bio.h" -#include "pty.h" -#include "wsdisplay.h" -#include "wskbd.h" -#include "wsmouse.h" -#include "wsmux.h" - -#include "bpfilter.h" -#include "tun.h" - -#include "ksyms.h" -#include "kstat.h" - -#include "lpt.h" -cdev_decl(lpt); - -#include "com.h" -cdev_decl(com); - -#include "dt.h" -#include "pf.h" - -#include "hotplug.h" -#include "vscsi.h" -#include "pppx.h" - -#ifdef USER_PCICONF -#include "pci.h" -cdev_decl(pci); -#endif - -#include "usb.h" -#include "uhid.h" -#include "fido.h" -#include "ujoy.h" -#include "ugen.h" -#include "ulpt.h" -#include "ucom.h" - -#include "fuse.h" - -struct cdevsw cdevsw[] = -{ - cdev_cn_init(1,cn), /* 0: virtual console */ - cdev_ctty_init(1,ctty), /* 1: controlling terminal */ - cdev_mm_init(1,mm), /* 2: /dev/{null,mem,kmem,...} */ - cdev_notdef(), /* 3 was /dev/drum */ - cdev_tty_init(NPTY,pts), /* 4: pseudo-tty slave */ - cdev_ptc_init(NPTY,ptc), /* 5: pseudo-tty master */ - cdev_log_init(1,log), /* 6: /dev/klog */ - cdev_notdef(), /* 7: was: concatenated disk */ - cdev_disk_init(NVND,vnd), /* 8: vnode disk driver */ - cdev_disk_init(NRD,rd), /* 9: RAM disk */ - cdev_disk_init(NSD,sd), /* 10: SCSI disk */ - cdev_tape_init(NST,st), /* 11: SCSI tape */ - cdev_disk_init(NCD,cd), /* 12: SCSI cd-rom */ - cdev_ch_init(NCH,ch), /* 13: SCSI changer */ - cdev_notdef(), /* 14: */ - cdev_uk_init(NUK,uk), /* 15: SCSI unknown */ - cdev_fd_init(1,filedesc), /* 16: file descriptor pseudo-device */ - cdev_bpf_init(NBPFILTER,bpf), /* 17: Berkeley packet filter */ - cdev_tun_init(NTUN,tun), /* 18: network tunnel */ - cdev_notdef(), /* 19: was LKM */ - cdev_random_init(1,random), /* 20: random generator */ - cdev_pf_init(NPF,pf), /* 21: packet filter */ - cdev_tty_init(1,pdc), /* 22: PDC device */ - cdev_tty_init(NCOM,com), /* 23: RS232 */ - cdev_disk_init(NFD,fd), /* 24: floppy drive */ - cdev_ksyms_init(NKSYMS,ksyms), /* 25: Kernel symbols device */ - cdev_lpt_init(NLPT,lpt), /* 26: parallel printer */ - cdev_wsdisplay_init(NWSDISPLAY, /* 27: workstation console */ - wsdisplay), - cdev_mouse_init(NWSKBD,wskbd), /* 28: keyboards */ - cdev_mouse_init(NWSMOUSE,wsmouse), /* 29: mice */ - cdev_mouse_init(NWSMUX,wsmux), /* 30: mux */ -#ifdef USER_PCICONF - cdev_pci_init(NPCI,pci), /* 31: PCI user */ -#else - cdev_notdef(), /* 31: */ -#endif - cdev_dt_init(NDT,dt), /* 32: dynamic tracer */ - cdev_video_init(NVIDEO,video), /* 33: generic video I/O */ - cdev_notdef(), /* 34 */ - cdev_audio_init(NAUDIO,audio), /* 35: /dev/audio */ - cdev_notdef(), /* 36: was: /dev/crypto */ - cdev_bio_init(NBIO,bio), /* 37: ioctl tunnel */ - cdev_ptm_init(NPTY,ptm), /* 38: pseudo-tty ptm device */ - cdev_disk_init(NWD,wd), /* 39: ST506 disk */ - cdev_usb_init(NUSB,usb), /* 40: USB controller */ - cdev_usbdev_init(NUHID,uhid), /* 41: USB generic HID */ - cdev_usbdev_init(NUGEN,ugen), /* 42: USB generic driver */ - cdev_ulpt_init(NULPT,ulpt), /* 43: USB printers */ - cdev_notdef(), /* 44: was urio */ - cdev_tty_init(NUCOM,ucom), /* 45: USB tty */ - cdev_notdef(), /* 46: was USB scanners */ - cdev_hotplug_init(NHOTPLUG,hotplug), /* 47: devices hot plugging */ - cdev_notdef(), /* 48: */ - cdev_notdef(), /* 49: */ - cdev_notdef(), /* 50: */ - cdev_kstat_init(NKSTAT,kstat), /* 51: kernel statistics */ - cdev_notdef(), /* 52: */ - cdev_notdef(), /* 53: */ - cdev_vscsi_init(NVSCSI,vscsi), /* 54: vscsi */ - cdev_notdef(), - cdev_disk_init(1,diskmap), /* 56: disk mapper */ - cdev_pppx_init(NPPPX,pppx), /* 57: pppx */ - cdev_fuse_init(NFUSE,fuse), /* 58: fuse */ - cdev_tun_init(NTUN,tap), /* 59: Ethernet network tunnel */ - cdev_notdef(), /* 60: was switch(4) */ - cdev_fido_init(NFIDO,fido), /* 61: FIDO/U2F security key */ - cdev_pppx_init(NPPPX,pppac), /* 62: PPP Access Concentrator */ - cdev_ujoy_init(NUJOY,ujoy), /* 63: USB joystick/gamecontroller */ -}; -int nchrdev = nitems(cdevsw); - -int mem_no = 2; /* major device number of memory special file */ - -/* - * Swapdev is a fake device implemented - * in sw.c used only internally to get to swstrategy. - * It cannot be provided to the users, because the - * swstrategy routine munches the b_dev and b_blkno entries - * before calling the appropriate driver. This would horribly - * confuse, e.g. the hashing routines. Instead, /dev/drum is - * provided as a character (raw) device. - */ -dev_t swapdev = makedev(0, 0); - -const int chrtoblktbl[] = { - /*VCHR*/ /*VBLK*/ - /* 0 */ NODEV, - /* 1 */ NODEV, - /* 2 */ NODEV, - /* 3 */ NODEV, - /* 4 */ NODEV, - /* 5 */ NODEV, - /* 6 */ NODEV, - /* 7 */ NODEV, - /* 8 */ 2, /* vnd */ - /* 9 */ 3, /* rd */ - /* 10 */ 4, /* sd */ - /* 11 */ NODEV, - /* 12 */ 6, /* cd */ - /* 13 */ NODEV, - /* 14 */ NODEV, - /* 15 */ NODEV, - /* 16 */ NODEV, - /* 17 */ NODEV, - /* 18 */ NODEV, - /* 19 */ NODEV, - /* 20 */ NODEV, - /* 21 */ NODEV, - /* 22 */ NODEV, - /* 23 */ NODEV, - /* 24 */ 7, /* fd */ - /* 25 */ NODEV, - /* 26 */ NODEV, - /* 27 */ NODEV, - /* 28 */ NODEV, - /* 29 */ NODEV, - /* 30 */ NODEV, - /* 31 */ NODEV, - /* 32 */ NODEV, - /* 33 */ NODEV, - /* 34 */ NODEV, - /* 35 */ NODEV, - /* 36 */ NODEV, - /* 37 */ NODEV, - /* 38 */ NODEV, - /* 39 */ 8, /* wd */ -}; -const int nchrtoblktbl = nitems(chrtoblktbl); - -/* - * Returns true if dev is /dev/zero. - */ -int -iszerodev(dev_t dev) -{ - return (major(dev) == mem_no && minor(dev) == 12); -} - -dev_t -getnulldev(void) -{ - return makedev(mem_no, 2); -} - -/* - * Returns true if dev is /dev/mem or /dev/kmem. - */ -int -iskmemdev(dev_t dev) -{ - return (major(dev) == mem_no && minor(dev) < 2); -} diff --git a/sys/arch/hppa/hppa/db_disasm.c b/sys/arch/hppa/hppa/db_disasm.c deleted file mode 100644 index d7b17c9a8..000000000 --- a/sys/arch/hppa/hppa/db_disasm.c +++ /dev/null @@ -1,2359 +0,0 @@ -/* $OpenBSD: db_disasm.c,v 1.24 2023/01/31 15:18:54 deraadt Exp $ */ - -/* TODO parse 64bit insns or rewrite */ - -/* - * Copyright (c) 1999,2005 Michael Shalayeff - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -/* - * (c) Copyright 1992 HEWLETT-PACKARD COMPANY - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of Hewlett-Packard Company not be - * used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Hewlett-Packard Company makes no representations about the - * suitability of this software for any purpose. - */ - -/* - * unasm.c -- HP_PA Instruction Printer - */ - -#include -#include - -#include -#include -#include -#include -#include - - -/* IMPORTANT NOTE: - * All modules using this header may assume that the datatype "int" is a - * 32-bit (or > 32-bit) signed quantity. - */ - - -/* Spectrum Architecturally Defined Datatypes */ -struct doubleword { - int wd0; - int wd1; -}; - -struct quadword { - struct doubleword d0; - struct doubleword d1; -}; - - /* datatypes for halfword and byte fields of a word are defined - * in ssBits.h */ - -/* Memory addressing datatypes */ -typedef unsigned int SID, /* range [0..MAXSID] */ - PGID, /* range [0..MAXPGID] */ - OFS, /* range [0..MAXINT] */ - REALADR; /* range [0..MAXINT] */ - - -/* data sizes */ -enum datasize { Byte, Halfword, Word, Doubleword, Quadword, Variable }; - -/* Miscellaneous datatypes */ -typedef unsigned int FLAGS; - -/* struct for entry in unwind table */ -struct ute { - int word1; - int word2; - int word3; - int word4; -}; -/* - * Header: /n/schirf/u/baford/CVS/mach4-parisc/kernel_unused/parisc/kdb/unasm.c,v 1.5 1994/07/21 22:32:05 mike Exp - * - * Spectrum Instruction Set Condition Completer Bit Assignments - * Dan Magenheimer - 6/14/82 - * Terrence Miller - 6/21/82 - * Computer Research Center, Hewlett-Packard Labs - * - * (c) copyright 1982 - * (p) protected 1982 - * The Hewlett-Packard Company - * Hewlett-Packard Laboratories - * Computer Research Center - * Palo Alto, California - * - * *** HP Company Confidential *** - * - * Log: unasm.c,v - * Revision 1.5 1994/07/21 22:32:05 mike - * official HP copyright notice - * - * Revision 1.4 1992/07/08 12:19:52 dalton - * Checkin before split to 1.0.4 release (by LBS). - * - * Revision 1.3 92/06/06 16:16:45 dalton - * *** empty log message *** - * - * Revision 1.2 92/06/06 15:42:28 dalton - * Changed include to be a path relative to hp800. - * - * Revision 1.1 92/06/06 14:05:33 dalton - * Initial revision - * - * Revision 1.2 91/04/14 20:29:49 osfrcs - * Initial version. - * [91/03/30 09:20:34 brezak] - * - * Revision 1.1.2.2 91/04/02 10:42:50 brezak - * Initial version. - * [91/03/30 09:20:34 brezak] - * - * Revision 1.1.1.2 91/03/30 09:20:34 brezak - * Initial version. - * - * Revision 1.1 88/07/11 14:05:15 14:05:15 ren (Bob Naas) - * Initial revision - * - * Revision 5.2 87/07/02 14:45:57 14:45:57 kent (Kent McMullen) - * added constants to support addDasm and addDCond added to ssDID.c - * - * Revision 5.1 87/02/27 11:12:08 11:12:08 kent (Kent McMullen) - * update all src to 5.1 - * - * Revision 5.0 87/02/18 16:31:15 16:31:15 kent (Kent McMullen) - * update all revision numbers to 5.0 for release - * - * Revision 1.1 86/07/15 08:34:55 08:34:55 kent (Kent McMullen) - * Initial revision - * - * Revision 4.1 83/10/25 17:01:22 17:01:22 djm (Daniel J Magenheimer) - * First release for ACD v4 - * - * Revision 3.0 83/06/13 10:22:59 djm (Daniel Magenheimer) - * First release for distribution - * - * - */ - - -/* Arithmetic/Logical Conditions */ -#define NEV 0x0 -#define EQZ 0x2 -#define LT 0x4 -#define LE 0x6 -#define LLT 0x8 -#define NUV 0x8 -#define LLE 0xA -#define ZNV 0xA -#define SV 0xC -#define OD 0xE -#define TR 0x1 -#define NEQZ 0x3 -#define GE 0x5 -#define GT 0x7 -#define LGE 0x9 -#define UV 0x9 -#define LGT 0xB -#define VNZ 0xB -#define NSV 0xD -#define EV 0xF - -/* unit conditions */ -#define SBZ 0x4 -#define SHZ 0x6 -#define SDC 0x8 -#define SBC 0xC -#define SHC 0xE -#define NBZ 0x5 -#define NHZ 0x7 -#define NDC 0x9 -#define NBC 0xD -#define NHC 0xF - -/*field conditions */ -#define XEQ 0x1 -#define XLT 0x2 -#define XOD 0x3 -#define XTR 0x4 -#define XNE 0x5 -#define XGE 0x6 -#define XEV 0x7 - - - -/* - * These macros are designed to be portable to all machines that have - * a wordsize greater than or equal to 32 bits that support the portable - * C compiler and the standard C preprocessor. Wordsize (default 32) - * and bitfield assignment (default left-to-right, unlike VAX, PDP-11) - * should be predefined using the constants HOSTWDSZ and BITFRL and - * the C compiler "-D" flag (e.g., -DHOSTWDSZ=36 -DBITFLR for the DEC-20). - * Note that the macro arguments assume that the integer being referenced - * is a 32-bit integer (right-justified on the 20) and that bit 0 is the - * most significant bit. - */ - -#ifndef HOSTWDSZ -#define HOSTWDSZ 32 -#endif - -#ifdef vax -#ifndef BITFLR -#define BITFRL -#endif -#else -#define BITFLR -#endif - -/*########################### Macros ######################################*/ - -/*--------------------------------------------------------------------------- - * DeclareBitfield$Reference - Declare a structure to be used to reference - * a specified bitfield within an integer (using BitfR, see below). - * The argument "n" must be an identifier name not used elsewhere in the - * program , "s" and "l" must (alas!) be constants. (Suggestion: if - * "s" == 2 and "l" == 8, use _b28 for "n".) The name "BITFLR" should - * be pre-defined if the compiler assigns bitfields from left-to-right. - * The resultant macro expansion defines a structure in which the bit field - * starting at position "s" with length "l" may be referenced by accessing - * member "n". [Note: The leftmost bits in a 36-bit word may be accessed - * by specifying -4 <= s < 0 on the DEC-20.] - *---------------------------------------------------------------------------*/ - -#ifdef BITFRL -#define DeclBitfR(s,l,n) struct n { int:(HOSTWDSZ-(s)-(l)); unsigned n:l;}; -#else -#define DeclBitfR(s,l,n) struct n { int:((s)+(HOSTWDSZ-32)); unsigned n:l;}; -#endif - -/*--------------------------------------------------------------------------- - * Bitfield$Reference - Reference a specified bitfield within an integer. - * The argument "i" must be an addressable variable (i.e., not a register - * variable or an expression... but see BitfX below), "n" must be an - * identifier name declared in a DeclBitfR invocation. The resultant - * macro expansion references the bit field in "i" described by the - * DeclBitfR invocation with the same name ("n"). BitfR may be used as - * an lvalue or an rvalue. (i.e., either side of an assignment statement) - * The "s" and "l" arguments are historical and are now unused. (They - * correspond to the "s" and "l" arguments in DeclBitfR) - * Translates to a single instruction on both the VAX and the DEC-20. - *---------------------------------------------------------------------------*/ -#define BitfR(i,s,l,n) (((struct n *)&i)->n) - -/*--------------------------------------------------------------------------- - * Bitfield$eXtract - Extract the specified field from an integer. Arguments - * are the same as for BitfR (except no "n"), however both "s" and "l" need - * no longer be constants. May only be used as an rvalue. Translates to - * two instructions on the VAX, three on the DEC-20. - *---------------------------------------------------------------------------*/ - -#define BitfX(i,s,l) (((i) >> (32-(s)-(l))) & ((1 << (l)) - 1)) - - -/*--------------------------------------------------------------------------- - * Mask$32bits - Mask the low order 32 bits of passed word. No-op on 32 - * bit machines. - *---------------------------------------------------------------------------*/ - -#if HOSTWDSZ > 32 -#define Mask32(x) ((x) & 0xffffffff) -#else -#define Mask32(x) (x) -#endif - - -/*--------------------------------------------------------------------------- - * SignExtend$32bits - Force the high-order bits in machines with wordsize - * longer than 32 to match bit 0. - *---------------------------------------------------------------------------*/ - -#if HOSTWDSZ > 32 -#define SignEx32(x) (((x) & 0x80000000) ? ((x) | ((unsigned)-1 << 32)) \ - : Mask32(x)) -#else -#define SignEx32(x) (x) -#endif - -/**************************/ -/* bit field declarations */ -/**************************/ - -/* since the compiler complains if a structure name is declared twice, even - * if the declarations are identical, all DeclBitfR invocations are - * given here in one file. */ - -DeclBitfR(0,1,_b01) -DeclBitfR(0,15,_b015) -DeclBitfR(0,16,_b016) -DeclBitfR(0,4,_b04) -DeclBitfR(0,6,_b06) -DeclBitfR(0,8,_b08) -DeclBitfR(4,1,_b41) -DeclBitfR(4,4,_b44) -DeclBitfR(6,1,_b61) -DeclBitfR(6,13,_b613) -DeclBitfR(6,15,_b615) -DeclBitfR(6,17,_b617) -DeclBitfR(6,26,_b626) -DeclBitfR(6,5,_b65) -DeclBitfR(7,1,_b71) -DeclBitfR(8,1,_b81) -DeclBitfR(8,4,_b84) -DeclBitfR(8,8,_b88) -DeclBitfR(9,1,_b91) -DeclBitfR(10,1,_b101) -DeclBitfR(11,1,_b111) -DeclBitfR(11,10,_b1110) -DeclBitfR(11,4,_b114) -DeclBitfR(11,5,_b115) -DeclBitfR(12,1,_b121) -DeclBitfR(12,4,_b124) -DeclBitfR(13,1,_b131) -DeclBitfR(14,1,_b141) -DeclBitfR(15,1,_b151) -DeclBitfR(16,1,_b161) -DeclBitfR(16,15,_b1615) -DeclBitfR(16,16,_b1616) -DeclBitfR(16,2,_b162) -DeclBitfR(16,3,_b163) -DeclBitfR(16,4,_b164) -DeclBitfR(16,5,_b165) -DeclBitfR(16,8,_b168) -DeclBitfR(17,1,_b171) -DeclBitfR(18,1,_b181) -DeclBitfR(18,13,_b1813) -DeclBitfR(18,2,_b182) -DeclBitfR(18,7,_b187) -DeclBitfR(19,1,_b191) -DeclBitfR(19,8,_b198) -DeclBitfR(19,10,_b1910) -DeclBitfR(20,11,_b2011) -DeclBitfR(20,2,_b202) -DeclBitfR(20,4,_b204) -DeclBitfR(21,10,_b2110) -DeclBitfR(21,2,_b212) -DeclBitfR(21,5,_b215) -DeclBitfR(22,5,_b225) -DeclBitfR(23,3,_b233) -DeclBitfR(24,1,_b241) -DeclBitfR(24,4,_b244) -DeclBitfR(24,8,_b248) -DeclBitfR(25,1,_b251) -DeclBitfR(26,1,_b261) -DeclBitfR(27,1,_b271) -DeclBitfR(27,4,_b274) -DeclBitfR(27,5,_b275) -DeclBitfR(28,1,_b281) -DeclBitfR(28,4,_b284) -DeclBitfR(29,1,_b291) -DeclBitfR(30,1,_b301) -DeclBitfR(30,2,_b302) -DeclBitfR(31,1,_b311) - -/******************/ -/* Word subfields */ -/******************/ - -#define Sign(i) BitfR(i,0,1,_b01) -/* halfwords */ -#define Hwd0(i) BitfR(i,0,16,_b016) -#define Hwd1sign(i) BitfR(i,16,1,_b161) -#define Hwd1(i) BitfR(i,16,16,_b1616) -/* bytes */ -#define Byte0(i) BitfR(i,0,8,_b08) -#define Byte1sign(i) BitfR(i,8,1,_b81) -#define Byte1(i) BitfR(i,8,8,_b88) -#define Byte2(i) BitfR(i,16,8,_b168) -#define Byte3sign(i) BitfR(i,24,1,_b241) -#define Byte3(i) BitfR(i,24,8,_b248) -/* digits */ -#define Digit0(i) BitfR(i,0,4,_b04) -#define Digit1(i) BitfR(i,4,4,_b44) -#define Digit2(i) BitfR(i,8,4,_b84) -#define Digit3(i) BitfR(i,12,4,_b124) -#define Digit4(i) BitfR(i,16,4,_b164) -#define Digit5(i) BitfR(i,20,4,_b204) -#define Digit6(i) BitfR(i,24,4,_b244) -#define Digit7(i) BitfR(i,28,4,_b284) - -/* Wordsize definitions */ - -#define BIT_P_DW 64 /* bits/doubleword */ -#define BIT_P_WD 32 /* bits/word */ -#define BIT_P_HW 16 /* bits/halfword */ -#define BIT_P_BYT 8 /* bits/byte */ -#define BYT_P_DW 8 /* bytes/doubleword */ -#define BYT_P_WD 4 /* bytes/word */ -#define BYT_P_HW 2 /* bytes/halfword */ - -/* Masks */ - -#define WDMASK 0xffffffff /* 32-bit mask */ -#define OFSMASK 0xffffffff /* 32-bit mask */ -#define SIDMASK 0xffffffff /* 32-bit mask */ -#define SIGNMASK 0x80000000 /* 32 bit word sign bit */ - -/* Alignments */ - -#define wdalign(ofs) (ofs &= ~3) -/* - * Header: /n/schirf/u/baford/CVS/mach4-parisc/kernel_unused/parisc/kdb/unasm.c,v 1.5 1994/07/21 22:32:05 mike Exp - * - * Spectrum Simulator Instruction Opcode Definitions - * Dan Magenheimer - * Computer Research Center, Hewlett-Packard Labs - * - * (c) copyright 1982 - * (p) protected 1982 - * The Hewlett-Packard Company - * Hewlett-Packard Laboratories - * Computer Research Center - * Palo Alto, California - * - * *** HP Company Confidential *** - * - * Log: unasm.c,v - * Revision 1.5 1994/07/21 22:32:05 mike - * official HP copyright notice - * - * Revision 1.4 1992/07/08 12:19:52 dalton - * Checkin before split to 1.0.4 release (by LBS). - * - * Revision 1.3 92/06/06 16:16:45 dalton - * *** empty log message *** - * - * Revision 1.2 92/06/06 15:42:28 dalton - * Changed include to be a path relative to hp800. - * - * Revision 1.1 92/06/06 14:05:33 dalton - * Initial revision - * - * Revision 1.2 91/04/14 20:29:49 osfrcs - * Initial version. - * [91/03/30 09:20:34 brezak] - * - * Revision 1.1.2.2 91/04/02 10:42:50 brezak - * Initial version. - * [91/03/30 09:20:34 brezak] - * - * Revision 1.1.1.2 91/03/30 09:20:34 brezak - * Initial version. - * - * Revision 6.1 89/09/06 10:39:58 burroughs - * Added shadow registers for gr0-gr7. - * gr0-7 are copied into sh0-7 whenever a trap occurs - * the instruction RFIR restores gr0-7 from sh0-7 and returns from - * interrupt. - * the "sh" command displays the shadow registers - * = sh7 0x789 works, too. - * - * Revision 6.0 89/09/01 15:46:37 15:46:37 burroughs (Greg Burroughs) - * baseline for pcx simple offsite - * - * Revision 5.2 87/09/02 14:30:23 14:30:23 kent - * separated stat gathering for indexed vs short. - * this will NOT work if cache hints ever get used - * since this field was assumed always zero - * - * Revision 5.1 87/02/27 11:12:16 11:12:16 kent (Kent McMullen) - * update all src to 5.1 - * - * Revision 5.0 87/02/18 16:31:35 16:31:35 kent (Kent McMullen) - * update all revision numbers to 5.0 for release - * - * Revision 1.1 86/07/15 08:34:57 08:34:57 kent (Kent McMullen) - * Initial revision - * - * Revision 4.1 83/10/25 17:02:34 17:02:34 djm (Daniel J Magenheimer) - * First release for ACD v4 - * - * Revision 3.0 83/06/13 10:24:45 djm (Daniel Magenheimer) - * First release for distribution - * - * - */ - -/* - * Changes: - * 01/30/90 ejf Simplify SPOPn support, now only gives assist emulation trap. - * 01/19/90 ejf Replace linpak instructions with just FSTQ[SX]. - * 12/19/89 ejf Add PA89 new floating point opcode 0E. - * 12/18/89 ejf Change 5 ops to PA89 format. - * 12/01/89 ejf Move additional instructions fmas, fmaa, fld2, fst2 to ssILst - * 09/22/89 ejf Fix unbalanced comments. - */ - - -/* ..and modified by hand to remove the load/store short references */ -/* ..and modified by hand to make memory management ops conform to the - * requirement that all subops of a major opcode begin in the same - * place and have the same length */ - -#define LDW 0x12, 0x00, 0, 0 /* LOAD WORD */ -#define LDWM 0x13, 0x00, 0, 0 /* LOAD WORD and MODIFY */ -#define LDH 0x11, 0x00, 0, 0 /* LOAD HALFWORD */ -#define LDB 0x10, 0x00, 0, 0 /* LOAD BYTE */ -#define LDO 0x0d, 0x00, 0, 0 /* LOAD OFFSET */ -#define STW 0x1a, 0x00, 0, 0 /* STORE WORD */ -#define STWM 0x1b, 0x00, 0, 0 /* STORE WORD and MODIFY */ -#define STH 0x19, 0x00, 0, 0 /* STORE HALFWORD */ -#define STB 0x18, 0x00, 0, 0 /* STORE BYTE */ -#define LDWX 0x03, 0x02, 19, 7 /* LOAD WORD INDEXED */ -#define LDHX 0x03, 0x01, 19, 7 /* LOAD HALFWORD INDEXED */ -#define LDBX 0x03, 0x00, 19, 7 /* LOAD BYTE INDEXED */ -#define LDWAX 0x03, 0x06, 19, 7 /* LOAD WORD ABSOLUTE INDEXED */ -#define LDCWX 0x03, 0x07, 19, 7 /* LOAD and CLEAR WORD INDEXED */ -#define LDWS 0x03, 0x42, 19, 7 /* LOAD WORD SHORT DISP */ -#define LDHS 0x03, 0x41, 19, 7 /* LOAD HALFWORD SHORT DISP */ -#define LDBS 0x03, 0x40, 19, 7 /* LOAD BYTE SHORT DISP */ -#define LDWAS 0x03, 0x46, 19, 7 /* LOAD WORD ABSOLUTE SHORT DISP */ -#define LDCWS 0x03, 0x47, 19, 7 /* LOAD and CLEAR WORD SHORT DISP */ -#define STWS 0x03, 0x4a, 19, 7 /* STORE WORD SHORT DISP */ -#define STHS 0x03, 0x49, 19, 7 /* STORE HALFWORD SHORT DISP */ -#define STBS 0x03, 0x48, 19, 7 /* STORE BYTE SHORT DISP */ -#define STWAS 0x03, 0x4e, 19, 7 /* STORE WORD ABSOLUTE SHORT DISP */ -#define STBYS 0x03, 0x4c, 19, 7 /* STORE BYTES SHORT DISP */ -#define LDIL 0x08, 0x00, 0, 0 /* LOAD IMMED LEFT */ -#define ADDIL 0x0a, 0x00, 0, 0 /* ADD IMMED LEFT */ -#define BL 0x3a, 0x00, 16, 3 /* BRANCH [and LINK] */ -#define GATE 0x3a, 0x01, 16, 3 /* GATEWAY */ -#define BLR 0x3a, 0x02, 16, 3 /* BRANCH and LINK REGISTER */ -#define BV 0x3a, 0x06, 16, 3 /* BRANCH VECTORED */ -#define BE 0x38, 0x00, 0, 0 /* BRANCH EXTERNAL */ -#define BLE 0x39, 0x00, 0, 0 /* BRANCH and LINK EXTERNAL */ -#define MOVB 0x32, 0x00, 0, 0 /* MOVE and BRANCH */ -#define MOVIB 0x33, 0x00, 0, 0 /* MOVE IMMED and BRANCH */ -#define COMBT 0x20, 0x00, 0, 0 /* COMPARE and BRANCH if TRUE */ -#define COMBF 0x22, 0x00, 0, 0 /* COMPARE and BRANCH if FALSE */ -#define COMIBT 0x21, 0x00, 0, 0 /* COMPARE IMMED and BRANCH if TRUE */ -#define COMIBF 0x23, 0x00, 0, 0 /* COMPARE IMMED and BRANCH if FALSE */ -#define ADDBT 0x28, 0x00, 0, 0 /* ADD and BRANCH if TRUE */ -#define ADDBF 0x2a, 0x00, 0, 0 /* ADD and BRANCH if FALSE */ -#define ADDIBT 0x29, 0x00, 0, 0 /* ADD IMMED and BRANCH if TRUE */ -#define ADDIBF 0x2b, 0x00, 0, 0 /* ADD IMMED and BRANCH if FALSE */ -#define BVB 0x30, 0x00, 0, 0 /* BRANCH on VARIABLE BIT */ -#define BB 0x31, 0x00, 0, 0 /* BRANCH on BIT */ -#define ADD 0x02, 0x30, 20, 7 /* ADD */ -#define ADDL 0x02, 0x50, 20, 7 /* ADD LOGICAL */ -#define ADDO 0x02, 0x70, 20, 7 /* ADD and TRAP on OVFLO */ -#define SH1ADD 0x02, 0x32, 20, 7 /* SHIFT 1, ADD */ -#define SH1ADDL 0x02, 0x52, 20, 7 /* SHIFT 1, ADD LOGICAL */ -#define SH1ADDO 0x02, 0x72, 20, 7 /* SHIFT 1, ADD and TRAP on OVFLO */ -#define SH2ADD 0x02, 0x34, 20, 7 /* SHIFT 2, ADD */ -#define SH2ADDL 0x02, 0x54, 20, 7 /* SHIFT 2, ADD LOGICAL */ -#define SH2ADDO 0x02, 0x74, 20, 7 /* SHIFT 2, ADD and TRAP on OVFLO */ -#define SH3ADD 0x02, 0x36, 20, 7 /* SHIFT 3, ADD */ -#define SH3ADDL 0x02, 0x56, 20, 7 /* SHIFT 3, ADD LOGICAL */ -#define SH3ADDO 0x02, 0x76, 20, 7 /* SHIFT 3, ADD and TRAP on OVFLO */ -#define ADDC 0x02, 0x38, 20, 7 /* ADD with CARRY */ -#define ADDCO 0x02, 0x78, 20, 7 /* ADD with CARRY and TRAP on OVFLO */ -#define SUB 0x02, 0x20, 20, 7 /* SUBTRACT */ -#define SUBO 0x02, 0x60, 20, 7 /* SUBTRACT and TRAP on OVFLO */ -#define SUBB 0x02, 0x28, 20, 7 /* SUBTRACT with BORROW */ -#define SUBBO 0x02, 0x68, 20, 7 /* SUBTRACT with BORROW and TRAP on OVFLO */ -#define SUBT 0x02, 0x26, 20, 7 /* SUBTRACT and TRAP on COND */ -#define SUBTO 0x02, 0x66, 20, 7 /* SUBTRACT and TRAP on COND or OVFLO */ -#define DS 0x02, 0x22, 20, 7 /* DIVIDE STEP */ -#define COMCLR 0x02, 0x44, 20, 7 /* COMPARE and CLEAR */ -#define OR 0x02, 0x12, 20, 7 /* INCLUSIVE OR */ -#define XOR 0x02, 0x14, 20, 7 /* EXCLUSIVE OR */ -#define AND 0x02, 0x10, 20, 7 /* AND */ -#define ANDCM 0x02, 0x00, 20, 7 /* AND COMPLEMENT */ -#define UXOR 0x02, 0x1c, 20, 7 /* UNIT XOR */ -#define UADDCM 0x02, 0x4c, 20, 7 /* UNIT ADD COMPLEMENT */ -#define UADDCMT 0x02, 0x4e, 20, 7 /* UNIT ADD COMPLEMENT and TRAP on COND */ -#define DCOR 0x02, 0x5c, 20, 7 /* DECIMAL CORRECT */ -#define IDCOR 0x02, 0x5e, 20, 7 /* INTERMEDIATE DECIMAL CORRECT */ -#define ADDI 0x2d, 0x00, 20, 1 /* ADD to IMMED */ -#define ADDIO 0x2d, 0x01, 20, 1 /* ADD to IMMED and TRAP on OVFLO */ -#define ADDIT 0x2c, 0x00, 20, 1 /* ADD to IMMED and TRAP on COND */ -#define ADDITO 0x2c, 0x01, 20, 1 /* ADD to IMMED and TRAP on COND or OVFLO */ -#define SUBI 0x25, 0x00, 20, 1 /* SUBTRACT from IMMED */ -#define SUBIO 0x25, 0x01, 20, 1 /* SUBTRACT from IMMED and TRAP on OVFLO */ -#define COMICLR 0x24, 0x00, 0, 0 /* COMPARE IMMED and CLEAR */ -#define VSHD 0x34, 0x00, 19, 3 /* VARIABLE SHIFT DOUBLE */ -#define SHD 0x34, 0x02, 19, 3 /* SHIFT DOUBLE */ -#define VEXTRU 0x34, 0x04, 19, 3 /* VARIABLE EXTRACT RIGHT UNSIGNED */ -#define VEXTRS 0x34, 0x05, 19, 3 /* VARIABLE EXTRACT RIGHT SIGNED */ -#define EXTRU 0x34, 0x06, 19, 3 /* EXTRACT RIGHT UNSIGNED */ -#define EXTRS 0x34, 0x07, 19, 3 /* EXTRACT RIGHT SIGNED */ -#define VDEP 0x35, 0x01, 19, 3 /* VARIABLE DEPOSIT */ -#define DEP 0x35, 0x03, 19, 3 /* DEPOSIT */ -#define VDEPI 0x35, 0x05, 19, 3 /* VARIABLE DEPOSIT IMMED */ -#define DEPI 0x35, 0x07, 19, 3 /* DEPOSIT IMMED */ -#define ZVDEP 0x35, 0x00, 19, 3 /* ZERO and VARIABLE DEPOSIT */ -#define ZDEP 0x35, 0x02, 19, 3 /* ZERO and DEPOSIT */ -#define ZVDEPI 0x35, 0x04, 19, 3 /* ZERO and VARIABLE DEPOSIT IMMED */ -#define ZDEPI 0x35, 0x06, 19, 3 /* ZERO and DEPOSIT IMMED */ -#define BREAK 0x00, 0x00, 19, 8 /* BREAK */ -#define RFI 0x00, 0x60, 19, 8 /* RETURN FROM INTERRUPTION */ -#define RFIR 0x00, 0x65, 19, 8 /* RFI & RESTORE SHADOW REGISTERS */ -#define SSM 0x00, 0x6b, 19, 8 /* SET SYSTEM MASK */ -#define RSM 0x00, 0x73, 19, 8 /* RESET SYSTEM MASK */ -#define MTSM 0x00, 0xc3, 19, 8 /* MOVE TO SYSTEM MASK */ -#define LDSID 0x00, 0x85, 19, 8 /* LOAD SPACE IDENTIFIER */ -#define MTSP 0x00, 0xc1, 19, 8 /* MOVE TO SPACE REGISTER */ -#define MTCTL 0x00, 0xc2, 19, 8 /* MOVE TO SYSTEM CONTROL REGISTER */ -#define MFSP 0x00, 0x25, 19, 8 /* MOVE FROM SPACE REGISTER */ -#define MFCTL 0x00, 0x45, 19, 8 /* MOVE FROM SYSTEM CONTROL REGISTER */ -#define SYNC 0x00, 0x20, 19, 8 /* SYNCHRONIZE DATA CACHE */ -#define DIAG 0x05, 0x00, 0, 0 /* DIAGNOSE */ -#define SPOP 0x04, 0x00, 0, 0 /* SPECIAL FUNCTION UNIT */ -#define COPR 0x0c, 0x00, 0, 0 /* COPROCESSOR */ -#define CLDWX 0x09, 0x00, 19, 4 /* COPROCESSOR LOAD WORD INDEXED */ -#define CLDDX 0x0b, 0x00, 19, 4 /* COPROCESSOR LOAD WORD INDEXED */ -#define CSTWX 0x09, 0x01, 19, 4 /* COPROCESSOR STORE WORD INDEXED */ -#define CSTDX 0x0b, 0x01, 19, 4 /* COPROCESSOR STORE WORD INDEXED */ -#define CLDWS 0x09, 0x08, 19, 4 /* COPROCESSOR LOAD WORD SHORT */ -#define CLDDS 0x0b, 0x08, 19, 4 /* COPROCESSOR LOAD WORD SHORT */ -#define CSTWS 0x09, 0x09, 19, 4 /* COPROCESSOR STORE WORD SHORT */ -#define CSTDS 0x0b, 0x09, 19, 4 /* COPROCESSOR STORE WORD SHORT */ -#define FLOAT0 0x0e, 0x00, 21, 2 /* FLOATING POINT CLASS 0 */ -#define FLOAT1 0x0e, 0x01, 21, 2 /* FLOATING POINT CLASS 1 */ -#define FLOAT2 0x0e, 0x02, 21, 2 /* FLOATING POINT CLASS 2 */ -#define FLOAT3 0x0e, 0x03, 21, 2 /* FLOATING POINT CLASS 3 */ -#define FMPYSUB 0x26, 0x00, 0, 0 /* FP MULTIPLY AND SUBTRACT */ -#define FMPYADD 0x06, 0x00, 0, 0 /* FP MULTIPLY AND ADD/TRUNCATE */ -#define FSTQX 0x0f, 0x01, 19, 4 /* FLOATING POINT STORE QUAD INDEXED */ -#define FSTQS 0x0f, 0x09, 19, 4 /* FLOATING POINT STORE QUAD SHORT */ -/* all of the following have been pushed around to conform */ -#define PROBER 0x01, 0x46, 19, 7 /* PROBE READ ACCESS */ -#ifdef notdef -#define PROBERI 0x01, 0xc6, 19, 7 /* PROBE READ ACCESS IMMEDIATE */ -#endif -#define PROBEW 0x01, 0x47, 19, 7 /* PROBE WRITE ACCESS */ -#ifdef notdef -#define PROBEWI 0x01, 0xc7, 19, 7 /* PROBE WRITE ACCESS IMMEDIATE */ -#endif -#define LPA 0x01, 0x4d, 19, 7 /* LOAD PHYSICAL ADDRESS */ -#define LHA 0x01, 0x4c, 19, 7 /* LOAD HASH ADDRESS */ -#define PDTLB 0x01, 0x48, 19, 7 /* PURGE DATA TRANS LOOKASIDE BUFFER */ -#define PITLB 0x01, 0x08, 19, 7 /* PURGE INST TRANS LOOKASIDE BUFFER */ -#define PDTLBE 0x01, 0x49, 19, 7 /* PURGE DATA TLB ENTRY */ -#define PITLBE 0x01, 0x09, 19, 7 /* PURGE INST TLB ENTRY */ -#define IDTLBA 0x01, 0x41, 19, 7 /* INSERT DATA TLB ADDRESS */ -#define IITLBA 0x01, 0x01, 19, 7 /* INSERT INSTRUCTION TLB ADDRESS */ -#define IDTLBP 0x01, 0x40, 19, 7 /* INSERT DATA TLB PROTECTION */ -#define IITLBP 0x01, 0x00, 19, 7 /* INSERT INSTRUCTION TLB PROTECTION */ -#define PDC 0x01, 0x4e, 19, 7 /* PURGE DATA CACHE */ -#define FDC 0x01, 0x4a, 19, 7 /* FLUSH DATA CACHE */ -#define FIC 0x01, 0x0a, 19, 7 /* FLUSH INSTRUCTION CACHE */ -#define FDCE 0x01, 0x4b, 19, 7 /* FLUSH DATA CACHE ENTRY */ -#define FICE 0x01, 0x0b, 19, 7 /* FLUSH DATA CACHE ENTRY */ - -/* - * Header: /n/schirf/u/baford/CVS/mach4-parisc/kernel_unused/parisc/kdb/unasm.c,v 1.5 1994/07/21 22:32:05 mike Exp - * - * Spectrum Simulator Instruction Set Constants and Datatypes - * Dan Magenheimer - 4/28/82 - * Computer Research Center, Hewlett-Packard Labs - * - * (c) copyright 1982 - * (p) protected 1982 - * The Hewlett-Packard Company - * Hewlett-Packard Laboratories - * Computer Research Center - * Palo Alto, California - * - * *** HP Company Confidential *** - * - * Log: unasm.c,v - * Revision 1.5 1994/07/21 22:32:05 mike - * official HP copyright notice - * - * Revision 1.4 1992/07/08 12:19:52 dalton - * Checkin before split to 1.0.4 release (by LBS). - * - * Revision 1.3 92/06/06 16:16:45 dalton - * *** empty log message *** - * - * Revision 1.2 92/06/06 15:42:28 dalton - * Changed include to be a path relative to hp800. - * - * Revision 1.1 92/06/06 14:05:33 dalton - * Initial revision - * - * Revision 1.2 91/04/14 20:29:49 osfrcs - * Initial version. - * [91/03/30 09:20:34 brezak] - * - * Revision 1.1.2.2 91/04/02 10:42:50 brezak - * Initial version. - * [91/03/30 09:20:34 brezak] - * - * Revision 1.1.1.2 91/03/30 09:20:34 brezak - * Initial version. - * -;Revision 1.1 88/07/11 14:05:21 14:05:21 ren (Bob Naas) -;Initial revision -; - * Revision 5.1 87/02/27 11:12:23 11:12:23 kent (Kent McMullen) - * update all src to 5.1 - * - * Revision 5.0 87/02/18 16:31:52 16:31:52 kent (Kent McMullen) - * update all revision numbers to 5.0 for release - * - * Revision 1.1 86/07/15 08:35:00 08:35:00 kent (Kent McMullen) - * Initial revision - * - * Revision 4.3 85/11/12 09:28:44 09:28:44 viggy (Viggy Mokkarala) - * first mpsim version, partially stable - * - * Revision 4.2 84/07/16 17:20:57 17:20:57 djm () - * Define field macros for COPR and SFU insts - * - * Revision 4.1 83/10/25 17:10:14 djm (Daniel Magenheimer) - * First release for ACD v4 - * - * Revision 3.1 83/08/03 14:09:59 djm (Daniel Magenheimer) - * Sys calls, args, -S, bug fixes, etc. - * - * Revision 3.0 83/06/13 10:25:13 djm (Daniel Magenheimer) - * First release for distribution - * - * - */ -/* - * Changes: - * 12/01/89 ejf Add Rsd(), Rse(), Rtd(), Rte() for 5 ops. - * 11/30/89 ejf Make instruction use counters shared, not per cpu. - * 11/28/89 ejf Change majoropcode for quicker extension extract. - */ - - - -/* - * Dependencies: std.h, ssDefs.h, bits.h - */ - - -/* Lookup/Execute structure for instructions */ -struct inst { - u_char majopc; /* major opcode of instruction, 0..MAXOPC */ - u_char opcext; /* opcode extension, 0 if not applic. */ - u_char extbs; /* starting bit pos of extension field */ - u_char extbl; /* bit length of extension field */ - u_int count; /* frequency counter for analysis */ - char mnem[8]; /* ascii mnemonic */ - /* disassembly function */ - int (*dasmfcn)(const struct inst *, OFS, int); -}; - - -#define NMAJOPCS 64 - -struct majoropcode { - const struct inst **subops; /* pointer to table of subops indexed by - * opcode extension */ - u_int maxsubop; /* largest opcode extension value or 0 */ - u_int extshft; /* right shift amount for extension field */ - u_int extmask; /* post shift mask for extension field */ -}; - -#define OpExt(i,m) ((i >> m->extshft) & m->extmask) /* extract opcode extension */ - - -/*****************************/ -/* Miscellaneous definitions */ -/*****************************/ - -/* Load/Store Indexed Opcode Extension Cache Control */ -#define NOACTION 0 -#define STACKREF 1 -#define SEQPASS 2 -#define PREFETCH 3 - -/******************************/ -/* Fields within instructions */ -/******************************/ - -/* opcode */ -#define Opcode(i) BitfR(i,0,6,_b06) -/* opcode true/false bit */ -#define OpcTF(i) BitfR(i,4,1,_b41) -/* register sources */ -#define Rsa(i) BitfR(i,11,5,_b115) -#define Rsb(i) BitfR(i,6,5,_b65) -#define Rsc(i) BitfR(i,27,5,_b275) -#define Rsd(i) BitfR(i,21,5,_b215) -#define Rse(i) BitfR(i,16,5,_b165) -/* register targets */ -#define Rta(i) BitfR(i,11,5,_b115) -#define Rtb(i) BitfR(i,6,5,_b65) -#define Rtc(i) BitfR(i,27,5,_b275) -#define Rtd(i) BitfR(i,21,5,_b215) -#define Rte(i) BitfR(i,16,5,_b165) -/* 5-bit immediates (Magnitude, Sign) */ -#define Imb5(i) BitfR(i,6,5,_b65) -#define Ima5M(i) BitfR(i,11,4,_b114) -#define Ima5S(i) BitfR(i,15,1,_b151) -#define Ima5A(i) BitfR(i,11,5,_b115) -#define Imd5(i) BitfR(i,22,5,_b225) -#define Imc5M(i) BitfR(i,27,4,_b274) -#define Imc5S(i) BitfR(i,31,1,_b311) -#define Imc5A(i) BitfR(i,27,5,_b275) -/* Other immediates */ -#define Im21L(i) BitfR(i,18,2,_b182) -#define Im21H(i) BitfR(i,20,11,_b2011) -#define Im21M1(i) BitfR(i,16,2,_b162) -#define Im21M2(i) BitfR(i,11,5,_b115) -#define Im21S(i) BitfR(i,31,1,_b311) -#define Im11M(i) BitfR(i,21,10,_b2110) -#define Im11S(i) BitfR(i,31,1,_b311) -/* displacements/offsets */ -#define DispM(i) BitfR(i,18,13,_b1813) -#define DispS(i) BitfR(i,31,1,_b311) -#define Off5(i) BitfR(i,11,5,_b115) -#define Off11H(i) BitfR(i,19,10,_b1910) -#define Off11L(i) BitfR(i,29,1,_b291) -#define OffS(i) BitfR(i,31,1,_b311) -/* miscellaneous */ -#define Dss(i) BitfR(i,16,2,_b162) -#define Cond(i) BitfR(i,16,3,_b163) -#define Cneg(i) BitfR(i,19,1,_b191) -#define Cond4(i) BitfR(i,16,4,_b164) /* Cond AND Cneg */ -#define Nu(i) BitfR(i,30,1,_b301) -#define SrL(i) BitfR(i,16,2,_b162) -#define SrH(i) BitfR(i,18,1,_b181) -#define ShortDisp(i) BitfR(i,19,1,_b191) -#define IndxShft(i) BitfR(i,18,1,_b181) -#define ModBefore(i) BitfR(i,18,1,_b181) -#define CacheCtrl(i) BitfR(i,20,2,_b202) -#define Modify(i) BitfR(i,26,1,_b261) -#define ProbeI(i) BitfR(i,18,1,_b181) -#define Uid(i) BitfR(i,23,3,_b233) -#define Sfu(i) BitfR(i,23,3,_b233) -#define CopExt17(i) BitfR(i,6,17,_b617) -#define CopExt5(i) BitfR(i,27,5,_b275) -#define SpopType(i) BitfR(i,21,2,_b212) -#define SpopExt15(i) BitfR(i,6,15,_b615) -#define SpopExt10(i) BitfR(i,11,10,_b1110) -#define SpopExt5L(i) BitfR(i,16,5,_b165) -#define SpopExt5(i) BitfR(i,27,5,_b275) -#define NoMajOpc(i) BitfR(i,6,26,_b626) -#define Bi1(i) BitfR(i,27,5,_b275) /* fields in BREAK */ -#define Bi2(i) BitfR(i,6,13,_b613) - -/* fragmented field collating macros */ -#define Ima5(i) (Ima5S(i) ? Ima5M(i) | (-1<<4) : Ima5M(i)) - -#define Imc5(i) (Imc5S(i) ? Imc5M(i) | (-1<<4) : Imc5M(i)) - -#define Disp(i) (DispS(i) ? DispM(i) | (-1<<13) : DispM(i)) - -#define Im21(i) (Im21S(i) << 31 | Im21H(i) << 20 | Im21M1(i) << 18 | \ - Im21M2(i) << 13 | Im21L(i) << 11) - -#define Im11(i) (Im11S(i) ? Im11M(i) | (-1<<10) : Im11M(i)) - -#define Bdisp(i) ((OffS(i) ? (Off5(i)<<11 | Off11L(i)<<10|Off11H(i)) \ -/* branch displacement (bytes) */ | (-1 << 16) \ - : (Off5(i)<<11|Off11L(i)<<10|Off11H(i))) << 2) - -#define Cbdisp(i) ((OffS(i) ? (Off11L(i) << 10 | Off11H(i)) \ - /* compare/branch disp (bytes) */ | (-1 << 11) \ - : Off11L(i) << 10 | Off11H(i)) << 2) - -#define Sr(i) (SrH(i)<<2 | SrL(i)) - -/* sfu/copr */ -#define CoprExt1(i) (CopExt17(i)) -#define CoprExt2(i) (CopExt5(i)) -#define CoprExt(i) ((CopExt17(i)<<5) | CopExt5(i)) -#define Spop0Ext(i) ((SpopExt15(i)<<5) | SpopExt5(i)) -#define Spop1Ext(i) (SpopExt15(i)) -#define Spop2Ext(i) ((SpopExt10(i)<<5) | SpopExt5(i)) -#define Spop3Ext(i) ((SpopExt5L(i)<<5) | SpopExt5(i)) - - -/*##################### Globals - Imports ##################################*/ - -/* Disassembly functions */ -int fcoprDasm(int w, u_int op1, u_int); -char *edDCond(u_int cond); -char *unitDCond(u_int cond); -char *addDCond(u_int cond); -char *subDCond(u_int cond); -int blDasm(const struct inst *i, OFS ofs, int w); -int ldDasm(const struct inst *, OFS, int); -int stDasm(const struct inst *i, OFS, int); -int addDasm(const struct inst *i, OFS, int); -int unitDasm(const struct inst *i, OFS, int); -int iaDasm(const struct inst *i, OFS, int); -int shdDasm(const struct inst *i, OFS, int); -int extrDasm(const struct inst *i, OFS, int); -int vextrDasm(const struct inst *i, OFS, int); -int depDasm(const struct inst *i, OFS, int); -int vdepDasm(const struct inst *i, OFS, int); -int depiDasm(const struct inst *i, OFS, int); -int vdepiDasm(const struct inst *i, OFS, int); -int limmDasm(const struct inst *i, OFS, int); -int brkDasm(const struct inst *i, OFS, int); -int lpkDasm(const struct inst *i, OFS, int); -int fmpyaddDasm(const struct inst *i, OFS, int); -int fmpysubDasm(const struct inst *i, OFS, int); -int floatDasm(const struct inst *i, OFS, int); -int coprDasm(const struct inst *i, OFS, int); -int diagDasm(const struct inst *i, OFS, int); -int scDasm(const struct inst *i, OFS, int); -int mmgtDasm(const struct inst *i, OFS, int); -int ldxDasm(const struct inst *i, OFS, int); -int stsDasm(const struct inst *i, OFS, int); -int stbysDasm(const struct inst *i, OFS, int); -int brDasm(const struct inst *i, OFS, int); -int bvDasm(const struct inst *i, OFS, int); -int beDasm(const struct inst *i, OFS, int); -int cbDasm(const struct inst *i,OFS ofs, int); -int cbiDasm(const struct inst *i,OFS ofs, int); -int bbDasm(const struct inst *i,OFS ofs, int); -int ariDasm(const struct inst *i, OFS, int); - -/*##################### Globals - Exports ##################################*/ -/*##################### Local Variables ####################################*/ - -static const char fmtStrTbl[][5] = { "sgl", "dbl", "sgl", "quad" }; -static const char condStrTbl[][7] = { - "false?", "false", "?", "!<=>", "=", "=t", "?=", "!<>", - "!?>=", "<", "?<", "!>=", "!?>", "<=", "?<=", "!>", - "!?<=", ">", "?>", "!<=", "!?<", ">=", "?>=", "!<", - "!?=", "<>", "!=", "!=t", "!?", "<=>", "true?", "true" -}; -static const char fsreg[][5] = { - "r0L", "r0R", "r1L", "r1R", "r2L", "r2R", "r3L", "r3R", - "r4L", "r4R", "r5L", "r5R", "r6L", "r6R", "r7L", "r7R", - "r8L", "r8R", "r9L", "r9R", "r10L", "r10R", "r11L", "r11R", - "r12L", "r12R", "r13L", "r13R", "r14L", "r14R", "r15L", "r15R", - "r16L", "r16R", "r17L", "r17R", "r18L", "r18R", "r19L", "r19R", - "r20L", "r20R", "r21L", "r21R", "r22L", "r22R", "r23L", "r23R", - "r24L", "r24R", "r25L", "r25R", "r26L", "r26R", "r27L", "r27R", - "r28L", "r28R", "r29L", "r29R", "r30L", "r30R", "r31L", "r31R" -}; -static const char fdreg[][4] = { - "r0", "r0", "r1", "r1", "r2", "r2", "r3", "r3", - "r4", "r4", "r5", "r5", "r6", "r6", "r7", "r7", - "r8", "r8", "r9", "r9", "r10", "r10", "r11", "r11", - "r12", "r12", "r13", "r13", "r14", "r14", "r15", "r15", - "r16", "r16", "r17", "r17", "r18", "r18", "r19", "r19", - "r20", "r20", "r21", "r21", "r22", "r22", "r23", "r23", - "r24", "r24", "r25", "r25", "r26", "r26", "r27", "r27", - "r28", "r28", "r29", "r29", "r30", "r30", "r31", "r31" -}; - -/*##################### Macros #############################################*/ - -#define Match(s) (strncmp(s,i->mnem,sizeof(s)-1) == 0) - -/* bits for assist ops */ -#define AstNu(w) Modify(w) -#define Fpi(w) (Uid(w)>3) - -/* bits for 5 ops */ -#define SinglePrec(i) Modify(i) -#define Ms1(i) ((Rsb(i)<<1)+(SinglePrec(i)?((Rsb(i)>15)?1:32):0)) -#define Ms2(i) ((Rsa(i)<<1)+(SinglePrec(i)?((Rsa(i)>15)?1:32):0)) -#define Mt(i) ((Rtc(i)<<1)+(SinglePrec(i)?((Rtc(i)>15)?1:32):0)) -#define As(i) ((Rsd(i)<<1)+(SinglePrec(i)?((Rsd(i)>15)?1:32):0)) -#define Ad(i) ((Rte(i)<<1)+(SinglePrec(i)?((Rte(i)>15)?1:32):0)) - -/*##################### Globals - Exports ##################################*/ - -/* To replace instr function, do the following: */ -/* a) locate the desired entry in instrs[] below */ -/* b) change the 3rd field if an alternate mneumonic is */ -/* desired for window disassembly */ -/* c) change the 4th field to the name of the function being */ -/* used for replacement (i.e. ldwRepl instead of ldw) */ -/* d) change the 5th field if an alternate disassembly routine */ -/* is desired (i.e. ldDasmRepl) */ - -static const struct inst instrs[] = { - { LDW, 0, "ldw", ldDasm }, - { LDH, 0, "ldh", ldDasm }, - { LDB, 0, "ldb", ldDasm }, - { LDWM, 0, "ldwm", ldDasm }, - { LDO, 0, "ldo", ldDasm }, - { STW, 0, "stw", stDasm }, - { STH, 0, "sth", stDasm }, - { STB, 0, "stb", stDasm }, - { STWM, 0, "stwm", stDasm }, - { LDWX, 0, "ldw", ldxDasm }, - { LDHX, 0, "ldh", ldxDasm }, - { LDBX, 0, "ldb", ldxDasm }, - { LDCWX, 0, "ldcw", ldxDasm }, - { LDWAX, 0, "ldwa", ldxDasm }, - { LDWS, 0, "ldw", ldxDasm }, - { LDHS, 0, "ldh", ldxDasm }, - { LDBS, 0, "ldb", ldxDasm }, - { LDCWS, 0, "ldcw", ldxDasm }, - { LDWAS, 0, "ldwa", ldxDasm }, - { STWS, 0, "stws", stsDasm }, - { STHS, 0, "sths", stsDasm }, - { STBS, 0, "stbs", stsDasm }, - { STWAS, 0, "stwas", stsDasm }, - { STBYS, 0, "stbys", stbysDasm }, - { LDIL, 0, "ldil", limmDasm }, - { ADDIL, 0, "addil", limmDasm }, - { GATE, 0, "gate", blDasm }, - { BL, 0, "b", blDasm }, - { BLR, 0, "blr", brDasm }, - { BV, 0, "bv", bvDasm }, - { BE, 0, "be", beDasm }, - { BLE, 0, "ble", beDasm }, - { COMBT, 0, "combt", cbDasm }, - { COMBF, 0, "combf", cbDasm }, - { COMIBT, 0, "comibt", cbiDasm }, - { COMIBF, 0, "comibf", cbiDasm }, - { ADDBT, 0, "addbt", cbDasm }, - { ADDBF, 0, "addbf", cbDasm }, - { ADDIBT, 0, "addibt", cbiDasm }, - { ADDIBF, 0, "addibf", cbiDasm }, - { MOVB, 0, "movb", cbDasm }, - { MOVIB, 0, "movib", cbiDasm }, - { BB, 0, "bb", bbDasm }, - { BVB, 0, "bvb", bbDasm }, - { SUBO, 0, "subo", ariDasm }, - { ADD, 0, "add", addDasm }, - { ADDL, 0, "addl", addDasm }, - { ADDO, 0, "addo", ariDasm }, - { SH1ADD, 0, "sh1add", ariDasm }, - { SH1ADDL,0, "sh1addl", ariDasm }, - { SH1ADDO,0, "sh1addo", ariDasm }, - { SH2ADD, 0, "sh2add", ariDasm }, - { SH2ADDL,0, "sh2addl", ariDasm }, - { SH2ADDO,0, "sh2addo", ariDasm }, - { SH3ADD, 0, "sh3add", ariDasm }, - { SH3ADDL,0, "sh3addl", ariDasm }, - { SH3ADDO,0, "sh3addo", ariDasm }, - { SUB, 0, "sub", ariDasm }, - { ADDCO, 0, "addco", ariDasm }, - { SUBBO, 0, "subbo", ariDasm }, - { ADDC, 0, "addc", ariDasm }, - { SUBB, 0, "subb", ariDasm }, - { COMCLR, 0, "comclr", ariDasm }, - { OR, 0, "or", ariDasm }, - { AND, 0, "and", ariDasm }, - { XOR, 0, "xor", ariDasm }, - { ANDCM, 0, "andcm", ariDasm }, - { DS, 0, "ds", ariDasm }, - { UXOR, 0, "uxor", unitDasm }, - { UADDCM, 0, "uaddcm", unitDasm }, - { UADDCMT,0, "uaddcmt", unitDasm }, - { SUBTO, 0, "subto", ariDasm }, - { SUBT, 0, "subt", ariDasm }, - { DCOR, 0, "dcor", unitDasm }, - { IDCOR, 0, "idcor", unitDasm }, - { ADDIO, 0, "addio", iaDasm }, - { SUBIO, 0, "subio", iaDasm }, - { ADDI, 0, "addi", iaDasm }, - { SUBI, 0, "subi", iaDasm }, - { COMICLR,0, "comiclr", iaDasm }, - { ADDITO, 0, "addito", iaDasm }, - { ADDIT, 0, "addit", iaDasm }, - { SHD, 0, "shd", shdDasm }, - { VSHD, 0, "vshd", shdDasm }, - { EXTRU, 0, "extru", extrDasm }, - { EXTRS, 0, "extrs", extrDasm }, - { VEXTRU, 0, "vextru", vextrDasm }, - { VEXTRS, 0, "vextrs", vextrDasm }, - { DEP, 0, "dep", depDasm }, - { VDEP, 0, "vdep", vdepDasm }, - { DEPI, 0, "depi", depiDasm }, - { VDEPI, 0, "vdepi", vdepiDasm }, - { ZDEP, 0, "zdep", depDasm }, - { ZVDEP, 0, "zvdep", vdepDasm }, - { ZDEPI, 0, "zdepi", depiDasm }, - { ZVDEPI, 0, "zvdepi", vdepiDasm }, - { BREAK, 0, "break", brkDasm }, - { RFI, 0, "rfi", 0 }, - { RFIR, 0, "rfir", 0 }, - { SSM, 0, "ssm", scDasm }, - { RSM, 0, "rsm", scDasm }, - { MTSM, 0, "mtsm", scDasm }, - { PROBER, 0, "prober", mmgtDasm }, - { PROBEW, 0, "probew", mmgtDasm }, - { LPA, 0, "lpa", mmgtDasm }, - { LHA, 0, "lha", mmgtDasm }, - { LDSID, 0, "ldsid", scDasm }, - { PDTLB, 0, "pdtlb", mmgtDasm }, - { PDTLBE, 0, "pdtlbe", mmgtDasm }, - { PITLB, 0, "pitlb", mmgtDasm }, - { PITLBE, 0, "pitlbe", mmgtDasm }, - { IDTLBA, 0, "idtlba", mmgtDasm }, - { IITLBA, 0, "iitlba", mmgtDasm }, - { IDTLBP, 0, "idtlbp", mmgtDasm }, - { IITLBP, 0, "iitlbp", mmgtDasm }, - { FIC, 0, "fic", mmgtDasm }, - { FICE, 0, "fice", mmgtDasm }, - { PDC, 0, "pdc", mmgtDasm }, - { FDC, 0, "fdc", mmgtDasm }, - { FDCE, 0, "fdce", mmgtDasm }, - { SYNC, 0, "sync", 0 }, - { MTSP, 0, "mtsp", scDasm }, - { MTCTL, 0, "mtctl", scDasm }, - { MFSP, 0, "mfsp", scDasm }, - { MFCTL, 0, "mfctl", scDasm }, - { DIAG, 0, "diag", diagDasm }, - { SPOP, 0, "???", 0 }, - { COPR, 0, "copr", coprDasm }, - { CLDWX, 0, "cldw", coprDasm }, - { CLDDX, 0, "cldd", coprDasm }, - { CSTWX, 0, "cstw", coprDasm }, - { CSTDX, 0, "cstd", coprDasm }, - { CLDWS, 0, "cldw", coprDasm }, - { CLDDS, 0, "cldd", coprDasm }, - { CSTWS, 0, "cstw", coprDasm }, - { CSTDS, 0, "cstd", coprDasm }, - { FLOAT0, 0, "f", floatDasm }, - { FLOAT1, 0, "fcnv", floatDasm }, - { FLOAT2, 0, "f", floatDasm }, - { FLOAT3, 0, "f", floatDasm }, - { FMPYSUB,0, "fmpy", fmpysubDasm }, - { FMPYADD,0, "fmpy", fmpyaddDasm }, - { FSTQX, 0, "fstqx", lpkDasm }, - { FSTQS, 0, "fstqs", lpkDasm }, - {0} -}; - - -static const struct inst illeg = { 0, 0, 0, 0, 0, "???", 0 }; -static const struct inst *so_sysop[0xd0]; -static const struct inst *so_mmuop[0x50]; -static const struct inst *so_arith[0x80]; -static const struct inst *so_loads[0x50]; -static const struct inst *so_cldw [0x0A]; -static const struct inst *so_cldd [0x0A]; -static const struct inst *so_float[0x04]; -static const struct inst *so_fstq [0x0A]; -static const struct inst *so_ebran[0x08]; -static const struct inst *so_addit[0x02]; -static const struct inst *so_addi [0x02]; -static const struct inst *so_subi [0x02]; -static const struct inst *so_shext[0x08]; -static const struct inst *so_deps [0x08]; - -#define ILLEG (const struct inst **)&illeg -#define NENTS(a) (sizeof(a)/sizeof(a[0])-1) -static struct majoropcode majopcs[NMAJOPCS] = { - { so_sysop, NENTS(so_sysop) }, /* 00 */ - { so_mmuop, NENTS(so_mmuop) }, /* 01 */ - { so_arith, NENTS(so_arith) }, /* 02 */ - { so_loads, NENTS(so_loads) }, /* 03 */ - { ILLEG, 1 }, /* 04 */ - { ILLEG, 1 }, /* 05 */ - { ILLEG, 1 }, /* 06 */ - { ILLEG, 1 }, /* 07 */ - { ILLEG, 1 }, /* 08 */ - { so_cldw , NENTS(so_cldw ) }, /* 09 */ - { ILLEG, 1 }, /* 0A */ - { so_cldd , NENTS(so_cldd ) }, /* 0B */ - { ILLEG, 1 }, /* 0C */ - { ILLEG, 1 }, /* 0D */ - { so_float, NENTS(so_float) }, /* 0E */ - { so_fstq , NENTS(so_fstq ) }, /* 0F */ - { ILLEG, 1 }, /* 10 */ - { ILLEG, 1 }, /* 11 */ - { ILLEG, 1 }, /* 12 */ - { ILLEG, 1 }, /* 13 */ - { ILLEG, 1 }, /* 14 */ - { ILLEG, 1 }, /* 15 */ - { ILLEG, 1 }, /* 16 */ - { ILLEG, 1 }, /* 17 */ - { ILLEG, 1 }, /* 18 */ - { ILLEG, 1 }, /* 19 */ - { ILLEG, 1 }, /* 1A */ - { ILLEG, 1 }, /* 1B */ - { ILLEG, 1 }, /* 1C */ - { ILLEG, 1 }, /* 1D */ - { ILLEG, 1 }, /* 1E */ - { ILLEG, 1 }, /* 1F */ - { ILLEG, 1 }, /* 20 */ - { ILLEG, 1 }, /* 21 */ - { ILLEG, 1 }, /* 22 */ - { ILLEG, 1 }, /* 23 */ - { ILLEG, 1 }, /* 24 */ - { so_subi , NENTS(so_subi ) }, /* 25 */ - { ILLEG, 1 }, /* 26 */ - { ILLEG, 1 }, /* 27 */ - { ILLEG, 1 }, /* 28 */ - { ILLEG, 1 }, /* 29 */ - { ILLEG, 1 }, /* 2A */ - { ILLEG, 1 }, /* 2B */ - { so_addit, NENTS(so_addit) }, /* 2C */ - { so_addi , NENTS(so_addi ) }, /* 2D */ - { ILLEG, 1 }, /* 2E */ - { ILLEG, 1 }, /* 2F */ - { ILLEG, 1 }, /* 30 */ - { ILLEG, 1 }, /* 31 */ - { ILLEG, 1 }, /* 32 */ - { ILLEG, 1 }, /* 33 */ - { so_shext, NENTS(so_shext) }, /* 34 */ - { so_deps , NENTS(so_deps ) }, /* 35 */ - { ILLEG, 1 }, /* 36 */ - { ILLEG, 1 }, /* 37 */ - { ILLEG, 1 }, /* 38 */ - { ILLEG, 1 }, /* 39 */ - { so_ebran, NENTS(so_ebran) }, /* 3A */ - { ILLEG, 1 }, /* 3B */ - { ILLEG, 1 }, /* 3C */ - { ILLEG, 1 }, /* 3D */ - { ILLEG, 1 }, /* 3E */ - { ILLEG, 1 }, /* 3F */ -}; -#undef NENTS -#undef ILLEG - -int iExInit(void); - -/*-------------------------------------------------------------------------- - * instruction$ExecutionInitialize - Initialize the instruction execution - * data structures. - *---------------------------------------------------------------------------*/ -int -iExInit(void) -{ - static int unasm_initted = 0; - register const struct inst *i; - register struct majoropcode *m; - u_int shft, mask; - - if (unasm_initted) - return 1; - - /* - * Determine maxsubop for each major opcode. - * Also, check all instructions of a given major opcode - * for consistent opcode extension field definition, and - * save a converted form of this definition in the majopcs - * entry for this major opcode. - */ - for (i = &instrs[0]; *i->mnem; i++) { - m = &majopcs[i->majopc]; - if (m->maxsubop < i->opcext) { - db_printf("iExInit not enough space for opcode %d", - i->majopc); - return 0; - } - shft = 32 - i->extbs - i->extbl; - mask = (1 << i->extbl) - 1; - if (m->extshft || m->extmask) { - if (m->extshft != shft || m->extmask != mask) { - db_printf("%s - Bad instruction initialization!\n", i->mnem); - return 0; - } - } else { - m->extshft = shft; - m->extmask = mask; - } - } - - /* - * Lastly, fill in all legal subops with the appropriate info. - */ - for (i = &instrs[0]; *i->mnem; i++) { - m = &majopcs[i->majopc]; - if (m->maxsubop == 1) - m->subops = (const struct inst **)i; - else - m->subops[i->opcext] = i; - } - - unasm_initted++; - return 1; -} - - - -/*##################### Functions and Subroutines ##########################*/ - -/**************************************/ -/* Miscellaneous Disassembly Routines */ -/**************************************/ - -/* Add instructions */ -int -addDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - db_printf("%s\t%%r%d,%%r%d,%%r%d",addDCond(Cond4(w)), - Rsa(w),Rsb(w),Rtc(w)); - return (1); -} - -/* Unit instructions */ -int -unitDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - db_printf("%s", unitDCond(Cond4(w))); - if (Match("dcor") || Match("idcor")) - db_printf("\t%%r%d,%%r%d",Rsb(w),Rtc(w)); - else - db_printf("\t%%r%d,%%r%d,%%r%d",Rsa(w),Rsb(w),Rtc(w)); - return (1); -} - -/* Immediate Arithmetic instructions */ -int -iaDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - if (Match("addi")) - db_printf("%s\t%d,%%r%d,%%r%d", - addDCond(Cond4(w)),Im11(w),Rsb(w),Rta(w)); - else - db_printf("%s\t%d,%%r%d,%%r%d", - subDCond(Cond4(w)),Im11(w),Rsb(w),Rta(w)); - return (1); -} - -/* Shift double instructions */ -int -shdDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - if (Match("vshd")) - db_printf("%s\t%%r%d,%%r%d,%%r%d", - edDCond(Cond(w)), Rsa(w),Rsb(w),Rtc(w)); - else - db_printf("%s\t%%r%d,%%r%d,%d,%%r%d", - edDCond(Cond(w)),Rsa(w),Rsb(w),31-Imd5(w),Rtc(w)); - return (1); -} - -/* Extract instructions */ -int -extrDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - db_printf("%s\t%%r%d,%d,%d,%%r%d", - edDCond(Cond(w)),Rsb(w),Imd5(w),32 - Rsc(w),Rta(w)); - return (1); -} - - -/* Variable extract instructions */ -int -vextrDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - db_printf("%s\t%%r%d,%d,%%r%d", - edDCond(Cond(w)),Rsb(w),32 - Rsc(w),Rta(w)); - return (1); -} - - -/* Deposit instructions */ -int -depDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - db_printf("%s\t%%r%d,%d,%d,%%r%d", - edDCond(Cond(w)),Rsa(w),31 - Imd5(w),32 - Rsc(w),Rtb(w)); - return (1); -} - - -/* Variable deposit instructions */ -int -vdepDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - db_printf("%s\t%%r%d,%d,%%r%d", - edDCond(Cond(w)),Rsa(w),32 - Rsc(w),Rtb(w)); - return (1); -} - - -/* Deposit Immediate instructions */ -int -depiDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - db_printf("%s\t%d,%d,%d,%%r%d", - edDCond(Cond(w)),Ima5(w),31 - Imd5(w),32 - Imc5A(w),Rtb(w)); - return (1); -} - -/* Variable Deposit Immediate instructions */ -int -vdepiDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - db_printf("%s\t%d,%d,%%r%d",edDCond(Cond(w)),Ima5(w),32-Imc5A(w),Rtb(w)); - return (1); -} - -/*--------------------------------------------------------------------------- - * conditionType$DisassembleCondition - Return a string which contains the - * ascii description of the passed numeric condition. - *---------------------------------------------------------------------------*/ - -char * -subDCond(cond) - u_int cond; -{ - switch(cond) { - case EQZ: return(",="); - case LT: return(",<"); - case LE: return(",<="); - case LLT: return(",<<"); - case LLE: return(",<<="); - case SV: return(",sv"); - case OD: return(",od"); - case NEQZ: return(",<>"); - case GE: return(",>="); - case GT: return(",>"); - case LGE: return(",>>="); - case LGT: return(",>>"); - case NSV: return(",nsv"); - case EV: return(",ev"); - case TR: return(",tr"); - case NEV: return(""); - default: - return(","); - } -} - - -/*--------------------------------------------------------------------------- - * conditionType$DisassembleCondition - Return a string which contains the - * ascii description of the passed numeric condition. - *---------------------------------------------------------------------------*/ - -char * -addDCond(cond) - u_int cond; -{ - switch(cond) { - case EQZ: return(",="); - case LT: return(",<"); - case LE: return(",<="); - case NUV: return(",nuv"); - case ZNV: return(",znv"); - case SV: return(",sv"); - case OD: return(",od"); - case NEQZ: return(",<>"); - case GE: return(",>="); - case GT: return(",>"); - case UV: return(",uv"); - case VNZ: return(",vnz"); - case NSV: return(",nsv"); - case EV: return(",ev"); - case TR: return(",tr"); - case NEV: return(""); - default: - return(","); - } -} - -char * -unitDCond(cond) - u_int cond; -{ - switch(cond) { - case SHC: return(",shc"); - case SHZ: return(",shz"); - case SBC: return(",sbc"); - case SBZ: return(",sbz"); - case SDC: return(",sdc"); - case NHC: return(",nhc"); - case NHZ: return(",nhz"); - case NBC: return(",nbc"); - case NBZ: return(",nbz"); - case NDC: return(",ndc"); - case TR: return(",tr"); - case NEV: return(""); - default: - return(","); - } -} - -char * -edDCond(cond) - u_int cond; -{ - switch(cond) { - case XOD: return(",od"); - case XTR: return(",tr"); - case XNE: return(",<>"); - case XLT: return(",<"); - case XEQ: return(",="); - case XGE: return(",>="); - case XEV: return(",ev"); - case NEV: return(""); - default: - return(","); - } -} - - - -/****************************************/ -/* Format Specific Disassembly Routines */ -/****************************************/ - - -/* Load [modify] instructions */ -int -ldDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register int d = Disp(w); - char s[2]; - - s[1] = '\0'; - if (d < 0) { - d = -d; - s[0] = '-'; - } else - s[0] = '\0'; - - if (Rsb(w) == 0 && Match("ldo")) { - db_printf("ldi\t%s%X,%%r%d",s,d,Rta(w)); - return (1); - } - db_printf("%s\t%s%s%X",i->mnem,(d < 2048? "R'":""), s, d); - if (Dss(w)) - db_printf("(%%sr%d,%%r%d),%%r%d",Dss(w),Rsb(w),Rta(w)); - else - db_printf("(%%r%d),%%r%d",Rsb(w),Rta(w)); - return (1); -} - -/* Store [modify] instructions */ -int -stDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register int d = Disp(w); - char s[2]; - - db_printf("\t%%r%d,",Rta(w)); - - s[1] = '\0'; - if (d < 0) { - d = -d; - s[0] = '-'; - } else - s[0] = '\0'; - - db_printf("%s%s%X", (d < 2048? "R'":""), s, d); - - if (Dss(w)) - db_printf("(%%sr%d,%%r%d)",Dss(w),Rsb(w)); - else - db_printf("(%%r%d)",Rsb(w)); - return (1); -} - -/* Load indexed instructions */ -int -ldxDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register const char *p; - - if (ShortDisp(w)) { - db_printf("s"); - if (Modify(w)) - db_printf(",m%s", ModBefore(w)? "b": "a"); - } else { - db_printf("x"); - if (Modify(w)) - db_printf(",%sm", IndxShft(w)? "s":""); - } - switch (CacheCtrl(w)) { - case NOACTION: p = ""; break; - case STACKREF: p = ",c"; break; - case SEQPASS: p = ",q"; break; - case PREFETCH: p = ",p"; break; - } - if (ShortDisp(w)) - db_printf("%s\t%d", p, Ima5(w)); - else - db_printf("%s\t%%r%d", p, Rsa(w)); - - if (Dss(w)) - db_printf("(%%sr%d,%%r%d),%%r%d",Dss(w),Rsb(w),Rtc(w)); - else - db_printf("(%%r%d),%%r%d",Rsb(w),Rtc(w)); - return (1); -} - -/* Store short displacement instructions */ -int -stsDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register const char *p; - if (Modify(w)) - db_printf(",m%s", ModBefore(w)? "b":"a"); - - switch (CacheCtrl(w)) { - case NOACTION: p = ""; break; - case STACKREF: p = ",c"; break; - case SEQPASS: p = ",q"; break; - case PREFETCH: p = ",p"; break; - } - db_printf("%s\t%%r%d,", p, Rta(w)); - if (Dss(w)) - db_printf("%d(%%sr%d,%%r%d)",Imc5(w),Dss(w),Rsb(w)); - else - db_printf("%d(%%r%d)",Imc5(w),Rsb(w)); - return (1); -} - -/* Store Bytes Instruction */ -int -stbysDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register const char *p; - db_printf(ModBefore(w)? ",e":",b"); - if (Modify(w)) - db_printf(",m"); - switch (CacheCtrl(w)) { - case NOACTION: p = ""; break; - case STACKREF: p = ",f"; break; - case SEQPASS: p = ",r"; break; - case PREFETCH: p = ",z"; break; - } - db_printf("%s\t%%r%d,", p, Rta(w)); - if (Dss(w)) - db_printf("%d(%%sr%d,%%r%d)",Imc5(w),Dss(w),Rsb(w)); - else - db_printf("%d(%%r%d)",Imc5(w),Rsb(w)); - return (1); -} - -/* Long Immediate instructions */ -int -limmDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - db_printf("\tL'%X,%%r%d", Im21(w), Rtb(w)); - return (1); -} - - -/* Branch and Link instruction(s) (Branch, too!!) */ -int -blDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register OFS tgtofs = ofs + 8 + Bdisp(w); - register u_int link = Rtb(w); - - if (link && !Match("gate")) - db_printf("l"); - if (Nu(w)) - db_printf(",n"); - db_printf("\t"); - - db_printsym((vaddr_t)tgtofs, DB_STGY_ANY, db_printf); - - if (link || Match("gate")) - db_printf(",%%r%d",link); - - return (1); -} - -/* Branch Register instruction */ -int -brDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - db_printf("%s\t%%r%d,%%r%d", Nu(w)?",n":"", Rsa(w), Rtb(w)); - return (1); -} - -/* Dispatch instructions */ -int -bvDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - db_printf("%s\t%%r%d(%%r%d)", Nu(w)?",n":"", Rsa(w), Rsb(w)); - return (1); -} - -/* Branch External instructions */ -int -beDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register int d = Bdisp(w); - register const char *p; - char s[2]; - - s[1] = '\0'; - if (d < 0) { - d = -d; - s[0] = '-'; - } else - s[0] = '\0'; - - p = Nu(w)? ",n":""; - db_printf("%s\tR'%s%X(%%sr%d,%%r%d)", p, s, d, Sr(w), Rsb(w)); - return (1); -} - - -/* Compare/Add and Branch instructions */ -int -cbDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register OFS tgtofs = ofs + 8 + Cbdisp(w); - - if (Match("movb")) - db_printf("%s", edDCond(Cond(w))); - else if (Match("addb")) - db_printf("%s", addDCond(Cond(w) << 1)); - else - db_printf("%s", subDCond(Cond(w) << 1)); - db_printf("%s\t%%r%d,%%r%d,", Nu(w)?",n":"", Rsa(w), Rsb(w)); - db_printsym((vaddr_t)tgtofs, DB_STGY_ANY, db_printf); - return (1); -} - -/* Compare/Add and Branch Immediate instructions */ -int -cbiDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register OFS tgtofs = ofs + 8 + Cbdisp(w); - - if (Match("movib")) - db_printf("%s", edDCond(Cond(w))); - else if (Match("addib")) - db_printf("%s", addDCond(Cond(w) << 1)); - else - db_printf("%s", subDCond(Cond(w) << 1)); - db_printf("%s\t%d,%%r%d,", Nu(w)? ",n":"", Ima5(w), Rsb(w)); - db_printsym((vaddr_t)tgtofs, DB_STGY_ANY, db_printf); - return (1); -} - -/* Branch on Bit instructions */ -int -bbDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register OFS tgtofs = ofs + 8 + Cbdisp(w); - register const char *p; - - db_printf("%s", edDCond(Cond(w))); - p = Nu(w)? ",n":""; - if (Match("bvb")) - db_printf("%s\t%%r%d,", p, Rta(w)); - else - db_printf("%s\t%%r%d,%d,", p, Rsa(w), Imb5(w)); - db_printsym((vaddr_t)tgtofs, DB_STGY_ANY, db_printf); - return (1); -} - -/* Arithmetic instructions */ -int -ariDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - if (Match("or") && Rsb(w) == 0 && Cond4(w) == NEV) { - if (Rsa(w) == 0 && Rtc(w) == 0) - db_printf("nop"); - else - db_printf("copy\t%%r%d,%%r%d",Rsa(w),Rtc(w)); - } else - db_printf("%s%s\t%%r%d,%%r%d,%%r%d", i->mnem, - subDCond(Cond4(w)), Rsa(w),Rsb(w),Rtc(w)); - return(1); -} - -/* System control operations */ -int -scDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - if (Match("mtctl")) { - if (Rtb(w) == 11) - db_printf("mtsar\t%%r%d",Rsa(w)); - else - db_printf("mtctl\t%%r%d,%%cr%d",Rsa(w),Rtb(w)); - return (1); - } - db_printf("%s", i->mnem); - if (Match("ssm") || Match("rsm")) - db_printf("\t%d,%%r%d",Ima5A(w),Rtc(w)); - else if (Match("mtsm")) db_printf("\t%%r%d",Rsa(w)); - else if (Match("ldprid")) db_printf("\t%%r%d",Rtc(w)); - else if (Match("mtsp")) db_printf("\t%%r%d,%%sr%d",Rsa(w),Sr(w)); - else if (Match("mfsp")) db_printf("\t%%sr%d,%%r%d",Sr(w),Rtc(w)); - else if (Match("mfctl")) db_printf("\t%%cr%d,%%r%d",Rsb(w),Rtc(w)); - else if (Match("ldsid")) { - if (Dss(w)) - db_printf("\t(%%sr%d,%%r%d),%%r%d",Dss(w),Rsb(w),Rtc(w)); - else - db_printf("\t(%%r%d),%%r%d",Rsb(w),Rtc(w)); - } else - return (0); - - return (1); -} - -/* Instruction cache/tlb control instructions */ -int -mmgtDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - if (Match("probe")) { - if (ProbeI(w)) { - if (Dss(w)) - db_printf("i\t(%%sr%d,%%r%d),%d,%%r%d", - Dss(w),Rsb(w),Rsa(w),Rtc(w)); - else - db_printf("i\t(%%r%d),%d,%%r%d", - Rsb(w),Rsa(w),Rtc(w)); - } else { - if (Dss(w)) - db_printf("\t(%%sr%d,%%r%d),%%r%d,%%r%d", - Dss(w),Rsb(w),Rsa(w),Rtc(w)); - else - db_printf("\t(%%r%d),%%r%d,%%r%d", - Rsb(w),Rsa(w),Rtc(w)); - } - } - else if (Match("lha") || Match("lpa")) { - if (Modify(w)) - db_printf(",m"); - if (Dss(w)) - db_printf("\t%%r%d(%%sr%d,%%r%d),%%r%d", - Rsa(w),Dss(w),Rsb(w),Rtc(w)); - else - db_printf("\t%%r%d(%%r%d),%%r%d",Rsa(w),Rsb(w),Rtc(w)); - } - else if (Match("pdtlb") || Match("pdc") || Match("fdc")) { - if (Modify(w)) db_printf(",m"); - if (Dss(w)) - db_printf("\t%%r%d(%%sr%d,%%r%d)",Rsa(w),Dss(w),Rsb(w)); - else - db_printf("\t%%r%d(%%r%d)",Rsa(w),Rsb(w)); - } - else if (Match("pitlb") || Match("fic")) { - if (Modify(w)) - db_printf(",m"); - db_printf("\t%%r%d(%%sr%d,%%r%d)",Rsa(w),Sr(w),Rsb(w)); - } - else if (Match("idtlb")) { - if (Dss(w)) - db_printf("\t%%r%d,(%%sr%d,%%r%d)",Rsa(w),Dss(w),Rsb(w)); - else - db_printf("\t%%r%d,(%%r%d)",Rsa(w),Rsb(w)); - } - else if (Match("iitlb")) - db_printf("\t%%r%d,(%%sr%d,%%r%d)",Rsa(w),Sr(w),Rsb(w)); - else - return (0); - - return(1); -} - -/* break instruction */ -int -brkDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - db_printf("\t%d,%d",Bi1(w),Bi2(w)); - return (1); -} - -int -floatDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register u_int op1, r1, fmt, t; - u_int op2, r2, dfmt; - char *p; - - op1 = CoprExt1(w); - op2 = CoprExt2(w); - fmt = (op1 >> 2) & 3; /* get precision of source */ - -#define ST(r) ((fmt & 1)? fdreg[(r)]:fsreg[(r)]) - /* - * get first (or only) source register - * (independent of class) - */ - r1 = (op1 >> 11) & 0x3e; - if ((fmt & 1) == 0 && (Uid(w) & 2)) - r1++; - - if (op1 & 2) { /* class 2 or 3 */ - /* - * get second source register - */ - r2 = (op1 >> 6) & 0x3e; - if (fmt == 2) - r2++; - - if ((op1 & 1) == 0) { /* class 2 */ - /* Opclass 2: 2 sources, no destination */ - switch((op1 >> 4) & 7) { - case 0: - p = "cmp"; - break; - default: - return(0); - } - db_printf("%s,%s",p,fmtStrTbl[fmt]); - db_printf(",%s\t%%f%s,%%f%s", - condStrTbl[op2], ST(r1), ST(r2)); - return (1); - } - /* - * get target register (class 3) - */ - t = (op2 << 1); - if ((fmt & 1) == 0 && (Uid(w) & 1)) - t++; - /* Opclass 3: 2 sources, 1 destination */ - switch((op1 >> 4) & 7) { - case 0: p = "add"; break; - case 1: p = "sub"; break; - case 2: p = (Fpi(w)) ? "mpyi" : "mpy"; break; - case 3: p = "div"; break; - case 4: p = "rem"; break; - default: return (0); - } - db_printf("%s,%s", p, fmtStrTbl[fmt]); - db_printf("\t%%f%s,%%f%s,%%f%s",ST(r1),ST(r2),ST(t)); - } else if (op1 & 1) { /* class 1 */ - dfmt = (op1 >> 4) & 3; -#define DT(r) ((dfmt & 1)? fdreg[(r)]:fsreg[(r)]) - - /* - * get target register - */ - t = (op2 << 1); - if ((dfmt & 1) == 0 && (Uid(w) & 1)) - t++; - /* Opclass 1: 1 source, 1 destination conversions */ - switch((op1 >> 6) & 3) { - case 0: p = "ff"; break; - case 1: p = "xf"; break; - case 2: p = "fx"; break; - case 3: p = "fxt"; break; - } - db_printf("%s,%s", p, fmtStrTbl[fmt]); - db_printf(",%s\t%%f%s,%%f%s",fmtStrTbl[dfmt],ST(r1),DT(t)); - } else { /* class 0 */ - /* - * get target register - */ - t = (op2 << 1); - if ((fmt & 1) == 0 && (Uid(w) & 1)) - t++; - /* Opclass 0: 1 source, 1 destination */ - switch((op1 >> 4) & 7) { - case 1: p = "rsqrt"; break; - case 2: p = "cpy"; break; - case 3: p = "abs"; break; - case 4: p = "sqrt"; break; - case 5: p = "rnd"; break; - default: return (0); - } - db_printf("%s,%s",p,fmtStrTbl[fmt]); - db_printf("\t%%f%s,%%f%s",ST(r1),ST(t)); - } - return (1); -} - -int -fcoprDasm(w, op1, op2) - int w; - u_int op1, op2; -{ - register u_int r1, r2, t, fmt, dfmt; - register char *p; - - if (AstNu(w) && op1 == ((1<<4) | 2)) { - if (op2 == 0 || op2 == 1 || op2 == 2) { - db_printf("ftest"); - if (op2 == 1) - db_printf(",acc"); - else if (op2 == 2) - db_printf(",rej"); - return (1); - } - return (0); - } else if (0 == op1 && 0 == op2) { - db_printf("fcopr identify"); - return (1); - } - switch(op1 & 3) { - case 0: - /* Opclass 0: 1 source, 1 destination */ - r1 = (op1 >> 12) & 0x1f; t = op2; fmt = (op1 >> 2) & 3; - switch((op1 >> 4) & 7) { - case 1: p = "rsqrt"; break; - case 2: p = "cpy"; break; - case 3: p = "abs"; break; - case 4: p = "sqrt"; break; - case 5: p = "rnd"; break; - default: return(0); - } - db_printf("f%s,%s\t%%fr%d,%%fr%d", p, fmtStrTbl[fmt], r1, t); - break; - case 1: - /* Opclass 1: 1 source, 1 destination conversions */ - r1 = (op1 >> 12) & 0x1f; t = op2; - fmt = (op1 >> 2) & 3; dfmt = (op1 >> 4) & 3; - switch((op1 >> 6) & 3) { - case 0: p = "ff"; break; - case 1: p = "xf"; break; - case 2: p = "fx"; break; - case 3: p = "fxt"; break; - } - db_printf("fcnv%s,%s,%s\t%%fr%d,%%fr%d", - p, fmtStrTbl[fmt], fmtStrTbl[dfmt], r1, t); - break; - case 2: - /* Opclass 2: 2 sources, no destination */ - r1 = (op1 >> 12) & 0x1f; r2 = (op1 >> 7) & 0x1f; - fmt = (op1 >> 2) & 3; - switch((op1 >> 4) & 7) { - case 0: p = "fcmp"; break; - default: return (0); - } - db_printf("%s,%s,%s\t%%fr%d,%%fr%d", - p,fmtStrTbl[fmt],condStrTbl[op2],r1,r2); - break; - case 3: - /* Opclass 3: 2 sources, 1 destination */ - r1 = (op1 >> 12) & 0x1f; r2 = (op1 >> 7) & 0x1f; t = op2; - fmt = (op1 >> 2) & 3; - switch((op1 >> 4) & 7) { - case 0: p = "add"; break; - case 1: p = "sub"; break; - case 2: p = "mpy"; break; - case 3: p = "div"; break; - case 4: p = "rem"; break; - default: return (0); - } - db_printf("f%s,%s\t%%fr%d,%%fr%d,%%fr%d", - p, fmtStrTbl[fmt], r1, r2, t); - break; - default: - return(0); - } - return (1); -} - -int -coprDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register u_int uid = Uid(w); - register int load = 0; - register char *pfx = uid > 1 ? "c" : "f"; - register int dreg = 0; - - if (Match("copr")) { - if (uid) { - db_printf("copr,%d,0x%x",uid,CoprExt(w)); - if (AstNu(w)) - db_printf(",n"); - return (1); - } - return fcoprDasm(w, CoprExt1(w),CoprExt2(w)); - } - if (Match("cldd")) { - dreg = 1; - load = 1; - db_printf("%sldd",pfx); - } else if (Match("cldw")) { - load = 1; - db_printf("%sldw",pfx); - } else if (Match("cstd")) { - dreg = 1; - db_printf("%sstd",pfx); - } else if (Match("cstw")) - db_printf("%sstw",pfx); - else - return (0); - - if (ShortDisp(w)) { - db_printf("s"); - if (AstNu(w)) - db_printf(",m%s", ModBefore(w)?"b":"a"); - } - else { - db_printf("x"); - if (AstNu(w)) - db_printf(",%sm", IndxShft(w)?"s":""); - else if (IndxShft(w)) - db_printf(",s"); - } - switch (CacheCtrl(w)) { - case NOACTION: break; - case STACKREF: db_printf(",c"); break; - case SEQPASS: db_printf(",q"); break; - case PREFETCH: db_printf(",p"); break; - } - if (load) { - register const char *p; - - if (dreg) - p = fdreg[(Rtc(w)<<1)+(uid&1)]; - else - p = fsreg[(Rtc(w)<<1)+(uid&1)]; - - if (ShortDisp(w)) - db_printf("\t%d",Ima5(w)); - else - db_printf("\t%%r%d",Rsa(w)); - if (Dss(w)) - db_printf("(%%sr%d,%%r%d),%%f%s", Dss(w),Rsb(w), p); - else - db_printf("(%%r%d),%%f%s",Rsb(w), p); - } else { - register const char *p; - - if (dreg) - p = fdreg[(Rsc(w)<<1)+(uid&1)]; - else - p = fsreg[(Rsc(w)<<1)+(uid&1)]; - - if (ShortDisp(w)) - db_printf("\t%%f%s,%d", p, Ima5(w)); - else - db_printf("\t%%f%s,%%r%d", p, Rta(w)); - if (Dss(w)) - db_printf("(%%sr%d,%%r%d)",Dss(w),Rsb(w)); - else - db_printf("(%%r%d)",Rsb(w)); - } - return (1); -} - -int -lpkDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - /* - * Floating point STore Quad - * Short or Indexed - */ - if (ShortDisp(w)) { - if (Modify(w)) - db_printf(",m%s", ModBefore(w)?"b":"a"); - } else { - if (Modify(w)) - db_printf(",%sm", IndxShft(w)? "s":""); - else if (IndxShft(w)) - db_printf(",s"); - } - switch (CacheCtrl(w)) { - case NOACTION: break; - case STACKREF: db_printf(",c"); break; - case SEQPASS: db_printf(",q"); break; - case PREFETCH: db_printf(",p"); break; - } - if (ShortDisp(w)) - db_printf("\t%%fr%d,%d",Rsc(w),Ima5(w)); - else - db_printf("\t%%fr%d,%%r%d",Rsc(w),Rta(w)); - if (Dss(w)) - db_printf("(%%sr%d,%%r%d)",Dss(w),Rsb(w)); - else - db_printf("(%%r%d)",Rsb(w)); - return (1); -} - -int -diagDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - if (0x0b0 == BitfR(w,19,8,_b198)) /* mtcpu */ - db_printf("mtcpu\t%%r%d,%%dr%d", Rsa(w), Rtb(w)); - else if (0x0d0 == BitfR(w,19,8,_b198)) /* mfcpu */ - db_printf("mfcpu\t%%dr%d,%%r%d", Rsb(w), Rta(w)); - else { - db_printf("%s", i->mnem); - if (Match("diag")) - db_printf("\t0x%X",w & 0x03ffffff); - else - return (0); - } - return (1); -} - -int -fmpysubDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - if (SinglePrec(w)) - db_printf("SUB,SGL\t%%f%s,%%f%s,%%f%s,%%f%s,%%f%s", - fsreg[Ms1(w)], fsreg[Ms2(w)], fsreg[Mt(w)], - fsreg[As(w)], fsreg[Ad(w)]); - else - db_printf("SUB,DBL\t%%f%s,%%f%s,%%f%s,%%f%s,%%f%s", - fdreg[Ms1(w)], fdreg[Ms2(w)], fdreg[Mt(w)], - fdreg[As(w)], fdreg[Ad(w)]); - return (1); -} - -int -fmpyaddDasm(i, ofs, w) - const struct inst *i; - OFS ofs; - int w; -{ - register const char - *ms1 = SinglePrec(w) ? fsreg[Ms1(w)] : fdreg[Ms1(w)], - *ms2 = SinglePrec(w) ? fsreg[Ms2(w)] : fdreg[Ms2(w)], - *mt = SinglePrec(w) ? fsreg[Mt(w)] : fdreg[Mt(w)], - *as = SinglePrec(w) ? fsreg[As(w)] : fdreg[As(w)], - *ad = SinglePrec(w) ? fsreg[Ad(w)] : fdreg[Ad(w)]; - - if (Rsd(w) == 0) - db_printf("\t%%fcfxt,%s,%%f%s,%%f%s,%%f%s", - ((SinglePrec(w)) ? "sgl" : "dbl"), ms1, ms2, mt); - else - db_printf("add%s\t%%f%s,%%f%s,%%f%s,%%f%s,%%f%s", - ((SinglePrec(w)) ? "sgl" : "dbl"), ms1, ms2, mt, as, ad); - - return (1); -} - -vaddr_t -db_disasm(vaddr_t loc, int flag) -{ - register const struct inst *i; - register const struct majoropcode *m; - register u_int ext; - int ok; - uint32_t instruct; - OFS ofs = loc; - - if (loc == PC_REGS(&ddb_regs) && ddb_regs.tf_iir) - instruct = ddb_regs.tf_iir; - else if (USERMODE(loc)) { - if (copyinsn(NULL, (uint32_t *)(loc &~ HPPA_PC_PRIV_MASK), - &instruct)) - instruct = 0; - } else - instruct = *(int *)loc; - - ok = 0; - if (iExInit() != 0) { - m = &majopcs[Opcode(instruct)]; - ext = OpExt(instruct, m); - if (ext <= m->maxsubop) { - /* special hack for majopcs table layout */ - if (m->maxsubop == 1) - i = (const struct inst *)m->subops; - else - i = m->subops[ext]; - - if (i && i->mnem[0] != '?') { - if (i->dasmfcn != coprDasm && - i->dasmfcn != diagDasm && - i->dasmfcn != ariDasm && - i->dasmfcn != scDasm && - i->dasmfcn != ldDasm) - db_printf("%s", i->mnem); - if (i->dasmfcn) - ok = (*i->dasmfcn)(i, ofs, instruct); - } - } - } - - if (!ok) - db_printf("<%08x>", instruct); - - db_printf("\n"); - return (loc + sizeof(instruct)); -} diff --git a/sys/arch/hppa/hppa/db_interface.c b/sys/arch/hppa/hppa/db_interface.c deleted file mode 100644 index 2d278b035..000000000 --- a/sys/arch/hppa/hppa/db_interface.c +++ /dev/null @@ -1,349 +0,0 @@ -/* $OpenBSD: db_interface.c,v 1.49 2023/04/26 16:53:58 claudio Exp $ */ - -/* - * Copyright (c) 1999-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#undef DDB_DEBUG - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -void kdbprinttrap(int, int); - -extern char *trap_type[]; -extern int trap_types; - -db_regs_t ddb_regs; -struct db_variable db_regs[] = { - { "flags", (long *)&ddb_regs.tf_flags, FCN_NULL }, - { "r1", (long *)&ddb_regs.tf_r1, FCN_NULL }, - { "rp", (long *)&ddb_regs.tf_rp, FCN_NULL }, - { "r3", (long *)&ddb_regs.tf_r3, FCN_NULL }, - { "r4", (long *)&ddb_regs.tf_r4, FCN_NULL }, - { "r5", (long *)&ddb_regs.tf_r5, FCN_NULL }, - { "r6", (long *)&ddb_regs.tf_r6, FCN_NULL }, - { "r7", (long *)&ddb_regs.tf_r7, FCN_NULL }, - { "r8", (long *)&ddb_regs.tf_r8, FCN_NULL }, - { "r9", (long *)&ddb_regs.tf_r9, FCN_NULL }, - { "r10", (long *)&ddb_regs.tf_r10, FCN_NULL }, - { "r11", (long *)&ddb_regs.tf_r11, FCN_NULL }, - { "r12", (long *)&ddb_regs.tf_r12, FCN_NULL }, - { "r13", (long *)&ddb_regs.tf_r13, FCN_NULL }, - { "r14", (long *)&ddb_regs.tf_r14, FCN_NULL }, - { "r15", (long *)&ddb_regs.tf_r15, FCN_NULL }, - { "r16", (long *)&ddb_regs.tf_r16, FCN_NULL }, - { "r17", (long *)&ddb_regs.tf_r17, FCN_NULL }, - { "r18", (long *)&ddb_regs.tf_r18, FCN_NULL }, - { "r19", (long *)&ddb_regs.tf_t4, FCN_NULL }, - { "r20", (long *)&ddb_regs.tf_t3, FCN_NULL }, - { "r21", (long *)&ddb_regs.tf_t2, FCN_NULL }, - { "r22", (long *)&ddb_regs.tf_t1, FCN_NULL }, - { "r23", (long *)&ddb_regs.tf_arg3, FCN_NULL }, - { "r24", (long *)&ddb_regs.tf_arg2, FCN_NULL }, - { "r25", (long *)&ddb_regs.tf_arg1, FCN_NULL }, - { "r26", (long *)&ddb_regs.tf_arg0, FCN_NULL }, - { "r27", (long *)&ddb_regs.tf_dp, FCN_NULL }, - { "r28", (long *)&ddb_regs.tf_ret0, FCN_NULL }, - { "r29", (long *)&ddb_regs.tf_ret1, FCN_NULL }, - { "r30", (long *)&ddb_regs.tf_sp, FCN_NULL }, - { "r31", (long *)&ddb_regs.tf_r31, FCN_NULL }, - { "sar", (long *)&ddb_regs.tf_sar, FCN_NULL }, - - { "rctr", (long *)&ddb_regs.tf_rctr, FCN_NULL }, - { "ccr", (long *)&ddb_regs.tf_ccr, FCN_NULL }, - { "eirr", (long *)&ddb_regs.tf_eirr, FCN_NULL }, - { "eiem", (long *)&ddb_regs.tf_eiem, FCN_NULL }, - { "iir", (long *)&ddb_regs.tf_iir, FCN_NULL }, - { "isr", (long *)&ddb_regs.tf_isr, FCN_NULL }, - { "ior", (long *)&ddb_regs.tf_ior, FCN_NULL }, - { "ipsw", (long *)&ddb_regs.tf_ipsw, FCN_NULL }, - { "iisqh", (long *)&ddb_regs.tf_iisq_head, FCN_NULL }, - { "iioqh", (long *)&ddb_regs.tf_iioq_head, FCN_NULL }, - { "iisqt", (long *)&ddb_regs.tf_iisq_tail, FCN_NULL }, - { "iioqt", (long *)&ddb_regs.tf_iioq_tail, FCN_NULL }, - - { "sr0", (long *)&ddb_regs.tf_sr0, FCN_NULL }, - { "sr1", (long *)&ddb_regs.tf_sr1, FCN_NULL }, - { "sr2", (long *)&ddb_regs.tf_sr2, FCN_NULL }, - { "sr3", (long *)&ddb_regs.tf_sr3, FCN_NULL }, - { "sr4", (long *)&ddb_regs.tf_sr4, FCN_NULL }, - { "sr5", (long *)&ddb_regs.tf_sr5, FCN_NULL }, - { "sr6", (long *)&ddb_regs.tf_sr6, FCN_NULL }, - { "sr7", (long *)&ddb_regs.tf_sr7, FCN_NULL }, - - { "pidr1", (long *)&ddb_regs.tf_pidr1, FCN_NULL }, - { "pidr2", (long *)&ddb_regs.tf_pidr2, FCN_NULL }, -#ifdef pbably_not_worth_it - { "pidr3", (long *)&ddb_regs.tf_pidr3, FCN_NULL }, - { "pidr4", (long *)&ddb_regs.tf_pidr4, FCN_NULL }, -#endif - - { "vtop", (long *)&ddb_regs.tf_vtop, FCN_NULL }, - { "cr28", (long *)&ddb_regs.tf_cr28, FCN_NULL }, - { "cr30", (long *)&ddb_regs.tf_cr30, FCN_NULL }, -}; -struct db_variable *db_eregs = db_regs + nitems(db_regs); - -void -db_enter(void) -{ - extern int kernelmapped; /* from locore.S */ - if (kernelmapped) - __asm volatile ("break %0, %1" - :: "i" (HPPA_BREAK_KERNEL), "i" (HPPA_BREAK_KGDB)); -} - -void -db_read_bytes(vaddr_t addr, size_t size, char *data) -{ - register char *src = (char *)addr; - - while (size--) - *data++ = *src++; -} - -void -db_write_bytes(vaddr_t addr, size_t size, char *data) -{ - register char *dst = (char *)addr; - - while (size--) - *dst++ = *data++; - - /* unfortunately ddb does not provide any hooks for these */ - ficache(HPPA_SID_KERNEL, (vaddr_t)data, size); - fdcache(HPPA_SID_KERNEL, (vaddr_t)data, size); -} - - -/* - * Print trap reason. - */ -void -kdbprinttrap(int type, int code) -{ - type &= ~T_USER; /* just in case */ - db_printf("kernel: "); - if (type >= trap_types || type < 0) - db_printf("type 0x%x", type); - else - db_printf("%s", trap_type[type]); - db_printf(" trap, code=0x%x\n", code); -} - -/* - * db_ktrap - field a BPT trap - */ -int -db_ktrap(int type, int code, db_regs_t *regs) -{ - extern label_t *db_recover; - int s; - - switch (type) { - case T_IBREAK: - case T_DBREAK: - case -1: - break; - default: - if (!db_panic) - return (0); - - kdbprinttrap(type, code); - if (db_recover != 0) { - db_error("Caught exception in DDB; continuing...\n"); - /* NOT REACHED */ - } - } - - /* XXX Should switch to kdb`s own stack here. */ - - s = splhigh(); - ddb_regs = *regs; - db_active++; - cnpollc(1); - db_trap(type, code); - cnpollc(0); - db_active--; - splx(s); - - *regs = ddb_regs; - - return (1); -} - -/* - * Validate an address for use as a breakpoint. - * Any address is allowed for now. - */ -int -db_valid_breakpoint(vaddr_t addr) -{ - return (1); -} - -void -db_stack_trace_print(db_expr_t addr, int have_addr, db_expr_t count, - char *modif, int (*pr)(const char *, ...)) -{ - register_t *fp, pc, rp, *argp; - Elf_Sym *sym; - db_expr_t off; - char *name; - int nargs; - - if (count < 0) - count = 65536; - - if (!have_addr) { - fp = (register_t *)ddb_regs.tf_r3; - pc = ddb_regs.tf_iioq_head; - rp = ddb_regs.tf_rp; - } else { - fp = (register_t *)addr; - pc = 0; - rp = ((register_t *)fp)[-5]; - } - -#ifdef DDB_DEBUG - (*pr) (">> %p, 0x%x, 0x%x\t", fp, pc, rp); -#endif - while (fp && count--) { - - if (USERMODE(pc)) - return; - - sym = db_search_symbol(pc, DB_STGY_ANY, &off); - db_symbol_values (sym, &name, NULL); - - if (name == NULL) - (*pr)("%lx(", pc); - else - (*pr)("%s(", name); - - /* args */ - nargs = 4; - /* - * XXX first four args are passed on registers, and may not - * be stored on stack, dunno how to recover their values yet - */ - for (argp = &fp[-9]; nargs--; argp--) { - (*pr)("%x%s", db_get_value((int)argp, 4, 0), - nargs? ",":""); - } - (*pr)(") at "); - db_printsym(pc, DB_STGY_PROC, pr); - (*pr)("\n"); - - /* TODO: print locals */ - - /* next frame */ - pc = rp; - rp = fp[-5]; - - /* if a terminal frame and not a start of a page - * then skip the trapframe and the terminal frame */ - if (!fp[0]) { - struct trapframe *tf; - - tf = (struct trapframe *)((char *)fp - sizeof(*tf)); - - if (tf->tf_flags & TFF_SYS) - (*pr)("-- syscall #%d(%x, %x, %x, %x, ...)\n", - tf->tf_t1, tf->tf_arg0, tf->tf_arg1, - tf->tf_arg2, tf->tf_arg3); - else - (*pr)("-- trap #%d%s\n", tf->tf_flags & 0x3f, - (tf->tf_flags & T_USER)? " from user" : ""); - - if (!(tf->tf_flags & TFF_LAST)) { - fp = (register_t *)tf->tf_r3; - pc = tf->tf_iioq_head; - rp = tf->tf_rp; - } else - fp = 0; - } else - fp = (register_t *)fp[0]; -#ifdef DDB_DEBUG - (*pr) (">> %x, %x, %x\t", fp, pc, rp); -#endif - } - - if (count && pc) { - db_printsym(pc, DB_STGY_XTRN, pr); - (*pr)(":\n"); - } -} - -void -stacktrace_save_at(struct stacktrace *st, unsigned int skip) -{ - register_t *fp, pc, rp; - int i; - - fp = (register_t *)__builtin_frame_address(0); - pc = 0; - rp = fp[-5]; - - st->st_count = 0; - for (i = 0; i < STACKTRACE_MAX; i++) { - if (skip == 0) - st->st_pc[st->st_count++] = rp; - else - skip--; - - /* next frame */ - pc = rp; - if (!fp[0] || USERMODE(pc)) - break; - - rp = fp[-5]; - fp = (register_t *)fp[0]; - } -} - -void -stacktrace_save_utrace(struct stacktrace *st) -{ - st->st_count = 0; -} diff --git a/sys/arch/hppa/hppa/disksubr.c b/sys/arch/hppa/hppa/disksubr.c deleted file mode 100644 index f255c0743..000000000 --- a/sys/arch/hppa/hppa/disksubr.c +++ /dev/null @@ -1,265 +0,0 @@ -/* $OpenBSD: disksubr.c,v 1.91 2022/10/11 23:39:07 krw Exp $ */ - -/* - * Copyright (c) 1999 Michael Shalayeff - * Copyright (c) 1997 Niklas Hallqvist - * Copyright (c) 1996 Theo de Raadt - * Copyright (c) 1982, 1986, 1988 Regents of the University of California. - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#include -#include -#include -#include -#include - -int readliflabel(struct buf *, void (*)(struct buf *), - struct disklabel *, daddr_t *, int); - -/* - * Attempt to read a disk label from a device - * using the indicated strategy routine. - * The label must be partly set up before this: - * secpercyl, secsize and anything required for a block i/o read - * operation in the driver's strategy/start routines - * must be filled in before calling us. - */ -int -readdisklabel(dev_t dev, void (*strat)(struct buf *), - struct disklabel *lp, int spoofonly) -{ - struct buf *bp = NULL; - int error; - - if ((error = initdisklabel(lp))) - goto done; - - /* get a buffer and initialize it */ - bp = geteblk(lp->d_secsize); - bp->b_dev = dev; - - error = readliflabel(bp, strat, lp, NULL, spoofonly); - if (error == 0) - goto done; - - error = readdoslabel(bp, strat, lp, NULL, spoofonly); - if (error == 0) - goto done; - -#if defined(CD9660) - error = iso_disklabelspoof(dev, strat, lp); - if (error == 0) - goto done; -#endif -#if defined(UDF) - error = udf_disklabelspoof(dev, strat, lp); - if (error == 0) - goto done; -#endif - -done: - if (bp) { - bp->b_flags |= B_INVAL; - brelse(bp); - } - disk_change = 1; - return (error); -} - -int -readliflabel(struct buf *bp, void (*strat)(struct buf *), - struct disklabel *lp, daddr_t *partoffp, int spoofonly) -{ - struct lifdir *p; - struct lifvol *lvp; - int error = 0; - daddr_t fsoff = 0, openbsdstart = MAXLIFSPACE; - int i; - - /* read LIF volume header */ - error = readdisksector(bp, strat, lp, DL_BLKTOSEC(lp, - btodb(LIF_VOLSTART))); - if (error) - return (error); - - lvp = (struct lifvol *)bp->b_data; - if (lvp->vol_id != LIF_VOL_ID) { - error = EINVAL; /* no LIF volume header */ - goto done; - } - - /* read LIF directory */ - error = readdisksector(bp, strat, lp, DL_BLKTOSEC(lp, - lifstodb(lvp->vol_addr))); - if (error) - goto done; - - /* scan for LIF_DIR_FS dir entry */ - for (i=0, p=(struct lifdir *)bp->b_data; i < LIF_NUMDIR; p++, i++) { - if (p->dir_type == LIF_DIR_FS || p->dir_type == LIF_DIR_HPLBL) - break; - } - - if (p->dir_type == LIF_DIR_FS) { - fsoff = lifstodb(p->dir_addr); - openbsdstart = 0; - goto finished; - } - - /* Only came here to find the offset... */ - if (partoffp) - goto finished; - - if (p->dir_type == LIF_DIR_HPLBL) { - struct hpux_label *hl; - struct partition *pp; - u_int8_t fstype; - int i; - - /* read LIF directory */ - error = readdisksector(bp, strat, lp, DL_BLKTOSEC(lp, - lifstodb(p->dir_addr))); - if (error) - goto done; - - hl = (struct hpux_label *)bp->b_data; - if (hl->hl_magic1 != hl->hl_magic2 || - hl->hl_magic != HPUX_MAGIC || hl->hl_version != 1) { - error = EINVAL; /* HPUX label magic mismatch */ - goto done; - } - - for (i = 0; i < MAXPARTITIONS; i++) { - DL_SETPSIZE(&lp->d_partitions[i], 0); - DL_SETPOFFSET(&lp->d_partitions[i], 0); - lp->d_partitions[i].p_fstype = 0; - } - - for (i = 0; i < HPUX_MAXPART; i++) { - if (!hl->hl_flags[i]) - continue; - if (hl->hl_flags[i] == HPUX_PART_ROOT) { - pp = &lp->d_partitions[0]; - fstype = FS_BSDFFS; - } else if (hl->hl_flags[i] == HPUX_PART_SWAP) { - pp = &lp->d_partitions[1]; - fstype = FS_SWAP; - } else if (hl->hl_flags[i] == HPUX_PART_BOOT) { - pp = &lp->d_partitions[RAW_PART + 1]; - fstype = FS_BSDFFS; - } else - continue; - - DL_SETPSIZE(pp, hl->hl_parts[i].hlp_length * 2); - DL_SETPOFFSET(pp, hl->hl_parts[i].hlp_start * 2); - pp->p_fstype = fstype; - } - - DL_SETPSIZE(&lp->d_partitions[RAW_PART], DL_GETDSIZE(lp)); - DL_SETPOFFSET(&lp->d_partitions[RAW_PART], 0); - lp->d_partitions[RAW_PART].p_fstype = FS_UNUSED; - lp->d_npartitions = MAXPARTITIONS; - lp->d_magic = DISKMAGIC; - lp->d_magic2 = DISKMAGIC; - lp->d_version = 1; - lp->d_checksum = 0; - lp->d_checksum = dkcksum(lp); - /* drop through */ - } - -finished: - /* record the OpenBSD partition's placement for the caller */ - if (partoffp) - *partoffp = fsoff; - else { - DL_SETBSTART(lp, DL_BLKTOSEC(lp, openbsdstart)); - DL_SETBEND(lp, DL_GETDSIZE(lp)); /* XXX */ - } - - /* don't read the on-disk label if we are in spoofed-only mode */ - if (spoofonly) - goto done; - - error = readdisksector(bp, strat, lp, DL_BLKTOSEC(lp, fsoff + - LABELSECTOR)); - if (error) - goto done; - - error = checkdisklabel(bp->b_dev, bp->b_data, lp, openbsdstart, - DL_GETDSIZE(lp)); - -done: - return (error); -} - -/* - * Write disk label back to device after modification. - */ -int -writedisklabel(dev_t dev, void (*strat)(struct buf *), struct disklabel *lp) -{ - daddr_t partoff = -1; - int error = EIO; - int offset; - struct disklabel *dlp; - struct buf *bp = NULL; - - /* get a buffer and initialize it */ - bp = geteblk(lp->d_secsize); - bp->b_dev = dev; - - /* Read it in, slap the new label in, and write it back out */ - if (readliflabel(bp, strat, lp, &partoff, 1) == 0) { - error = readdisksector(bp, strat, lp, DL_BLKTOSEC(lp, - partoff + LABELSECTOR)); - offset = LABELOFFSET; - } else if (readdoslabel(bp, strat, lp, &partoff, 1) == 0) { - error = readdisksector(bp, strat, lp, DL_BLKTOSEC(lp, - partoff + DOS_LABELSECTOR)); - offset = DL_BLKOFFSET(lp, partoff + DOS_LABELSECTOR); - } else - goto done; - - if (error) - goto done; - - dlp = (struct disklabel *)(bp->b_data + offset); - *dlp = *lp; - CLR(bp->b_flags, B_READ | B_WRITE | B_DONE); - SET(bp->b_flags, B_BUSY | B_WRITE | B_RAW); - (*strat)(bp); - error = biowait(bp); - -done: - if (bp) { - bp->b_flags |= B_INVAL; - brelse(bp); - } - disk_change = 1; - return (error); -} diff --git a/sys/arch/hppa/hppa/fpemu.S b/sys/arch/hppa/hppa/fpemu.S deleted file mode 100644 index f81ebba15..000000000 --- a/sys/arch/hppa/hppa/fpemu.S +++ /dev/null @@ -1,330 +0,0 @@ -/* $OpenBSD: fpemu.S,v 1.15 2018/11/15 21:27:31 jmc Exp $ */ - -/* - * Copyright (c) 2000-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include "assym.h" - -#define FPEMU_VERSION (1 << 11) - -#define FP_TABLE2(name,ep0,ep1,ep2,ep3) \ - ldil L%$fpemu_tbl$name, t1 ! \ - ldo R%$fpemu_tbl$name(t1), t1 ! \ - ldwx,s r1(t1), t2 ! \ - bv r0(t2) ! \ - copy r0, ret0 ! \ - .label $fpemu_tbl$name ! \ - .import ep0##_##name, code ! \ - .import ep1##_##name, code ! \ - .import ep2##_##name, code ! \ - .import ep3##_##name, code ! \ - .word ep0##_##name, ep1##_##name, ep2##_##name, ep3##_##name - -#define FP_TABLE3(name,ep0,ep1,ep2,ep3,ep4,ep5,ep6,ep7,ep8,ep9,epa,epb,epc,epd,epe,epf) \ - ldil L%$fpemu_tbl$name, t1 ! \ - ldo R%$fpemu_tbl$name(t1), t1 ! \ - ldwx,s r1(t1), t2 ! \ - bv r0(t2) ! \ - nop ! \ - .label $fpemu_tbl$name ! \ - .import ep0##_##name, code ! \ - .import ep1##_##name, code ! \ - .import ep2##_##name, code ! \ - .import ep3##_##name, code ! \ - .import ep4##_##name, code ! \ - .import ep5##_##name, code ! \ - .import ep6##_##name, code ! \ - .import ep7##_##name, code ! \ - .import ep8##_##name, code ! \ - .import ep9##_##name, code ! \ - .import epa##_##name, code ! \ - .import epb##_##name, code ! \ - .import epc##_##name, code ! \ - .import epd##_##name, code ! \ - .import epe##_##name, code ! \ - .import epf##_##name, code ! \ - .word ep0##_##name, ep1##_##name, ep2##_##name, ep3##_##name, \ - ep4##_##name, ep5##_##name, ep6##_##name, ep7##_##name, \ - ep8##_##name, ep9##_##name, epa##_##name, epb##_##name, \ - epc##_##name, epe##_##name, epf##_##name - - .text -/* - * fpu_emulate(iir,0,fpregs) - */ -LEAF_ENTRY(fpu_emulate) - - copy arg0, t4 - extru arg0, 18, 3, r31 - extru arg0, 20, 2, r1 - extru arg0, 22, 2, t3 - subi,<> 1, t3, r0 - extru arg0, 16, 2, r31 - - /* - * theoretically we would need to determine the fpu instruction - * exception type (there could be 4 of those, but stick w/ - * non-timex fpus for now) - */ - extru,<> arg0, 10, 5, t1 - ldi 32, t1 /* fpemu zero reg */ - extru,<> arg0, 31, 5, t2 - b,n $fpemu_nzt - nop - /*comib,=,n 2, t3, $fpemu_exit*/ - nop -$fpemu_nzt - /* - * arg0 -- source register (address) - * arg1 -- fpregs context - * arg2 -- target register (address) - * arg3 -- fpregs context - * t3 -- class - * r31 -- subop - * r1 -- format specifier - * (t4 -- copy of arg0, ie iir) - */ - copy arg2, arg3 - copy arg2, arg1 - sh3add t1, arg2, arg0 - sh3add t2, arg2, arg2 - stw r0, 32*8+0(arg1) /* make sure zero reg is zero */ - stw r0, 32*8+4(arg1) - - extru,= t4, 24, 1, r0 /* adjust for the L in source */ - addi 4, arg0, arg0 - - comib,=,n 2, t3, $fpemu0c_2 - nop - - extru,= t4, 24, 1, r0 /* adjust for the L in target */ - addi 4, arg2, arg2 - - comib,=,n 0, t3, $fpemu0c_0 - comib,=,n 1, t3, $fpemu0c_1 - comib,=,n 3, t3, $fpemu0c_3 - -$fpemu0c_0 - comib,=,n 2, r1, $fpemu_exit - - comib,=,n 0, r31, $fpemu0c_0_0 - comib,=,n 1, r31, $fpemu_exit - comib,=,n 2, r31, $fpemu0c_0_2 - comib,=,n 3, r31, $fpemu0c_0_3 - comib,=,n 4, r31, $fpemu0c_0_4 - comib,=,n 5, r31, $fpemu0c_0_5 - comib,=,n 6, r31, $fpemu_exit - comib,=,n 7, r31, $fpemu_exit - -$fpemu0c_0_0 - ldi FPEMU_VERSION, t4 - stw t4, 0(arg3) - bv 0(rp) - copy r0, ret0 - -$fpemu0c_0_2 /* fcpy */ - subi 3, r1, r1 - ldw 0*4(arg0), t1 - ldw 1*4(arg0), t2 - ldw 2*4(arg0), t3 - blr,n r1, r0 - ldw 3*4(arg0), t4 - stw t3, 2*4(arg2) - stw t4, 3*4(arg2) - nop - nop - nop - stw t2, 1*4(arg2) - stw t1, 0*4(arg2) - bv 0(rp) - copy r0, ret0 - -$fpemu0c_0_3 /* fabs */ - subi 3, r1, r1 - ldw 0*4(arg0), t1 - ldw 1*4(arg0), t2 - ldw 2*4(arg0), t3 - ldw 3*4(arg0), t4 - blr,n r1, r0 - depi 0, 0, 1, t1 - stw t3, 2*4(arg2) - stw t4, 3*4(arg2) - nop - nop - nop - stw t2, 1*4(arg2) - stw t1, 0*4(arg2) - bv 0(rp) - copy r0, ret0 - -$fpemu0c_0_4 /* fsqrt */ - /* quad not implemented */ - FP_TABLE2(fsqrt,sgl,dbl,invalid,invalid) - -$fpemu0c_0_5 /* frnd */ - /* quad not implemented */ - FP_TABLE2(frnd,sgl,dbl,invalid,quad) - -$fpemu0c_1 - extru t4, 20, 4, r1 - comib,=,n 0, r31, $fpemu0c_1_0 - comib,=,n 1, r31, $fpemu0c_1_1 - comib,=,n 2, r31, $fpemu0c_1_2 - comib,=,n 3, r31, $fpemu0c_1_3 - -$fpemu0c_1_0 /* fcnvff */ - FP_TABLE3(fcnvff, invalid, dbl_to_sgl, invalid, quad_to_sgl, sgl_to_dbl, invalid, invalid, quad_to_dbl, invalid, invalid, invalid, invalid, sgl_to_quad, dbl_to_quad, invalid, invalid) - -$fpemu0c_1_1 /* fcnvxf */ - FP_TABLE3(fcnvxf, sgl_to_sgl, dbl_to_sgl, invalid, quad_to_sgl, sgl_to_dbl, dbl_to_dbl, invalid, quad_to_dbl, invalid, invalid, invalid, invalid, sgl_to_quad, dbl_to_quad, invalid, quad_to_quad) - -$fpemu0c_1_2 /* fcnvfx */ - FP_TABLE3(fcnvfx, sgl_to_sgl, dbl_to_sgl, invalid, quad_to_sgl, sgl_to_dbl, dbl_to_dbl, invalid, quad_to_dbl, invalid, invalid, invalid, invalid, sgl_to_quad, dbl_to_quad, invalid, quad_to_quad) - -$fpemu0c_1_3 /* fcnvfxt */ - FP_TABLE3(fcnvfxt, sgl_to_sgl, dbl_to_sgl, invalid, quad_to_sgl, sgl_to_dbl, dbl_to_dbl, invalid, quad_to_dbl, invalid, invalid, invalid, invalid, sgl_to_quad, dbl_to_quad, invalid, quad_to_quad) - -$fpemu0c_2 - comib,=,n 1, r31, $fpemu0c_2_1 - comib,<>,n 0, r31, $fpemu_exit - -$fpemu0c_2_0 - extru,<> t4, 15, 5, t1 - ldi 32, t1 - sh3add t1, arg3, arg1 - extru,= t4, 19, 1, r0 /* see if it's the L reg */ - addi 4, arg1, arg1 - extru t4, 31, 5, arg2 - FP_TABLE2(fcmp,sgl,dbl,invalid,invalid) - -$fpemu0c_2_1 - comib,<>,n 0, r1, $fpemu_exit - - /* XXX timex is much more complicated */ - ldw 0(arg3), t1 - ldi 0, ret0 - extru,<> t1, 5, 1, r0 - bv,n r0(rp) - - /* advance the pcqueue */ - mtctl r0, pcsq - mfctl pcsq, t2 - mtctl t2, pcsq - mtctl t2, pcsq - mtctl r0, pcoq - mfctl pcoq, t2 - mtctl t2, pcoq - ldo 4(t2), t2 - bv r0(rp) - mtctl t2, pcoq - -$fpemu0c_3 - extru,<> t4, 15, 5, t1 - ldi 32, t1 - extru,= t4, 19, 1, r0 /* see if it's the L reg */ - addi 4, arg1, arg1 - blr r31, r0 - nop - - b $fpemu0c_3_0 - sh3add t1, arg1, arg1 - b $fpemu0c_3_1 - sh3add t1, arg1, arg1 - b $fpemu0c_3_2 - sh3add t1, arg1, arg1 - b $fpemu0c_3_3 - sh3add t1, arg1, arg1 - b $fpemu0c_3_4 - sh3add t1, arg1, arg1 - b $fpemu_exit - sh3add t1, arg1, arg1 - b $fpemu_exit - sh3add t1, arg1, arg1 - b $fpemu_exit - sh3add t1, arg1, arg1 - -$fpemu0c_3_0 /* fadd */ - FP_TABLE2(fadd,sgl,dbl,invalid,invalid) - -$fpemu0c_3_1 /* fsub */ - FP_TABLE2(fsub,sgl,dbl,invalid,invalid) - -$fpemu0c_3_2 /* fmpy/xmpy */ - bb,>= t4, 23, $fpemu0c_3_2_f - nop - - FP_TABLE2(xmpy,s,u,s,u) -$fpemu0c_3_2_f - FP_TABLE2(fmpy,sgl,dbl,invalid,invalid) - -$fpemu0c_3_3 /* fdiv */ - FP_TABLE2(fdiv,sgl,dbl,invalid,invalid) - -$fpemu0c_3_4 /* frem */ - FP_TABLE2(frem,sgl,dbl,invalid,invalid) - - .export $fpemu_exit, code -$fpemu_exit - /* these look very ugly, but we don't want to mess up w/ m4 just - * for the sake of overall world prettiness value growth XXX */ -invalid_fsqrt -invalid_frnd -invalid_fcnvff -sgl_to_quad_fcnvff -dbl_to_quad_fcnvff -quad_to_sgl_fcnvff -quad_to_dbl_fcnvff -invalid_fcnvxf -sgl_to_quad_fcnvxf -dbl_to_quad_fcnvxf -quad_to_sgl_fcnvxf -quad_to_dbl_fcnvxf -quad_to_quad_fcnvxf -invalid_fcnvfx -sgl_to_quad_fcnvfx -dbl_to_quad_fcnvfx -quad_to_sgl_fcnvfx -quad_to_dbl_fcnvfx -quad_to_quad_fcnvfx -invalid_fcnvfxt -sgl_to_quad_fcnvfxt -dbl_to_quad_fcnvfxt -quad_to_sgl_fcnvfxt -quad_to_dbl_fcnvfxt -quad_to_quad_fcnvfxt -invalid_fcmp -invalid_fadd -invalid_fsub -invalid_fmpy -invalid_fdiv -invalid_frem - bv 0(rp) - ldi HPPA_FPU_ILL, ret0 -EXIT(fpu_emulate) - - .end diff --git a/sys/arch/hppa/hppa/fpu.c b/sys/arch/hppa/hppa/fpu.c deleted file mode 100644 index 6fdd5b6f9..000000000 --- a/sys/arch/hppa/hppa/fpu.c +++ /dev/null @@ -1,126 +0,0 @@ -/* $OpenBSD: fpu.c,v 1.5 2010/08/07 03:50:01 krw Exp $ */ - -/* - * Copyright (c) 2010 Joel Sing - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -__inline void fpu_proc(struct proc *, int); - -void -fpu_proc_flush(struct proc *p) -{ - fpu_proc(p, 0); -} - -void -fpu_proc_save(struct proc *p) -{ - fpu_proc(p, 1); -} - -__inline void -fpu_proc(struct proc *p, int save) -{ - struct cpu_info *ci = curcpu(); - struct hppa_fpstate *hfp; - struct cpu_info *fpuci; -#ifdef MULTIPROCESSOR - int s; -#endif - - hfp = (struct hppa_fpstate *)p->p_md.md_regs->tf_cr30; - fpuci = (struct cpu_info *)hfp->hfp_cpu; - - if (fpuci == NULL) - return; - -#ifdef MULTIPROCESSOR - if (fpuci != ci) { - - if (hppa_ipi_send(fpuci, HPPA_IPI_FPU_SAVE)) - panic("FPU shootdown failed!"); - - /* - * The sync is essential here since the volatile on hfp_cpu - * is ignored by gcc. Without this we will deadlock since - * hfp_cpu is never reloaded within the loop. - */ - while (hfp->hfp_cpu != NULL) - asm volatile ("sync" ::: "memory"); - - } else if (p->p_md.md_regs->tf_cr30 == ci->ci_fpu_state) { - - s = splipi(); - fpu_cpu_save(save); - splx(s); - - } -#else - if (p->p_md.md_regs->tf_cr30 == ci->ci_fpu_state) - fpu_cpu_save(save); -#endif -} - -/* - * Save or flush FPU state - note that this must be called at IPL IPI when - * running on a MULTIPROCESSOR kernel. - */ -void -fpu_cpu_save(int save) -{ - struct cpu_info *ci = curcpu(); - struct hppa_fpstate *hfp; - struct cpu_info *fpuci; - extern u_int fpu_enable; - -#ifdef MULTIPROCESSOR - splassert(IPL_IPI); -#endif - - if (ci->ci_fpu_state == 0) - return; - - hfp = (struct hppa_fpstate *)ci->ci_fpu_state; - fpuci = (struct cpu_info *)hfp->hfp_cpu; - -#ifdef DIAGNOSTIC - if (fpuci != ci) - panic("FPU context is not on this CPU (%p != %p)", - ci, hfp->hfp_cpu); -#endif - - if (save) { - mtctl(fpu_enable, CR_CCR); - fpu_save((paddr_t)&hfp->hfp_regs); - mtctl(0, CR_CCR); - } else - fpu_exit(); - - hfp->hfp_cpu = NULL; - ci->ci_fpu_state = 0; - asm volatile ("sync" ::: "memory"); -} diff --git a/sys/arch/hppa/hppa/genassym.cf b/sys/arch/hppa/hppa/genassym.cf deleted file mode 100644 index ee816ca58..000000000 --- a/sys/arch/hppa/hppa/genassym.cf +++ /dev/null @@ -1,175 +0,0 @@ -# $OpenBSD: genassym.cf,v 1.48 2019/06/11 15:23:41 mpi Exp $ - -# -# Copyright (c) 1982, 1990, 1993 -# The Regents of the University of California. 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. -# 3. Neither the name of the University nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -# -# @(#)genassym.c 8.3 (Berkeley) 1/4/94 -# - -include -include -include -include -include -include -include -include - -include - -include -include -include -include -include -include -include -include - -# general constants -export HPPA_PID_KERNEL -export HPPA_SID_KERNEL -export VM_MAXUSER_ADDRESS - -# `break' entry points -export HPPA_BREAK_KERNEL -export HPPA_BREAK_GET_PSW -export HPPA_BREAK_SET_PSW - -# saved state fields -struct trapframe -member tf_flags -member TF_PHYS tf_sar -member tf_r1 -member TF_R2 tf_rp -member TF_GOTO tf_rp -member tf_r3 -member tf_r4 -member tf_r5 -member tf_r6 -member tf_r7 -member tf_r8 -member tf_r9 -member tf_r10 -member tf_r11 -member tf_r12 -member tf_r13 -member tf_r14 -member tf_r15 -member tf_r16 -member tf_r17 -member tf_r18 -member TF_R19 tf_t4 -member TF_R20 tf_t3 -member TF_R21 tf_t2 -member TF_R22 tf_t1 -member TF_R23 tf_arg3 -member TF_R24 tf_arg2 -member TF_R25 tf_arg1 -member TF_R26 tf_arg0 -member TF_R27 tf_dp -member TF_R28 tf_ret0 -member TF_R29 tf_ret1 -member TF_R30 tf_sp -member tf_r31 -member tf_sr0 -member tf_sr1 -member tf_sr2 -member tf_sr3 -member tf_sr4 -member tf_sr5 -member tf_sr6 -member tf_sr7 -member TF_CR0 tf_rctr -member TF_CR10 tf_ccr -member TF_IIOQH tf_iioq_head -member TF_IIOQT tf_iioq_tail -member TF_IISQH tf_iisq_head -member TF_IISQT tf_iisq_tail -member TF_CR8 tf_pidr1 -member TF_CR9 tf_pidr2 -member TF_CR11 tf_sar -member TF_CR12 tf_pidr3 -member TF_CR13 tf_pidr4 -member TF_CR15 tf_eiem -member TF_CR19 tf_iir -member TF_CR20 tf_isr -member TF_CR21 tf_ior -member TF_CR22 tf_ipsw -member TF_CR23 tf_eirr -member TF_CR25 tf_vtop -member tf_cr27 -member tf_cr28 -member tf_cr30 - -# proc fields and values -struct proc -member p_addr -member p_stat -member p_md -member P_MD_FLAGS p_md.md_flags -member P_MD_REGS p_md.md_regs - -export SONPROC - -struct pcb -member pcb_fpstate -member pcb_onfault -member pcb_space -member pcb_ksp - -struct user -member u_pcb - -struct uvmexp -member fpswtch - -struct cpu_info -member ci_curproc -member ci_stack -member ci_psw -member ci_cpl -member ci_ipending -member ci_trap_save -member ci_fpu_state -member ci_ipi -member ci_hpa - -struct hppa_fpstate -member hfp_regs -member hfp_cpu - -# system calls -export SYSCALLGATE -export SYS_exit -export SYS_execve -export SYS_sigreturn - -# errno -export EFAULT -export ENAMETOOLONG diff --git a/sys/arch/hppa/hppa/in_cksum.c b/sys/arch/hppa/hppa/in_cksum.c deleted file mode 100644 index fdab18ef6..000000000 --- a/sys/arch/hppa/hppa/in_cksum.c +++ /dev/null @@ -1,123 +0,0 @@ -/* $OpenBSD: in_cksum.c,v 1.4 2010/04/26 19:43:23 kettenis Exp $ */ - -/* - * Copyright (c) 2000 Michael Shalayeff - * All rights reserved. - * - * based on a sparc version of Zubin Dittia. - * Copyright (c) 1995 Zubin Dittia. - * - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include - -/* - * Checksum routine for Internet Protocol family headers. - * - * This routine is very heavily used in the network - * code and should be modified for each CPU to be as fast as possible. - * - * HPPA version. - */ - -#define ADD32 asm volatile( "ldw 0x00(%1), %%r19! ldw 0x04(%1), %%r20\n\t" \ - "add %0, %%r19, %0 ! addc %0, %%r20, %0\n\t" \ - "ldw 0x08(%1), %%r19! ldw 0x0c(%1), %%r20\n\t" \ - "addc %0, %%r19, %0 ! addc %0, %%r20, %0\n\t" \ - "ldw 0x10(%1), %%r19! ldw 0x14(%1), %%r20\n\t" \ - "addc %0, %%r19, %0 ! addc %0, %%r20, %0\n\t" \ - "ldw 0x18(%1), %%r19! ldw 0x1c(%1), %%r20\n\t" \ - "addc %0, %%r19, %0 ! addc %0, %%r20, %0\n\t" \ - "ldo 0x20(%1), %1 ! addc %0, %%r0 , %0" \ - : "+r" (sum), "+r" (w) :: "r20", "r19") -#define ADD16 asm volatile( "ldw 0x00(%1), %%r19! ldw 0x04(%1), %%r20\n\t" \ - "add %0, %%r19, %0! addc %0, %%r20, %0\n\t" \ - "ldw 0x08(%1), %%r19! ldw 0x0c(%1), %%r20\n\t" \ - "addc %0, %%r19, %0! addc %0, %%r20, %0\n\t" \ - "ldo 0x10(%1), %1 ! addc %0, %%r0 , %0" \ - : "+r" (sum), "+r" (w) :: "r20", "r19") - -#define ADDCARRY {if (sum > 0xffff) sum -= 0xffff;} -#define REDUCE {sum = (sum & 0xffff) + (sum >> 16); ADDCARRY} -#define ROL asm volatile ("shd %0, %0, 8, %0" : "+r" (sum)) -#define ADDBYTE {ROL; sum += *w++; bins++; mlen--;} -#define ADDSHORT {sum += *(u_short *)w; w += 2; mlen -= 2;} -#define ADDWORD asm volatile( "ldwm 4(%1), %%r19! add %0, %%r19, %0\n\t" \ - "ldo -4(%2), %2 ! addc %0, 0, %0" \ - : "+r" (sum), "+r" (w), "+r" (mlen) :: "r19") - -int -in_cksum(m, len) - register struct mbuf *m; - register int len; -{ - register u_int sum = 0; - register u_int bins = 0; - - for (; m && len; m = m->m_next) { - register int mlen = m->m_len; - register u_char *w; - - if (!mlen) - continue; - if (len < mlen) - mlen = len; - len -= mlen; - w = mtod(m, u_char *); - - if (mlen > 16) { - /* - * If we are aligned on a doubleword boundary - * do 32 bit bundled operations - */ - if ((7 & (u_long)w) != 0) { - if ((1 & (u_long)w) != 0) - ADDBYTE; - if ((2 & (u_long)w) != 0) - ADDSHORT; - if ((4 & (u_long)w) != 0) - ADDWORD; - } - - while ((mlen -= 32) >= 0) - ADD32; - - mlen += 32; - if (mlen >= 16) { - ADD16; - mlen -= 16; - } - } - - while (mlen > 0) - ADDBYTE; - } - if (bins & 1) - ROL; - REDUCE; - - return (0xffff ^ sum); -} diff --git a/sys/arch/hppa/hppa/intr.c b/sys/arch/hppa/hppa/intr.c deleted file mode 100644 index 7660b3e04..000000000 --- a/sys/arch/hppa/hppa/intr.c +++ /dev/null @@ -1,398 +0,0 @@ -/* $OpenBSD: intr.c,v 1.51 2021/03/11 11:16:56 jsg Exp $ */ - -/* - * Copyright (c) 2002-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -struct hppa_iv { - char pri; - char irq; - char flags; -#define HPPA_IV_CALL 0x01 -#define HPPA_IV_SOFT 0x02 - char pad; - int pad2; - int (*handler)(void *); - void *arg; - u_int bit; - struct hppa_iv *share; - struct hppa_iv *next; - struct evcount *cnt; -} __packed; - -struct hppa_iv intr_store[8*2*CPU_NINTS] __attribute__ ((aligned(32))), - *intr_more = intr_store, *intr_list; -struct hppa_iv intr_table[CPU_NINTS] __attribute__ ((aligned(32))) = { - { IPL_SOFTCLOCK, 0, HPPA_IV_SOFT, 0, 0, NULL }, - { IPL_SOFTNET , 0, HPPA_IV_SOFT, 0, 0, NULL }, - { 0 }, - { 0 }, - { IPL_SOFTTTY , 0, HPPA_IV_SOFT, 0, 0, NULL } -}; -volatile u_long imask[NIPL] = { - 0, - 1 << (IPL_SOFTCLOCK - 1), - 1 << (IPL_SOFTNET - 1), - 0, - 0, - 1 << (IPL_SOFTTTY - 1) -}; - -#ifdef DIAGNOSTIC -void -splassert_check(int wantipl, const char *func) -{ - struct cpu_info *ci = curcpu(); - - if (ci->ci_cpl < wantipl) - splassert_fail(wantipl, ci->ci_cpl, func); -} -#endif - -void -cpu_intr_init(void) -{ - struct cpu_info *ci = curcpu(); - struct hppa_iv *iv; - int level, bit; - u_long mask; - - mask = ci->ci_mask | SOFTINT_MASK; - - /* map the shared ints */ - while (intr_list) { - iv = intr_list; - intr_list = iv->next; - bit = ffs(imask[(int)iv->pri]); - if (!bit--) { - bit = ffs(~mask); - if (!bit--) - panic("cpu_intr_init: out of bits"); - - iv->next = NULL; - iv->bit = 1 << bit; - intr_table[bit] = *iv; - mask |= (1 << bit); - imask[(int)iv->pri] |= (1 << bit); - } else { - iv->bit = 1 << bit; - iv->next = intr_table[bit].next; - intr_table[bit].next = iv; - } - } - - for (level = 0; level < NIPL - 1; level++) - imask[level + 1] |= imask[level]; - - /* XXX the whacky trick is to prevent hardclock from happening */ - mfctl(CR_ITMR, mask); - mtctl(mask - 1, CR_ITMR); - - mtctl(ci->ci_mask, CR_EIEM); - /* ack the unwanted interrupts */ - mfctl(CR_EIRR, mask); - mtctl(mask & (1U << 31), CR_EIRR); - - /* in spl*() we trust, clock is started in initclocks() */ - ci->ci_psw |= PSL_I; - ssm(PSL_I, mask); -} - -/* - * Find an available, non-shared interrupt bit. - * Returns -1 if all interrupt bits are in use. - */ -int -cpu_intr_findirq(void) -{ - int irq; - - for (irq = 0; irq < CPU_NINTS; irq++) - if (intr_table[irq].handler == NULL && - intr_table[irq].pri == 0) - return irq; - - return -1; -} - -void * -cpu_intr_map(void *v, int pri, int irq, int (*handler)(void *), void *arg, - const char *name) -{ - struct hppa_iv *iv, *pv = v, *ivb = pv->next; - struct evcount *cnt; - - if (irq < 0 || irq >= CPU_NINTS) - return (NULL); - - cnt = (struct evcount *)malloc(sizeof *cnt, M_DEVBUF, M_NOWAIT); - if (!cnt) - return (NULL); - - iv = &ivb[irq]; - if (iv->handler) { - if (!pv->share) { - free(cnt, M_DEVBUF, sizeof *cnt); - return (NULL); - } else { - iv = pv->share; - pv->share = iv->share; - iv->share = ivb[irq].share; - ivb[irq].share = iv; - } - } - - evcount_attach(cnt, name, NULL); - iv->pri = pri; - iv->irq = irq; - iv->flags = 0; - iv->handler = handler; - iv->arg = arg; - iv->cnt = cnt; - iv->next = intr_list; - intr_list = iv; - - return (iv); -} - -void * -cpu_intr_establish(int pri, int irq, int (*handler)(void *), void *arg, - const char *name) -{ - struct cpu_info *ci = curcpu(); - struct hppa_iv *iv, *ev; - struct evcount *cnt; - - if (irq < 0 || irq >= CPU_NINTS || intr_table[irq].handler) - return (NULL); - - if ((intr_table[irq].flags & HPPA_IV_SOFT) != 0) - return (NULL); - - cnt = (struct evcount *)malloc(sizeof *cnt, M_DEVBUF, M_NOWAIT); - if (!cnt) - return (NULL); - - ci->ci_mask |= (1 << irq); - imask[pri] |= (1 << irq); - - iv = &intr_table[irq]; - iv->pri = pri; - iv->irq = irq; - iv->bit = 1 << irq; - iv->flags = 0; - iv->handler = handler; - iv->arg = arg; - iv->cnt = cnt; - iv->next = NULL; - iv->share = NULL; - - if (pri == IPL_NESTED) { - iv->flags = HPPA_IV_CALL; - iv->next = intr_more; - intr_more += 2 * CPU_NINTS; - for (ev = iv->next + CPU_NINTS; ev < intr_more; ev++) - ev->share = iv->share, iv->share = ev; - free(cnt, M_DEVBUF, sizeof *cnt); - iv->cnt = NULL; - } else if (name == NULL) { - free(cnt, M_DEVBUF, sizeof *cnt); - iv->cnt = NULL; - } else - evcount_attach(cnt, name, NULL); - - return (iv); -} - -void -cpu_intr(void *v) -{ - struct cpu_info *ci = curcpu(); - struct trapframe *frame = v; - struct hppa_iv *iv; - int pri, r, s, bit; - u_long mask; - void *arg; - - mtctl(0, CR_EIEM); - - s = ci->ci_cpl; - if (ci->ci_in_intr++) - frame->tf_flags |= TFF_INTR; - - /* Process higher priority interrupts first. */ - for (pri = NIPL - 1; pri > s; pri--) { - - mask = imask[pri] ^ imask[pri - 1]; - - while (ci->ci_ipending & mask) { - bit = fls(ci->ci_ipending & mask) - 1; - iv = &intr_table[bit]; - - ci->ci_ipending &= ~(1L << bit); - - if (iv->flags & HPPA_IV_CALL) - continue; - - uvmexp.intrs++; - if (iv->flags & HPPA_IV_SOFT) - uvmexp.softs++; - - ci->ci_cpl = iv->pri; - mtctl(frame->tf_eiem, CR_EIEM); - -#ifdef MULTIPROCESSOR - if (pri < IPL_CLOCK) - __mp_lock(&kernel_lock); -#endif - - for (r = iv->flags & HPPA_IV_SOFT; - iv && iv->handler; iv = iv->next) { - /* no arg means pass the frame */ - arg = iv->arg ? iv->arg : v; - if ((iv->handler)(arg) == 1) { - if (iv->cnt) - iv->cnt->ec_count++; - r |= 1; - } - } -#if 0 /* XXX this does not work, lasi gives us double ints */ - if (!r) { - ci->ci_cpl = 0; - printf("stray interrupt %d\n", bit); - } -#endif - -#ifdef MULTIPROCESSOR - if (pri < IPL_CLOCK) - __mp_unlock(&kernel_lock); -#endif - mtctl(0, CR_EIEM); - } - } - ci->ci_in_intr--; - ci->ci_cpl = s; - - mtctl(frame->tf_eiem, CR_EIEM); -} - -void -intr_barrier(void *cookie) -{ - sched_barrier(NULL); -} - -void * -softintr_establish(int pri, void (*handler)(void *), void *arg) -{ - struct hppa_iv *iv; - int irq; - - if (pri == IPL_TTY) - pri = IPL_SOFTTTY; - - irq = pri - 1; - iv = &intr_table[irq]; - if ((iv->flags & HPPA_IV_SOFT) == 0 || iv->pri != pri) - return (NULL); - - if (iv->handler) { - struct hppa_iv *nv; - - nv = malloc(sizeof *iv, M_DEVBUF, M_NOWAIT); - if (!nv) - return (NULL); - while (iv->next) - iv = iv->next; - iv->next = nv; - iv = nv; - } else - imask[pri] |= (1 << irq); - - iv->pri = pri; - iv->irq = 0; - iv->bit = 1 << irq; - iv->flags = HPPA_IV_SOFT; - iv->handler = (int (*)(void *))handler; /* XXX */ - iv->arg = arg; - iv->cnt = NULL; - iv->next = NULL; - iv->share = NULL; - - return (iv); -} - -void -softintr_disestablish(void *cookie) -{ - struct hppa_iv *iv = cookie; - int irq = iv->pri - 1; - - if (&intr_table[irq] == cookie) { - if (iv->next) { - struct hppa_iv *nv = iv->next; - - iv->handler = nv->handler; - iv->arg = nv->arg; - iv->next = nv->next; - free(nv, M_DEVBUF, sizeof *nv); - return; - } else { - iv->handler = NULL; - iv->arg = NULL; - return; - } - } - - for (iv = &intr_table[irq]; iv; iv = iv->next) { - if (iv->next == cookie) { - iv->next = iv->next->next; - free(cookie, M_DEVBUF, 0); - return; - } - } -} - -void -softintr_schedule(void *cookie) -{ - struct hppa_iv *iv = cookie; - - atomic_setbits_long(&curcpu()->ci_ipending, 1 << (iv->pri - 1)); -} diff --git a/sys/arch/hppa/hppa/ipi.c b/sys/arch/hppa/hppa/ipi.c deleted file mode 100644 index 8d31d2f60..000000000 --- a/sys/arch/hppa/hppa/ipi.c +++ /dev/null @@ -1,137 +0,0 @@ -/* $OpenBSD: ipi.c,v 1.5 2017/09/08 05:36:51 deraadt Exp $ */ - -/* - * Copyright (c) 2010 Joel Sing - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -void hppa_ipi_nop(void); -void hppa_ipi_halt(void); -void hppa_ipi_fpu_save(void); -void hppa_ipi_fpu_flush(void); - -void (*ipifunc[HPPA_NIPI])(void) = -{ - hppa_ipi_nop, - hppa_ipi_halt, - hppa_ipi_fpu_save, - hppa_ipi_fpu_flush -}; - -void -hppa_ipi_init(struct cpu_info *ci) -{ - /* Initialise IPIs for given CPU. */ - mtx_init(&ci->ci_ipi_mtx, IPL_IPI); - ci->ci_mask |= (1 << 30); -} - -int -hppa_ipi_intr(void *arg) -{ - struct cpu_info *ci = curcpu(); - u_long ipi_pending; - int bit = 0; - - /* Handle an IPI. */ - mtx_enter(&ci->ci_ipi_mtx); - ipi_pending = ci->ci_ipi; - ci->ci_ipi = 0; - mtx_leave(&ci->ci_ipi_mtx); - - while (ipi_pending) { - if (ipi_pending & (1L << bit)) - (*ipifunc[bit])(); - ipi_pending &= ~(1L << bit); - bit++; - } - - return 1; -} - -int -hppa_ipi_send(struct cpu_info *ci, u_long ipi) -{ - struct iomod *cpu; - - if (!(ci->ci_flags & CPUF_RUNNING)) - return -1; - - mtx_enter(&ci->ci_ipi_mtx); - ci->ci_ipi |= (1L << ipi); - asm volatile ("sync" ::: "memory"); - mtx_leave(&ci->ci_ipi_mtx); - - /* Send an IPI to the specified CPU by triggering EIR{1} (irq 30). */ - cpu = (struct iomod *)(ci->ci_hpa); - cpu->io_eir = 1; - asm volatile ("sync" ::: "memory"); - - return 0; -} - -int -hppa_ipi_broadcast(u_long ipi) -{ - CPU_INFO_ITERATOR cii; - struct cpu_info *ci; - int count = 0; - - CPU_INFO_FOREACH(cii, ci) - if (ci != curcpu() && (ci->ci_flags & CPUF_RUNNING)) - if (hppa_ipi_send(ci, ipi)) - count++; - - return count; -} - -void -hppa_ipi_nop(void) -{ -} - -void -hppa_ipi_halt(void) -{ - /* Turn off interrupts and halt CPU. */ - SCHED_ASSERT_UNLOCKED(); - hppa_intr_disable(); - curcpu()->ci_flags &= ~CPUF_RUNNING; - - for (;;) ; -} - -void -hppa_ipi_fpu_save(void) -{ - fpu_cpu_save(1); -} - -void -hppa_ipi_fpu_flush(void) -{ - fpu_cpu_save(0); -} diff --git a/sys/arch/hppa/hppa/lock_machdep.c b/sys/arch/hppa/hppa/lock_machdep.c deleted file mode 100644 index 44c9dda7f..000000000 --- a/sys/arch/hppa/hppa/lock_machdep.c +++ /dev/null @@ -1,231 +0,0 @@ -/* $OpenBSD: lock_machdep.c,v 1.14 2019/04/23 13:35:12 visa Exp $ */ - -/* - * Copyright (c) 2007 Artur Grabowski - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -static __inline int -__cpu_cas(struct __mp_lock *mpl, volatile unsigned long *addr, - unsigned long old, unsigned long new) -{ - volatile int *lock = (int *)(((vaddr_t)mpl->mpl_lock + 0xf) & ~0xf); - volatile register_t old_lock = 0; - int ret = 1; - - /* Note: lock must be 16-byte aligned. */ - asm volatile ( - "ldcws 0(%2), %0" - : "=&r" (old_lock), "+m" (lock) - : "r" (lock) - ); - - if (old_lock == MPL_UNLOCKED) { - if (*addr == old) { - *addr = new; - asm("sync" ::: "memory"); - ret = 0; - } - *lock = MPL_UNLOCKED; - } - - return ret; -} - -void -___mp_lock_init(struct __mp_lock *lock) -{ - lock->mpl_lock[0] = MPL_UNLOCKED; - lock->mpl_lock[1] = MPL_UNLOCKED; - lock->mpl_lock[2] = MPL_UNLOCKED; - lock->mpl_lock[3] = MPL_UNLOCKED; - lock->mpl_cpu = NULL; - lock->mpl_count = 0; -} - -#if defined(MP_LOCKDEBUG) -#ifndef DDB -#error "MP_LOCKDEBUG requires DDB" -#endif - -/* CPU-dependent timing, this needs to be settable from ddb. */ -extern int __mp_lock_spinout; -#endif - -static __inline void -__mp_lock_spin(struct __mp_lock *mpl) -{ -#ifndef MP_LOCKDEBUG - while (mpl->mpl_count != 0) - CPU_BUSY_CYCLE(); -#else - int nticks = __mp_lock_spinout; - - while (mpl->mpl_count != 0 && --nticks > 0) - CPU_BUSY_CYCLE(); - - if (nticks == 0) { - db_printf("__mp_lock(%p): lock spun out", mpl); - db_enter(); - } -#endif -} - -void -__mp_lock(struct __mp_lock *mpl) -{ - int s; - -#ifdef WITNESS - if (!__mp_lock_held(mpl, curcpu())) - WITNESS_CHECKORDER(&mpl->mpl_lock_obj, - LOP_EXCLUSIVE | LOP_NEWORDER, NULL); -#endif - - /* - * Please notice that mpl_count gets incremented twice for the - * first lock. This is on purpose. The way we release the lock - * in mp_unlock is to decrement the mpl_count and then check if - * the lock should be released. Since mpl_count is what we're - * spinning on, decrementing it in mpl_unlock to 0 means that - * we can't clear mpl_cpu, because we're no longer holding the - * lock. In theory mpl_cpu doesn't need to be cleared, but it's - * safer to clear it and besides, setting mpl_count to 2 on the - * first lock makes most of this code much simpler. - */ - - while (1) { - s = hppa_intr_disable(); - if (__cpu_cas(mpl, &mpl->mpl_count, 0, 1) == 0) { - __asm volatile("sync" ::: "memory"); - mpl->mpl_cpu = curcpu(); - } - if (mpl->mpl_cpu == curcpu()) { - mpl->mpl_count++; - hppa_intr_enable(s); - break; - } - hppa_intr_enable(s); - - __mp_lock_spin(mpl); - } - - WITNESS_LOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE); -} - -void -__mp_unlock(struct __mp_lock *mpl) -{ - int s; - -#ifdef MP_LOCKDEBUG - if (mpl->mpl_cpu != curcpu()) { - db_printf("__mp_unlock(%p): lock not held - %p != %p\n", - mpl, mpl->mpl_cpu, curcpu()); - db_enter(); - } -#endif - - WITNESS_UNLOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE); - - s = hppa_intr_disable(); - if (--mpl->mpl_count == 1) { - mpl->mpl_cpu = NULL; - __asm volatile("sync" ::: "memory"); - mpl->mpl_count = 0; - } - hppa_intr_enable(s); -} - -int -__mp_release_all(struct __mp_lock *mpl) -{ - int rv = mpl->mpl_count - 1; - int s; -#ifdef WITNESS - int i; -#endif - -#ifdef MP_LOCKDEBUG - if (mpl->mpl_cpu != curcpu()) { - db_printf("__mp_release_all(%p): lock not held - %p != %p\n", - mpl, mpl->mpl_cpu, curcpu()); - db_enter(); - } -#endif - -#ifdef WITNESS - for (i = 0; i < rv; i++) - WITNESS_UNLOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE); -#endif - - s = hppa_intr_disable(); - mpl->mpl_cpu = NULL; - __asm volatile("sync" ::: "memory"); - mpl->mpl_count = 0; - hppa_intr_enable(s); - - return (rv); -} - -int -__mp_release_all_but_one(struct __mp_lock *mpl) -{ - int rv = mpl->mpl_count - 2; -#ifdef WITNESS - int i; -#endif - -#ifdef MP_LOCKDEBUG - if (mpl->mpl_cpu != curcpu()) { - db_printf("__mp_release_all_but_one(%p): lock not held - " - "%p != %p\n", mpl, mpl->mpl_cpu, curcpu()); - db_enter(); - } -#endif - -#ifdef WITNESS - for (i = 0; i < rv; i++) - WITNESS_UNLOCK(&mpl->mpl_lock_obj, LOP_EXCLUSIVE); -#endif - - mpl->mpl_count = 2; - - return (rv); -} - -void -__mp_acquire_count(struct __mp_lock *mpl, int count) -{ - while (count--) - __mp_lock(mpl); -} - -int -__mp_lock_held(struct __mp_lock *mpl, struct cpu_info *ci) -{ - return mpl->mpl_cpu == ci; -} diff --git a/sys/arch/hppa/hppa/locore.S b/sys/arch/hppa/hppa/locore.S deleted file mode 100644 index a9963b380..000000000 --- a/sys/arch/hppa/hppa/locore.S +++ /dev/null @@ -1,2897 +0,0 @@ -/* $OpenBSD: locore.S,v 1.204 2022/10/25 15:15:38 guenther Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - * - * Portitions of this file are derived from other sources, see - * the copyrights and acknowledgements below. - */ -/* - * (c) Copyright 1988 HEWLETT-PACKARD COMPANY - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of Hewlett-Packard Company not be - * used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Hewlett-Packard Company makes no representations about the - * suitability of this software for any purpose. - */ -/* - * Copyright (c) 1990,1991,1992,1994 The University of Utah and - * the Computer Systems Laboratory (CSL). All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: locore.s 1.63 95/01/20$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "assym.h" - -/* - * hw-specific instructions - */ - -/* source: mklinux cache.s */ -#define MFCPU_C_PCXST(r,x) .word 0x14001a00 | ((r) << 21) | ((x) << 16) -#define MTCPU_PCXST(x,r) .word 0x14001600 | ((r) << 21) | ((x) << 16) - -/* source: PCXL and PCXL2 ERS */ -/* Use MFCPU_C for DR0-8; MFCPU_T for DR25,27,28,29 */ -#define MFCPU_C_PCXL(r,x) .word 0x14000600 | ((r) << 21) | ((x) << 16) -#define MFCPU_T_PCXL(r,x) .word 0x14001800 | ((r) << 21) | ((x)) -#define MTCPU_PCXL(x,r) .word 0x14000240 | ((r) << 21) | ((x) << 16) -#define DR_PAGE0_PCXL .word 0x14000e00 -#define DR_PAGE1_PCXL .word 0x14000e40 - -#define MFCPU_PCXU(r,x) .word 0x140008a0 | ((r) << 21) | ((x)) -#define MTCPU_PCXU(x,r) .word 0x14001840 | ((r) << 21) | ((x) << 16) - - .import $global$, data - .import pdc, data - .import cpu_info, data - .import panic, code - -LEAF_ENTRY($kernel_setup) - - /* - * disable interrupts and turn off all bits in the psw so that - * we start in a known state. - */ - rsm RESET_PSL, r0 - nop ! nop ! nop ! nop ! nop ! nop - - /* get things ready for the kernel to run in virtual mode */ - ldi HPPA_PID_KERNEL, r1 - mtctl r1, pidr1 - mtctl r1, pidr2 -#if pbably_not_worth_it - mtctl r0, pidr3 - mtctl r0, pidr4 -#endif - mtsp r0, sr0 - mtsp r0, sr1 - mtsp r0, sr2 - mtsp r0, sr3 - mtsp r0, sr4 - mtsp r0, sr5 - mtsp r0, sr6 - mtsp r0, sr7 - - /* - * to keep the spl() routines consistent we need to put the correct - * spl level into eiem, and reset any pending interrupts - */ - ldi -1, r1 - mtctl r0, eiem - mtctl r1, eirr - - /* - * load address of interrupt vector table - */ - ldil L%$ivaaddr, t2 - ldo R%$ivaaddr(t2), t2 - mtctl t2, iva - - /* - * set up the dp pointer so that we can do quick references off of it - */ - ldil L%$global$,dp - ldo R%$global$(dp),dp - - /* - * Create a stack frame for us to call C with. Clear out the previous - * sp marker to mark that this is the first frame on the stack. - */ - copy arg1, sp - ldo 0(arg1), r3 - stw,ma r0, HPPA_FRAME_SIZE(sp) - stw r0, HPPA_FRAME_CRP(sp) - stw r0, HPPA_FRAME_PSP(sp) - - /* - * We need to set the Q bit so that we can take TLB misses after we - * turn on virtual memory. - */ - mtctl r0, pcsq - mtctl r0, pcsq - mtctl rp, pcoq - ldo 4(rp), rp - mtctl rp, pcoq - mtctl arg2, ipsw - rfi - nop - nop -EXIT($kernel_setup) - -/* int - * pdc_call(func, pdc_flag, ...) - * iodcio_t func; - * int pdc_flag; - */ -ENTRY(pdc_call,160) - - mfctl eiem, t1 - mtctl r0, eiem - stw rp, HPPA_FRAME_CRP(sp) - copy arg0, r31 - copy sp, ret1 - - ldil L%kernelmapped, ret0 - ldw R%kernelmapped(ret0), ret0 - comb,= r0, ret0, pdc_call_unmapped1 - nop - ldil L%pdc_stack, ret1 - ldw R%pdc_stack(ret1), ret1 - -pdc_call_unmapped1 - copy sp, r1 - ldo HPPA_FRAME_SIZE+24*4(ret1), sp - - stw r1, HPPA_FRAME_PSP(sp) - - /* save kernelmapped and eiem */ - stw ret0, HPPA_FRAME_ARG(21)(sp) - stw t1, HPPA_FRAME_ARG(22)(sp) - - /* copy arguments */ - copy arg2, arg0 - copy arg3, arg1 - ldw HPPA_FRAME_ARG(4)(r1), arg2 - ldw HPPA_FRAME_ARG(5)(r1), arg3 - ldw HPPA_FRAME_ARG(6)(r1), t1 - ldw HPPA_FRAME_ARG(7)(r1), t2 - ldw HPPA_FRAME_ARG(8)(r1), t3 - ldw HPPA_FRAME_ARG(9)(r1), t4 - stw t1, HPPA_FRAME_ARG(4)(sp) /* XXX can use ,bc */ - stw t2, HPPA_FRAME_ARG(5)(sp) - stw t3, HPPA_FRAME_ARG(6)(sp) - stw t4, HPPA_FRAME_ARG(7)(sp) - ldw HPPA_FRAME_ARG(10)(r1), t1 - ldw HPPA_FRAME_ARG(11)(r1), t2 - ldw HPPA_FRAME_ARG(12)(r1), t3 - ldw HPPA_FRAME_ARG(13)(r1), t4 - stw t1, HPPA_FRAME_ARG(8)(sp) - stw t2, HPPA_FRAME_ARG(9)(sp) - stw t3, HPPA_FRAME_ARG(10)(sp) - stw t4, HPPA_FRAME_ARG(11)(sp) - - /* save temp control regs */ - mfctl cr24, t1 - mfctl cr25, t2 - mfctl cr26, t3 - mfctl cr27, t4 - stw t1, HPPA_FRAME_ARG(12)(sp) /* XXX can use ,bc */ - stw t2, HPPA_FRAME_ARG(13)(sp) - stw t3, HPPA_FRAME_ARG(14)(sp) - stw t4, HPPA_FRAME_ARG(15)(sp) - mfctl cr28, t1 - mfctl cr29, t2 - mfctl cr30, t3 - mfctl cr31, t4 - stw t1, HPPA_FRAME_ARG(16)(sp) - stw t2, HPPA_FRAME_ARG(17)(sp) - stw t3, HPPA_FRAME_ARG(18)(sp) - stw t4, HPPA_FRAME_ARG(19)(sp) - - comb,= r0, ret0, pdc_call_unmapped2 - nop - - copy arg0, t4 - ldi PSL_Q, arg0 /* (!pdc_flag && args[0] == PDC_PIM)? PSL_M:0) */ - break HPPA_BREAK_KERNEL, HPPA_BREAK_SET_PSW - stw ret0, HPPA_FRAME_ARG(23)(sp) - copy t4, arg0 - -pdc_call_unmapped2 - .call - blr r0, rp - bv,n (r31) - nop - - /* load temp control regs */ - ldw HPPA_FRAME_ARG(12)(sp), t1 - ldw HPPA_FRAME_ARG(13)(sp), t2 - ldw HPPA_FRAME_ARG(14)(sp), t3 - ldw HPPA_FRAME_ARG(15)(sp), t4 - mtctl t1, cr24 - mtctl t2, cr25 - mtctl t3, cr26 - mtctl t4, cr27 - ldw HPPA_FRAME_ARG(16)(sp), t1 - ldw HPPA_FRAME_ARG(17)(sp), t2 - ldw HPPA_FRAME_ARG(18)(sp), t3 - ldw HPPA_FRAME_ARG(19)(sp), t4 - mtctl t1, cr28 - mtctl t2, cr29 - mtctl t3, cr30 - mtctl t4, cr31 - - ldw HPPA_FRAME_ARG(21)(sp), t1 - ldw HPPA_FRAME_ARG(22)(sp), t2 - comb,= r0, t1, pdc_call_unmapped3 - nop - - copy ret0, t3 - ldw HPPA_FRAME_ARG(23)(sp), arg0 - break HPPA_BREAK_KERNEL, HPPA_BREAK_SET_PSW - copy t3, ret0 - -pdc_call_unmapped3 - ldw HPPA_FRAME_PSP(sp), sp - ldw HPPA_FRAME_CRP(sp), rp - bv r0(rp) - mtctl t2, eiem -EXIT(pdc_call) - -/* - * Kernel Gateway Page (must be at known address) - * System Call Gate - * Signal Return Gate - * - * GATEway instructions have to be at a fixed known locations - * because their addresses are hard coded in routines such as - * those in the C library. - */ - .align NBPG - .export gateway_page, entry -gateway_page - nop /* @ 0.C0000000 (Nothing) */ - gate,n $bsd_syscall,r0 /* @ 0.C0000004 (HPUX/BSD) */ - nop /* @ 0.C0000008 (HPOSF UNIX) */ - nop /* @ 0.C000000C (HPOSF Mach) */ - nop - nop - nop - nop - -$bsd_syscall - /* - * set up a space register and a protection id so that - * we can access kernel memory - */ - mfctl eiem, r1 - mtctl r0, eiem - mtsp r0, sr1 - mfctl pidr1, ret0 - ldi HPPA_PID_KERNEL, t2 - mtctl t2, pidr1 - - .import $syscall,code - .call - ldil L%$syscall, t2 - be R%$syscall(sr1, t2) - nop ! nop ! nop ! nop - - .size gateway_page, .-gateway_page - .align NBPG - .export gateway_page_end, entry -gateway_page_end - - .export $syscall,entry - .proc - .callinfo calls - .entry -$syscall - /* - * - * t1: syscall number - * t2: user - * t3: args - * t4: user stack - * - */ - mfctl cr29, t2 - ldw CI_CURPROC(sr1, t2), t2 - ldw P_ADDR(sr1, t2), t3 /* XXX can use ,sl */ - - /* calculate kernel sp, load, create kernel stack frame */ - ldo NBPG(t3), t3 - stw t3, P_MD_REGS(sr1, t2) - ldo TRAPFRAME_SIZEOF(t3), t3 - stw t4, TF_R19 -TRAPFRAME_SIZEOF(sr1, t3) /* t4 for vfork() */ - stw t1, TF_R22 -TRAPFRAME_SIZEOF(sr1, t3) /* syscall # */ - /* gotta save the args, in case we gonna restart */ - stw arg3, TF_R23-TRAPFRAME_SIZEOF(sr1, t3) - stw arg2, TF_R24-TRAPFRAME_SIZEOF(sr1, t3) - stw arg1, TF_R25-TRAPFRAME_SIZEOF(sr1, t3) - stw arg0, TF_R26-TRAPFRAME_SIZEOF(sr1, t3) - stw r27, TF_R27-TRAPFRAME_SIZEOF(sr1, t3) /* dp */ - stw sp, TF_R30 -TRAPFRAME_SIZEOF(sr1, t3) /* user stack */ - copy t3, sp - stw,ma r0, HPPA_FRAME_SIZE+HPPA_FRAME_MAXARGS(sr1, sp) - stw r0, HPPA_FRAME_CRP(sr1, sp) - mfctl r29, t1 - ldw CI_PSW(sr1, t1), t1 - stw r1, TF_CR15-TRAPFRAME_SIZEOF(sr1, t3) /* eiem ,bc */ - stw t1, TF_CR22-TRAPFRAME_SIZEOF(sr1, t3) /* ipsw */ - mfsp sr3, t1 - stw t1, TF_SR3-TRAPFRAME_SIZEOF(sr1, t3) - stw ret0, TF_CR8-TRAPFRAME_SIZEOF(sr1, t3) /* pidr1 */ - /* now we can allow interrupts to happen */ - mtctl r1, eiem - - /* - * we believe that any callee-save registers - * will be saved accordingly in either syscall() - * or deeper called functions and caller-save - * are saved in userland. - */ - stw r2 , TF_R2 -TRAPFRAME_SIZEOF(sr1, t3) - stw r3 , TF_R3 -TRAPFRAME_SIZEOF(sr1, t3) - copy t3, r3 - /* save callee-save registers */ - stw r4 , TF_R4 -TRAPFRAME_SIZEOF(sr1, t3) - stw r5 , TF_R5 -TRAPFRAME_SIZEOF(sr1, t3) - stw r6 , TF_R6 -TRAPFRAME_SIZEOF(sr1, t3) - stw r7 , TF_R7 -TRAPFRAME_SIZEOF(sr1, t3) - stw r8 , TF_R8 -TRAPFRAME_SIZEOF(sr1, t3) - stw r9 , TF_R9 -TRAPFRAME_SIZEOF(sr1, t3) - stw r10, TF_R10-TRAPFRAME_SIZEOF(sr1, t3) - stw r11, TF_R11-TRAPFRAME_SIZEOF(sr1, t3) - stw r12, TF_R12-TRAPFRAME_SIZEOF(sr1, t3) - stw r13, TF_R13-TRAPFRAME_SIZEOF(sr1, t3) - stw r14, TF_R14-TRAPFRAME_SIZEOF(sr1, t3) - stw r15, TF_R15-TRAPFRAME_SIZEOF(sr1, t3) - stw r16, TF_R16-TRAPFRAME_SIZEOF(sr1, t3) - stw r17, TF_R17-TRAPFRAME_SIZEOF(sr1, t3) - stw r18, TF_R18-TRAPFRAME_SIZEOF(sr1, t3) - /* - * Save the rest of the CPU context - */ - mfsp sr0, arg0 /* use ,bc */ - stw arg0, TF_IISQH-TRAPFRAME_SIZEOF(sr1, t3) - stw arg0, TF_IISQT-TRAPFRAME_SIZEOF(sr1, t3) - - ldo 4(r31), arg1 - stw r31, TF_IIOQH-TRAPFRAME_SIZEOF(sr1, t3) - stw arg1, TF_IIOQT-TRAPFRAME_SIZEOF(sr1, t3) - - stw arg0, TF_CR20-TRAPFRAME_SIZEOF(sr1, t3) /* use ,bc */ - stw r31, TF_CR21-TRAPFRAME_SIZEOF(sr1, t3) - - ldil L%TFF_LAST|TFF_SYS, arg1 - stw r0, TF_CR19-TRAPFRAME_SIZEOF(sr1, t3) /* iir */ - stw arg1, TF_FLAGS-TRAPFRAME_SIZEOF(sr1, t3) - - mfsp sr2, arg2 - mfsp sr4, arg3 - stw arg0, TF_SR0-TRAPFRAME_SIZEOF(sr1, t3) - stw arg0, TF_SR1-TRAPFRAME_SIZEOF(sr1, t3) - stw arg2, TF_SR2-TRAPFRAME_SIZEOF(sr1, t3) - stw arg3, TF_SR4-TRAPFRAME_SIZEOF(sr1, t3) - - mfsp sr5, arg0 - mfsp sr6, arg1 - mfsp sr7, arg2 - mfctl pidr2, arg3 - stw arg0, TF_SR5-TRAPFRAME_SIZEOF(sr1, t3) - stw arg1, TF_SR6-TRAPFRAME_SIZEOF(sr1, t3) - stw arg2, TF_SR7-TRAPFRAME_SIZEOF(sr1, t3) - stw arg3, TF_CR9-TRAPFRAME_SIZEOF(sr1, t3) - -#if pbably_not_worth_it - mfctl pidr3, arg2 - mfctl pidr4, arg3 - stw arg2, TF_CR12-TRAPFRAME_SIZEOF(sr1, t3) - stw arg3, TF_CR13-TRAPFRAME_SIZEOF(sr1, t3) -#endif - -#ifdef DDB - /* - * Save hpt mask and v2p translation table pointer - */ - mfctl eirr, arg0 - mfctl vtop, arg1 - stw arg0, TF_CR23-TRAPFRAME_SIZEOF(sr1, t3) - stw arg1, TF_CR25-TRAPFRAME_SIZEOF(sr1, t3) - - mfctl cr28, arg1 - stw arg1, TF_CR28-TRAPFRAME_SIZEOF(sr1, t3) -#endif - - /* setup kernel context */ - mtsp r0, sr0 - mtsp r0, sr1 - mtsp r0, sr2 - mtsp r0, sr3 - mtsp r0, sr4 - mtsp r0, sr5 - mtsp r0, sr6 - mtsp r0, sr7 - - ldo -TRAPFRAME_SIZEOF(t3), arg0 - ldo 4(t3), arg1 - - ldil L%$global$,dp - ldo R%$global$(dp),dp - - /* do a syscall */ - .import syscall,code - ldil L%syscall, r1 - ldo R%syscall(r1), r1 - .call - blr r0, rp - bv,n 0(r1) - nop - - mfctl cr29, r1 - ldw CI_CURPROC(r1), r1 - ldw P_MD_REGS(r1), t3 - - .exit - .procend - /* FALLTHROUGH */ - - .export $syscall_return, entry - .proc - .callinfo no_calls - .entry -$syscall_return - /* t3 == VA trapframe */ - - /* disable interrupts, just in case */ -#ifdef MULTIPROCESSOR - mfctl eiem, t1 - stw t1, TF_CR15(t3) -#endif - mtctl r0, eiem - - /* - * 1a. Copy a `phys' part of the frame into temp store - * (see a note for trapall) - * hopefully no page fault would happen on or after the copy, - * and interrupts are disabled. - */ - mfctl cr29, t2 - ldo CI_TRAP_SAVE(t2), t2 - /* use ,bc each cache line */ - ldw 0(t3), r1 ! ldw 4(t3), t1 ! stw r1, 0(t2) ! stw t1, 4(t2) - ldw 8(t3), r1 ! ldw 12(t3), t1 ! stw r1, 8(t2) ! stw t1, 12(t2) - ldw 16(t3), r1 ! ldw 20(t3), t1 ! stw r1, 16(t2) ! stw t1, 20(t2) - ldw 24(t3), r1 ! ldw 28(t3), t1 ! stw r1, 24(t2) ! stw t1, 28(t2) - ldw 32(t3), r1 ! ldw 36(t3), t1 ! stw r1, 32(t2) ! stw t1, 36(t2) - ldw 40(t3), r1 ! ldw 44(t3), t1 ! stw r1, 40(t2) ! stw t1, 44(t2) - ldw 48(t3), r1 ! ldw 52(t3), t1 ! stw r1, 48(t2) ! stw t1, 52(t2) - ldw 56(t3), r1 ! ldw 60(t3), t1 ! stw r1, 56(t2) ! stw t1, 60(t2) - - /* 1b. restore most of the general registers */ - ldw TF_CR11(t3), t1 - mtctl t1, sar - ldw TF_R1(t3), r1 - ldw TF_R2(t3), r2 - ldw TF_R3(t3), r3 - ldw TF_R4(t3), r4 - ldw TF_R5(t3), r5 - ldw TF_R6(t3), r6 - ldw TF_R7(t3), r7 - ldw TF_R8(t3), r8 - ldw TF_R9(t3), r9 - ldw TF_R10(t3), r10 - ldw TF_R11(t3), r11 - ldw TF_R12(t3), r12 - ldw TF_R13(t3), r13 - ldw TF_R14(t3), r14 - ldw TF_R15(t3), r15 - ldw TF_R16(t3), r16 - ldw TF_R17(t3), r17 - ldw TF_R18(t3), r18 - ldw TF_R19(t3), t4 - /* r20(t3) is used as a temporary and will be restored later */ - /* r21(t2) is used as a temporary and will be restored later */ - /* r22(t1) is used as a temporary and will be restored later */ - ldw TF_R23(t3), r23 - ldw TF_R24(t3), r24 - ldw TF_R25(t3), r25 - ldw TF_R26(t3), r26 - ldw TF_R27(t3), r27 - ldw TF_R28(t3), r28 - ldw TF_R29(t3), r29 - /* r30 (sp) will be restored later */ - ldw TF_R31(t3), r31 - - /* 2. restore all the space regs and pid regs, except sr3, pidr1 */ - ldw TF_SR0(t3), t1 - ldw TF_SR1(t3), t2 - mtsp t1, sr0 - mtsp t2, sr1 - - ldw TF_SR2(sr3, t3), t1 - ldw TF_SR4(sr3, t3), t2 - mtsp t1, sr2 - mtsp t2, sr4 - - ldw TF_SR5(sr3, t3), t1 - ldw TF_SR6(sr3, t3), t2 - mtsp t1, sr5 - mtsp t2, sr6 - - ldw TF_SR7(sr3, t3), t1 - ldw TF_CR9(sr3, t3), t2 - mtsp t1, sr7 - mtctl t2, pidr2 - -#if pbably_not_worth_it - ldw TF_CR12(sr3, t3), t1 - ldw TF_CR13(sr3, t3), t2 - mtctl t1, pidr3 - mtctl t2, pidr4 -#endif - ldw TF_CR0(sr3, t3), t1 - mtctl t1, rctr - ldw TF_CR27(sr3, t3), t1 - ldw TF_CR30(sr3, t3), t2 - mtctl t1, cr27 - mtctl t2, cr30 - - /* - * clear the system mask, this puts us back into physical mode. - * reload trapframe pointer w/ correspondent PA value. - * sp will be left in virtual until restored from trapframe, - * since we don't use it anyway. - */ - ssm 0, r0 - mfctl cr29, t3 - ldo CI_TRAP_SAVE(t3), t3 - nop ! nop ! nop ! nop ! nop - rsm RESET_PSL, r0 -$syscall_return_phys - - /* clear cr26 to avoid information leak */ - mtctl r0, cr26 - - /* finally we can restore the space and offset queues and the ipsw */ - ldw TF_IISQH(t3), t1 - ldw TF_IISQT(t3), t2 - mtctl t1, pcsq - mtctl t2, pcsq - - ldw TF_IIOQH(t3), t1 - ldw TF_IIOQT(t3), t2 - mtctl t1, pcoq - mtctl t2, pcoq - - ldw TF_CR15(t3), t1 - ldw TF_CR22(t3), t2 - mtctl t1, eiem - mtctl t2, ipsw - - ldw TF_SR3(t3), t1 - ldw TF_CR8(t3), t2 - mtsp t1, sr3 - mtctl t2, pidr1 - - ldw TF_R22(t3), t1 - ldw TF_R21(t3), t2 - ldw TF_R30(t3), sp - ldw TF_R20(t3), t3 - - rfi - nop - .exit - .procend - .size $syscall, .-$syscall -$syscall_end - -/* - * interrupt vector table - */ -#define TLABEL(name) $trap$name -#define TRAP(name,num) \ - mtctl r1, tr7 ! \ - .call ! \ - .import TLABEL(name), code ! \ - b TLABEL(name) ! \ - ldi num, r1 ! \ - .align 32 - -#define ATRAP(name,num) \ - .export TLABEL(name)$num, entry ! \ - .label TLABEL(name)$num ! \ - TRAP(all,num) ! \ - .size TLABEL(name)$num, .-TLABEL(name)$num - -#define CTRAP(name,num,pre) \ - .export TLABEL(name)$num, entry ! \ - .label TLABEL(name)$num ! \ - pre ! \ - TRAP(name,num) ! \ - .size TLABEL(name)$num, .-TLABEL(name)$num - -#define STRAP(name,num,pre) \ - .export TLABEL(name)$num, entry ! \ - .label TLABEL(name)$num ! \ - pre ! \ - mtctl r1, tr7 ! \ - .export trap_ep_##num, entry ! \ - .label trap_ep_##num ! \ - .call ! \ - b __CONCAT($name,_l) ! \ - ldi num, r1 ! \ - b __CONCAT($name,_t)+8 ! \ - b __CONCAT($name,_s)+12 ! \ - b __CONCAT($name,_u)+16 ! \ - .size TLABEL(name)$num, .-TLABEL(name)$num - -#define ITLBPRE \ - mfctl pcoq,r9 ! \ - mfctl pcsq,r8 -#define DTLBPRE \ - mfctl ior, r9 ! \ - mfctl isr, r8 - /* CR28XXX according to a popular belief cr28 should be read here */ - -#define HPMCPRE nop -#define INTRPRE \ - mfctl eirr, r8 ! \ - mtctl r8, eirr - - .align NBPG - .export $ivaaddr, entry - .export hpmc_v, entry -$ivaaddr - ATRAP(null,T_NONEXIST) /* 0. invalid interrupt vector */ -hpmc_v - CTRAP(hpmc,T_HPMC,HPMCPRE) /* 1. high priority machine check */ - ATRAP(power,T_POWERFAIL) /* 2. power failure */ - ATRAP(recnt,T_RECOVERY) /* 3. recovery counter trap */ - CTRAP(intr,T_INTERRUPT,INTRPRE) /* 4. external interrupt */ - ATRAP(lpmc,T_LPMC) /* 5. low-priority machine check */ - STRAP(itlb,T_ITLBMISS,ITLBPRE) /* 6. instruction TLB miss fault */ - ATRAP(iprot,T_IPROT) /* 7. instruction protection trap */ - ATRAP(ill,T_ILLEGAL) /* 8. Illegal instruction trap */ - CTRAP(ibrk,T_IBREAK,) /* 9. break instruction trap */ - ATRAP(privop,T_PRIV_OP) /* 10. privileged operation trap */ - ATRAP(privr,T_PRIV_REG) /* 11. privileged register trap */ - ATRAP(ovrfl,T_OVERFLOW) /* 12. overflow trap */ - ATRAP(cond,T_CONDITION) /* 13. conditional trap */ - CTRAP(excpt,T_EXCEPTION,) /* 14. assist exception trap */ - STRAP(dtlb,T_DTLBMISS,DTLBPRE) /* 15. data TLB miss fault */ - STRAP(itlbna,T_ITLBMISSNA,DTLBPRE)/* 16. ITLB non-access miss fault */ - STRAP(dtlbna,T_DTLBMISSNA,DTLBPRE)/* 17. DTLB non-access miss fault */ - ATRAP(dprot,T_DPROT) /* 18. data protection trap - unaligned data reference trap */ - ATRAP(dbrk,T_DBREAK) /* 19. data break trap */ - STRAP(tlbd,T_TLB_DIRTY,DTLBPRE) /* 20. TLB dirty bit trap */ - ATRAP(pgref,T_PAGEREF) /* 21. page reference trap */ - CTRAP(emu,T_EMULATION,) /* 22. assist emulation trap */ - ATRAP(hpl,T_HIGHERPL) /* 23. higher-privelege transfer trap*/ - ATRAP(lpl,T_LOWERPL) /* 24. lower-privilege transfer trap */ - ATRAP(tknbr,T_TAKENBR) /* 25. taken branch trap */ - ATRAP(dacc,T_DATACC) /* 26. data access rights trap */ - ATRAP(dpid,T_DATAPID) /* 27. data protection ID trap */ - ATRAP(dalgn,T_DATALIGN) /* 28. unaligned data ref trap */ - ATRAP(unk29,29) - ATRAP(unk30,30) - ATRAP(unk31,31) - ATRAP(unk32,32) - ATRAP(unk33,33) - ATRAP(unk34,34) - ATRAP(unk35,35) - ATRAP(unk36,36) - ATRAP(unk37,37) - ATRAP(unk38,38) - ATRAP(unk39,39) - ATRAP(unk40,40) - ATRAP(unk41,41) - ATRAP(unk42,42) - ATRAP(unk43,43) - ATRAP(unk44,44) - ATRAP(unk45,45) - ATRAP(unk46,46) - ATRAP(unk47,47) - ATRAP(unk48,48) - ATRAP(unk49,49) - ATRAP(unk50,50) - ATRAP(unk51,51) - ATRAP(unk52,52) - ATRAP(unk53,53) - ATRAP(unk54,54) - ATRAP(unk55,55) - ATRAP(unk56,56) - ATRAP(unk57,57) - ATRAP(unk58,58) - ATRAP(unk59,59) - ATRAP(unk60,60) - ATRAP(unk61,61) - ATRAP(unk62,62) - ATRAP(unk63,63) - /* 64 */ - .size $ivaaddr, .-$ivaaddr - - .export TLABEL(excpt), entry -ENTRY(TLABEL(excpt),0) - /* assume we never get this one w/o fpu [enabled] */ - copy rp, r1 - copy arg0, r8 - mfctl cr30, r9 -#if HFP_REGS != 0 - ldo HFP_REGS(r9), r9 -#endif - .import fpu_save, code - .call - bl fpu_save, rp - copy r9, arg0 - copy r1, rp - copy r8, arg0 - mfctl cr29, r1 - mtctl r0, ccr /* cause a reload after exception */ - ldw CI_FPU_STATE(r1), r16 - stw r0, CI_FPU_STATE(r1) - stw r0, HFP_CPU(r16) - sync - - /* now, check for trap */ - ldw 0(r9), r1 - bb,>=,n r1, HPPA_FPU_T_POS, excpt_notrap - ldw 1*4(r9), r1 - comb,<>,n r0, r1, excpt_emulate - ldw 2*4(r9), r1 - comb,<>,n r0, r1, excpt_emulate - ldw 3*4(r9), r1 - comb,<>,n r0, r1, excpt_emulate - ldw 4*4(r9), r1 - comb,<>,n r0, r1, excpt_emulate - ldw 5*4(r9), r1 - comb,<>,n r0, r1, excpt_emulate - ldw 6*4(r9), r1 - comb,<>,n r0, r1, excpt_emulate - ldw 7*4(r9), r1 - -excpt_emulate - bb,>=,n r1, 5, excpt_notrap /* HPPA_FPU_UNMPL not set */ - - ldw 0(r9), r16 - depi 0, HPPA_FPU_T_POS, 1, r16 - .import $fpu_emulate, code - b $fpu_emulate - stw r16, 0(r9) - -excpt_notrap - sync - b TLABEL(all) - ldi T_EXCEPTION, r1 -EXIT(TLABEL(excpt)) - - .export TLABEL(emu), entry -ENTRY(TLABEL(emu),0) - - /* - * Switch FPU/SFU context - * - * isr:ior - data address - * iir - instruction to emulate - * iisq:iioq - address of instruction to emulate - * - * note: ISR and IOR contain valid data only if the - * instruction is a coprocessor load or store. - * - */ - - mfctl iir, r8 - extru r8, 5, 6, r9 /* no sfu implementation right now */ - comib,= 4, r9, TLABEL(all) - ldi T_ILLEGAL, r1 - - /* - * pass through for all coprocessors now and - * do not check the uid here. - * in case that piece does not exist emulate - * or the trap will be generated later. - */ - - ldil L%cpu_fpuena, r1 - ldw R%cpu_fpuena(r1), r9 - comib,= 0, r9, $fpusw_emu - - /* if we are already enabled and hit again, emulate */ - mfctl ccr, r1 - extru,<> r1, 25, 2, r0 - b,n $fpusw_set - nop - -$fpusw_emu - mfctl cr29, r1 - mtctl r0, ccr /* cause a reload after exception */ - ldw CI_FPU_STATE(r1), r16 - stw r0, CI_FPU_STATE(r1) - stw r0, HFP_CPU(r16) - sync -#if 0 - /* here we emulate the fld/fst */ - mfctl iir, r1 - extru r1, 5, 6, r1 - comib,= 0xb, r9, TLABEL(all) - ldi T_ILLEGAL, r1 - - mfctl iir, r1 - extru r1, 5, 6, r1 - comib,= 0x9, r9, TLABEL(all) - ldi T_ILLEGAL, r1 -#endif - mfctl iir, r1 - .import $fpu_emulate, code - b $fpu_emulate - nop - -$fpusw_set - /* enable coprocessor XXX */ - depi 3, 25, 2, r1 - mtctl r1, ccr - - mfctl cr29, r16 - mfctl cr30, r9 - ldw CI_FPU_STATE(r16), r16 - - comb,=,n r16, r0, $fpusw_nosave - comb,=,n r16, r9, $fpusw_done - - copy arg0, r17 - copy rp, r1 -#if HFP_REGS != 0 - ldo HFP_REGS(r16), r16 -#endif - .import fpu_save, code - .call - bl fpu_save, rp - copy r16, arg0 - copy r1, rp - copy r17, arg0 - - mfctl cr29, r1 - ldw CI_FPU_STATE(r1), r16 - stw r0, CI_FPU_STATE(r1) - stw r0, HFP_CPU(r16) - sync - -$fpusw_nosave - -#ifdef MULTIPROCESSOR - /* See if this process has FPU context on another CPU. */ - ldw HFP_CPU(r9), r1 - comb,=,n r1, r0, $fpusw_noshoot - - /* Perform FPU shootdown. */ - ldi (1 << HPPA_IPI_FPU_SAVE), r1 - ldw HFP_CPU(r9), r16 - stw r1, CI_IPI(r16) - ldi 1, r1 - ldw CI_HPA(r16), r16 - stw r1, 0(r16) - -$fpusw_spin - /* Wait for shootdown to complete. */ - sync - ldw HFP_CPU(r9), r1 - comb,<>,n r1, r0, $fpusw_spin - -$fpusw_noshoot -#endif - - /* count switches */ - .import uvmexp, data - ldil L%(uvmexp+FPSWTCH), r1 - ldw R%(uvmexp+FPSWTCH)(r1), r16 - ldo 31*8+HFP_REGS(r9), r17 - ldo 1(r16), r16 - stw r16, R%(uvmexp+FPSWTCH)(r1) - - fldds,ma -8(r17), fr31 - fldds,ma -8(r17), fr30 - fldds,ma -8(r17), fr29 - fldds,ma -8(r17), fr28 - fldds,ma -8(r17), fr27 - fldds,ma -8(r17), fr26 - fldds,ma -8(r17), fr25 - fldds,ma -8(r17), fr24 - fldds,ma -8(r17), fr23 - fldds,ma -8(r17), fr22 - fldds,ma -8(r17), fr21 - fldds,ma -8(r17), fr20 - fldds,ma -8(r17), fr19 - fldds,ma -8(r17), fr18 - fldds,ma -8(r17), fr17 - fldds,ma -8(r17), fr16 - fldds,ma -8(r17), fr15 - fldds,ma -8(r17), fr14 - fldds,ma -8(r17), fr13 - fldds,ma -8(r17), fr12 - fldds,ma -8(r17), fr11 - fldds,ma -8(r17), fr10 - fldds,ma -8(r17), fr9 - fldds,ma -8(r17), fr8 - fldds,ma -8(r17), fr7 - fldds,ma -8(r17), fr6 - fldds,ma -8(r17), fr5 - fldds,ma -8(r17), fr4 - fldds,ma -8(r17), fr3 - fldds,ma -8(r17), fr2 - fldds,ma -8(r17), fr1 - fldds 0(r17), fr0 /* fr0 must be restored last */ - - mfctl cr29, r1 - stw r9, CI_FPU_STATE(r1) - stw r1, HFP_CPU(r9) - sync - -$fpusw_done - rfir - nop -EXIT(TLABEL(emu)) - - /* Construct the virtual address tag. */ -#define VTAG ! \ - shd r0, r9, 1, r16 /* r16[1..15] = off[0..14] */ ! \ - dep r8, 31, 16, r16 /* put in the space id */ ! \ - depi 1, 0, 1, r16 /* and set the valid bit */ - -#if 0 - .export dtlb_c, data - BSS(dtlb_c, 8) - .export tlbd_c, data - BSS(tlbd_c, 8) - .export itlb_c, data - BSS(itlb_c, 8) - - .text - /* XXX this touches tr5, which it should not, perhaps */ - -#define TLB_STATS_PRE(t) \ - mfctl itmr, r17 ! \ - mtctl r17, tr5 -#define TLB_STATS_AFT(t) \ - mfctl itmr, r16 ! \ - mfctl tr5, r17 ! \ - ldil L%__CONCAT(t,_c), r25 ! \ - ldo R%__CONCAT(t,_c)(r25), r25 ! \ - sub r16, r17, r16 ! \ - ldw 0(r25), r24 ! \ - ldw 4(r25), r17 ! \ - ldo 1(r24), r24 ! \ - ldo -2(r16), r16 /* for mtctl */ ! \ - add r16, r17, r17 ! \ - stw r24, 0(r25) ! \ - stw r17, 4(r25) - -#else -#define TLB_STATS_PRE(t) /**/ -#define TLB_STATS_AFT(t) /**/ -#endif - -#if defined(HP7000_CPU) || defined(HP7100_CPU) || defined(HP7200_CPU) -#define TLB_PULL(bits,lbl) ! \ - /* space:pgaddr -- r8:r9 */ ! \ - mfctl vtop, r16 ! \ - ldwax,s r8(r16), r17 /* space -> page directory */ ! \ - extru r9, 9, 10, r25 ! \ - combt,=,n r0, r17, lbl ! \ - ldwax,s r25(r17), r24 /* page -> page table */ ! \ - extru r9, 19, 10, r16 ! \ - combt,=,n r0, r24, lbl ! \ - ldwax,s r16(r24), r17 /* va -> pa:prot */ ! \ - sh2addl r16, r24, r25 ! \ - combt,=,n r0, r17, lbl ! \ - copy r17, r16 ! \ - depi (bits), 21+bits, 1+bits, r17 ! \ - sub,= r16, r17, r0 /* do not store if unchanged */ ! \ - stwas r17, 0(r25) /* store back w/ the bits */ ! \ - shd r17, r0, 13, r25 ! \ - dep r8, 30, 15, r25 /* mix0r the pid from the sid */! \ - dep r0, 31, 12, r17 /* needed ? */ ! \ - addi 2, r25, r25 ! \ - extru r17, 24, 25, r17 - - .align 32 -LEAF_ENTRY($tlbd_s) -ALTENTRY($tlbd_t) - TLB_STATS_PRE(tlbd) - TLB_PULL(1, TLABEL(all)) - mfsp sr1, r16 - mtsp r8, sr1 - idtlba r17,(sr1, r9) - idtlbp r25,(sr1, r9) - mtsp r16, sr1 - TLB_STATS_AFT(tlbd) - rfir - nop -EXIT($tlbd_s) - -LEAF_ENTRY($itlb_s) -ALTENTRY($itlb_t) - TLB_STATS_PRE(itlb) - TLB_PULL(0, TLABEL(all)) - extru,= r25, 5, 1, r0 /* gateway page needs to be public */ - depi 0, 30, 15, r25 - mfsp sr1, r16 - mtsp r8, sr1 - iitlba r17,(sr1, r9) - iitlbp r25,(sr1, r9) - mtsp r16, sr1 - TLB_STATS_AFT(itlb) - rfir - nop -EXIT($itlb_s) - -LEAF_ENTRY($dtlb_s) -ALTENTRY($dtlb_t) - TLB_STATS_PRE(dtlb) - TLB_PULL(0, TLABEL(all)) - mfsp sr1, r16 - mtsp r8, sr1 - idtlba r17,(sr1, r9) - idtlbp r25,(sr1, r9) - mtsp r16, sr1 - TLB_STATS_AFT(dtlb) - rfir - nop -EXIT($dtlb_s) - -LEAF_ENTRY($dtlbna_s) -ALTENTRY($itlbna_s) -ALTENTRY($dtlbna_t) -ALTENTRY($itlbna_t) - TLB_STATS_PRE(dtlb) - TLB_PULL(0, $dtlbna_t_fake) - mfsp sr1, r16 - mtsp r8, sr1 - idtlba r17,(sr1, r9) - idtlbp r25,(sr1, r9) - mtsp r16, sr1 - TLB_STATS_AFT(dtlb) - rfir - nop -$dtlbna_s_fake -$dtlbna_t_fake - /* parse prober/w insns, have to decent to trap() to set regs proper */ - mfctl iir, r16 - extru r16, 6, 6, r24 - comib,=,n 1, r24, TLABEL(all) - extru r16, 24, 6, r24 - subi,<> 0x23, r24, r0 - b TLABEL(all) - /* otherwise generate a flush-only tlb entry */ - copy r0, r17 - zdep r8, 30, 15, r25 - depi -13, 11, 7, r25 - ldo 2(r25), r25 /* 3? */ - mfsp sr1, r16 - mtsp r8, sr1 - idtlba r17,(sr1, r9) - idtlbp r25,(sr1, r9) - mtsp r16, sr1 - TLB_STATS_AFT(dtlb) - rfir - nop -EXIT($dtlbna_s) - -#endif /* defined(HP7000_CPU) || defined(HP7100_CPU) || defined(HP7200_CPU) */ - -#if defined(HP7100LC_CPU) || defined(HP7300LC_CPU) - -#define IITLBAF(r) .word 0x04000440 | ((r) << 16) -#define IITLBPF(r) .word 0x04000400 | ((r) << 16) -#define IDTLBAF(r) .word 0x04001440 | ((r) << 16) -#define IDTLBPF(r) .word 0x04001400 | ((r) << 16) - -/* - * possible optimizations: - * change pte to reduce number of shifts - * reorder to reduce stalls - */ -#define TLB_PULL_L(bits,lbl) ! \ - /* space:pgaddr -- r8:r9 */ ! \ - mfctl vtop, r16 ! \ - ldwx,s r8(r16), r17 /* space -> page directory */ ! \ - extru r9, 9, 10, r25 ! \ - combt,=,n r0, r17, lbl ! \ - ldwx,s r25(r17), r24 /* page -> page table */ ! \ - extru r9, 19, 10, r16 ! \ - combt,=,n r0, r24, lbl ! \ - ldwx,s r16(r24), r17 /* va -> pa:prot */ ! \ - sh2addl r16, r24, r25 ! \ - combt,=,n r0, r17, lbl ! \ - copy r17, r16 ! \ - depi (bits), 21+bits, 1+bits, r17 ! \ - sub,= r16, r17, r0 /* do not store if unchanged */ ! \ - stws r17, 0(r25) /* store back w/ the bits */ ! \ - shd r17, r0, 13, r25 ! \ - dep r8, 30, 15, r25 /* mix0r the pid from the sid */! \ - dep r0, 31, 12, r17 /* needed ? */ ! \ - addi 2, r25, r25 ! \ - extru r17, 24, 25, r17 /* tlbbtop(r17) */ ! \ - sync - - .align 32 -LEAF_ENTRY($tlbd_l) - TLB_STATS_PRE(tlbd) - TLB_PULL_L(1, TLABEL(all)) - IDTLBAF(17) - IDTLBPF(25) -#ifdef USE_HPT - /* invalidate instead of update */ - mfctl cr28, r17 - ldw 0(r17), r24 - VTAG - sub,<> r16, r24, r0 - stw r0, 0(r17) -#endif - TLB_STATS_AFT(tlbd) - rfir - nop -EXIT($tlbd_l) - - /* - * from 7100lc ers, pg.6: - * we found a post-silicon bug that makes cr28 - * unreliable for the itlb miss handler - */ -LEAF_ENTRY($itlb_l) - TLB_STATS_PRE(itlb) - TLB_PULL_L(0, TLABEL(all)) - extru,= r25, 5, 1, r0 /* gateway page needs to be public */ - depi 0, 30, 15, r25 - IITLBAF(17) - IITLBPF(25) - TLB_STATS_AFT(itlb) - rfir - nop -EXIT($itlb_l) - -LEAF_ENTRY($dtlbna_l) -ALTENTRY($itlbna_l) - TLB_STATS_PRE(dtlb) - TLB_PULL_L(0, $dtlbna_l_fake) - IDTLBAF(17) - IDTLBPF(25) - TLB_STATS_AFT(dtlb) - rfir - nop -$dtlbna_l_fake - /* parse prober/w insns, have to decent to trap() to set regs proper */ - mfctl iir, r16 - extru r16, 6, 6, r24 - comib,=,n 1, r24, TLABEL(all) - extru r16, 24, 6, r24 - subi,<> 0x23, r24, r0 - b TLABEL(all) - /* otherwise generate a flush-only tlb entry */ - copy r0, r17 - zdep r8, 30, 15, r25 - depi -13, 11, 7, r25 - ldo 2(r25), r25 /* 3? */ - IDTLBAF(17) - IDTLBPF(25) - TLB_STATS_AFT(dtlb) - rfir - nop -EXIT($dtlbna_l) - -LEAF_ENTRY($dtlb_l) - TLB_STATS_PRE(dtlb) - TLB_PULL_L(0, TLABEL(all)) - IDTLBAF(17) - IDTLBPF(25) -#ifdef USE_HPT - /* - * cache the next page mapping in the hpt. - * - * mapping for a page at the end of each 128k is uncachable - * in the hvt since it'd be in the tlb itself and thus there - * is no reason to cache it! - * as a side effect this avoids recomputing hpt entry and - * retraversing the whole page table each time. - */ - - ldo PAGE_SIZE(r9), r9 - extru,<> r9, 20, 5, r0 - b,n $dtlb_done_l /* skip if no simple advance */ - /* do not check the PT overlap since the above - * check already guaranties that */ - - /* ripped from TLB_PULL_L(0) */ - extru r9, 19, 10, r16 /* r24 was loaded in the TLB_PULL_L */ - ldwx,s r16(r24), r17 /* va -> pa:prot */ - sh2addl r16, r24, r25 - combt,=,n r0, r17, $dtlb_done_l - copy r17, r16 - depi 0, 21, 1, r17 - sub,= r16, r17, r0 /* do not store if unchanged */ - stws r17, 0(r25) /* store back w/ the bits */ - shd r17, r0, 13, r25 - dep r8, 30, 15, r25 /* mix0r the pid from the sid */ - dep r0, 31, 12, r17 /* needed ? */ - addi 2, r25, r25 - extru r17, 24, 25, r17 - sync - - mfctl cr28, r24 - VTAG - ldo 16(r24), r24 - stw r16, 0(r24) - stw r25, 4(r24) - stw r17, 8(r24) -$dtlb_done_l -#endif - TLB_STATS_AFT(dtlb) - rfir - nop -EXIT($dtlb_l) -#endif /* HP7100LC_CPU */ - -#if defined(HP8000_CPU) || defined(HP8200_CPU) || defined(HP8500_CPU) - .level 2.0w - - /* xlate 32bit->64bit pte */ -#define TLB_PCX2PCXU \ - extrw,u r25, 14, 13, r16 ! \ - depdi 0, 31, 32, r17 ! \ - /* fix io mappings */ ! \ - extrd,s r17, 42, 4, r1 ! \ - addi,<> 1, r1, r0 ! \ - depdi -1, 38, 32, r17 ! \ - /* fix prom mappings */ ! \ - extrd,s r17, 46, 8, r1 ! \ - addi,<> 0x10, r1, r0 ! \ - depdi 0, 38, 4, r17 ! \ - /* weak ordering, dyn bp */ ! \ - depwi 1, 31, 2, r16 ! \ - depdi 0, 44, 30, r25 ! \ - depd r16, 14, 15, r25 - -LEAF_ENTRY($tlbd_u) - TLB_STATS_PRE(tlbd) - TLB_PULL_L(1, TLABEL(all)) - TLB_PCX2PCXU - idtlbt r17, r25 - TLB_STATS_AFT(tlbd) - rfir - nop -EXIT($tlbd_u) - -LEAF_ENTRY($itlb_u) - TLB_STATS_PRE(itlb) - TLB_PULL_L(0, TLABEL(all)) - extru,= r25, 5, 1, r0 /* gateway page needs to be public */ - depi 0, 30, 15, r25 - TLB_PCX2PCXU - iitlbt r17, r25 - TLB_STATS_AFT(itlb) - rfir - nop -EXIT($itlb_u) - -LEAF_ENTRY($dtlbna_u) -ALTENTRY($itlbna_u) - TLB_STATS_PRE(dtlb) - TLB_PULL_L(0, $dtlbna_u_fake) - TLB_PCX2PCXU - idtlbt r17, r25 - TLB_STATS_AFT(dtlb) - rfir - nop -$dtlbna_u_fake - /* parse prober/w insns, have to decent to trap() to set regs proper */ - mfctl iir, r16 - extru r16, 6, 6, r24 - comib,=,n 1, r24, TLABEL(all) - extru r16, 24, 6, r24 - subi,<> 0x23, r24, r0 - b TLABEL(all) - /* otherwise generate a flush-only tlb entry */ - copy r0, r17 - zdep r8, 30, 15, r25 - depi -13, 11, 7, r25 - ldo 2(r25), r25 /* 3? */ - idtlbt r17, r25 - TLB_STATS_AFT(dtlb) - rfir - nop -EXIT($dtlbna_u) - -LEAF_ENTRY($dtlb_u) - TLB_STATS_PRE(dtlb) - TLB_PULL_L(0, TLABEL(all)) - TLB_PCX2PCXU - idtlbt r17, r25 - TLB_STATS_AFT(dtlb) - rfir - nop -EXIT($dtlb_u) - - .level 1.1 -#endif /* HP8000_CPU */ - - .align 64 - .export TLABEL(all), entry -ENTRY(TLABEL(all),0) - /* r1 still has trap type */ - - /* - * at this point we have: - * psw copied into ipsw - * psw = E(default), M(1 if HPMC, else 0) - * PL = 0 - * r1, r8, r9, r16, r17, r24, r25 shadowed (maybe) - * trap number in r1 (old r1 is saved in tr7) - */ - - /* do not overwrite cr28 */ - mtctl t3, cr26 - - mfctl cr29, t3 - ldo CI_TRAP_SAVE(t3), t3 - stw t1, TF_R22(t3) /* use ,bc */ - stw t2, TF_R21(t3) - - mfctl cr26, t1 - stw sp, TF_R30(t3) /* sp */ - stw t1, TF_R20(t3) /* t3 */ - - /* - * Now, save away other volatile state that prevents us from turning - * the PC queue back on, namely, the pc queue and ipsw, and the - * interrupt information. - */ - - mfctl eiem, t1 - mfctl ipsw, t2 - stw t1, TF_CR15(t3) /* use ,bc */ - stw t2, TF_CR22(t3) - - mfsp sr3, t1 - mfctl pidr1, t2 - stw t1, TF_SR3(t3) - stw t2, TF_CR8(t3) - - /* - * Setup kernel context - */ - - ldi HPPA_PID_KERNEL,t1 - mtctl t1, pidr1 - mtsp r0, sr3 - - /* this will enable interrupts after `cold' */ - mfctl cr29, t1 - ldw CI_PSW(t1), t2 - mtctl r0, eiem - mtctl t2, ipsw - - mfctl pcsq, t1 - mtctl r0, pcsq - mfctl pcsq, t2 - stw t1, TF_IISQH(t3) /* use ,bc */ - stw t2, TF_IISQT(t3) - mtctl r0, pcsq - - /* - * Set up the kernel stack pointer. If the trap happened - * while we were in unprivileged code, or in privileged - * code in the SYSCALLGATE page, move to the kernel stack - * in curproc's PCB; otherwise, start a new stack frame - * on whatever kernel stack we're already on. - * - * This used to check only for a trap while we were in - * unprivileged code, but this ignored the possibility - * that a trap could come in during the period between - * a gateway instruction to raise privilege and the - * disabling of interrupts. During this period we're - * still on the user's stack, and we must move to the - * kernel stack. - * - * - fredette@ - */ - mfctl pcoq, t1 - ldil L%SYSCALLGATE, t2 - ldo TF_PHYS-1(sp), sp - dep t1, 31, PGSHIFT, t2 - dep,<> t1, 31, 2, r0 - comb,<> t1, t2, $trap_from_kernel - dep r0, 31, 6, sp - - mfctl cr29, t2 - ldw CI_CURPROC(t2), t2 - depi 1, T_USER_POS, 1, r1 - depi 1, TFF_LAST_POS, 1, r1 - ldw P_ADDR(t2), sp - ldo NBPG(sp), sp - -$trap_from_kernel - ldil L%$trapnowvirt, t2 - ldo R%$trapnowvirt(t2), t2 - mtctl t2, pcoq - stw t1, TF_IIOQH(t3) - ldo 4(t2), t2 - mfctl pcoq, t1 - stw t1, TF_IIOQT(t3) - mtctl t2, pcoq - - mfctl isr, t1 - mfctl ior, t2 - stw t1, TF_CR20(t3) /* use ,bc */ - stw t2, TF_CR21(t3) - - mfctl iir, t2 - stw t2, TF_CR19(t3) - stw r1, TF_FLAGS(t3) - - mfctl rctr, t1 /* gotta get it before R is up */ - - copy sp, t3 - ldo HPPA_FRAME_SIZE+TRAPFRAME_SIZEOF(sp), sp - rfir - nop ! nop ! nop ! nop ! nop ! nop ! nop ! nop -$trapnowvirt - /* - * t3 contains the virtual address of the trapframe - * sp is loaded w/ the right VA (we did not need it being physical) - */ - - mfctl ccr, t2 - stw t1, TF_CR0(sr3, t3) - stw t2, TF_CR10(sr3, t3) - - mfsp sr0, t1 - mfsp sr1, t2 - stw t1, TF_SR0(sr3, t3) - stw t2, TF_SR1(sr3, t3) - - mfsp sr2, t1 - mfsp sr4, t2 - stw t1, TF_SR2(sr3, t3) - stw t2, TF_SR4(sr3, t3) - - mfsp sr5, t2 - mfsp sr6, t1 - stw t2, TF_SR5(sr3, t3) - stw t1, TF_SR6(sr3, t3) - - mfsp sr7, t1 - mfctl pidr2, t2 - stw t1, TF_SR7(sr3, t3) - stw t2, TF_CR9(sr3, t3) - - mtsp r0, sr0 - mtsp r0, sr1 - mtsp r0, sr2 - mtsp r0, sr4 - mtsp r0, sr5 - mtsp r0, sr6 - mtsp r0, sr7 - -#if pbably_not_worth_it - mfctl pidr3, t1 - mfctl pidr4, t2 - stw t1, TF_CR12(t3) - stw t2, TF_CR13(t3) -#endif - - /* - * Save all general registers that we haven't saved already - */ - - mfctl sar, t1 /* use ,bc each cache line */ - stw t1, TF_CR11(t3) - stw r1, TF_R1(t3) - stw r2, TF_R2(t3) - stw r3, TF_R3(t3) - - copy sp, r3 - stw,mb r0, -HPPA_FRAME_SIZE(r3) - - /* - * Copy partially saved state from the store into the frame - */ - mfctl cr29, t2 - ldo CI_TRAP_SAVE(t2), t2 - /* use ,bc each cache line */ - ldw 0(t2), r1 ! ldw 4(t2), t1 ! stw r1, 0(t3) ! stw t1, 4(t3) - ldw 8(t2), r1 ! ldw 12(t2), t1 ! stw r1, 8(t3) ! stw t1, 12(t3) - ldw 16(t2), r1 ! ldw 20(t2), t1 ! stw r1, 16(t3) ! stw t1, 20(t3) - ldw 24(t2), r1 ! ldw 28(t2), t1 ! stw r1, 24(t3) ! stw t1, 28(t3) - ldw 32(t2), r1 ! ldw 36(t2), t1 ! stw r1, 32(t3) ! stw t1, 36(t3) - ldw 40(t2), r1 ! ldw 44(t2), t1 ! stw r1, 40(t3) ! stw t1, 44(t3) - ldw 48(t2), r1 ! ldw 52(t2), t1 ! stw r1, 48(t3) ! stw t1, 52(t3) - ldw 56(t2), r1 ! ldw 60(t2), t1 ! stw r1, 56(t3) ! stw t1, 60(t3) - - stw r4, TF_R4(t3) - stw r5, TF_R5(t3) - stw r6, TF_R6(t3) - stw r7, TF_R7(t3) - stw r8, TF_R8(t3) - stw r9, TF_R9(t3) - stw r10, TF_R10(t3) - stw r11, TF_R11(t3) - stw r12, TF_R12(t3) - stw r13, TF_R13(t3) - stw r14, TF_R14(t3) - stw r15, TF_R15(t3) - stw r16, TF_R16(t3) - stw r17, TF_R17(t3) - stw r18, TF_R18(t3) - stw r19, TF_R19(t3) /* t4 */ - stw r23, TF_R23(t3) - stw r24, TF_R24(t3) - stw r25, TF_R25(t3) - stw r26, TF_R26(t3) - stw r27, TF_R27(t3) - stw r28, TF_R28(t3) - stw r29, TF_R29(t3) - stw r31, TF_R31(t3) - - /* - * Save the necessary control registers that have not already saved. - */ - -#ifdef DDB - /* - * Save hpt mask and v2p translation table pointer - */ - mfctl eirr, t1 - mfctl vtop, t2 - stw t1, TF_CR23(t3) - stw t2, TF_CR25(t3) - - mfctl cr28, t2 - stw t2, TF_CR28(t3) -#endif - mfctl cr27, t1 - mfctl cr30, t2 - stw t1, TF_CR27(t3) - stw t2, TF_CR30(t3) - - /* - * load the global pointer for the kernel - */ - - ldil L%$global$, dp - ldo R%$global$(dp), dp - - /* - * call the C routine trap(). - * form trap type in the first argument to trap() - */ - ldw TF_FLAGS(t3), arg0 - dep r0, 24, 25, arg0 - copy t3, arg1 - - copy arg0, r4 - copy arg1, r5 - - .import trap, code - ldil L%trap,t1 - ldo R%trap(t1),t1 - .call - blr r0,rp - bv,n r0(t1) - nop - - copy r5, t3 - - /* see if curproc have changed */ - extru,<> r4, TFF_LAST_POS, 1, r0 - b $syscall_return - - /* see if curproc have really changed */ - mfctl cr29, t1 - ldw CI_CURPROC(t1), t2 - sub,<> r0, t2, r0 - ldw P_MD_REGS(t2), t3 - - /* means curproc has actually changed */ - b $syscall_return - nop -EXIT(TLABEL(all)) - -#if defined(HP7000_CPU) -/* - * void desidhash_s(void) - */ -LEAF_ENTRY(desidhash_s) - sync - MFCPU_C_PCXST(DR_CPUCFG,22) /* t1 */ - MFCPU_C_PCXST(DR_CPUCFG,22) - nop - nop - depi 0, DR0_PCXS_DHE, 3, t1 /* 3: DR0_PCXS_DOMAIN|DR0_PCXS_IHE */ - depi 1, DR0_PCXS_EQWSTO, 1, t1 - /* clear `write to clear' bits so they don't get reset */ - depi 0, DR0_PCXS_DHPMC, 1, t1 - depi 0, DR0_PCXS_ILPMC, 1, t1 - sync - MTCPU_PCXST(22,DR_CPUCFG) - MTCPU_PCXST(22,DR_CPUCFG) - nop - nop - bv 0(rp) - extru t1, 4, 5, ret0 /* return chip revision */ -EXIT(desidhash_s) -#endif /* HP7000_CPU */ - -#if defined(HP7100_CPU) || defined(HP7200_CPU) -/* - * void desidhash_t(void) - */ -LEAF_ENTRY(desidhash_t) - sync - MFCPU_C_PCXST(DR_CPUCFG,22) /* t1 */ - MFCPU_C_PCXST(DR_CPUCFG,22) - nop - nop - depi 0, DR0_PCXT_IHE, 1, t1 - depi 0, DR0_PCXT_DHE, 1, t1 - /* clear `write to clear' bits so they don't get reset */ - depi 0, DR0_PCXT_DHPMC, 1, t1 - depi 0, DR0_PCXT_ILPMC, 1, t1 - sync - MTCPU_PCXST(22,DR_CPUCFG) - MTCPU_PCXST(22,DR_CPUCFG) - nop - nop - bv 0(rp) - extru t1, 4, 5, ret0 /* return chip revision */ -EXIT(desidhash_t) -#endif /* HP7100_CPU || HP7200_CPU */ - -#ifdef HP7300LC_CPU - .data - BSS(eaio_l2_mask, 4) -LEAF_ENTRY(eaio_l2) - ldil L%eaio_l2_mask, t2 - ldw R%eaio_l2_mask(t2), t1 - or t1, arg0, t1 - MTCPU_PCXL(22, DR0_PCXL2_ACCEL_IO) - nop - nop - bv 0(rp) - stw t1, R%eaio_l2_mask(t2) -EXIT(eaio_l2) -#endif /* HP7300LC_CPU */ - -#if defined(HP7100LC_CPU) || defined(HP7300LC_CPU) - -/* - * int - * ibtlb_l(int i, pa_space_t sp, vaddr_t va, paddr_t pa, vsize_t sz, u_int prot) - */ -LEAF_ENTRY(ibtlb_l) - rsm (PSL_R|PSL_I), t4 - nop ! nop ! nop ! nop ! nop ! nop ! nop - - bv 0(rp) - mtsm t4 -EXIT(ibtlb_l) - -/* - * int desidhash_l(void) - */ -LEAF_ENTRY(desidhash_l) - MFCPU_C_PCXL(DR_CPUCFG,22) /* t1 */ - nop - nop - depi 0, DR0_PCXL_L2IHASH_EN, 2, t1 /* 2: DR0_PCXL_L2DHASH_EN */ -#if 0 /* better trust the PROM if it left some bits set here */ - depi 0, DR0_PCXL_DUAL_DIS, 2, t1 -#endif - /* clear `write to clear' bits so they don't get reset */ - depi 0, DR0_PCXL_L2IHPMC, 1, t1 - depi 0, DR0_PCXL_L2DHPMC, 1, t1 - depi 0, DR0_PCXL_L1IHPMC, 1, t1 - depi 0, DR0_PCXL_L2PARERR, 4, t1 - sync - MTCPU_PCXL(22,DR_CPUCFG) - nop - nop - bv 0(rp) - extru t1, 4, 5, ret0 /* return chip revision */ -EXIT(desidhash_l) - -#endif /* HP7100LC_CPU */ - -#if defined(HP8000_CPU) || defined(HP8200_CPU) || defined(HP8500_CPU) - .level 2.0w -LEAF_ENTRY(desidhash_u) - MFCPU_PCXU(2,28) - depdi 0, 54, 1, r28 - MTCPU_PCXU(28,2) - bv r0(rp) - copy r0, ret0 /* XXX dunno how to get chip rev */ -EXIT(desidhash_u) - -LEAF_ENTRY(ibtlb_u) - /* TODO insert a locked large tlb entry */ - bv 0(rp) - nop -EXIT(ibtlb_u) - -LEAF_ENTRY(pbtlb_u) - /* TODO purge a locked tlb entry */ - bv 0(rp) - nop -EXIT(pbtlb_u) - .level 1.1 -#endif /* HP8000_CPU */ - -/* - * High Priority Machine Check Interrupt - */ - .export TLABEL(hpmc), entry -ENTRY(TLABEL(hpmc),0) -ALTENTRY(hpmc_tramp) - - mtsp r0, sr0 - ldil L%hppa_vtop, t1 - ldw R%hppa_vtop(t1), t1 - mtctl t1, CR_VTOP - - .import hpmc_dump, code - ldil L%hpmc_dump, rp - ldo R%hpmc_dump(rp), rp - mfctl cr29, %arg2 - ldw CI_PSW(%arg2), %arg2 - depi 0, PSL_I_POS, 1, %arg2 - stw %arg2, CI_PSW(t1) - ldil L%emrg_stack, arg1 - b $kernel_setup - ldw R%emrg_stack(arg1), arg1 - - /* never returns, but still */ - ldil L%HPPA_GBCAST, t1 - ldi CMD_RESET, t2 - stw t2, R%HPPA_GBCAST(t1) -hpmc_never_dies - b hpmc_never_dies - nop -ALTENTRY(hpmc_tramp_end) -EXIT(TLABEL(hpmc)) - -/* - * transfer of control handler - */ -ENTRY(hppa_toc,0) - - mtsp r0, sr0 - ldil L%hppa_vtop, t1 - ldw R%hppa_vtop(t1), t1 - mtctl t1, CR_VTOP - - /* TODO reload btlb */ - - .import boot, code - ldil L%boot, rp - ldo R%boot(rp), rp - mfctl cr29, %arg2 - ldw CI_PSW(%arg2), %arg2 - depi 0, PSL_I_POS, 1, %arg2 - stw %arg2, CI_PSW(t1) - ldi 0, arg0 - ldil L%emrg_stack, arg1 - b $kernel_setup - ldw R%emrg_stack(arg1), arg1 - -ALTENTRY(hppa_toc_end) - .word 0 -EXIT(hppa_toc) - -/* - * power fail recovery handler - */ -ENTRY(hppa_pfr,0) - - mtsp r0, sr0 - ldil L%hppa_vtop, t1 - ldw R%hppa_vtop(t1), t1 - mtctl t1, CR_VTOP - - /* TODO reload btlb */ - - .import boot, code - ldil L%boot, rp - ldo R%boot(rp), rp - mfctl cr29, %arg2 - ldw CI_PSW(%arg2), %arg2 - depi 0, PSL_I_POS, 1, %arg2 - stw %arg2, CI_PSW(t1) - ldi RB_HALT|RB_POWERDOWN, arg0 - ldil L%emrg_stack, arg1 - b $kernel_setup - ldw R%emrg_stack(arg1), arg1 - -ALTENTRY(hppa_pfr_end) - .word 0 -EXIT(hppa_pfr) - -#if 0 - .align 8 -intr_ticks - .word 0, 0 - -#define INTR_PROF_PRE \ - mfctl itmr, r9 ! \ - mtctl r9, tr5 -#define INTR_PROF_AFT \ - mfctl itmr, r8 ! \ - mfctl tr5, r9 ! \ - ldil L%intr_ticks, r1 ! \ - ldo R%intr_ticks(r1), r1 ! \ - sub r8, r9, r8 ! \ - ldw 0(r1), r16 ! \ - ldw 4(r1), r17 ! \ - add r8, r16, r16 ! \ - addi 1, r17, r17 ! \ - stw r16, 0(r1) ! \ - stw r17, 4(r1) -#else -#define INTR_PROF_PRE /* */ -#define INTR_PROF_AFT /* */ -#endif - - .import imask, data - .import intr_table, data - .align 32 -ENTRY(TLABEL(intr),0) - /* - * r8 is set to eirr in the INTRPRE - */ - - INTR_PROF_PRE - - ldil L%intr_table + 32*32, r1 - ldo R%intr_table + 32*32(r1), r1 - mfctl cr29, r17 - b $intr_cont - ldw CI_IPENDING(r17), r24 - -$intr_ffs - addi -32, r1, r1 - bb,>= r8, 0, $intr_ffs - zdep r8, 30, 31, r8 - - ldw 0(r1), r17 - bb,>=,n r17, 23, $intr_nocall - - ldw 2*4(r1), r16 /* func */ - ldw 3*4(r1), r9 /* arg: ioreg */ - mtctl r1, tr7 - bv r0(r16) - ldw 6*4(r1), r1 /* next: sub-intr_table */ - -$intr_nocall - ldw 4*4(r1), r17 /* bit */ - or r17, r24, r24 /* ipending */ - - /* also return from nested handlers */ -$intr_cont - comb,<>,n r0, r8, $intr_ffs - ldw -32(r1), r0 /* preload cache */ - - mfctl cr29, r17 - stw r24, CI_IPENDING(r17) - ldw CI_CPL(r17), r17 - ldil L%imask, r16 - ldo R%imask(r16), r16 - ldwx,s r17(r16), r25 - - INTR_PROF_AFT - - ldi T_INTERRUPT, r1 - andcm,= r24, r25, r0 - b TLABEL(all) - nop - - rfir - nop -EXIT(TLABEL(intr)) - -/* - * called with: - * r1 sub intr_table - * r9 ioregs - * r24 ipending (in/out) - * tr7 saved r1 (restore on return) - * free: - * r9, r16, r17, r25 - */ - .align 32 -LEAF_ENTRY(gsc_intr) - ldw 0(r9), r16 /* irr */ - - /* we know that first 5 bits are never used ... should skip */ -$gsc_intr_loop - comb,=,n r0, r16, $intr_cont - mfctl tr7, r1 -$gsc_ffs - addi 32, r1, r1 - bb,>= r16, 31, $gsc_ffs - shd r0, r16, 1, r16 - - ldo -32(r1), r9 -$gsc_share - ldw 4*4(r9), r17 /* bit */ - ldw 5*4(r9), r9 /* share */ - - comb,<> r0, r9, $gsc_share - or r17, r24, r24 /* ipending */ - - b,n $gsc_intr_loop -EXIT(gsc_intr) - - /* see above for calling conventions */ - .align 32 -LEAF_ENTRY(dino_intr) - ldw 3*4(r9), r16 /* irr0 */ - -$dino_intr_loop - comb,=,n r0, r16, $intr_cont - mfctl tr7, r1 -$dino_ffs - addi 32, r1, r1 - bb,>= r16, 31, $dino_ffs - shd r0, r16, 1, r16 - - ldo -32(r1), r9 -$dino_share - ldw 4*4(r9), r17 /* bit */ - ldw 5*4(r9), r9 /* share */ - - comb,<> r0, r9, $dino_share - or r17, r24, r24 /* ipending */ - - b,n $dino_intr_loop -EXIT(dino_intr) - - .export TLABEL(ibrk), entry -ENTRY(TLABEL(ibrk),0) - /* If called by a user process then always pass it to trap() */ - mfctl pcoq, r8 - extru,= r8, 31, 2, r0 - b,n $ibrk_bad - - /* don't accept breaks from data segments */ - .import etext - ldil L%etext, r9 - ldo R%etext(r9), r9 - comb,>>=,n r8, r9, $ibrk_bad - - mfctl iir, r8 - extru r8, 31, 5, r9 - comib,<>,n HPPA_BREAK_KERNEL, r9, $ibrk_bad - - /* now process all those `break' calls we make */ - extru r8, 18, 13, r9 - comib,=,n HPPA_BREAK_GET_PSW, r9, $ibrk_getpsw - comib,=,n HPPA_BREAK_SET_PSW, r9, $ibrk_setpsw - comib,=,n HPPA_BREAK_SPLLOWER, r9, $ibrk_spllower - -$ibrk_bad - /* illegal (unimplemented) break entry point */ - b TLABEL(all) - nop - -$ibrk_getpsw - b $ibrk_exit - mfctl ipsw, ret0 - -$ibrk_setpsw - mfctl ipsw, ret0 - b $ibrk_exit - mtctl arg0, ipsw - -$ibrk_spllower - /* skip the break */ - mtctl r0, pcoq - mfctl pcoq, r9 - mtctl r9, pcoq - ldo 4(r9), r9 - mtctl r9, pcoq - - mfctl cr29, r17 - ldw CI_IPENDING(r17), r8 - ldil L%imask, r9 - ldo R%imask(r9), r9 - ldw CI_CPL(r17), ret0 - ldwx,s arg0(r9), r16 - stw arg0, CI_CPL(r17) - ldi T_INTERRUPT, r1 - andcm,= r8, r16, r0 - b TLABEL(all) - nop - rfir - nop - - /* insert other fast breaks here */ - nop ! nop - -$ibrk_exit - /* skip the break */ - mtctl r0, pcoq - mfctl pcoq, r9 - mtctl r9, pcoq - ldo 4(r9), r9 - mtctl r9, pcoq - - rfir - nop -EXIT(TLABEL(ibrk)) - -LEAF_ENTRY(fpu_exit) - /* enable coprocessor XXX */ - depi 3, 25, 2, r1 - mtctl r1, ccr - - ldil L%fpu_scratch, %r25 - ldo R%fpu_scratch(%r25), %r25 - fstds %fr0, 0(%r25) - sync - bv %r0(%rp) - mtctl r0, ccr -EXIT(fpu_exit) - -LEAF_ENTRY(fpu_save) - fstds,ma %fr0 , 8(arg0) - fstds,ma %fr1 , 8(arg0) - fstds,ma %fr2 , 8(arg0) - fstds,ma %fr3 , 8(arg0) - fstds,ma %fr4 , 8(arg0) - fstds,ma %fr5 , 8(arg0) - fstds,ma %fr6 , 8(arg0) - fstds,ma %fr7 , 8(arg0) - fstds,ma %fr8 , 8(arg0) - fstds,ma %fr9 , 8(arg0) - fstds,ma %fr10, 8(arg0) - fstds,ma %fr11, 8(arg0) - fstds,ma %fr12, 8(arg0) - fstds,ma %fr13, 8(arg0) - fstds,ma %fr14, 8(arg0) - fstds,ma %fr15, 8(arg0) - fstds,ma %fr16, 8(arg0) - fstds,ma %fr17, 8(arg0) - fstds,ma %fr18, 8(arg0) - fstds,ma %fr19, 8(arg0) - fstds,ma %fr20, 8(arg0) - fstds,ma %fr21, 8(arg0) - fstds,ma %fr22, 8(arg0) - fstds,ma %fr23, 8(arg0) - fstds,ma %fr24, 8(arg0) - fstds,ma %fr25, 8(arg0) - fstds,ma %fr26, 8(arg0) - fstds,ma %fr27, 8(arg0) - fstds,ma %fr28, 8(arg0) - fstds,ma %fr29, 8(arg0) - fstds,ma %fr30, 8(arg0) - fstds %fr31, 0(arg0) - bv r0(rp) - sync -EXIT(fpu_save) - -#ifdef FPEMUL - /* - * Emulate FPU - * - * iisq:iioq - exception triggered instruction - */ -ENTRY($fpu_emulate,320) - copy r31, r9 - - mfctl cr29, r31 - ldw CI_STACK(r31), r31 - - /* stw r1 , TF_R1 (r31) shadowed */ - stw r2 , TF_R2 (r31) - stw r3 , TF_R3 (r31) - stw r4 , TF_R4 (r31) - stw r5 , TF_R5 (r31) - stw r6 , TF_R6 (r31) - stw r7 , TF_R7 (r31) - /* stw r8 , TF_R8 (r31) shadowed */ - /* stw r9 , TF_R9 (r31) shadowed */ - stw r10, TF_R10(r31) - stw r11, TF_R11(r31) - stw r12, TF_R12(r31) - stw r13, TF_R13(r31) - stw r14, TF_R14(r31) - stw r15, TF_R15(r31) - /* stw r16, TF_R16(r31) shadowed */ - /* stw r17, TF_R17(r31) shadowed */ - stw r18, TF_R18(r31) - stw r19, TF_R19(r31) - stw r20, TF_R20(r31) - stw r21, TF_R21(r31) - stw r22, TF_R22(r31) - stw r23, TF_R23(r31) - /* stw r24, TF_R24(r31) shadowed */ - /* stw r25, TF_R25(r31) shadowed */ - stw r26, TF_R26(r31) - stw r27, TF_R27(r31) - stw r28, TF_R28(r31) - stw r29, TF_R29(r31) - stw sp, TF_R30(r31) - stw r9, TF_R31(r31) - copy r1, arg0 - mfctl sar, r1 - stw r1, TF_CR11(r31) - stw arg0, TF_CR19(r31) - - ldo TRAPFRAME_SIZEOF(r31), r3 - ldo TRAPFRAME_SIZEOF+HPPA_FRAME_SIZE(r31), sp - - ldil L%$global$, dp - ldo R%$global$(dp), dp - - .import fpu_emulate, code - ldil L%fpu_emulate,t1 - ldo R%fpu_emulate(t1),t1 - mfctl cr30, arg2 - .call - blr r0,rp - bv,n 0(t1) - nop - - mfctl cr30, r25 - ldi 32, r1 - - ldw 4(r25), r17 /* fpu exception reg 0 */ - zdep ret0, 5, 6, r17 /* intentionally zero the insn */ - stw r17, 4(r25) - - mfctl cr29, r31 - ldw CI_STACK(r31), r31 - - ldw TF_CR11(r31), r1 - ldw TF_R2 (r31), r2 - ldw TF_R3 (r31), r3 - mtsar r1 - copy ret0, r1 - ldw TF_R4 (r31), r4 - ldw TF_R5 (r31), r5 - ldw TF_R6 (r31), r6 - ldw TF_R7 (r31), r7 - /* ldw TF_R8 (r31), r8 shadowed */ - /* ldw TF_R9 (r31), r9 shadowed */ - ldw TF_R10(r31), r10 - ldw TF_R11(r31), r11 - ldw TF_R12(r31), r12 - ldw TF_R13(r31), r13 - ldw TF_R14(r31), r14 - ldw TF_R15(r31), r15 - /* ldw TF_R16(r31), r16 shadowed */ - /* ldw TF_R17(r31), r17 shadowed */ - ldw TF_R18(r31), r18 - ldw TF_R19(r31), r19 - ldw TF_R20(r31), r20 - ldw TF_R21(r31), r21 - ldw TF_R22(r31), r22 - ldw TF_R23(r31), r23 - /* ldw TF_R24(r31), r24 shadowed */ - /* ldw TF_R25(r31), r25 shadowed */ - ldw TF_R26(r31), r26 - ldw TF_R27(r31), r27 - ldw TF_R28(r31), r28 - ldw TF_R29(r31), r29 - ldw TF_R30(r31), r30 - ldw TF_R31(r31), r31 - - bb,>=,n r1, 24, $fpu_emulate_done - - b TLABEL(all) - ldi T_EMULATION, r1 - -$fpu_emulate_done - comb,<> r0, r1, TLABEL(all) - ldi T_EXCEPTION, r1 - - rfir - nop -EXIT($fpu_emulate) - -#endif /* FPEMUL */ - - .import dcache_stride, data -LEAF_ENTRY(fdcache) - ldil L%dcache_stride,t1 - ldw R%dcache_stride(t1), arg3 - - mtsp arg0, sr1 /* move the space register to sr1 */ - add arg1, arg2, arg0 /* get the last byte to flush in arg0 */ - - zdep arg3, 27, 28, t1 /* get size of a 16X loop in t1 */ - comb,< arg2, t1, fdc_short /* check for count < 16 * stride */ - addi -1, t1, t1 /* compute size of large loop - 1 */ - - andcm arg2, t1, t1 /* L = count - (count mod lenbigloop) */ - add arg1, t1, t1 /* ub for big loop is lb + L */ - - fdc,m arg3(sr1, arg1) /* Start flushing first cache line. */ -fdc_long - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - fdc,m arg3(sr1, arg1) - comb,<<,n arg1, t1, fdc_long - fdc,m arg3(sr1, arg1) -fdc_short /* flush one line at a time */ - comb,<<,n arg1, arg0, fdc_short - fdc,m arg3(sr1, arg1) - - addi -1, arg0, arg1 - fdc r0(sr1, arg1) - - sync - syncdma - bv r0(r2) - nop -EXIT(fdcache) - - .import dcache_stride, data -LEAF_ENTRY(pdcache) - ldil L%dcache_stride,t1 - ldw R%dcache_stride(t1), arg3 - - mtsp arg0, sr1 /* move the space register to sr1 */ - add arg1, arg2, arg0 /* get the last byte to purge in arg0 */ - - zdep arg3, 27, 28, t1 /* get size of a 16X loop in t1 */ - comb,< arg2, t1, pdc_short /* check for count < 16 * stride */ - addi -1, t1, t1 /* compute size of large loop - 1 */ - - andcm arg2, t1, t1 /* L = count - (count mod lenbigloop) */ - add arg1, t1, t1 /* ub for big loop is lb + L */ - - pdc,m arg3(sr1, arg1) /* Start purging first cache line. */ -pdc_long - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - pdc,m arg3(sr1, arg1) - comb,<<,n arg1, t1, pdc_long - pdc,m arg3(sr1, arg1) -pdc_short /* purge one line at a time */ - comb,<<,n arg1, arg0, pdc_short - pdc,m arg3(sr1, arg1) - - addi -1, arg0, arg1 - pdc r0(sr1, arg1) - - sync - syncdma - bv r0(r2) - nop -EXIT(pdcache) - - .import icache_stride, data -LEAF_ENTRY(ficache) - ldil L%icache_stride,t1 - ldw R%icache_stride(t1), arg3 - - mtsp arg0, sr1 /* move the space register to sr1 */ - add arg1, arg2, arg0 /* get the last byte to flush in arg0 */ - - zdep arg3, 27, 28, t1 /* get size of a 16X loop in t1 */ - comb,< arg2, t1, fic_short /* check for count < 16 * stride */ - addi -1, t1, t1 /* compute size of large loop - 1 */ - - andcm arg2, t1, t1 /* L = count - (count mod lenbigloop) */ - add arg1, t1, t1 /* ub for big loop is lb + L */ - - fic,m arg3(sr1, arg1) /* Start flushing first cache line. */ -fic_long - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - fic,m arg3(sr1, arg1) - comb,<<,n arg1, t1, fic_long - fic,m arg3(sr1, arg1) -fic_short /* flush one line at a time */ - comb,<<,n arg1, arg0, fic_short - fic,m arg3(sr1, arg1) - - addi -1, arg0, arg1 - fic r0(sr1, arg1) - - sync - syncdma - bv r0(r2) - nop -EXIT(ficache) - -#ifdef DDB -LEAF_ENTRY(setjmp) -/* - * Save the other general registers whose contents are expected to remain - * across function calls. According to the "HP 9000 Series 800 Assembly - * Language Reference Manual", procedures can use general registers 19-26, - * 28, 29, 1, and 31 without restoring them. Hence, we do not save these. - */ - stwm r3,4(arg0) - stwm r4,4(arg0) - stwm r5,4(arg0) - stwm r6,4(arg0) - stwm r7,4(arg0) - stwm r8,4(arg0) - stwm r9,4(arg0) - stwm r10,4(arg0) - stwm r11,4(arg0) - stwm r12,4(arg0) - stwm r13,4(arg0) - stwm r14,4(arg0) - stwm r15,4(arg0) - stwm r16,4(arg0) - stwm r17,4(arg0) - stwm r18,4(arg0) - stwm r27,4(arg0) /* Good idea to save the data pointer (dp) */ - stwm rp,4(arg0) /* Save the return pointer */ - stwm sp,4(arg0) /* Save the original stack pointer */ - - bv 0(rp) - copy r0, ret0 -EXIT(setjmp) - -LEAF_ENTRY(longjmp) -/* - * Restore general registers. - */ - ldwm 4(arg0),r3 - ldwm 4(arg0),r4 - ldwm 4(arg0),r5 - ldwm 4(arg0),r6 - ldwm 4(arg0),r7 - ldwm 4(arg0),r8 - ldwm 4(arg0),r9 - ldwm 4(arg0),r10 - ldwm 4(arg0),r11 - ldwm 4(arg0),r12 - ldwm 4(arg0),r13 - ldwm 4(arg0),r14 - ldwm 4(arg0),r15 - ldwm 4(arg0),r16 - ldwm 4(arg0),r17 - ldwm 4(arg0),r18 - ldwm 4(arg0),r27 - ldwm 4(arg0),rp /* Restore return address pointer, */ - ldwm 4(arg0),sp /* stack pointer, */ - - bv 0(rp) - ldi 1, ret0 -EXIT(longjmp) -#endif /* DDB */ - - .align 32 - -LEAF_ENTRY(copy_on_fault) - mtsp r0, sr1 - mtsp r0, sr2 - stw r1, PCB_ONFAULT+U_PCB(r2) - ldw HPPA_FRAME_CRP(sp), rp - ldo -64(sp), sp - bv 0(rp) - ldi EFAULT, %ret0 -EXIT(copy_on_fault) - -/* - * int spstrcpy (pa_space_t ssp, const void *src, pa_space_t dsp, void *dst, - * size_t size, size_t *rsize) - * do a space to space strncpy, return actual copy size in the rsize; - */ -LEAF_ENTRY(spstrcpy) - ldw HPPA_FRAME_ARG(4)(sp), t2 - ldo 64(sp), sp - add t2, arg1, t2 - stw rp, HPPA_FRAME_CRP(sp) - /* setup fault handler */ - mfctl cr29, t1 - ldw CI_CURPROC(t1), t3 - ldil L%copy_on_fault, t4 - ldw P_ADDR(t3), r2 - ldo R%copy_on_fault(t4), t4 - ldw PCB_ONFAULT+U_PCB(r2), r1 - stw t4, PCB_ONFAULT+U_PCB(r2) - - mtsp arg0, sr1 - mtsp arg2, sr2 - copy arg1, arg0 - copy r0, ret0 - -$spstrcpy_loop - ldbs,ma 1(sr1, arg1), t1 - comb,= r0, t1, $spstrcpy_exit - stbs,ma t1, 1(sr2, arg3) - comb,<>,n t2, arg1, $spstrcpy_loop - nop - ldi ENAMETOOLONG, ret0 - -$spstrcpy_exit - mtsp r0, sr1 - mtsp r0, sr2 - stw r1, PCB_ONFAULT+U_PCB(r2) - ldw HPPA_FRAME_CRP(sp), rp - sub arg1, arg0, arg1 - ldo -64(sp), sp - ldw HPPA_FRAME_ARG(5)(sp), arg0 - sub,= r0, arg0, r0 - stw arg1, 0(arg0) - bv 0(rp) - nop -EXIT(spstrcpy) - -/* - * int spcopy32 (pa_space_t ssp, const uint32_t *src, pa_space_t dsp, - * uint32_t *dst) - * do an atomic space to space copy of a futex - */ -LEAF_ENTRY(spcopy32) - extru arg1, 31, 2, t3 - extru arg3, 31, 2, t4 - comb,<>,n 0, t3, $spcopy32_misaligned - comb,<>,n 0, t4, $spcopy32_misaligned - - ldo 64(sp), sp - stw rp, HPPA_FRAME_CRP(sp) - /* setup fault handler */ - mfctl cr29, t1 - ldw CI_CURPROC(t1), t3 - ldil L%copy_on_fault, t2 - ldw P_ADDR(t3), r2 - ldo R%copy_on_fault(t2), t2 - ldw PCB_ONFAULT+U_PCB(r2), r1 - stw t2, PCB_ONFAULT+U_PCB(r2) - - mtsp arg0, sr1 - mtsp arg2, sr2 - - ldw 0(sr1, arg1), t1 - stw t1, 0(sr2, arg3) - - mtsp r0, sr1 - mtsp r0, sr2 - /* reset fault handler */ - stw r1, PCB_ONFAULT+U_PCB(r2) - ldw HPPA_FRAME_CRP(sp), rp - ldo -64(sp), sp - bv 0(rp) - copy r0, ret0 - -$spcopy32_misaligned - bv 0(rp) - ldi EFAULT, ret0 -EXIT(spcopy32) - -/* - * int cpu_switchto(struct proc *old, struct proc *new) - * Switch from "old" proc to "new". - */ - .align 32 -ENTRY(cpu_switchto,128) - copy r3, r1 - stw rp, HPPA_FRAME_CRP(sp) - copy sp, r3 - stwm r1, HPPA_FRAME_SIZE+16*4(sp) - -#ifdef DIAGNOSTIC - b kstack_check - nop -switch_error - copy arg1, arg2 - copy arg0, arg1 - ldil L%panic, r1 - ldil L%Lcspstr, arg0 - ldo R%panic(r1), r1 - ldo R%Lcspstr(arg0), arg0 - .call - blr %r0, rp - bv,n %r0(r1) - nop -Lcspstr - .asciz "cpu_switch:old=%p, new=%p" - .align 8 -kstack_check - /* - * The new process' kernel stack must be reasonable. - */ - ldw P_ADDR(arg1), arg2 - ldw U_PCB+PCB_KSP(arg2), t1 - ldo NBPG(arg2), arg2 - comb,>>,n arg2, t1, switch_error - nop - sub t1, arg2, t1 - ldil L%USPACE, arg2 - ldo R%USPACE(arg2), arg2 - comb,<<=,n arg2, t1, switch_error - nop -kstack_ok -#endif - - /* Record new proc. */ - ldi SONPROC, t1 - stb t1, P_STAT(arg1) - mfctl cr29, t1 - stw arg1, CI_CURPROC(t1) - - /* If old process exited, don't bother. */ - comb,=,n r0, arg0, switch_exited - - /* - * 2. save old proc context - * - * arg0: old proc - */ - ldw P_ADDR(arg0), t1 - /* save callee-save registers */ - stw r4, 1*4(r3) - stw sp, U_PCB+PCB_KSP(t1) - stw r5, 2*4(r3) - stw r6, 3*4(r3) - stw r7, 4*4(r3) - stw r8, 5*4(r3) - stw r9, 6*4(r3) - stw r10, 7*4(r3) - stw r11, 8*4(r3) - stw r12, 9*4(r3) - stw r13, 10*4(r3) - stw r14, 11*4(r3) - stw r15, 12*4(r3) - stw r16, 13*4(r3) - stw r17, 14*4(r3) - stw r18, 15*4(r3) - fdc r0(t1) - stw r0, HPPA_FRAME_ARG(1)(sp) /* say no trampoline */ - sync - - /* don't need old curproc (arg0) starting from here */ -switch_exited - /* - * 3. restore new proc context - * - * arg1: new proc - */ - /* XXX disable interrupts? */ - ldw P_ADDR(arg1), t2 - ldw P_MD_REGS(arg1), t1 - ldw U_PCB+PCB_KSP(t2), sp - mtctl r0, ccr /* disable FPU */ - ldw TF_CR30(t1), t2 - ldw TF_CR9(t1), t3 - mtctl t2, cr30 - mtctl t3, pidr2 - /* XXX enable interrupts? */ - ldo -(HPPA_FRAME_SIZE+16*4)(sp), r3 - ldw HPPA_FRAME_ARG(0)(sp), arg0 - ldw HPPA_FRAME_ARG(1)(sp), t4 /* in case we're on trampoline */ - sub,= r0, t4, r0 - b switch_return - ldw 1*4(r3), r4 - ldw 2*4(r3), r5 - ldw 3*4(r3), r6 - ldw 4*4(r3), r7 - ldw 5*4(r3), r8 - ldw 6*4(r3), r9 - ldw 7*4(r3), r10 - ldw 8*4(r3), r11 - ldw 9*4(r3), r12 - ldw 10*4(r3), r13 - ldw 11*4(r3), r14 - ldw 12*4(r3), r15 - ldw 13*4(r3), r16 - ldw 14*4(r3), r17 - ldw 15*4(r3), r18 - -switch_return - ldw HPPA_FRAME_CRP(r3), rp - bv 0(rp) - ldwm -(HPPA_FRAME_SIZE+16*4)(sp), r3 -EXIT(cpu_switchto) - -LEAF_ENTRY(cpu_idle_enter) - bv 0(rp) - nop -EXIT(cpu_idle_enter) - -LEAF_ENTRY(cpu_idle_cycle) - bv 0(rp) - nop -EXIT(cpu_idle_cycle) - -LEAF_ENTRY(cpu_idle_leave) - bv 0(rp) - nop -EXIT(cpu_idle_leave) - -ENTRY(proc_trampoline,0) - copy r0, r3 -#ifdef MULTIPROCESSOR - copy t4, r5 - copy arg0, r4 - bl proc_trampoline_mp, rp - nop - copy r4, arg0 - copy r5, t4 -#endif - mfctl cr29, t1 - stw r0, CI_CPL(t1) - .call - blr r0, rp - bv,n r0(t4) - nop - mfctl cr29, t1 - ldw CI_CURPROC(t1), t2 - .call - b $syscall_return - ldw P_MD_REGS(t2), t3 -EXIT(proc_trampoline) - -#ifdef MULTIPROCESSOR -/* - * Trampoline to spin up secondary processors. - */ -ENTRY(hw_cpu_spinup_trampoline, 0) - - /* - * disable interrupts and turn off all bits in the psw so that - * we start in a known state. - */ - rsm RESET_PSL, r0 - nop ! nop ! nop ! nop ! nop ! nop - - /* get things ready for the kernel to run in virtual mode */ - ldi HPPA_PID_KERNEL, r1 - mtctl r1, pidr1 - mtctl r1, pidr2 -#if pbably_not_worth_it - mtctl r0, pidr3 - mtctl r0, pidr4 -#endif - mtsp r0, sr0 - mtsp r0, sr1 - mtsp r0, sr2 - mtsp r0, sr3 - mtsp r0, sr4 - mtsp r0, sr5 - mtsp r0, sr6 - mtsp r0, sr7 - - /* - * disable all coprocessors - */ - mtctl r0, ccr - - /* - * to keep the spl() routines consistent we need to put the correct - * spl level into eiem, and reset any pending interrupts - */ - ldi -1, r1 - mtctl r0, eiem - mtctl r1, eirr - - /* - * load address of interrupt vector table - */ - ldil L%$ivaaddr, t2 - ldo R%$ivaaddr(t2), t2 - mtctl t2, iva - - /* - * set up the dp pointer so that we can do quick references off of it - */ - ldil L%$global$,dp - ldo R%$global$(dp),dp - - /* - * Store address of cpu_info in CR29. - */ - ldil L%cpu_hatch_info, r3 - ldw R%cpu_hatch_info(r3), r3 - mtctl r3, cr29 - - /* - * Setup the stack frame for us to call C with and mark this as the - * first frame on the stack. - */ - ldw CI_STACK(r3), sp - stw,ma r0, HPPA_FRAME_SIZE(sp) - stw r0, HPPA_FRAME_CRP(sp) - stw r0, HPPA_FRAME_PSP(sp) - - ldil L%TFF_LAST, t1 - stw t1, TF_FLAGS-TRAPFRAME_SIZEOF(sp) - - /* Provide CPU with page tables. */ - ldil L%hppa_vtop, t1 - ldw R%hppa_vtop(t1), t1 - mtctl t1, CR_VTOP - - /* Turn on the Q bit so that we can handle TLB traps. */ - ldil L%$q_enabled, t1 - ldo R%$q_enabled(t1), t1 - mtctl r0, pcsq - mtctl r0, pcsq - mtctl t1, pcoq - ldo 4(t1), t1 - mtctl t1, pcoq - ldi PSL_Q|PSL_I, t2 - mtctl t2, ipsw - rfi - nop - -$q_enabled - - /* Call C routine to setup CPU. */ - ldil L%cpu_hw_init, r1 - ldo R%cpu_hw_init(r1), r1 - .import cpu_hw_init, code - .call - blr r0, rp - bv,n (r1) - nop - - /* Switch CPU mode. */ - ldil L%$cpu_spinup_vm, t1 - ldo R%$cpu_spinup_vm(t1), t1 - mtctl r0, pcsq - mtctl r0, pcsq - mtctl t1, pcoq - ldo 4(t1), t1 - mtctl t1, pcoq - mfctl cr29, t2 - ldw CI_PSW(t2), t2 - mtctl t2, ipsw - rfi - nop - -$cpu_spinup_vm - - /* - * Okay, time to return to the land of C. - */ - b cpu_hatch - nop - -EXIT(hw_cpu_spinup_trampoline) -#endif - -/* - * Signal "trampoline" code. Invoked from RTE setup by sendsig(). - */ - .section .rodata - .align 4 - .export sigcode, entry - .label sigcode - .proc - .callinfo frame=0,calls, save_rp, save_sp - .entry -sigcode: - bb,>=,n arg3, 30, sigcode_call - dep r0, 31, 2, arg3 - ldw 4(arg3), r19 - ldw 0(arg3), arg3 -sigcode_call - .call - ble 0(sr0, arg3) - copy r31, rp - - ldil L%SYSCALLGATE, r1 - copy r4, arg0 - .call - ble 4(sr7, r1) - ldi SYS_sigreturn, t1 - .globl sigcoderet -sigcoderet: - - ldil L%SYSCALLGATE, r1 - copy ret0, arg0 - .call - ble 4(sr7, r1) - ldi SYS_exit, t1 -ALTENTRY(esigcode) -EXIT(sigcode) - - .globl sigfill -sigfill: - break 0,0 -esigfill: - .align 4 - .globl sigfillsiz -sigfillsiz: - .word esigfill - sigfill - - .text - - .end diff --git a/sys/arch/hppa/hppa/locore0.S b/sys/arch/hppa/hppa/locore0.S deleted file mode 100644 index bb9172193..000000000 --- a/sys/arch/hppa/hppa/locore0.S +++ /dev/null @@ -1,270 +0,0 @@ -/* $OpenBSD: locore0.S,v 1.1 2017/06/05 18:59:06 deraadt Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - * - * Portitions of this file are derived from other sources, see - * the copyrights and acknowledgements below. - */ -/* - * (c) Copyright 1988 HEWLETT-PACKARD COMPANY - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of Hewlett-Packard Company not be - * used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Hewlett-Packard Company makes no representations about the - * suitability of this software for any purpose. - */ -/* - * Copyright (c) 1990,1991,1992,1994 The University of Utah and - * the Computer Systems Laboratory (CSL). All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: locore.s 1.63 95/01/20$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "assym.h" - - .import $global$, data - .import pdc, data - .import boothowto, data - .import bootdev, data - .import esym, data - .import cpu_info, data - .import proc0, data - .import proc0paddr, data - .import proc0fpstate, data - -#define EMRG_STACKSIZE (1*NBPG) -#define FPEMU_STACKSIZE (1*NBPG) - - .data - - BSS(pdc_stack, 4) /* temp stack for PDC call */ - BSS(emrg_stack, 4) /* stack for HPMC/TOC/PWRF */ - - .export kernelmapped, data - BSS(kernelmapped, 4) /* set when kernel is mapped */ - .export fpu_enable, data - BSS(fpu_enable, 4) /* bits to set in the ccr to enable fpu */ - BSS(cpu_fpuena, 4) /* enable FPU, otherwise force emulate */ - BSS(fpu_scratch, 16) /* FPU scratch space, enough for a quad */ - .export hppa_vtop, data - BSS(hppa_vtop, 4) /* a vtop translation table addr (pa=va) */ - - .text - .import $kernel_setup, entry - -/* - * This is the starting location for the kernel - */ -ENTRY($start,0) -/* - * start(pdc, boothowto, bootdev, esym, bootapiver, argv, argc) - * - * pdc - PDC entry point - * boothowto - boot flags (see "reboot.h") - * bootdev - boot device (index into bdevsw) - * esym - end of symbol table (or &end if not present) - * bootapiver - /boot API version - * argv - options block passed from /boot - * argc - the length of the block - */ - - /* - * save the pdc, boothowto, bootdev and esym arguments - */ - ldil L%pdc,r1 - stw arg0,R%pdc(r1) - ldil L%boothowto,r1 - stw arg1,R%boothowto(r1) - ldil L%bootdev,r1 - stw arg2,R%bootdev(r1) - ldil L%esym,r1 - stw arg3,R%esym(r1) - - /* Align arg3, which is the start of available memory */ - ldo NBPG-1(arg3), arg3 - dep r0, 31, PGSHIFT, arg3 - - /* assuming size being page-aligned */ -#define STACK_ALLOC(n,s) \ - ldil L%(n), t1 ! \ - ldil L%(s), t2 ! \ - stw arg3, R%(n)(t1) ! \ - add arg3, t2, arg3 - - STACK_ALLOC(pdc_stack, PDC_STACKSIZE) - STACK_ALLOC(emrg_stack, EMRG_STACKSIZE) - -#undef STACK_ALLOC - - /* zero fake trapframe and proc0 u-area */ - copy arg3, t2 - ldi NBPG+TRAPFRAME_SIZEOF, t1 -$start_zero_tf - stws,ma r0, 4(t2) - addib,>= -8, t1, $start_zero_tf - stws,ma r0, 4(t2) /* XXX could use ,bc here, but gas is broken */ - - /* - * kernel stack lives here (arg3 is page-aligned esym) - * initialize the pcb - * arg0 will be available space for hppa_init() - */ - ldo NBPG+TRAPFRAME_SIZEOF(arg3), sp - stw r0, U_PCB+PCB_ONFAULT(arg3) - stw r0, U_PCB+PCB_SPACE(arg3) /* XXX HPPA_SID_KERNEL == 0 */ - ldil L%(USPACE+NBPG), arg0 /* normal U plus red zone */ - add arg0, arg3, arg0 - ldil L%proc0paddr, t1 - stw arg3, R%proc0paddr(t1) - ldil L%proc0, t2 - stw arg3, R%proc0+P_ADDR(t2) - ldo -TRAPFRAME_SIZEOF(sp), t3 - stw t3, R%proc0+P_MD_REGS(t2) - - ldil L%TFF_LAST, t1 - stw t1, TF_FLAGS-TRAPFRAME_SIZEOF(sp) - ldil L%proc0fpstate, t1 - ldo R%proc0fpstate(t1), t1 - stw t1, TF_CR30-TRAPFRAME_SIZEOF(sp) - mtctl t1, cr30 - - /* - * disable all coprocessors - */ - mtctl r0, ccr - - /* Store pointer to cpu_info in CR29. */ - ldil L%cpu_info, r1 - ldo R%cpu_info(r1), r1 - mtctl r1, cr29 - -#ifdef MULTIPROCESSOR - /* Setup SMP rendezvous address. */ - ldil L%hw_cpu_spinup_trampoline, r1 - ldo R%hw_cpu_spinup_trampoline(r1), r1 - stw r1, 0x10(0) /* MEM_RENDEZ */ - stw r0, 0x28(0) /* MEM_RENDEZ */ -#endif - - copy sp, arg1 - ldil L%$qisnowon, rp - ldo R%$qisnowon(rp), rp - b $kernel_setup - ldi PSL_Q|PSL_I, arg2 - -$qisnowon - /* - * call C routine hppa_init() to initialize VM - */ - ldil L%hppa_init, r1 - ldo R%hppa_init(r1), r1 - .import hppa_init, code - .call - blr r0, rp - bv,n (r1) - nop - - /* - * Cannot change the queues or IPSW with the Q-bit on - */ - rsm RESET_PSL, r0 - nop ! nop ! nop ! nop ! nop ! nop ! nop - - /* - * We need to do an rfi to get the C bit set - */ - mtctl r0, pcsq - mtctl r0, pcsq - ldil L%$virtual_mode, t1 - ldo R%$virtual_mode(t1), t1 - mtctl t1, pcoq - ldo 4(t1), t1 - mtctl t1, pcoq - mfctl r29, t1 - ldw CI_PSW(t1), t2 - mtctl t2, ipsw - rfi - nop - -$virtual_mode - ldil L%kernelmapped, t1 - stw t1, R%kernelmapped(t1) - -#ifdef DDB - .import db_enter, code - /* have to call debugger from here, from virtual mode */ - ldil L%boothowto, r1 - ldw R%boothowto(r1), r1 - bb,>= r1, 25, $noddb - nop - - break HPPA_BREAK_KERNEL, HPPA_BREAK_KGDB -$noddb -#endif - - .import main,code - ldil L%main, r1 - ldo R%main(r1), r1 -$callmain - .call - blr r0, rp - bv,n (r1) - nop - - /* should never return... */ - bv (rp) - nop -EXIT($start) diff --git a/sys/arch/hppa/hppa/machdep.c b/sys/arch/hppa/hppa/machdep.c deleted file mode 100644 index d84f1d830..000000000 --- a/sys/arch/hppa/hppa/machdep.c +++ /dev/null @@ -1,1491 +0,0 @@ -/* $OpenBSD: machdep.c,v 1.268 2023/01/06 19:10:18 miod Exp $ */ - -/* - * Copyright (c) 1999-2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef DDB -#include -#include -#include -#include -#endif - -#include - -/* - * Different kinds of flags used throughout the kernel. - */ -int cold = 1; /* unset when engine is up to go */ -extern int msgbufmapped; /* set when safe to use msgbuf */ - -/* - * cache configuration, for most machines is the same - * numbers, so it makes sense to do defines w/ numbers depending - * on configured cpu types in the kernel - */ -int icache_stride, icache_line_mask; -int dcache_stride, dcache_line_mask; - -/* - * things to not kill - */ -volatile u_int8_t *machine_ledaddr; -int machine_ledword, machine_leds; -struct cpu_info cpu_info[HPPA_MAXCPUS]; - -/* - * CPU params (should be the same for all cpus in the system) - */ -struct pdc_cache pdc_cache PDC_ALIGNMENT; -struct pdc_btlb pdc_btlb PDC_ALIGNMENT; -struct pdc_model pdc_model PDC_ALIGNMENT; - - /* w/ a little deviation should be the same for all installed cpus */ -u_int cpu_ticksnum, cpu_ticksdenom; - - /* exported info */ -char machine[] = MACHINE; -char cpu_model[128]; -enum hppa_cpu_type cpu_type; -const char *cpu_typename; -int cpu_hvers; -u_int fpu_version; - -int led_blink; - -/* - * exported methods for cpus - */ -int (*cpu_desidhash)(void); -int (*cpu_hpt_init)(vaddr_t hpt, vsize_t hptsize); -int (*cpu_ibtlb_ins)(int i, pa_space_t sp, vaddr_t va, paddr_t pa, - vsize_t sz, u_int prot); -int (*cpu_dbtlb_ins)(int i, pa_space_t sp, vaddr_t va, paddr_t pa, - vsize_t sz, u_int prot); - -dev_t bootdev; -int physmem, resvmem, resvphysmem, esym; - -#ifdef MULTIPROCESSOR -__cpu_simple_lock_t atomic_lock = __SIMPLELOCK_UNLOCKED; -#endif - -/* - * Things for MI glue to stick on. - */ -struct user *proc0paddr; -long mem_ex_storage[EXTENT_FIXED_STORAGE_SIZE(64) / sizeof(long)]; -struct extent *hppa_ex; -struct pool hppa_fppl; -struct hppa_fpstate proc0fpstate; -struct consdev *cn_tab; - -struct vm_map *exec_map = NULL; -struct vm_map *phys_map = NULL; - -void delay_init(void); -static __inline void fall(int, int, int, int, int); -void dumpsys(void); -void hpmc_dump(void); -void cpuid(void); -void blink_led_timeout(void *); - -/* - * safepri is a safe priority for sleep to set for a spin-wait - * during autoconfiguration or after a panic. - */ -int safepri = 0; - -/* - * wide used hardware params - */ -struct pdc_hwtlb pdc_hwtlb PDC_ALIGNMENT; -struct pdc_coherence pdc_coherence PDC_ALIGNMENT; -struct pdc_spidb pdc_spidbits PDC_ALIGNMENT; -struct pdc_model pdc_model PDC_ALIGNMENT; - -struct uvm_constraint_range dma_constraint = { 0x0, (paddr_t)-1 }; -struct uvm_constraint_range *uvm_md_constraints[] = { NULL }; - -/* - * Whatever CPU types we support - */ -extern const u_int itlb_x[], itlbna_x[], dtlb_x[], dtlbna_x[], tlbd_x[]; -extern const u_int itlb_s[], itlbna_s[], dtlb_s[], dtlbna_s[], tlbd_s[]; -extern const u_int itlb_t[], itlbna_t[], dtlb_t[], dtlbna_t[], tlbd_t[]; -extern const u_int itlb_l[], itlbna_l[], dtlb_l[], dtlbna_l[], tlbd_l[]; -extern const u_int itlb_u[], itlbna_u[], dtlb_u[], dtlbna_u[], tlbd_u[]; -int iibtlb_s(int i, pa_space_t sp, vaddr_t va, paddr_t pa, - vsize_t sz, u_int prot); -int idbtlb_s(int i, pa_space_t sp, vaddr_t va, paddr_t pa, - vsize_t sz, u_int prot); -int ibtlb_t(int i, pa_space_t sp, vaddr_t va, paddr_t pa, - vsize_t sz, u_int prot); -int ibtlb_l(int i, pa_space_t sp, vaddr_t va, paddr_t pa, - vsize_t sz, u_int prot); -int ibtlb_u(int i, pa_space_t sp, vaddr_t va, paddr_t pa, - vsize_t sz, u_int prot); -int ibtlb_g(int i, pa_space_t sp, vaddr_t va, paddr_t pa, - vsize_t sz, u_int prot); -int pbtlb_g(int i); -int pbtlb_u(int i); -int hpti_g(vaddr_t, vsize_t); -int desidhash_s(void); -int desidhash_t(void); -int desidhash_l(void); -int desidhash_u(void); -const struct hppa_cpu_typed { - char name[8]; - enum hppa_cpu_type type; - int cpuid; - int features; - int patch; - int (*desidhash)(void); - int (*dbtlbins)(int i, pa_space_t sp, vaddr_t va, paddr_t pa, - vsize_t sz, u_int prot); - int (*ibtlbins)(int i, pa_space_t sp, vaddr_t va, paddr_t pa, - vsize_t sz, u_int prot); - int (*btlbprg)(int i); - int (*hptinit)(vaddr_t hpt, vsize_t hptsize); -} cpu_types[] = { -#ifdef HP7000_CPU - { "PCXS", hpcxs, 0, 0, 3, desidhash_s, ibtlb_g, NULL, pbtlb_g}, -#endif -#ifdef HP7100_CPU - { "PCXT", hpcxt, 0, HPPA_FTRS_BTLBU, - 2, desidhash_t, ibtlb_g, NULL, pbtlb_g}, -#endif -#ifdef HP7200_CPU - { "PCXT'", hpcxta,HPPA_CPU_PCXT2, HPPA_FTRS_BTLBU, - 2, desidhash_t, ibtlb_g, NULL, pbtlb_g}, -#endif -#ifdef HP7100LC_CPU - { "PCXL", hpcxl, HPPA_CPU_PCXL, HPPA_FTRS_BTLBU|HPPA_FTRS_HVT, - 0, desidhash_l, ibtlb_g, NULL, pbtlb_g, hpti_g}, -#endif -#ifdef HP7300LC_CPU - { "PCXL2", hpcxl2,HPPA_CPU_PCXL2, HPPA_FTRS_BTLBU|HPPA_FTRS_HVT, - 0, desidhash_l, ibtlb_g, NULL, pbtlb_g, hpti_g}, -#endif -#ifdef HP8000_CPU - { "PCXU", hpcxu, HPPA_CPU_PCXU, HPPA_FTRS_W32B, - 4, desidhash_u, ibtlb_u, NULL, pbtlb_u }, -#endif -#ifdef HP8200_CPU - { "PCXU+", hpcxu2,HPPA_CPU_PCXUP, HPPA_FTRS_W32B, - 4, desidhash_u, ibtlb_u, NULL, pbtlb_u }, -#endif -#ifdef HP8500_CPU - { "PCXW", hpcxw, HPPA_CPU_PCXW, HPPA_FTRS_W32B, - 4, desidhash_u, ibtlb_u, NULL, pbtlb_u }, -#endif -#ifdef HP8700_CPU - { "PCXW2", hpcxw, HPPA_CPU_PCXW2, HPPA_FTRS_W32B, - 4, desidhash_u, ibtlb_u, NULL, pbtlb_u }, -#endif - { "", 0 } -}; - -int hppa_cpuspeed(int *mhz); - -int -hppa_cpuspeed(int *mhz) -{ - *mhz = PAGE0->mem_10msec / 10000; - - return (0); -} - -void -hppa_init(paddr_t start) -{ - extern int kernel_text; - struct cpu_info *ci; - int error; - paddr_t avail_end; - - pdc_init(); /* init PDC iface, so we can call em easy */ - - delay_init(); /* calculate cpu clock ratio */ - - /* cache parameters */ - if ((error = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_DFLT, - &pdc_cache)) < 0) { -#ifdef DEBUG - printf("WARNING: PDC_CACHE error %d\n", error); -#endif - } - - dcache_line_mask = pdc_cache.dc_conf.cc_line * 16 - 1; - dcache_stride = pdc_cache.dc_stride; - icache_line_mask = pdc_cache.ic_conf.cc_line * 16 - 1; - icache_stride = pdc_cache.ic_stride; - - /* cache coherence params (pbably available for 8k only) */ - error = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_SETCS, - &pdc_coherence, 1, 1, 1, 1); -#ifdef DEBUG - printf ("PDC_CACHE_SETCS: %d, %d, %d, %d (%d)\n", - pdc_coherence.ia_cst, pdc_coherence.da_cst, - pdc_coherence.ita_cst, pdc_coherence.dta_cst, error); -#endif - error = pdc_call((iodcio_t)pdc, 0, PDC_CACHE, PDC_CACHE_GETSPIDB, - &pdc_spidbits, 0, 0, 0, 0); - printf("SPID bits: 0x%x, error = %d\n", pdc_spidbits.spidbits, error); - - /* setup hpmc handler */ - { - /* from locore.s */ - extern uint32_t hpmc_v[], hpmc_tramp[], hpmc_tramp_end[]; - uint32_t *p; - uint32_t cksum = 0; - - for (p = hpmc_tramp; p < hpmc_tramp_end; p++) - cksum += *p; - - p = hpmc_v; - if (pdc_call((iodcio_t)pdc, 0, PDC_INSTR, PDC_INSTR_DFLT, p)) - *p = 0x08000240; - - p[6] = (uint32_t)&hpmc_tramp; - p[7] = (hpmc_tramp_end - hpmc_tramp) * sizeof(uint32_t); - p[5] = - -(p[0] + p[1] + p[2] + p[3] + p[4] + p[6] + p[7] + cksum); - } - - { - extern u_int hppa_toc[], hppa_toc_end[]; - u_int cksum, *p; - - for (cksum = 0, p = hppa_toc; p < hppa_toc_end; p++) - cksum += *p; - - *p = cksum; - PAGE0->ivec_toc = (u_int)hppa_toc; - PAGE0->ivec_toclen = (hppa_toc_end - hppa_toc + 1) * 4; - } - - { - extern u_int hppa_pfr[], hppa_pfr_end[]; - u_int cksum, *p; - - for (cksum = 0, p = hppa_pfr; p < hppa_pfr_end; p++) - cksum += *p; - - *p = cksum; - PAGE0->ivec_mempf = (u_int)hppa_pfr; - PAGE0->ivec_mempflen = (hppa_pfr_end - hppa_pfr + 1) * 4; - } - - ci = curcpu(); - ci->ci_cpl = IPL_NESTED; - ci->ci_psw = PSL_Q | PSL_P | PSL_C | PSL_D; - - cpuid(); - ptlball(); - ficacheall(); - fdcacheall(); - - avail_end = trunc_page(PAGE0->imm_max_mem); - if (avail_end > SYSCALLGATE) - avail_end = SYSCALLGATE; - physmem = atop(avail_end); - resvmem = atop(((vaddr_t)&kernel_text)); - - /* we hope this won't fail */ - hppa_ex = extent_create("mem", 0x0, 0xffffffff, M_DEVBUF, - (caddr_t)mem_ex_storage, sizeof(mem_ex_storage), - EX_NOCOALESCE|EX_NOWAIT); - if (extent_alloc_region(hppa_ex, 0, (vaddr_t)PAGE0->imm_max_mem, - EX_NOWAIT)) - panic("cannot reserve main memory"); - - /* sets resvphysmem */ - pmap_bootstrap(round_page(start)); - - /* space has been reserved in pmap_bootstrap() */ - initmsgbuf((caddr_t)(ptoa(physmem) - round_page(MSGBUFSIZE)), - round_page(MSGBUFSIZE)); - - /* they say PDC_COPROC might turn fault light on */ - pdc_call((iodcio_t)pdc, 0, PDC_CHASSIS, PDC_CHASSIS_DISP, - PDC_OSTAT(PDC_OSTAT_RUN) | 0xCEC0); - - cpu_cpuspeed = &hppa_cpuspeed; -#ifdef DDB - ddb_init(); -#endif - ficacheall(); - fdcacheall(); - - proc0paddr->u_pcb.pcb_fpstate = &proc0fpstate; - pool_init(&hppa_fppl, sizeof(struct hppa_fpstate), 16, IPL_NONE, 0, - "hppafp", NULL); -} - -void -cpuid() -{ - /* - * Ptrs to various tlb handlers, to be filled - * based on cpu features. - * from locore.S - */ - extern u_int trap_ep_T_TLB_DIRTY[]; - extern u_int trap_ep_T_DTLBMISS[]; - extern u_int trap_ep_T_DTLBMISSNA[]; - extern u_int trap_ep_T_ITLBMISS[]; - extern u_int trap_ep_T_ITLBMISSNA[]; - - extern u_int fpu_enable; - extern int cpu_fpuena; - struct pdc_cpuid pdc_cpuid PDC_ALIGNMENT; - struct pdc_coproc pdc_coproc PDC_ALIGNMENT; - const struct hppa_cpu_typed *p = NULL; - u_int cpu_features; - int error; - - /* may the scientific guessing begin */ - cpu_features = 0; - cpu_type = 0; - - /* identify system type */ - if ((error = pdc_call((iodcio_t)pdc, 0, PDC_MODEL, PDC_MODEL_INFO, - &pdc_model)) < 0) { -#ifdef DEBUG - printf("WARNING: PDC_MODEL error %d\n", error); -#endif - pdc_model.hvers = 0; - } - - bzero(&pdc_cpuid, sizeof(pdc_cpuid)); - if (pdc_call((iodcio_t)pdc, 0, PDC_MODEL, PDC_MODEL_CPUID, - &pdc_cpuid, 0, 0, 0, 0) >= 0) { - - /* patch for old 8200 */ - if (pdc_cpuid.version == HPPA_CPU_PCXU && - pdc_cpuid.revision > 0x0d) - pdc_cpuid.version = HPPA_CPU_PCXUP; - - cpu_type = pdc_cpuid.version; - } - - /* locate coprocessors and SFUs */ - bzero(&pdc_coproc, sizeof(pdc_coproc)); - if ((error = pdc_call((iodcio_t)pdc, 0, PDC_COPROC, PDC_COPROC_DFLT, - &pdc_coproc, 0, 0, 0, 0, 0)) < 0) { - /* - * Some 1.1 systems fail the PDC_COPROC call with error == -3, - * when booting from disk (but not when netbooting). - * Until the cause of this misbehaviour is found, assume the - * usual 1.1 FPU settings, so that userland gets a chance to - * run. - */ - if ((pdc_model.hvers >> 4) != 0 && pdc_model.arch_rev == 4) { - printf("WARNING: PDC_COPROC error %d," - " assuming 1.1 FPU\n", error); - fpu_enable = 0xc0; - cpu_fpuena = 1; - } else { - printf("WARNING: PDC_COPROC error %d\n", error); - cpu_fpuena = 0; - } - } else { - printf("pdc_coproc: 0x%x, 0x%x; model %x rev %x\n", - pdc_coproc.ccr_enable, pdc_coproc.ccr_present, - pdc_coproc.fpu_model, pdc_coproc.fpu_revision); - fpu_enable = pdc_coproc.ccr_enable & CCR_MASK; - cpu_fpuena = 1; - - /* a kludge to detect PCXW */ - if (pdc_coproc.fpu_model == HPPA_FPU_PCXW) - cpu_type = HPPA_CPU_PCXW; - } - - /* BTLB params */ - if (cpu_type < HPPA_CPU_PCXU && - (error = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB, - PDC_BTLB_DEFAULT, &pdc_btlb)) < 0) { -#ifdef DEBUG - printf("WARNING: PDC_BTLB error %d\n", error); -#endif - } else { -#ifdef BTLBDEBUG - printf("btlb info: minsz=%d, maxsz=%d\n", - pdc_btlb.min_size, pdc_btlb.max_size); - printf("btlb fixed: i=%d, d=%d, c=%d\n", - pdc_btlb.finfo.num_i, - pdc_btlb.finfo.num_d, - pdc_btlb.finfo.num_c); - printf("btlb varbl: i=%d, d=%d, c=%d\n", - pdc_btlb.vinfo.num_i, - pdc_btlb.vinfo.num_d, - pdc_btlb.vinfo.num_c); -#endif /* BTLBDEBUG */ - /* purge TLBs and caches */ - if (pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB, - PDC_BTLB_PURGE_ALL) < 0) - printf("WARNING: BTLB purge failed\n"); - - if (pdc_btlb.finfo.num_c) - cpu_features |= HPPA_FTRS_BTLBU; - } - - if (!pdc_call((iodcio_t)pdc, 0, PDC_TLB, PDC_TLB_INFO, &pdc_hwtlb) && - pdc_hwtlb.min_size && pdc_hwtlb.max_size) { - cpu_features |= HPPA_FTRS_HVT; - if (pmap_hptsize > pdc_hwtlb.max_size) - pmap_hptsize = pdc_hwtlb.max_size; - else if (pmap_hptsize && pmap_hptsize < pdc_hwtlb.min_size) - pmap_hptsize = pdc_hwtlb.min_size; - } else { -#ifdef DEBUG - printf("WARNING: no HPT support, fine!\n"); -#endif - pmap_hptsize = 0; - } - - if (cpu_type) - for (p = cpu_types; p->name[0] && p->cpuid != cpu_type; p++); - else - for (p = cpu_types; - p->name[0] && p->features != cpu_features; p++); - - if (!p->name[0]) { - printf("WARNING: UNKNOWN CPU TYPE; GOOD LUCK " - "(type 0x%x, features 0x%x)\n", cpu_type, cpu_features); - p = cpu_types; - } else if ((p->type == hpcxl || p->type == hpcxl2) && !fpu_enable) { - /* we know PCXL and PCXL2 do not exist w/o FPU */ - fpu_enable = 0xc0; - cpu_fpuena = 1; - } - - /* - * TODO: HPT on 7200 is not currently supported - */ - if (pmap_hptsize && p->type != hpcxl && p->type != hpcxl2) - pmap_hptsize = 0; - - cpu_type = p->type; - cpu_typename = p->name; - cpu_ibtlb_ins = p->ibtlbins; - cpu_dbtlb_ins = p->dbtlbins; - cpu_hpt_init = p->hptinit; - cpu_desidhash = p->desidhash; - - /* patch tlb handler branches */ - if (p->patch) { - trap_ep_T_TLB_DIRTY [0] = trap_ep_T_TLB_DIRTY [p->patch]; - trap_ep_T_DTLBMISS [0] = trap_ep_T_DTLBMISS [p->patch]; - trap_ep_T_DTLBMISSNA[0] = trap_ep_T_DTLBMISSNA[p->patch]; - trap_ep_T_ITLBMISS [0] = trap_ep_T_ITLBMISS [p->patch]; - trap_ep_T_ITLBMISSNA[0] = trap_ep_T_ITLBMISSNA[p->patch]; - } - - /* force strong ordering for now */ - if (p->features & HPPA_FTRS_W32B) { - curcpu()->ci_psw |= PSL_O; - } - - { - const char *p, *q; - char buf[32]; - int lev; - - lev = 0xa + (*cpu_desidhash)(); - cpu_hvers = pdc_model.hvers >> 4; - if (!cpu_hvers) { - p = "(UNKNOWN)"; - q = lev == 0xa? "1.0" : "1.1"; - } else { - p = hppa_mod_info(HPPA_TYPE_BOARD, cpu_hvers); - if (!p) { - snprintf(buf, sizeof buf, "(UNKNOWN 0x%x)", - cpu_hvers); - p = buf; - } - - switch (pdc_model.arch_rev) { - default: - case 0: - q = "1.0"; - break; - case 4: - q = "1.1"; - /* this one is just a 100MHz pcxl */ - if (lev == 0x10) - lev = 0xc; - /* this one is a pcxl2 */ - if (lev == 0x16) - lev = 0xe; - break; - case 8: - q = "2.0"; - break; - } - } - - snprintf(cpu_model, sizeof cpu_model, - "HP 9000/%s PA-RISC %s%x", p, q, lev); - } -#ifdef DEBUG - printf("cpu: %s\n", cpu_model); -#endif -} - -void -cpu_startup(void) -{ - vaddr_t minaddr, maxaddr; - - /* - * i won't understand a friend of mine, - * who sat in a room full of artificial ice, - * fogging the air w/ humid cries -- - * WELCOME TO SUMMER! - */ - printf("%s", version); - - printf("%s\n", cpu_model); - printf("real mem = %lu (%luMB)\n", ptoa(physmem), - ptoa(physmem) / 1024 / 1024); - printf("rsvd mem = %lu (%luKB)\n", ptoa(resvmem), ptoa(resvmem) / 1024); - - /* - * Allocate a submap for exec arguments. This map effectively - * limits the number of processes exec'ing at any time. - */ - minaddr = vm_map_min(kernel_map); - exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, - 16*NCARGS, VM_MAP_PAGEABLE, FALSE, NULL); - - /* - * Allocate a submap for physio - */ - phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, - VM_PHYS_SIZE, 0, FALSE, NULL); - - printf("avail mem = %lu (%luMB)\n", ptoa(uvmexp.free), - ptoa(uvmexp.free) / 1024 / 1024); - - /* - * Set up buffers, so they can be used to read disk labels. - */ - bufinit(); - - /* - * Configure the system. - */ - if (boothowto & RB_CONFIG) { -#ifdef BOOT_CONFIG - user_config(); -#else - printf("kernel does not support -c; continuing..\n"); -#endif - } -} - -/* - * compute cpu clock ratio such as: - * cpu_ticksnum / cpu_ticksdenom = t + delta - * delta -> 0 - */ -void -delay_init(void) -{ - u_int num, denom, delta, mdelta; - - mdelta = UINT_MAX; - for (denom = 1; denom < 1000; denom++) { - num = (PAGE0->mem_10msec * denom) / 10000; - delta = num * 10000 / denom - PAGE0->mem_10msec; - if (!delta) { - cpu_ticksdenom = denom; - cpu_ticksnum = num; - break; - } else if (delta < mdelta) { - cpu_ticksdenom = denom; - cpu_ticksnum = num; - mdelta = delta; - } - } -} - -void -delay(u_int us) -{ - u_int start, end, n; - - mfctl(CR_ITMR, start); - while (us) { - n = min(1000, us); - end = start + n * cpu_ticksnum / cpu_ticksdenom; - - /* N.B. Interval Timer may wrap around */ - if (end < start) - do - mfctl(CR_ITMR, start); - while (start > end); - - do - mfctl(CR_ITMR, start); - while (start < end); - - us -= n; - } -} - -static __inline void -fall(int c_base, int c_count, int c_loop, int c_stride, int data) -{ - int loop; - - for (; c_count--; c_base += c_stride) - for (loop = c_loop; loop--; ) - if (data) - fdce(0, c_base); - else - fice(0, c_base); -} - -void -ficacheall(void) -{ - /* - * Flush the instruction, then data cache. - */ - fall(pdc_cache.ic_base, pdc_cache.ic_count, pdc_cache.ic_loop, - pdc_cache.ic_stride, 0); - sync_caches(); -} - -void -fdcacheall(void) -{ - fall(pdc_cache.dc_base, pdc_cache.dc_count, pdc_cache.dc_loop, - pdc_cache.dc_stride, 1); - sync_caches(); -} - -void -ptlball(void) -{ - pa_space_t sp; - int i, j, k; - - /* instruction TLB */ - sp = pdc_cache.it_sp_base; - for (i = 0; i < pdc_cache.it_sp_count; i++) { - vaddr_t off = pdc_cache.it_off_base; - for (j = 0; j < pdc_cache.it_off_count; j++) { - for (k = 0; k < pdc_cache.it_loop; k++) - pitlbe(sp, off); - off += pdc_cache.it_off_stride; - } - sp += pdc_cache.it_sp_stride; - } - - /* data TLB */ - sp = pdc_cache.dt_sp_base; - for (i = 0; i < pdc_cache.dt_sp_count; i++) { - vaddr_t off = pdc_cache.dt_off_base; - for (j = 0; j < pdc_cache.dt_off_count; j++) { - for (k = 0; k < pdc_cache.dt_loop; k++) - pdtlbe(sp, off); - off += pdc_cache.dt_off_stride; - } - sp += pdc_cache.dt_sp_stride; - } -} - -int -hpti_g(vaddr_t hpt, vsize_t hptsize) -{ - return pdc_call((iodcio_t)pdc, 0, PDC_TLB, PDC_TLB_CONFIG, - &pdc_hwtlb, hpt, hptsize, PDC_TLB_CURRPDE); -} - -int -pbtlb_g(int i) -{ - return -1; -} - -int -ibtlb_g(int i, pa_space_t sp, vaddr_t va, paddr_t pa, vsize_t sz, u_int prot) -{ - int error; - - if ((error = pdc_call((iodcio_t)pdc, 0, PDC_BLOCK_TLB, PDC_BTLB_INSERT, - sp, va, pa, sz, prot, i)) < 0) { -#ifdef BTLBDEBUG - printf("WARNING: BTLB insert failed (%d)\n", error); -#endif - } - return error; -} - -int -btlb_insert(pa_space_t space, vaddr_t va, paddr_t pa, vsize_t *lenp, u_int prot) -{ - static u_int32_t mask; - vsize_t len; - int error, i, btlb_max; - - if (!pdc_btlb.min_size && !pdc_btlb.max_size) - return -(ENXIO); - - /* - * On PCXS processors with split BTLB, we should theoretically - * insert in the IBTLB (if executable mapping requested), and - * into the DBTLB. The PDC documentation is very clear that - * slot numbers are, in order, IBTLB, then DBTLB, then combined - * BTLB. - * - * However it also states that ``successful completion may not mean - * that the entire address range specified in the call has been - * mapped in the block TLB. For both fixed range slots and variable - * range slots, complete coverage of the address range specified - * is not guaranteed. Only a portion of the address range specified - * may get mapped as a result''. - * - * On an HP 9000/720 with PDC ROM v1.2, it turns out that IBTLB - * entries are inserted as expected, but no DBTLB gets inserted - * at all, despite PDC returning success. - * - * So play it dumb, and do not attempt to insert DBTLB entries at - * all on split BTLB systems. Callers are supposed to be able to - * cope with this. - */ - - if (pdc_btlb.finfo.num_c == 0) { - if ((prot & TLB_EXECUTE) == 0) - return -(EINVAL); - - btlb_max = pdc_btlb.finfo.num_i; - } else { - btlb_max = pdc_btlb.finfo.num_c; - } - - /* align size */ - for (len = pdc_btlb.min_size << PGSHIFT; len < *lenp; len <<= 1); - len >>= PGSHIFT; - i = ffs(~mask) - 1; - if (len > pdc_btlb.max_size || i < 0 || i >= btlb_max) { -#ifdef BTLBDEBUG - printf("btln_insert: too big (%u < %u < %u)\n", - pdc_btlb.min_size, len, pdc_btlb.max_size); -#endif - return -(ENOMEM); - } - - mask |= 1 << i; - pa >>= PGSHIFT; - va >>= PGSHIFT; - /* check address alignment */ - if (pa & (len - 1)) { -#ifdef BTLBDEBUG - printf("WARNING: BTLB address misaligned pa=0x%x, len=0x%x\n", - pa, len); -#endif - return -(ERANGE); - } - - /* ensure IO space is uncached */ - if ((pa & (HPPA_IOBEGIN >> PGSHIFT)) == (HPPA_IOBEGIN >> PGSHIFT)) - prot |= TLB_UNCACHABLE; - -#ifdef BTLBDEBUG - printf("btlb_insert(%d): %x:%x=%x[%x,%x]\n", - i, space, va, pa, len, prot); -#endif - if ((error = (*cpu_dbtlb_ins)(i, space, va, pa, len, prot)) < 0) - return -(EINVAL); - *lenp = len << PGSHIFT; - - return i; -} - -int waittime = -1; - -__dead void -boot(int howto) -{ - if ((howto & RB_RESET) != 0) - goto doreset; - - /* - * On older systems without software power control, prevent mi code - * from spinning disks off, in case the operator changes his mind - * and prefers to reboot - the firmware will not send a spin up - * command to the disks. - */ - if (cold_hook == NULL) - howto &= ~RB_POWERDOWN; - - if (cold) { - if ((howto & RB_USERREQ) == 0) - howto |= RB_HALT; - goto haltsys; - } - - boothowto = howto | (boothowto & RB_HALT); - - if ((howto & RB_NOSYNC) == 0) { - waittime = 0; - vfs_shutdown(curproc); - - if ((howto & RB_TIMEBAD) == 0) { - resettodr(); - } else { - printf("WARNING: not updating battery clock\n"); - } - } - if_downall(); - - uvm_shutdown(); - splhigh(); - cold = 1; - - if ((howto & RB_DUMP) != 0) - dumpsys(); - -haltsys: - config_suspend_all(DVACT_POWERDOWN); - -#ifdef MULTIPROCESSOR - hppa_ipi_broadcast(HPPA_IPI_HALT); -#endif - - /* in case we came on powerfail interrupt */ - if (cold_hook) - (*cold_hook)(HPPA_COLD_COLD); - - if ((howto & RB_HALT) != 0) { - if ((howto & RB_POWERDOWN) != 0) { - printf("Powering off..."); - DELAY(2000000); - (*cold_hook)(HPPA_COLD_OFF); - DELAY(1000000); - } - - printf("System halted!\n"); - DELAY(2000000); - __asm volatile("stwas %0, 0(%1)" - :: "r" (CMD_STOP), "r" (HPPA_LBCAST + iomod_command)); - } else { -doreset: - printf("rebooting..."); - DELAY(2000000); - - /* ask firmware to reset */ - pdc_call((iodcio_t)pdc, 0, PDC_BROADCAST_RESET, PDC_DO_RESET); - - /* forcibly reset module if that fails */ - __asm volatile(".export hppa_reset, entry\n\t" - ".label hppa_reset"); - __asm volatile("stwas %0, 0(%1)" - :: "r" (CMD_RESET), "r" (HPPA_LBCAST + iomod_command)); - } - - for (;;) - continue; - /* NOTREACHED */ -} - -u_long dumpmag = 0x8fca0101; /* magic number */ -int dumpsize = 0; /* pages */ -long dumplo = 0; /* blocks */ - -/* - * cpu_dumpsize: calculate size of machine-dependent kernel core dump headers. - */ -int -cpu_dumpsize(void) -{ - int size; - - size = ALIGN(sizeof(kcore_seg_t)) + ALIGN(sizeof(cpu_kcore_hdr_t)); - if (roundup(size, dbtob(1)) != dbtob(1)) - return -1; - - return 1; -} - -/* - * Called from HPMC handler in locore - */ -void -hpmc_dump(void) -{ - cold = 0; - panic("HPMC"); - /* NOTREACHED */ -} - -int -cpu_dump(void) -{ - long buf[dbtob(1) / sizeof (long)]; - kcore_seg_t *segp; - cpu_kcore_hdr_t *cpuhdrp; - - segp = (kcore_seg_t *)buf; - cpuhdrp = (cpu_kcore_hdr_t *)&buf[ALIGN(sizeof(*segp)) / sizeof (long)]; - - /* - * Generate a segment header. - */ - CORE_SETMAGIC(*segp, KCORE_MAGIC, MID_MACHINE, CORE_CPU); - segp->c_size = dbtob(1) - ALIGN(sizeof(*segp)); - - /* - * Add the machine-dependent header info - */ - /* nothing for now */ - - return (bdevsw[major(dumpdev)].d_dump) - (dumpdev, dumplo, (caddr_t)buf, dbtob(1)); -} - -/* - * Dump the kernel's image to the swap partition. - */ -#define BYTES_PER_DUMP NBPG - -void -dumpsys(void) -{ - int psize, bytes, i, n; - caddr_t maddr; - daddr_t blkno; - int (*dump)(dev_t, daddr_t, caddr_t, size_t); - int error; - - /* Save registers - savectx(&dumppcb); */ - - if (dumpsize == 0) - dumpconf(); - if (dumplo <= 0) { - printf("\ndump to dev %x not possible\n", dumpdev); - return; - } - printf("\ndumping to dev %x, offset %ld\n", dumpdev, dumplo); - - psize = (*bdevsw[major(dumpdev)].d_psize)(dumpdev); - printf("dump "); - if (psize == -1) { - printf("area unavailable\n"); - return; - } - - if (!(error = cpu_dump())) { - - bytes = ptoa(physmem); - maddr = NULL; - blkno = dumplo + cpu_dumpsize(); - dump = bdevsw[major(dumpdev)].d_dump; - /* TODO block map the whole physical memory */ - for (i = 0; i < bytes; i += n) { - - /* Print out how many MBs we are to go. */ - n = bytes - i; - if (n && (n % (1024*1024)) == 0) - printf("%d ", n / (1024 * 1024)); - - /* Limit size for next transfer. */ - - if (n > BYTES_PER_DUMP) - n = BYTES_PER_DUMP; - - if ((error = (*dump)(dumpdev, blkno, maddr, n))) - break; - maddr += n; - blkno += btodb(n); - } - } - - switch (error) { - case ENXIO: printf("device bad\n"); break; - case EFAULT: printf("device not ready\n"); break; - case EINVAL: printf("area improper\n"); break; - case EIO: printf("i/o error\n"); break; - case EINTR: printf("aborted from console\n"); break; - case 0: printf("succeeded\n"); break; - default: printf("error %d\n", error); break; - } -} - -/* bcopy(), error on fault */ -int -kcopy(const void *from, void *to, size_t size) -{ - return spcopy(HPPA_SID_KERNEL, from, HPPA_SID_KERNEL, to, size); -} - -int -copyinstr(const void *src, void *dst, size_t size, size_t *lenp) -{ - if (size == 0) - return ENAMETOOLONG; - return spstrcpy(curproc->p_addr->u_pcb.pcb_space, src, - HPPA_SID_KERNEL, dst, size, lenp); -} - -int -copyoutstr(const void *src, void *dst, size_t size, size_t *lenp) -{ - if (size == 0) - return ENAMETOOLONG; - return spstrcpy(HPPA_SID_KERNEL, src, - curproc->p_addr->u_pcb.pcb_space, dst, size, lenp); -} - -int -copyin(const void *src, void *dst, size_t size) -{ - return spcopy(curproc->p_addr->u_pcb.pcb_space, src, - HPPA_SID_KERNEL, dst, size); -} - -int -copyout(const void *src, void *dst, size_t size) -{ - return spcopy(HPPA_SID_KERNEL, src, - curproc->p_addr->u_pcb.pcb_space, dst, size); -} - -int -copyin32(const uint32_t *src, uint32_t *dst) -{ - return spcopy32(curproc->p_addr->u_pcb.pcb_space, src, - HPPA_SID_KERNEL, dst); -} - -/* - * Set up tf_sp and tf_r3 (the frame pointer) and copy out the - * frame marker and the old r3 - */ -int -setstack(struct trapframe *tf, u_long stack, register_t old_r3) -{ - static const register_t zero = 0; - int err; - - tf->tf_r3 = stack; - err = copyout(&old_r3, (caddr_t)stack, sizeof(register_t)); - - tf->tf_sp = stack += HPPA_FRAME_SIZE; - return (copyout(&zero, (caddr_t)(stack + HPPA_FRAME_CRP), - sizeof(register_t)) || err); -} - - -/* - * Set registers on exec. - */ -void -setregs(struct proc *p, struct exec_package *pack, u_long stack, - struct ps_strings *arginfo) -{ - struct trapframe *tf = p->p_md.md_regs; - struct pcb *pcb = &p->p_addr->u_pcb; - struct fpreg *fpreg = &pcb->pcb_fpstate->hfp_regs; - - memset(tf, 0, sizeof *tf); - tf->tf_flags = TFF_SYS|TFF_LAST; - tf->tf_iioq_head = pack->ep_entry | HPPA_PC_PRIV_USER; - tf->tf_iioq_tail = tf->tf_iioq_head + 4; - tf->tf_iisq_head = tf->tf_iisq_tail = pcb->pcb_space; - tf->tf_arg0 = p->p_p->ps_strings; - - /* setup terminal stack frame */ - setstack(tf, (stack + 0x3f) & ~0x3f, 0); - - tf->tf_cr30 = (paddr_t)pcb->pcb_fpstate; - - tf->tf_sr0 = tf->tf_sr1 = tf->tf_sr2 = tf->tf_sr3 = - tf->tf_sr4 = tf->tf_sr5 = tf->tf_sr6 = pcb->pcb_space; - tf->tf_pidr1 = tf->tf_pidr2 = pmap_sid2pid(tf->tf_sr0); - - /* - * theoretically these could be inherited, - * but just in case. - */ - tf->tf_sr7 = HPPA_SID_KERNEL; - mfctl(CR_EIEM, tf->tf_eiem); - tf->tf_ipsw = PSL_C | PSL_Q | PSL_P | PSL_D | PSL_I /* | PSL_L */ | - (curcpu()->ci_psw & PSL_O); - - /* clear the FPU */ - fpu_proc_flush(p); - memset(fpreg, 0, sizeof *fpreg); - fpreg->fpr_regs[0] = ((u_int64_t)HPPA_FPU_INIT) << 32; - - p->p_md.md_bpva = 0; -} - -/* - * Send an interrupt to process. - */ -int -sendsig(sig_t catcher, int sig, sigset_t mask, const siginfo_t *ksip, - int info, int onstack) -{ - struct proc *p = curproc; - struct trapframe *tf = p->p_md.md_regs; - struct pcb *pcb = &p->p_addr->u_pcb; - struct sigcontext ksc; - register_t scp, sip; - int sss; - - /* Save the FPU context first. */ - fpu_proc_save(p); - - /* - * Allocate space for the signal handler context. - */ - if ((p->p_sigstk.ss_flags & SS_DISABLE) == 0 && - !sigonstack(tf->tf_sp) && onstack) - scp = round_page((vaddr_t)p->p_sigstk.ss_sp); - else - scp = (tf->tf_sp + 63) & ~63; - - sss = (sizeof(ksc) + 63) & ~63; - sip = 0; - if (info) { - sip = scp + sizeof(ksc); - sss += (sizeof(*ksip) + 63) & ~63; - } - - bzero(&ksc, sizeof(ksc)); - ksc.sc_mask = mask; - ksc.sc_fp = scp + sss; - ksc.sc_ps = tf->tf_ipsw; - ksc.sc_pcoqh = tf->tf_iioq_head; - ksc.sc_pcoqt = tf->tf_iioq_tail; - ksc.sc_regs[0] = tf->tf_t1; - ksc.sc_regs[1] = tf->tf_t2; - ksc.sc_regs[2] = tf->tf_sp; - ksc.sc_regs[3] = tf->tf_t3; - ksc.sc_regs[4] = tf->tf_sar; - ksc.sc_regs[5] = tf->tf_r1; - ksc.sc_regs[6] = tf->tf_rp; - ksc.sc_regs[7] = tf->tf_r3; - ksc.sc_regs[8] = tf->tf_r4; - ksc.sc_regs[9] = tf->tf_r5; - ksc.sc_regs[10] = tf->tf_r6; - ksc.sc_regs[11] = tf->tf_r7; - ksc.sc_regs[12] = tf->tf_r8; - ksc.sc_regs[13] = tf->tf_r9; - ksc.sc_regs[14] = tf->tf_r10; - ksc.sc_regs[15] = tf->tf_r11; - ksc.sc_regs[16] = tf->tf_r12; - ksc.sc_regs[17] = tf->tf_r13; - ksc.sc_regs[18] = tf->tf_r14; - ksc.sc_regs[19] = tf->tf_r15; - ksc.sc_regs[20] = tf->tf_r16; - ksc.sc_regs[21] = tf->tf_r17; - ksc.sc_regs[22] = tf->tf_r18; - ksc.sc_regs[23] = tf->tf_t4; - ksc.sc_regs[24] = tf->tf_arg3; - ksc.sc_regs[25] = tf->tf_arg2; - ksc.sc_regs[26] = tf->tf_arg1; - ksc.sc_regs[27] = tf->tf_arg0; - ksc.sc_regs[28] = tf->tf_dp; - ksc.sc_regs[29] = tf->tf_ret0; - ksc.sc_regs[30] = tf->tf_ret1; - ksc.sc_regs[31] = tf->tf_r31; - bcopy(&p->p_addr->u_pcb.pcb_fpstate->hfp_regs, ksc.sc_fpregs, - sizeof(ksc.sc_fpregs)); - - if (setstack(tf, scp + sss, tf->tf_r3)) - return 1; - - tf->tf_arg0 = sig; - tf->tf_arg1 = sip; - tf->tf_arg2 = tf->tf_r4 = scp; - tf->tf_arg3 = (register_t)catcher; - tf->tf_ipsw &= ~(PSL_N|PSL_B|PSL_T); - tf->tf_iioq_head = HPPA_PC_PRIV_USER | p->p_p->ps_sigcode; - tf->tf_iioq_tail = tf->tf_iioq_head + 4; - tf->tf_iisq_tail = tf->tf_iisq_head = pcb->pcb_space; - /* disable tracing in the trapframe */ - - ksc.sc_cookie = (long)scp ^ p->p_p->ps_sigcookie; - if (copyout(&ksc, (void *)scp, sizeof(ksc))) - return 1; - - if (sip) { - if (copyout(ksip, (void *)sip, sizeof *ksip)) - return 1; - } - - return 0; -} - -int -sys_sigreturn(struct proc *p, void *v, register_t *retval) -{ - struct sys_sigreturn_args /* { - syscallarg(struct sigcontext *) sigcntxp; - } */ *uap = v; - struct sigcontext ksc, *scp = SCARG(uap, sigcntxp); - struct trapframe *tf = p->p_md.md_regs; - int error; - - if (PROC_PC(p) != p->p_p->ps_sigcoderet) { - sigexit(p, SIGILL); - return (EPERM); - } - - /* Flush the FPU context first. */ - fpu_proc_flush(p); - - if ((error = copyin((caddr_t)scp, (caddr_t)&ksc, sizeof ksc))) - return (error); - - if (ksc.sc_cookie != ((long)scp ^ p->p_p->ps_sigcookie)) { - sigexit(p, SIGILL); - return (EFAULT); - } - - /* Prevent reuse of the sigcontext cookie */ - ksc.sc_cookie = 0; - (void)copyout(&ksc.sc_cookie, (caddr_t)scp + - offsetof(struct sigcontext, sc_cookie), sizeof (ksc.sc_cookie)); - -#define PSL_MBS (PSL_C|PSL_Q|PSL_P|PSL_D|PSL_I) -#define PSL_MBZ (PSL_Y|PSL_Z|PSL_S|PSL_X|PSL_M|PSL_R) - if ((ksc.sc_ps & (PSL_MBS|PSL_MBZ)) != PSL_MBS) - return (EINVAL); - - p->p_sigmask = ksc.sc_mask &~ sigcantmask; - - tf->tf_t1 = ksc.sc_regs[0]; /* r22 */ - tf->tf_t2 = ksc.sc_regs[1]; /* r21 */ - tf->tf_sp = ksc.sc_regs[2]; - tf->tf_t3 = ksc.sc_regs[3]; /* r20 */ - tf->tf_sar = ksc.sc_regs[4]; - tf->tf_r1 = ksc.sc_regs[5]; - tf->tf_rp = ksc.sc_regs[6]; - tf->tf_r3 = ksc.sc_regs[7]; - tf->tf_r4 = ksc.sc_regs[8]; - tf->tf_r5 = ksc.sc_regs[9]; - tf->tf_r6 = ksc.sc_regs[10]; - tf->tf_r7 = ksc.sc_regs[11]; - tf->tf_r8 = ksc.sc_regs[12]; - tf->tf_r9 = ksc.sc_regs[13]; - tf->tf_r10 = ksc.sc_regs[14]; - tf->tf_r11 = ksc.sc_regs[15]; - tf->tf_r12 = ksc.sc_regs[16]; - tf->tf_r13 = ksc.sc_regs[17]; - tf->tf_r14 = ksc.sc_regs[18]; - tf->tf_r15 = ksc.sc_regs[19]; - tf->tf_r16 = ksc.sc_regs[20]; - tf->tf_r17 = ksc.sc_regs[21]; - tf->tf_r18 = ksc.sc_regs[22]; - tf->tf_t4 = ksc.sc_regs[23]; /* r19 */ - tf->tf_arg3 = ksc.sc_regs[24]; /* r23 */ - tf->tf_arg2 = ksc.sc_regs[25]; /* r24 */ - tf->tf_arg1 = ksc.sc_regs[26]; /* r25 */ - tf->tf_arg0 = ksc.sc_regs[27]; /* r26 */ - tf->tf_dp = ksc.sc_regs[28]; - tf->tf_ret0 = ksc.sc_regs[29]; - tf->tf_ret1 = ksc.sc_regs[30]; - tf->tf_r31 = ksc.sc_regs[31]; - bcopy(ksc.sc_fpregs, &p->p_addr->u_pcb.pcb_fpstate->hfp_regs, - sizeof(ksc.sc_fpregs)); - - tf->tf_iioq_head = ksc.sc_pcoqh | HPPA_PC_PRIV_USER; - tf->tf_iioq_tail = ksc.sc_pcoqt | HPPA_PC_PRIV_USER; - if ((tf->tf_iioq_head & ~PAGE_MASK) == SYSCALLGATE) - tf->tf_iisq_head = HPPA_SID_KERNEL; - else - tf->tf_iisq_head = p->p_addr->u_pcb.pcb_space; - if ((tf->tf_iioq_tail & ~PAGE_MASK) == SYSCALLGATE) - tf->tf_iisq_tail = HPPA_SID_KERNEL; - else - tf->tf_iisq_tail = p->p_addr->u_pcb.pcb_space; - tf->tf_ipsw = ksc.sc_ps | (curcpu()->ci_psw & PSL_O); - - return (EJUSTRETURN); -} - -void -signotify(struct proc *p) -{ - setsoftast(p); - cpu_unidle(p->p_cpu); -} - -/* - * machine dependent system variables. - */ -int -cpu_sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, - size_t newlen, struct proc *p) -{ - extern u_int fpu_enable; - extern int cpu_fpuena; - dev_t consdev; - int oldval, ret; - - /* all sysctl names at this level are terminal */ - if (namelen != 1) - return (ENOTDIR); /* overloaded */ - switch (name[0]) { - case CPU_CONSDEV: - if (cn_tab != NULL) - consdev = cn_tab->cn_dev; - else - consdev = NODEV; - return (sysctl_rdstruct(oldp, oldlenp, newp, &consdev, - sizeof consdev)); - case CPU_FPU: - if (curcpu()->ci_fpu_state) { - mtctl(fpu_enable, CR_CCR); - fpu_save(curcpu()->ci_fpu_state); - curcpu()->ci_fpu_state = 0; - mtctl(0, CR_CCR); - } - return (sysctl_int(oldp, oldlenp, newp, newlen, &cpu_fpuena)); - case CPU_LED_BLINK: - oldval = led_blink; - ret = sysctl_int(oldp, oldlenp, newp, newlen, &led_blink); - /* - * If we were false and are now true, start the timer. - */ - if (!oldval && led_blink > oldval) - blink_led_timeout(NULL); - return (ret); - default: - return (EOPNOTSUPP); - } - /* NOTREACHED */ -} - - -/* - * consinit: - * initialize the system console. - */ -void -consinit(void) -{ - /* - * Initial console setup has been done in pdc_init(). - */ -} - - -struct blink_led_softc { - SLIST_HEAD(, blink_led) bls_head; - int bls_on; - struct timeout bls_to; -} blink_sc = { SLIST_HEAD_INITIALIZER(bls_head), 0 }; - -void -blink_led_register(struct blink_led *l) -{ - if (SLIST_EMPTY(&blink_sc.bls_head)) { - timeout_set(&blink_sc.bls_to, blink_led_timeout, &blink_sc); - blink_sc.bls_on = 0; - if (led_blink) - timeout_add(&blink_sc.bls_to, 1); - } - SLIST_INSERT_HEAD(&blink_sc.bls_head, l, bl_next); -} - -void -blink_led_timeout(void *vsc) -{ - struct blink_led_softc *sc = &blink_sc; - struct blink_led *l; - int t; - - if (SLIST_EMPTY(&sc->bls_head)) - return; - - SLIST_FOREACH(l, &sc->bls_head, bl_next) { - (*l->bl_func)(l->bl_arg, sc->bls_on); - } - sc->bls_on = !sc->bls_on; - - if (!led_blink) - return; - - /* - * Blink rate is: - * full cycle every second if completely idle (loadav = 0) - * full cycle every 2 seconds if loadav = 1 - * full cycle every 3 seconds if loadav = 2 - * etc. - */ - t = (((averunnable.ldavg[0] + FSCALE) * hz) >> (FSHIFT + 1)); - timeout_add(&sc->bls_to, t); -} diff --git a/sys/arch/hppa/hppa/mainbus.c b/sys/arch/hppa/hppa/mainbus.c deleted file mode 100644 index 0009da071..000000000 --- a/sys/arch/hppa/hppa/mainbus.c +++ /dev/null @@ -1,1298 +0,0 @@ -/* $OpenBSD: mainbus.c,v 1.90 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 "lcd.h" -#include "power.h" - -#undef BTLBDEBUG - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include - -struct mainbus_softc { - struct device sc_dv; - - hppa_hpa_t sc_hpa; -}; - -int mbmatch(struct device *, void *, void *); -void mbattach(struct device *, struct device *, void *); - -const struct cfattach mainbus_ca = { - sizeof(struct mainbus_softc), mbmatch, mbattach -}; - -struct cfdriver mainbus_cd = { - NULL, "mainbus", DV_DULL -}; - -struct pdc_hpa pdc_hpa PDC_ALIGNMENT; -struct pdc_power_info pdc_power_info PDC_ALIGNMENT; -struct pdc_chassis_info pdc_chassis_info PDC_ALIGNMENT; -struct pdc_chassis_lcd pdc_chassis_lcd PDC_ALIGNMENT; - -/* from machdep.c */ -extern struct extent *hppa_ex; -extern struct pdc_btlb pdc_btlb; - -int mbus_add_mapping(bus_addr_t bpa, bus_size_t size, int flags, - bus_space_handle_t *bshp); -int mbus_map(void *v, bus_addr_t bpa, bus_size_t size, - int flags, bus_space_handle_t *bshp); -void mbus_unmap(void *v, bus_space_handle_t bsh, bus_size_t size); -int mbus_alloc(void *v, bus_addr_t rstart, bus_addr_t rend, - bus_size_t size, bus_size_t align, bus_size_t boundary, - int flags, bus_addr_t *addrp, bus_space_handle_t *bshp); -void mbus_free(void *v, bus_space_handle_t h, bus_size_t size); -int mbus_subregion(void *v, bus_space_handle_t bsh, - bus_size_t offset, bus_size_t size, - bus_space_handle_t *nbshp); -void mbus_barrier(void *v, bus_space_handle_t h, bus_size_t o, - bus_size_t l, int op); -void *mbus_vaddr(void *v, bus_space_handle_t h); -u_int8_t mbus_r1(void *v, bus_space_handle_t h, bus_size_t o); -u_int16_t mbus_r2(void *v, bus_space_handle_t h, bus_size_t o); -u_int32_t mbus_r4(void *v, bus_space_handle_t h, bus_size_t o); -u_int64_t mbus_r8(void *v, bus_space_handle_t h, bus_size_t o); -void mbus_w1(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t vv); -void mbus_w2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t vv); -void mbus_w4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t vv); -void mbus_w8(void *v, bus_space_handle_t h, bus_size_t o, - u_int64_t vv); -void mbus_rm_1(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c); -void mbus_rm_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t *a, bus_size_t c); -void mbus_rm_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t *a, bus_size_t c); -void mbus_rm_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int64_t *a, bus_size_t c); -void mbus_wm_1(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c); -void mbus_wm_2(void *v, bus_space_handle_t h, bus_size_t o, - const u_int16_t *a, bus_size_t c); -void mbus_wm_4(void *v, bus_space_handle_t h, bus_size_t o, - const u_int32_t *a, bus_size_t c); -void mbus_wm_8(void *v, bus_space_handle_t h, bus_size_t o, - const u_int64_t *a, bus_size_t c); -void mbus_sm_1(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t vv, bus_size_t c); -void mbus_sm_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t vv, bus_size_t c); -void mbus_sm_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t vv, bus_size_t c); -void mbus_sm_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int64_t vv, bus_size_t c); - -void mbus_rr_1(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t *a, bus_size_t c); -void mbus_rr_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t *a, bus_size_t c); -void mbus_rr_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t *a, bus_size_t c); -void mbus_rr_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int64_t *a, bus_size_t c); -void mbus_wr_1(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c); -void mbus_wr_2(void *v, bus_space_handle_t h, bus_size_t o, - const u_int16_t *a, bus_size_t c); -void mbus_wr_4(void *v, bus_space_handle_t h, bus_size_t o, - const u_int32_t *a, bus_size_t c); -void mbus_wr_8(void *v, bus_space_handle_t h, bus_size_t o, - const u_int64_t *a, bus_size_t c); -void mbus_sr_1(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t vv, bus_size_t c); -void mbus_sr_2(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t vv, bus_size_t c); -void mbus_sr_4(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t vv, bus_size_t c); -void mbus_sr_8(void *v, bus_space_handle_t h, bus_size_t o, - u_int64_t vv, bus_size_t c); -void mbus_cp_1(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c); -void mbus_cp_2(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c); -void mbus_cp_4(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c); -void mbus_cp_8(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c); - -int -mbus_add_mapping(bus_addr_t bpa, bus_size_t size, int flags, - bus_space_handle_t *bshp) -{ - static u_int32_t bmm[0x4000/32]; - int bank, off, flex; - vaddr_t pa, spa, epa; - vsize_t len; - -#ifdef BTLBDEBUG - printf("bus_mem_add_mapping(%x,%x,%scachable,%p)\n", - bpa, size, flags? "" : "non", bshp); -#endif - - if ((bank = vm_physseg_find(atop(bpa), &off)) >= 0) - panic("mbus_add_mapping: mapping real memory @0x%lx", bpa); - -#ifdef DEBUG - if (flags & BUS_SPACE_MAP_CACHEABLE) { - printf("WARNING: mapping I/O space cacheable\n"); - flags &= ~BUS_SPACE_MAP_CACHEABLE; - } -#endif - - /* - * Mappings are established in HPPA_FLEX_SIZE units, - * either with BTLB, or regular mappings of the whole area. - */ - pa = bpa; - while (size != 0) { - flex = HPPA_FLEX(pa); - spa = pa & HPPA_FLEX_MASK; - epa = spa + HPPA_FLEX_SIZE; /* may wrap to 0... */ - - size -= min(size, HPPA_FLEX_SIZE - (pa - spa)); - - /* do need a new mapping? */ - if (!(bmm[flex / 32] & (1 << (flex % 32)))) { -#ifdef BTLBDEBUG - printf("bus_mem_add_mapping: adding flex=%x " - "%x-%x, ", flex, spa, epa - 1); -#endif - while (spa != epa) { - len = epa - spa; - - /* - * Try to map with a BTLB first (might map - * much more than what we are requesting - * for, and cross HPPA_FLEX boundaries). - * - * Note that this code assumes that - * BTLB size are a power of two, so if - * the size is larger than HPPA_FLEX_SIZE - * it will span an integral number of - * HPPA_FLEX_SIZE slots. - */ - if (len > pdc_btlb.max_size << PGSHIFT) - len = pdc_btlb.max_size << PGSHIFT; - - if (btlb_insert(HPPA_SID_KERNEL, spa, spa, &len, - pmap_sid2pid(HPPA_SID_KERNEL) | - pmap_prot(pmap_kernel(), PROT_READ | PROT_WRITE)) - >= 0) { - pa = spa + len; /* may wrap to 0... */ -#ifdef BTLBDEBUG - printf("--- %x/%x, %x-%x ", - flex, HPPA_FLEX(pa - 1), - spa, pa - 1); -#endif - /* register all ranges */ - for (; flex <= HPPA_FLEX(pa - 1); - flex++) { -#ifdef BTLBDEBUG - printf("mask %x ", flex); -#endif - bmm[flex / 32] |= - (1 << (flex % 32)); - } - if (len > epa - spa) - spa = epa; - else - spa = pa; - } else { -#ifdef BTLBDEBUG - printf("kenter 0x%x-0x%x", spa, epa); -#endif - for (; spa != epa; spa += PAGE_SIZE) - pmap_kenter_pa(spa, spa, - PROT_READ | PROT_WRITE); - } -#ifdef BTLBDEBUG - printf("\n"); -#endif - } - } -#ifdef BTLBDEBUG - else { - printf("+++ already b-mapped flex=%x, mask=%x\n", - flex, bmm[flex / 32]); - } -#endif - - pa = epa; - } - - *bshp = bpa; - return (0); -} - -int -mbus_map(void *v, bus_addr_t bpa, bus_size_t size, - int flags, bus_space_handle_t *bshp) -{ - int error; - - if ((error = extent_alloc_region(hppa_ex, bpa, size, EX_NOWAIT))) - return (error); - - if ((error = mbus_add_mapping(bpa, size, flags, bshp))) { - if (extent_free(hppa_ex, bpa, size, EX_NOWAIT)) { - printf("bus_space_map: pa 0x%lx, size 0x%lx\n", - bpa, size); - printf("bus_space_map: can't free region\n"); - } - } - - return error; -} - -void -mbus_unmap(void *v, bus_space_handle_t bsh, bus_size_t size) -{ - u_long sva, eva; - - sva = trunc_page(bsh); - eva = round_page(bsh + size); - -#ifdef DIAGNOSTIC - if (eva <= sva) - panic("bus_space_unmap: overflow"); -#endif - - if (pmap_extract(pmap_kernel(), bsh, NULL)) - pmap_kremove(sva, eva - sva); - else - ; /* XXX assuming equ b-mapping been done */ - - if (extent_free(hppa_ex, bsh, size, EX_NOWAIT)) { - printf("bus_space_unmap: ps 0x%lx, size 0x%lx\n", - bsh, size); - printf("bus_space_unmap: can't free region\n"); - } -} - -int -mbus_alloc(void *v, bus_addr_t rstart, bus_addr_t rend, bus_size_t size, - bus_size_t align, bus_size_t boundary, int flags, - bus_addr_t *addrp, bus_space_handle_t *bshp) -{ - u_long bpa; - int error; - - if (rstart < hppa_ex->ex_start || rend > hppa_ex->ex_end) - panic("bus_space_alloc: bad region start/end"); - - if ((error = extent_alloc_subregion(hppa_ex, rstart, rend, size, - align, 0, boundary, EX_NOWAIT, &bpa))) - return (error); - - if ((error = mbus_add_mapping(bpa, size, flags, bshp))) { - if (extent_free(hppa_ex, bpa, size, EX_NOWAIT)) { - printf("bus_space_alloc: pa 0x%lx, size 0x%lx\n", - bpa, size); - printf("bus_space_alloc: can't free region\n"); - } - } - - *addrp = bpa; - return (error); -} - -void -mbus_free(void *v, bus_space_handle_t h, bus_size_t size) -{ - /* bus_space_unmap() does all that we need to do. */ - mbus_unmap(v, h, size); -} - -int -mbus_subregion(void *v, bus_space_handle_t bsh, bus_size_t offset, - bus_size_t size, bus_space_handle_t *nbshp) -{ - *nbshp = bsh + offset; - return (0); -} - -void -mbus_barrier(void *v, bus_space_handle_t h, bus_size_t o, bus_size_t l, int op) -{ - sync_caches(); -} - -void * -mbus_vaddr(void *v, bus_space_handle_t h) -{ - return ((void *)h); -} - -u_int8_t -mbus_r1(void *v, bus_space_handle_t h, bus_size_t o) -{ - return *((volatile u_int8_t *)(h + o)); -} - -u_int16_t -mbus_r2(void *v, bus_space_handle_t h, bus_size_t o) -{ - return *((volatile u_int16_t *)(h + o)); -} - -u_int32_t -mbus_r4(void *v, bus_space_handle_t h, bus_size_t o) -{ - return *((volatile u_int32_t *)(h + o)); -} - -u_int64_t -mbus_r8(void *v, bus_space_handle_t h, bus_size_t o) -{ - return *((volatile u_int64_t *)(h + o)); -} - -void -mbus_w1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv) -{ - *((volatile u_int8_t *)(h + o)) = vv; -} - -void -mbus_w2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv) -{ - *((volatile u_int16_t *)(h + o)) = vv; -} - -void -mbus_w4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv) -{ - *((volatile u_int32_t *)(h + o)) = vv; -} - -void -mbus_w8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv) -{ - *((volatile u_int64_t *)(h + o)) = vv; -} - - -void -mbus_rm_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t *a, bus_size_t c) -{ - h += o; - while (c--) - *(a++) = *(volatile u_int8_t *)h; -} - -void -mbus_rm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t c) -{ - h += o; - while (c--) - *(a++) = *(volatile u_int16_t *)h; -} - -void -mbus_rm_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t *a, bus_size_t c) -{ - h += o; - while (c--) - *(a++) = *(volatile u_int32_t *)h; -} - -void -mbus_rm_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t *a, bus_size_t c) -{ - h += o; - while (c--) - *(a++) = *(volatile u_int64_t *)h; -} - -void -mbus_wm_1(void *v, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, bus_size_t c) -{ - h += o; - while (c--) - *(volatile u_int8_t *)h = *(a++); -} - -void -mbus_wm_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_size_t c) -{ - h += o; - while (c--) - *(volatile u_int16_t *)h = *(a++); -} - -void -mbus_wm_4(void *v, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, bus_size_t c) -{ - h += o; - while (c--) - *(volatile u_int32_t *)h = *(a++); -} - -void -mbus_wm_8(void *v, bus_space_handle_t h, bus_size_t o, const u_int64_t *a, bus_size_t c) -{ - h += o; - while (c--) - *(volatile u_int64_t *)h = *(a++); -} - -void -mbus_sm_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv, bus_size_t c) -{ - h += o; - while (c--) - *(volatile u_int8_t *)h = vv; -} - -void -mbus_sm_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, bus_size_t c) -{ - h += o; - while (c--) - *(volatile u_int16_t *)h = vv; -} - -void -mbus_sm_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv, bus_size_t c) -{ - h += o; - while (c--) - *(volatile u_int32_t *)h = vv; -} - -void -mbus_sm_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv, bus_size_t c) -{ - h += o; - while (c--) - *(volatile u_int64_t *)h = vv; -} - -void -mbus_rr_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t *a, bus_size_t c) -{ - volatile u_int8_t *p = (u_int8_t *)(h + o); - - while (c--) - *a++ = *p++; -} - -void -mbus_rr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t *a, bus_size_t c) -{ - volatile u_int16_t *p = (u_int16_t *)(h + o); - - while (c--) - *a++ = *p++; -} - -void -mbus_rr_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t *a, bus_size_t c) -{ - volatile u_int32_t *p = (u_int32_t *)(h + o); - - while (c--) - *a++ = *p++; -} - -void -mbus_rr_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t *a, bus_size_t c) -{ - volatile u_int64_t *p = (u_int64_t *)(h + o); - - while (c--) - *a++ = *p++; -} - -void -mbus_wr_1(void *v, bus_space_handle_t h, bus_size_t o, const u_int8_t *a, bus_size_t c) -{ - volatile u_int8_t *p = (u_int8_t *)(h + o); - - while (c--) - *p++ = *a++; -} - -void -mbus_wr_2(void *v, bus_space_handle_t h, bus_size_t o, const u_int16_t *a, bus_size_t c) -{ - volatile u_int16_t *p = (u_int16_t *)(h + o); - - while (c--) - *p++ = *a++; -} - -void -mbus_wr_4(void *v, bus_space_handle_t h, bus_size_t o, const u_int32_t *a, bus_size_t c) -{ - volatile u_int32_t *p = (u_int32_t *)(h + o); - - while (c--) - *p++ = *a++; -} - -void -mbus_wr_8(void *v, bus_space_handle_t h, bus_size_t o, const u_int64_t *a, bus_size_t c) -{ - volatile u_int64_t *p = (u_int64_t *)(h + o); - - while (c--) - *p++ = *a++; -} - -void -mbus_sr_1(void *v, bus_space_handle_t h, bus_size_t o, u_int8_t vv, bus_size_t c) -{ - volatile u_int8_t *p = (u_int8_t *)(h + o); - - while (c--) - *p++ = vv; -} - -void -mbus_sr_2(void *v, bus_space_handle_t h, bus_size_t o, u_int16_t vv, bus_size_t c) -{ - volatile u_int16_t *p = (u_int16_t *)(h + o); - - while (c--) - *p++ = vv; -} - -void -mbus_sr_4(void *v, bus_space_handle_t h, bus_size_t o, u_int32_t vv, bus_size_t c) -{ - volatile u_int32_t *p = (u_int32_t *)(h + o); - - while (c--) - *p++ = vv; -} - -void -mbus_sr_8(void *v, bus_space_handle_t h, bus_size_t o, u_int64_t vv, bus_size_t c) -{ - volatile u_int64_t *p = (u_int64_t *)(h + o); - - while (c--) - *p++ = vv; -} - -void -mbus_cp_1(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - volatile u_int8_t *p1 = (u_int8_t *)(h1 + o1); - volatile u_int8_t *p2 = (u_int8_t *)(h2 + o2); - - while (c--) - *p1++ = *p2++; -} - -void -mbus_cp_2(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - volatile u_int16_t *p1 = (u_int16_t *)(h1 + o1); - volatile u_int16_t *p2 = (u_int16_t *)(h2 + o2); - - while (c--) - *p1++ = *p2++; -} - -void -mbus_cp_4(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - volatile u_int32_t *p1 = (u_int32_t *)(h1 + o1); - volatile u_int32_t *p2 = (u_int32_t *)(h2 + o2); - - while (c--) - *p1++ = *p2++; -} - -void -mbus_cp_8(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c) -{ - volatile u_int64_t *p1 = (u_int64_t *)(h1 + o1); - volatile u_int64_t *p2 = (u_int64_t *)(h2 + o2); - - while (c--) - *p1++ = *p2++; -} - - -/* ugly typecast macro */ -#define crr(n) ((void (*)(void *, bus_space_handle_t, bus_size_t, u_int8_t *, bus_size_t))(n)) -#define cwr(n) ((void (*)(void *, bus_space_handle_t, bus_size_t, const u_int8_t *, bus_size_t))(n)) - -const struct hppa_bus_space_tag hppa_bustag = { - NULL, - - mbus_map, mbus_unmap, mbus_subregion, mbus_alloc, mbus_free, - mbus_barrier, mbus_vaddr, - mbus_r1, mbus_r2, mbus_r4, mbus_r8, - mbus_w1, mbus_w2, mbus_w4, mbus_w8, - mbus_rm_1, mbus_rm_2, mbus_rm_4, mbus_rm_8, - mbus_wm_1, mbus_wm_2, mbus_wm_4, mbus_wm_8, - mbus_sm_1, mbus_sm_2, mbus_sm_4, mbus_sm_8, - /* *_raw_* are the same as non-raw for native busses */ - crr(mbus_rm_1), crr(mbus_rm_1), crr(mbus_rm_1), - cwr(mbus_wm_1), cwr(mbus_wm_1), cwr(mbus_wm_1), - mbus_rr_1, mbus_rr_2, mbus_rr_4, mbus_rr_8, - mbus_wr_1, mbus_wr_2, mbus_wr_4, mbus_wr_8, - /* *_raw_* are the same as non-raw for native busses */ - crr(mbus_rr_1), crr(mbus_rr_1), crr(mbus_rr_1), - cwr(mbus_wr_1), cwr(mbus_wr_1), cwr(mbus_wr_1), - mbus_sr_1, mbus_sr_2, mbus_sr_4, mbus_sr_8, - mbus_cp_1, mbus_cp_2, mbus_cp_4, mbus_cp_8 -}; - -int mbus_dmamap_create(void *v, bus_size_t size, int nsegments, - bus_size_t maxsegsz, bus_size_t boundary, int flags, - bus_dmamap_t *dmamp); -void mbus_dmamap_unload(void *v, bus_dmamap_t map); -void mbus_dmamap_destroy(void *v, bus_dmamap_t map); -int _bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, - void *buf, bus_size_t buflen, struct proc *p, int flags, - paddr_t *lastaddrp, int *segp, int first); -int mbus_dmamap_load(void *v, bus_dmamap_t map, void *addr, - bus_size_t size, struct proc *p, int flags); -int mbus_dmamap_load_mbuf(void *v, bus_dmamap_t map, - struct mbuf *m0, int flags); -int mbus_dmamap_load_uio(void *v, bus_dmamap_t map, - struct uio *uio, int flags); -int mbus_dmamap_load_raw(void *v, bus_dmamap_t map, - bus_dma_segment_t *segs, int nsegs, bus_size_t size, - int flags); -void mbus_dmamap_sync(void *v, bus_dmamap_t map, bus_addr_t off, - bus_size_t len, int ops); -int mbus_dmamem_alloc(void *v, bus_size_t size, - bus_size_t alignment, bus_size_t boundary, - bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags); -void mbus_dmamem_free(void *v, bus_dma_segment_t *segs, int nsegs); -int mbus_dmamem_map(void *v, bus_dma_segment_t *segs, int nsegs, - size_t size, caddr_t *kvap, int flags); -void mbus_dmamem_unmap(void *v, caddr_t kva, size_t size); -paddr_t mbus_dmamem_mmap(void *v, bus_dma_segment_t *segs, int nsegs, - off_t off, int prot, int flags); - -int -mbus_dmamap_create(void *v, bus_size_t size, int nsegments, - bus_size_t maxsegsz, bus_size_t boundary, int flags, - bus_dmamap_t *dmamp) -{ - struct hppa_bus_dmamap *map; - size_t mapsize; - - mapsize = sizeof(struct hppa_bus_dmamap) + - (sizeof(bus_dma_segment_t) * (nsegments - 1)); - map = malloc(mapsize, M_DEVBUF, (flags & BUS_DMA_NOWAIT) ? - (M_NOWAIT | M_ZERO) : (M_WAITOK | M_ZERO)); - if (!map) - return (ENOMEM); - - map->_dm_size = size; - map->_dm_segcnt = nsegments; - map->_dm_maxsegsz = maxsegsz; - map->_dm_boundary = boundary; - map->_dm_flags = flags & ~(BUS_DMA_WAITOK|BUS_DMA_NOWAIT); - map->dm_mapsize = 0; - map->dm_nsegs = 0; - - *dmamp = map; - return (0); -} - -void -mbus_dmamap_unload(void *v, bus_dmamap_t map) -{ - map->dm_mapsize = 0; - map->dm_nsegs = 0; -} - -void -mbus_dmamap_destroy(void *v, bus_dmamap_t map) -{ - if (map->dm_mapsize != 0) - mbus_dmamap_unload(v, map); - - free(map, M_DEVBUF, 0); -} - -/* - * Utility function to load a linear buffer. lastaddrp holds state - * between invocations (for multiple-buffer loads). segp contains - * the starting segment on entrance, and the ending segment on exit. - * first indicates if this is the first invocation of this function. - */ -int -_bus_dmamap_load_buffer(bus_dma_tag_t t, bus_dmamap_t map, void *buf, - bus_size_t buflen, struct proc *p, int flags, paddr_t *lastaddrp, - int *segp, int first) -{ - bus_size_t sgsize; - bus_addr_t curaddr, lastaddr, baddr, bmask; - vaddr_t vaddr = (vaddr_t)buf; - int seg; - pmap_t pmap; - - pmap = p? p->p_vmspace->vm_map.pmap : pmap_kernel(); - lastaddr = *lastaddrp; - bmask = ~(map->_dm_boundary - 1); - - for (seg = *segp; buflen > 0 ; ) { - /* - * Get the physical address for this segment. - */ - pmap_extract(pmap, vaddr, (paddr_t *)&curaddr); - - /* - * Compute the segment size, and adjust counts. - */ - sgsize = PAGE_SIZE - ((u_long)vaddr & PGOFSET); - if (buflen < sgsize) - sgsize = buflen; - - /* - * Make sure we don't cross any boundaries. - */ - if (map->_dm_boundary > 0) { - baddr = (curaddr + map->_dm_boundary) & bmask; - if (sgsize > (baddr - curaddr)) - sgsize = (baddr - curaddr); - } - - /* - * Insert chunk into a segment, coalescing with - * previous segment if possible. - */ - if (first) { - map->dm_segs[seg].ds_addr = curaddr; - map->dm_segs[seg].ds_len = sgsize; - map->dm_segs[seg]._ds_va = vaddr; - first = 0; - } else { - if (curaddr == lastaddr && - (map->dm_segs[seg].ds_len + sgsize) <= - map->_dm_maxsegsz && - (map->_dm_boundary == 0 || - (map->dm_segs[seg].ds_addr & bmask) == - (curaddr & bmask))) - map->dm_segs[seg].ds_len += sgsize; - else { - if (++seg >= map->_dm_segcnt) - break; - map->dm_segs[seg].ds_addr = curaddr; - map->dm_segs[seg].ds_len = sgsize; - map->dm_segs[seg]._ds_va = vaddr; - } - } - - lastaddr = curaddr + sgsize; - vaddr += sgsize; - buflen -= sgsize; - } - - *segp = seg; - *lastaddrp = lastaddr; - - /* - * Did we fit? - */ - if (buflen != 0) - return (EFBIG); /* XXX better return value here? */ - return (0); -} - -int -mbus_dmamap_load(void *v, bus_dmamap_t map, void *addr, bus_size_t size, - struct proc *p, int flags) -{ - paddr_t lastaddr; - int seg, error; - - /* - * Make sure that on error condition we return "no valid mappings". - */ - map->dm_nsegs = 0; - map->dm_mapsize = 0; - - if (size > map->_dm_size) - return (EINVAL); - - seg = 0; - lastaddr = 0; - error = _bus_dmamap_load_buffer(NULL, map, addr, size, p, flags, - &lastaddr, &seg, 1); - if (error == 0) { - map->dm_mapsize = size; - map->dm_nsegs = seg + 1; - } - - return (0); -} - -int -mbus_dmamap_load_mbuf(void *v, bus_dmamap_t map, struct mbuf *m0, int flags) -{ - paddr_t lastaddr; - int seg, error, first; - struct mbuf *m; - - map->dm_mapsize = 0; - map->dm_nsegs = 0; - -#ifdef DIAGNOSTIC - if ((m0->m_flags & M_PKTHDR) == 0) - panic("_bus_dmamap_load_mbuf: no packet header"); -#endif - - if (m0->m_pkthdr.len > map->_dm_size) - return (EINVAL); - - first = 1; - seg = 0; - error = 0; - lastaddr = 0; - for (m = m0; m != NULL && error == 0; m = m->m_next) { - if (m->m_len == 0) - continue; - error = _bus_dmamap_load_buffer(NULL, map, m->m_data, m->m_len, - NULL, flags, &lastaddr, &seg, first); - first = 0; - } - if (error == 0) { - map->dm_mapsize = m0->m_pkthdr.len; - map->dm_nsegs = seg + 1; - } - - return (error); -} - -int -mbus_dmamap_load_uio(void *v, bus_dmamap_t map, struct uio *uio, int flags) -{ - paddr_t lastaddr; - int seg, i, error, first; - bus_size_t minlen, resid; - struct proc *p = NULL; - struct iovec *iov; - caddr_t addr; - - /* - * Make sure that on error condition we return "no valid mappings". - */ - map->dm_mapsize = 0; - map->dm_nsegs = 0; - - resid = uio->uio_resid; - iov = uio->uio_iov; - - if (resid > map->_dm_size) - return (EINVAL); - - if (uio->uio_segflg == UIO_USERSPACE) { - p = uio->uio_procp; -#ifdef DIAGNOSTIC - if (p == NULL) - panic("_bus_dmamap_load_uio: USERSPACE but no proc"); -#endif - } - - first = 1; - seg = 0; - error = 0; - lastaddr = 0; - for (i = 0; i < uio->uio_iovcnt && resid != 0 && error == 0; i++) { - /* - * Now at the first iovec to load. Load each iovec - * until we have exhausted the residual count. - */ - minlen = resid < iov[i].iov_len ? resid : iov[i].iov_len; - addr = (caddr_t)iov[i].iov_base; - - error = _bus_dmamap_load_buffer(NULL, map, addr, minlen, - p, flags, &lastaddr, &seg, first); - first = 0; - - resid -= minlen; - } - if (error == 0) { - map->dm_mapsize = uio->uio_resid; - map->dm_nsegs = seg + 1; - } - return (error); -} - -int -mbus_dmamap_load_raw(void *v, bus_dmamap_t map, bus_dma_segment_t *segs, - int nsegs, bus_size_t size, int flags) -{ - if (nsegs > map->_dm_segcnt || size > map->_dm_size) - return (EINVAL); - - /* - * Make sure we don't cross any boundaries. - */ - if (map->_dm_boundary) { - bus_addr_t bmask = ~(map->_dm_boundary - 1); - int i; - - for (i = 0; i < nsegs; i++) { - if (segs[i].ds_len > map->_dm_maxsegsz) - return (EINVAL); - if ((segs[i].ds_addr & bmask) != - ((segs[i].ds_addr + segs[i].ds_len - 1) & bmask)) - return (EINVAL); - } - } - - bcopy(segs, map->dm_segs, nsegs * sizeof(*segs)); - map->dm_nsegs = nsegs; - map->dm_mapsize = size; - return (0); -} - -void -mbus_dmamap_sync(void *v, bus_dmamap_t map, bus_addr_t off, bus_size_t len, - int ops) -{ - bus_dma_segment_t *ps = map->dm_segs, - *es = &map->dm_segs[map->dm_nsegs]; - - if (off >= map->_dm_size) - return; - - if ((off + len) > map->_dm_size) - len = map->_dm_size - off; - - for (; len && ps < es; ps++) - if (off > ps->ds_len) - off -= ps->ds_len; - else { - bus_size_t l = ps->ds_len - off; - if (l > len) - l = len; - fdcache(HPPA_SID_KERNEL, ps->_ds_va + off, l); - len -= l; - off = 0; - } - - /* for either operation sync the shit away */ - __asm volatile ("sync\n\tsyncdma\n\tsync\n\t" - "nop\n\tnop\n\tnop\n\tnop\n\tnop\n\tnop\n\tnop"); -} - -int -mbus_dmamem_alloc(void *v, bus_size_t size, bus_size_t alignment, - bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, - int *rsegs, int flags) -{ - struct pglist pglist; - struct vm_page *pg; - int plaflag; - - size = round_page(size); - - plaflag = flags & BUS_DMA_NOWAIT ? UVM_PLA_NOWAIT : UVM_PLA_WAITOK; - if (flags & BUS_DMA_ZERO) - plaflag |= UVM_PLA_ZERO; - - TAILQ_INIT(&pglist); - if (uvm_pglistalloc(size, 0, -1, alignment, boundary, - &pglist, 1, plaflag)) - return (ENOMEM); - - pg = TAILQ_FIRST(&pglist); - segs[0]._ds_va = segs[0].ds_addr = VM_PAGE_TO_PHYS(pg); - segs[0].ds_len = size; - *rsegs = 1; - - for(; pg; pg = TAILQ_NEXT(pg, pageq)) - /* XXX for now */ - pmap_changebit(pg, PTE_PROT(TLB_UNCACHABLE), 0); - pmap_update(pmap_kernel()); - - return (0); -} - -void -mbus_dmamem_free(void *v, bus_dma_segment_t *segs, int nsegs) -{ - struct pglist pglist; - paddr_t pa, epa; - - TAILQ_INIT(&pglist); - for(; nsegs--; segs++) - for (pa = segs->ds_addr, epa = pa + segs->ds_len; - pa < epa; pa += PAGE_SIZE) { - struct vm_page *pg = PHYS_TO_VM_PAGE(pa); - if (!pg) - panic("mbus_dmamem_free: no page for pa"); - TAILQ_INSERT_TAIL(&pglist, pg, pageq); - pdcache(HPPA_SID_KERNEL, pa, PAGE_SIZE); - pdtlb(HPPA_SID_KERNEL, pa); - pitlb(HPPA_SID_KERNEL, pa); - } - uvm_pglistfree(&pglist); -} - -int -mbus_dmamem_map(void *v, bus_dma_segment_t *segs, int nsegs, size_t size, - caddr_t *kvap, int flags) -{ - *kvap = (caddr_t)segs[0].ds_addr; - return 0; -} - -void -mbus_dmamem_unmap(void *v, caddr_t kva, size_t size) -{ -} - -paddr_t -mbus_dmamem_mmap(void *v, bus_dma_segment_t *segs, int nsegs, off_t off, - int prot, int flags) -{ - panic("_dmamem_mmap: not implemented"); -} - -const struct hppa_bus_dma_tag hppa_dmatag = { - NULL, - mbus_dmamap_create, mbus_dmamap_destroy, - mbus_dmamap_load, mbus_dmamap_load_mbuf, - mbus_dmamap_load_uio, mbus_dmamap_load_raw, - mbus_dmamap_unload, mbus_dmamap_sync, - - mbus_dmamem_alloc, mbus_dmamem_free, mbus_dmamem_map, - mbus_dmamem_unmap, mbus_dmamem_mmap -}; - -int -mbmatch(parent, cfdata, aux) - struct device *parent; - void *cfdata; - void *aux; -{ - struct cfdata *cf = cfdata; - - /* there will be only one */ - if (cf->cf_unit) - return 0; - - return 1; -} - -void -mbattach(parent, self, aux) - struct device *parent; - struct device *self; - void *aux; -{ - struct mainbus_softc *sc = (struct mainbus_softc *)self; - struct confargs nca; - bus_space_handle_t ioh; - - /* fetch the "default" cpu hpa */ - if (pdc_call((iodcio_t)pdc, 0, PDC_HPA, PDC_HPA_DFLT, &pdc_hpa) < 0) - panic("mbattach: PDC_HPA failed"); - - printf(" [flex %x]\n", pdc_hpa.hpa & HPPA_FLEX_MASK); - - /* map all the way till the end of the memory */ - if (bus_space_map(&hppa_bustag, pdc_hpa.hpa, - (~0LU - pdc_hpa.hpa + 1), 0, &ioh)) - panic("mbattach: cannot map mainbus IO space"); - - /* - * Local-Broadcast the HPA to all modules on this bus - */ - ((struct iomod *)HPPA_LBCAST)->io_flex = - (pdc_hpa.hpa & HPPA_FLEX_MASK) | DMA_ENABLE; - - sc->sc_hpa = pdc_hpa.hpa; - - /* PDC first */ - bzero(&nca, sizeof(nca)); - nca.ca_name = "pdc"; - nca.ca_iot = &hppa_bustag; - nca.ca_dmatag = &hppa_dmatag; - config_found(self, &nca, mbprint); - -#if NPOWER > 0 - /* get some power */ - bzero(&nca, sizeof(nca)); - nca.ca_name = "power"; - nca.ca_irq = -1; - if (!pdc_call((iodcio_t)pdc, 0, PDC_SOFT_POWER, - PDC_SOFT_POWER_INFO, &pdc_power_info, 0)) { - nca.ca_iot = &hppa_bustag; - nca.ca_hpa = pdc_power_info.addr; - nca.ca_hpamask = HPPA_IOBEGIN; - } - config_found(self, &nca, mbprint); -#endif - -#if NLCD > 0 - if (!pdc_call((iodcio_t)pdc, 0, PDC_CHASSIS, PDC_CHASSIS_INFO, - &pdc_chassis_info, &pdc_chassis_lcd, sizeof(pdc_chassis_lcd)) && - pdc_chassis_lcd.enabled) { - bzero(&nca, sizeof(nca)); - nca.ca_name = "lcd"; - nca.ca_irq = -1; - nca.ca_iot = &hppa_bustag; - nca.ca_hpa = pdc_chassis_lcd.cmd_addr; - nca.ca_hpamask = HPPA_IOBEGIN; - nca.ca_pdc_iodc_read = (void *)&pdc_chassis_lcd; - - config_found(self, &nca, mbprint); - } -#endif - - bzero(&nca, sizeof(nca)); - nca.ca_hpa = 0; - nca.ca_irq = -1; - nca.ca_hpamask = HPPA_IOBEGIN; - nca.ca_iot = &hppa_bustag; - nca.ca_dmatag = &hppa_dmatag; - nca.ca_dp.dp_bc[0] = nca.ca_dp.dp_bc[1] = nca.ca_dp.dp_bc[2] = - nca.ca_dp.dp_bc[3] = nca.ca_dp.dp_bc[4] = nca.ca_dp.dp_bc[5] = -1; - nca.ca_dp.dp_mod = -1; - switch (cpu_hvers) { - case HPPA_BOARD_HP809: - case HPPA_BOARD_HP819: - case HPPA_BOARD_HP829: - case HPPA_BOARD_HP839: - case HPPA_BOARD_HP849: - case HPPA_BOARD_HP859: - case HPPA_BOARD_HP869: -#if 0 - case HPPA_BOARD_HP770_J200: - case HPPA_BOARD_HP770_J210: - case HPPA_BOARD_HP770_J210XC: - case HPPA_BOARD_HP780_J282: - case HPPA_BOARD_HP782_J2240: -#endif - case HPPA_BOARD_HP780_C160: - case HPPA_BOARD_HP780_C180P: - case HPPA_BOARD_HP780_C180XP: - case HPPA_BOARD_HP780_C200: - case HPPA_BOARD_HP780_C230: - case HPPA_BOARD_HP780_C240: - case HPPA_BOARD_HP785_C360: - /* Attach CPUs first, then everything else... */ - ncpusfound = 0; - pdc_scanbus(self, &nca, MAXMODBUS, HPPA_FPA, 1); - pdc_scanbus(self, &nca, MAXMODBUS, HPPA_FPA, 0); - break; - default: - /* Attach CPUs first, then everything else... */ - ncpusfound = 0; - pdc_scanbus(self, &nca, MAXMODBUS, 0, 1); - pdc_scanbus(self, &nca, MAXMODBUS, 0, 0); - } -} - -/* - * Retrieve CPU #N HPA value - */ -hppa_hpa_t -cpu_gethpa(n) - int n; -{ - struct mainbus_softc *sc; - - sc = mainbus_cd.cd_devs[0]; - - return sc->sc_hpa; -} - -int -mbprint(aux, pnp) - void *aux; - const char *pnp; -{ - struct confargs *ca = aux; - - if (pnp) - printf("\"%s\" at %s (type %x sv %x mod %x hv %x)", - ca->ca_name, pnp, - ca->ca_type.iodc_type, ca->ca_type.iodc_sv_model, - ca->ca_type.iodc_model, ca->ca_type.iodc_revision); - if (ca->ca_hpa) { - if (~ca->ca_hpamask) - printf(" offset %lx", ca->ca_hpa & ~ca->ca_hpamask); - if (!pnp && ca->ca_irq >= 0) - printf(" irq %d", ca->ca_irq); - } - - return (UNCONF); -} - -int -mbsubmatch(parent, match, aux) - struct device *parent; - void *match, *aux; -{ - struct cfdata *cf = match; - struct confargs *ca = aux; - int ret; - - if (autoconf_verbose) - printf(">> hpa %lx off %lx cf_off %lx\n", - ca->ca_hpa, ca->ca_hpa & ~ca->ca_hpamask, cf->hppacf_off); - - if (ca->ca_hpa && ~ca->ca_hpamask && cf->hppacf_off != -1 && - ((ca->ca_hpa & ~ca->ca_hpamask) != cf->hppacf_off)) - return (0); - - if ((ret = (*cf->cf_attach->ca_match)(parent, match, aux))) - ca->ca_irq = cf->hppacf_irq; - - return ret; -} - diff --git a/sys/arch/hppa/hppa/mem.c b/sys/arch/hppa/hppa/mem.c deleted file mode 100644 index 6752427dc..000000000 --- a/sys/arch/hppa/hppa/mem.c +++ /dev/null @@ -1,431 +0,0 @@ -/* $OpenBSD: mem.c,v 1.6 2022/03/13 08:04:38 mpi Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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) 1991,1992,1994, The University of Utah and - * the Computer Systems Laboratory (CSL). All rights reserved. - * - * Subject to your agreements with CMU, - * permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: mem.c 1.9 94/12/16$ - */ -/* - * Mach Operating System - * Copyright (c) 1992 Carnegie Mellon University - * All Rights Reserved. - * - * Permission to use, copy, modify and distribute this software and its - * documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR - * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie Mellon - * the rights to redistribute these changes. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#define VIPER_HPA 0xfffbf000 - -/* registers on the PCXL2 MIOC */ -struct l2_mioc { - u_int32_t pad[0x20]; /* 0x000 */ - u_int32_t mioc_control; /* 0x080 MIOC control bits */ - u_int32_t mioc_status; /* 0x084 MIOC status bits */ - u_int32_t pad1[6]; /* 0x088 */ - u_int32_t sltcv; /* 0x0a0 L2 cache control */ -#define SLTCV_AVWL 0x00002000 /* extra cycle for addr valid write low */ -#define SLTCV_UP4COUT 0x00001000 /* update cache on CPU castouts */ -#define SLTCV_EDCEN 0x08000000 /* enable error correction */ -#define SLTCV_EDTAG 0x10000000 /* enable diagtag */ -#define SLTCV_CHKTP 0x20000000 /* enable parity checking */ -#define SLTCV_LOWPWR 0x40000000 /* low power mode */ -#define SLTCV_ENABLE 0x80000000 /* enable L2 cache */ -#define SLTCV_BITS "\020\15avwl\16up4cout\24edcen\25edtag\26chktp\27lowpwr\30l2ena" - u_int32_t tagmask; /* 0x0a4 L2 cache tag mask */ - u_int32_t diagtag; /* 0x0a8 L2 invalidates tag */ - u_int32_t sltestat; /* 0x0ac L2 last logged tag read */ - u_int32_t slteadd; /* 0x0b0 L2 pa of -- " -- */ - u_int32_t pad2[3]; /* 0x0b4 */ - u_int32_t mtcv; /* 0x0c0 MIOC timings */ - u_int32_t ref; /* 0x0cc MIOC refresh timings */ - u_int32_t pad3[4]; /* 0x0d0 */ - u_int32_t mderradd; /* 0x0e0 addr of most evil mem error */ - u_int32_t pad4; /* 0x0e4 */ - u_int32_t dmaerr; /* 0x0e8 addr of most evil dma error */ - u_int32_t dioerr; /* 0x0ec addr of most evil dio error */ - u_int32_t gsc_timeout; /* 0x0f0 1-compl of GSC timeout delay */ - u_int32_t hidmamem; /* 0x0f4 amount of phys mem installed */ - u_int32_t pad5[2]; /* 0x0f8 */ - u_int32_t memcomp[16]; /* 0x100 memory address comparators */ - u_int32_t memmask[16]; /* 0x140 masks for -- " -- */ - u_int32_t memtest; /* 0x180 test address decoding */ - u_int32_t pad6[0xf]; /* 0x184 */ - u_int32_t outchk; /* 0x1c0 address decoding output */ - u_int32_t pad7[0x168]; /* 0x200 */ - u_int32_t gsc15x_config; /* 0x7a0 writev enable */ -}; - -struct mem_softc { - struct device sc_dev; - - volatile struct vi_trs *sc_vp; - volatile struct l2_mioc *sc_l2; -}; - -int memmatch(struct device *, void *, void *); -void memattach(struct device *, struct device *, void *); - -const struct cfattach mem_ca = { - sizeof(struct mem_softc), memmatch, memattach -}; - -struct cfdriver mem_cd = { - NULL, "mem", DV_DULL -}; - -caddr_t zeropage; - -int -memmatch(struct device *parent, void *cfdata, void *aux) -{ - struct confargs *ca = aux; - - if (ca->ca_type.iodc_type != HPPA_TYPE_MEMORY || - ca->ca_type.iodc_sv_model != HPPA_MEMORY_PDEP) - return 0; - - return 1; -} - -void -memattach(struct device *parent, struct device *self, void *aux) -{ - struct pdc_iodc_minit pdc_minit PDC_ALIGNMENT; - struct mem_softc *sc = (struct mem_softc *)self; - struct confargs *ca = aux; - int err; - - printf (":"); - - /* XXX check if we are dealing w/ Viper */ - if (ca->ca_hpa == (hppa_hpa_t)VIPER_HPA) { - - sc->sc_vp = (struct vi_trs *) - &((struct iomod *)ca->ca_hpa)->priv_trs; - - printf(" viper rev %x,", sc->sc_vp->vi_status.hw_rev); - - /* XXX other values seem to blow it up */ - if (sc->sc_vp->vi_status.hw_rev == 0) { - u_int32_t vic; - int s, settimeout; - - switch (cpu_hvers) { - case HPPA_BOARD_HP705: - case HPPA_BOARD_HP710: - case HPPA_BOARD_HP715_33: - case HPPA_BOARD_HP715S_33: - case HPPA_BOARD_HP715T_33: - case HPPA_BOARD_HP715_50: - case HPPA_BOARD_HP715S_50: - case HPPA_BOARD_HP715T_50: - case HPPA_BOARD_HP715_75: - case HPPA_BOARD_HP720: - case HPPA_BOARD_HP725_50: - case HPPA_BOARD_HP725_75: - case HPPA_BOARD_HP730_66: - case HPPA_BOARD_HP750_66: - settimeout = 1; - break; - default: - settimeout = 0; - break; - } - if (sc->sc_dev.dv_cfdata->cf_flags & 1) - settimeout = !settimeout; - -#ifdef DEBUG - printf(" ctrl %b", VI_CTRL, VI_CTRL_BITS); -#endif - s = splhigh(); - vic = VI_CTRL; - vic &= ~VI_CTRL_CORE_DEN; - vic &= ~VI_CTRL_SGC0_DEN; - vic &= ~VI_CTRL_SGC1_DEN; - vic |= VI_CTRL_EISA_DEN; - vic |= VI_CTRL_CORE_PRF; - - if (settimeout && (vic & VI_CTRL_VSC_TOUT) == 0) - vic |= (850 << 19); /* clks */ - - sc->sc_vp->vi_control = vic; - - __asm volatile("stwas %1, 0(%0)" - :: "r" (&VI_CTRL), "r" (vic) : "memory"); - splx(s); -#ifdef DEBUG - printf (" >> %b,", vic, VI_CTRL_BITS); -#endif - } else { - /* set at least VI_CTRL_EISA_DEN ? */ - } - } else - sc->sc_vp = NULL; - - if ((err = pdc_call((iodcio_t)pdc, 0, PDC_IODC, PDC_IODC_NINIT, - &pdc_minit, ca->ca_hpa, PAGE0->imm_spa_size)) < 0) - pdc_minit.max_spa = PAGE0->imm_max_mem; - - printf(" size %d", pdc_minit.max_spa / (1024*1024)); - if (pdc_minit.max_spa % (1024*1024)) - printf(".%d", pdc_minit.max_spa % (1024*1024)); - printf("MB"); - - /* L2 cache controller is a part of the memory controller on PCXL2 */ - if (cpu_type == hpcxl2) { - sc->sc_l2 = (struct l2_mioc *)ca->ca_hpa; -#ifdef DEBUG - printf(", sltcv %b", sc->sc_l2->sltcv, SLTCV_BITS); -#endif - /* sc->sc_l2->sltcv |= SLTCV_UP4COUT; */ - if (sc->sc_l2->sltcv & SLTCV_ENABLE) { - u_int32_t tagmask = sc->sc_l2->tagmask >> 20; - - printf(", %dMB L2 cache", tagmask + 1); - } - } - - printf("\n"); -} - -void -viper_setintrwnd(u_int32_t mask) -{ - struct mem_softc *sc; - - sc = mem_cd.cd_devs[0]; - - if (sc->sc_vp) - sc->sc_vp->vi_intrwd = mask; -} - -void -viper_eisa_en(void) -{ - struct mem_softc *sc; - - sc = mem_cd.cd_devs[0]; - if (sc->sc_vp) { - u_int32_t vic; - int s; - - s = splhigh(); - vic = VI_CTRL; - vic &= ~VI_CTRL_EISA_DEN; - sc->sc_vp->vi_control = vic; - __asm volatile("stwas %1, 0(%0)" - :: "r" (&VI_CTRL), "r" (vic) : "memory"); - splx(s); - } -} - -int -mmopen(dev_t dev, int flag, int ioflag, struct proc *p) -{ - extern int allowkmem; - - switch (minor(dev)) { - case 0: - case 1: - if (securelevel <= 0 || allowkmem) - break; - return (EPERM); - case 2: - case 12: - break; - default: - return (ENXIO); - } - return (0); -} - -int -mmclose(dev_t dev, int flag, int mode, struct proc *p) -{ - return (0); -} - -int -mmrw(dev_t dev, struct uio *uio, int flags) -{ - struct iovec *iov; - vaddr_t v, o; - int error = 0; - size_t c; - - while (uio->uio_resid > 0 && error == 0) { - iov = uio->uio_iov; - if (iov->iov_len == 0) { - uio->uio_iov++; - uio->uio_iovcnt--; - if (uio->uio_iovcnt < 0) - panic("mmrw"); - continue; - } - switch (minor(dev)) { - - case 0: /* /dev/mem */ - - /* If the address isn't in RAM, bail. */ - v = uio->uio_offset; - if (atop(v) > physmem) { - error = EFAULT; - /* this will break us out of the loop */ - continue; - } - c = ptoa(physmem) - v; - c = ulmin(c, uio->uio_resid); - error = uiomove((caddr_t)v, c, uio); - break; - - case 1: /* /dev/kmem */ - v = uio->uio_offset; - o = v & PGOFSET; - c = ulmin(uio->uio_resid, PAGE_SIZE - o); - if (atop(v) > physmem && !uvm_kernacc((caddr_t)v, - c, (uio->uio_rw == UIO_READ) ? B_READ : B_WRITE)) { - error = EFAULT; - /* this will break us out of the loop */ - continue; - } - error = uiomove((caddr_t)v, c, uio); - break; - - case 2: /* /dev/null */ - if (uio->uio_rw == UIO_WRITE) - uio->uio_resid = 0; - return (0); - - case 12: /* /dev/zero */ - /* Write to /dev/zero is ignored. */ - if (uio->uio_rw == UIO_WRITE) { - uio->uio_resid = 0; - return (0); - } - /* - * On the first call, allocate and zero a page - * of memory for use with /dev/zero. - */ - if (zeropage == NULL) - zeropage = malloc(PAGE_SIZE, M_TEMP, - M_WAITOK | M_ZERO); - c = ulmin(iov->iov_len, PAGE_SIZE); - error = uiomove(zeropage, c, uio); - break; - - default: - return (ENXIO); - } - } - - return (error); -} - -paddr_t -mmmmap(dev_t dev, off_t off, int prot) -{ - if (minor(dev) != 0) - return (-1); - - /* - * Allow access only in RAM. - */ -#if 0 - if (off < ptoa(firstusablepage) || - off >= ptoa(lastusablepage + 1)) - return (-1); -#endif - return (off); -} - -int -mmioctl(dev_t dev, u_long cmd, caddr_t data, int flags, struct proc *p) -{ - switch (cmd) { - case FIONBIO: - case FIOASYNC: - /* handled by fd layer */ - return 0; - } - - return (EOPNOTSUPP); -} diff --git a/sys/arch/hppa/hppa/mutex.c b/sys/arch/hppa/hppa/mutex.c deleted file mode 100644 index ff58831e5..000000000 --- a/sys/arch/hppa/hppa/mutex.c +++ /dev/null @@ -1,154 +0,0 @@ -/* $OpenBSD: mutex.c,v 1.17 2019/04/23 13:35:12 visa Exp $ */ - -/* - * Copyright (c) 2004 Artur Grabowski - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``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 -#include -#include -#include - -#include - -#include - -#ifdef MULTIPROCESSOR -/* Note: lock must be 16-byte aligned. */ -#define __mtx_lock(mtx) ((int *)(((vaddr_t)mtx->mtx_lock + 0xf) & ~0xf)) -#endif - -void -__mtx_init(struct mutex *mtx, int wantipl) -{ -#ifdef MULTIPROCESSOR - mtx->mtx_lock[0] = 1; - mtx->mtx_lock[1] = 1; - mtx->mtx_lock[2] = 1; - mtx->mtx_lock[3] = 1; -#endif - mtx->mtx_wantipl = wantipl; - mtx->mtx_oldipl = IPL_NONE; - mtx->mtx_owner = NULL; -} - -#ifdef MULTIPROCESSOR -void -mtx_enter(struct mutex *mtx) -{ - while (mtx_enter_try(mtx) == 0) - ; -} - -int -mtx_enter_try(struct mutex *mtx) -{ - struct cpu_info *ci = curcpu(); - volatile int *lock = __mtx_lock(mtx); - int ret; - int s; - - if (mtx->mtx_wantipl != IPL_NONE) - s = splraise(mtx->mtx_wantipl); - -#ifdef DIAGNOSTIC - if (__predict_false(mtx->mtx_owner == ci)) - panic("mtx %p: locking against myself", mtx); -#endif - - asm volatile ( - "ldcws 0(%2), %0" - : "=&r" (ret), "+m" (lock) - : "r" (lock) - ); - - if (ret) { - membar_enter(); - mtx->mtx_owner = ci; - if (mtx->mtx_wantipl != IPL_NONE) - mtx->mtx_oldipl = s; -#ifdef DIAGNOSTIC - ci->ci_mutex_level++; -#endif - - return (1); - } - - if (mtx->mtx_wantipl != IPL_NONE) - splx(s); - - return (0); -} -#else -void -mtx_enter(struct mutex *mtx) -{ - struct cpu_info *ci = curcpu(); - -#ifdef DIAGNOSTIC - if (__predict_false(mtx->mtx_owner == ci)) - panic("mtx %p: locking against myself", mtx); -#endif - - if (mtx->mtx_wantipl != IPL_NONE) - mtx->mtx_oldipl = splraise(mtx->mtx_wantipl); - - mtx->mtx_owner = ci; - -#ifdef DIAGNOSTIC - ci->ci_mutex_level++; -#endif -} - -int -mtx_enter_try(struct mutex *mtx) -{ - mtx_enter(mtx); - return (1); -} -#endif - -void -mtx_leave(struct mutex *mtx) -{ -#ifdef MULTIPROCESSOR - volatile int *lock = __mtx_lock(mtx); -#endif - int s; - - MUTEX_ASSERT_LOCKED(mtx); - -#ifdef DIAGNOSTIC - curcpu()->ci_mutex_level--; -#endif - s = mtx->mtx_oldipl; - mtx->mtx_owner = NULL; -#ifdef MULTIPROCESSOR - membar_exit(); - *lock = 1; -#endif - - if (mtx->mtx_wantipl != IPL_NONE) - splx(s); -} diff --git a/sys/arch/hppa/hppa/pmap.c b/sys/arch/hppa/hppa/pmap.c deleted file mode 100644 index fcb711c28..000000000 --- a/sys/arch/hppa/hppa/pmap.c +++ /dev/null @@ -1,1310 +0,0 @@ -/* $OpenBSD: pmap.c,v 1.181 2023/01/24 16:51:05 kettenis Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ -/* - * References: - * 1. PA7100LC ERS, Hewlett-Packard, March 30 1999, Public version 1.0 - * 2. PA7300LC ERS, Hewlett-Packard, March 18 1996, Version 1.0 - * - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include - -#ifdef PMAPDEBUG -#define DPRINTF(l,s) do { \ - if ((pmapdebug & (l)) == (l)) \ - printf s; \ -} while(0) -#define PDB_FOLLOW 0x00000001 -#define PDB_INIT 0x00000002 -#define PDB_ENTER 0x00000004 -#define PDB_REMOVE 0x00000008 -#define PDB_CREATE 0x00000010 -#define PDB_PTPAGE 0x00000020 -#define PDB_CACHE 0x00000040 -#define PDB_BITS 0x00000080 -#define PDB_COLLECT 0x00000100 -#define PDB_PROTECT 0x00000200 -#define PDB_EXTRACT 0x00000400 -#define PDB_VP 0x00000800 -#define PDB_PV 0x00001000 -#define PDB_PARANOIA 0x00002000 -#define PDB_WIRING 0x00004000 -#define PDB_PMAP 0x00008000 -#define PDB_STEAL 0x00010000 -#define PDB_PHYS 0x00020000 -#define PDB_POOL 0x00040000 -int pmapdebug = 0 -/* | PDB_INIT */ -/* | PDB_FOLLOW */ -/* | PDB_VP */ -/* | PDB_PV */ -/* | PDB_ENTER */ -/* | PDB_REMOVE */ -/* | PDB_STEAL */ -/* | PDB_PROTECT */ -/* | PDB_PHYS */ - ; -#else -#define DPRINTF(l,s) /* */ -#endif - -paddr_t physical_steal, physical_end; - -int pmap_hptsize = 16 * PAGE_SIZE; /* patchable */ -vaddr_t pmap_hpt; - -struct pmap kernel_pmap_store; -int hppa_sid_max = HPPA_SID_MAX; -struct pool pmap_pmap_pool; -struct pool pmap_pv_pool; -int pmap_pvlowat = 252; -int pmap_initialized; - -u_int hppa_prot[8]; - -#define pmap_sid(pmap, va) \ - (((va & 0xc0000000) != 0xc0000000)? pmap->pmap_space : HPPA_SID_KERNEL) - -static inline int -pmap_pvh_attrs(pt_entry_t pte) -{ - int attrs = 0; - if (pte & PTE_PROT(TLB_DIRTY)) - attrs |= PG_PMAP_MOD; - if ((pte & PTE_PROT(TLB_REFTRAP)) == 0) - attrs |= PG_PMAP_REF; - return attrs; -} - -struct vm_page *pmap_pagealloc(struct uvm_object *obj, voff_t off); -void pmap_pte_flush(struct pmap *pmap, vaddr_t va, pt_entry_t pte); -#ifdef DDB -void pmap_dump_table(pa_space_t space, vaddr_t sva); -void pmap_dump_pv(paddr_t pa); -#endif -int pmap_check_alias(struct vm_page *pg, vaddr_t va, - pt_entry_t pte); - -#define IS_IOPAGE(pa) ((pa) >= HPPA_IOBEGIN) - -static inline void -pmap_lock(struct pmap *pmap) -{ - if (pmap != pmap_kernel()) - mtx_enter(&pmap->pm_mtx); -} - -static inline void -pmap_unlock(struct pmap *pmap) -{ - if (pmap != pmap_kernel()) - mtx_leave(&pmap->pm_mtx); -} - -struct vm_page * -pmap_pagealloc(struct uvm_object *obj, voff_t off) -{ - struct vm_page *pg; - - if ((pg = uvm_pagealloc(obj, off, NULL, - UVM_PGA_USERESERVE | UVM_PGA_ZERO)) == NULL) - printf("pmap_pagealloc fail\n"); - - return (pg); -} - -#ifdef USE_HPT -/* - * This hash function is the one used by the hardware TLB walker on the 7100LC. - */ -static __inline struct vp_entry * -pmap_hash(struct pmap *pmap, vaddr_t va) -{ - return (struct vp_entry *)(pmap_hpt + - (((va >> 8) ^ (pmap->pm_space << 9)) & (pmap_hptsize - 1))); -} - -static __inline u_int32_t -pmap_vtag(struct pmap *pmap, vaddr_t va) -{ - return (0x80000000 | (pmap->pm_space & 0xffff) | - ((va >> 1) & 0x7fff0000)); -} -#endif - -static __inline void -pmap_sdir_set(pa_space_t space, volatile u_int32_t *pd) -{ - volatile u_int32_t *vtop; - - mfctl(CR_VTOP, vtop); -#ifdef PMAPDEBUG - if (!vtop) - panic("pmap_sdir_set: zero vtop"); -#endif - vtop[space] = (u_int32_t)pd; -} - -static __inline u_int32_t * -pmap_sdir_get(pa_space_t space) -{ - u_int32_t *vtop; - - mfctl(CR_VTOP, vtop); - return ((u_int32_t *)vtop[space]); -} - -static __inline volatile pt_entry_t * -pmap_pde_get(volatile u_int32_t *pd, vaddr_t va) -{ - return ((pt_entry_t *)pd[va >> 22]); -} - -static __inline void -pmap_pde_set(struct pmap *pm, vaddr_t va, paddr_t ptp) -{ -#ifdef PMAPDEBUG - if (ptp & PGOFSET) - panic("pmap_pde_set, unaligned ptp 0x%lx", ptp); -#endif - DPRINTF(PDB_FOLLOW|PDB_VP, - ("pmap_pde_set(%p, 0x%lx, 0x%lx)\n", pm, va, ptp)); - - pm->pm_pdir[va >> 22] = ptp; -} - -static __inline pt_entry_t * -pmap_pde_alloc(struct pmap *pm, vaddr_t va, struct vm_page **pdep) -{ - struct vm_page *pg; - volatile pt_entry_t *pde; - paddr_t pa; - - DPRINTF(PDB_FOLLOW|PDB_VP, - ("pmap_pde_alloc(%p, 0x%lx, %p)\n", pm, va, pdep)); - - pmap_unlock(pm); - pg = pmap_pagealloc(&pm->pm_obj, va); - pmap_lock(pm); - if (pg == NULL) - return (NULL); - pde = pmap_pde_get(pm->pm_pdir, va); - if (pde) { - pmap_unlock(pm); - uvm_pagefree(pg); - pmap_lock(pm); - return (pt_entry_t *)pde; - } - - pa = VM_PAGE_TO_PHYS(pg); - - DPRINTF(PDB_FOLLOW|PDB_VP, ("pmap_pde_alloc: pde %lx\n", pa)); - - atomic_clearbits_int(&pg->pg_flags, PG_BUSY); - pg->wire_count = 1; /* no mappings yet */ - pmap_pde_set(pm, va, pa); - pm->pm_stats.resident_count++; /* count PTP as resident */ - pm->pm_ptphint = pg; - if (pdep) - *pdep = pg; - return ((pt_entry_t *)pa); -} - -static __inline struct vm_page * -pmap_pde_ptp(struct pmap *pm, volatile pt_entry_t *pde) -{ - paddr_t pa = (paddr_t)pde; - - DPRINTF(PDB_FOLLOW|PDB_PV, ("pmap_pde_ptp(%p, %p)\n", pm, pde)); - - if (pm->pm_ptphint && VM_PAGE_TO_PHYS(pm->pm_ptphint) == pa) - return (pm->pm_ptphint); - - DPRINTF(PDB_FOLLOW|PDB_PV, ("pmap_pde_ptp: lookup 0x%lx\n", pa)); - - return (PHYS_TO_VM_PAGE(pa)); -} - -static __inline void -pmap_pde_release(struct pmap *pmap, vaddr_t va, struct vm_page *ptp) -{ - paddr_t pa; - - DPRINTF(PDB_FOLLOW|PDB_PV, - ("pmap_pde_release(%p, 0x%lx, %p)\n", pmap, va, ptp)); - - if (pmap != pmap_kernel() && --ptp->wire_count <= 1) { - DPRINTF(PDB_FOLLOW|PDB_PV, - ("pmap_pde_release: disposing ptp %p\n", ptp)); - - pmap_pde_set(pmap, va, 0); - pmap->pm_stats.resident_count--; - if (pmap->pm_ptphint == ptp) { - pmap->pm_ptphint = RBT_ROOT(uvm_objtree, - &pmap->pm_obj.memt); - } - ptp->wire_count = 0; -#ifdef DIAGNOSTIC - if (ptp->pg_flags & PG_BUSY) - panic("pmap_pde_release: busy page table page"); -#endif - pa = VM_PAGE_TO_PHYS(ptp); - pdcache(HPPA_SID_KERNEL, pa, PAGE_SIZE); - pdtlb(HPPA_SID_KERNEL, pa); - uvm_pagefree(ptp); - } -} - -static __inline pt_entry_t -pmap_pte_get(volatile pt_entry_t *pde, vaddr_t va) -{ - return (pde[(va >> 12) & 0x3ff]); -} - -static __inline void -pmap_pte_set(volatile pt_entry_t *pde, vaddr_t va, pt_entry_t pte) -{ - DPRINTF(PDB_FOLLOW|PDB_VP, ("pmap_pte_set(%p, 0x%lx, 0x%x)\n", - pde, va, pte)); - -#ifdef PMAPDEBUG - if (!pde) - panic("pmap_pte_set: zero pde"); - - if ((paddr_t)pde & PGOFSET) - panic("pmap_pte_set, unaligned pde %p", pde); -#endif - - pde[(va >> 12) & 0x3ff] = pte; -} - -void -pmap_pte_flush(struct pmap *pmap, vaddr_t va, pt_entry_t pte) -{ - fdcache(pmap->pm_space, va, PAGE_SIZE); - if (pte & PTE_PROT(TLB_EXECUTE)) { - ficache(pmap->pm_space, va, PAGE_SIZE); - pdtlb(pmap->pm_space, va); - pitlb(pmap->pm_space, va); - } else - pdtlb(pmap->pm_space, va); -#ifdef USE_HPT - if (pmap_hpt) { - struct vp_entry *hpt; - hpt = pmap_hash(pmap, va); - if (hpt->vp_tag == pmap_vtag(pmap, va)) - hpt->vp_tag = 0xffff; - } -#endif -} - -static __inline pt_entry_t -pmap_vp_find(struct pmap *pm, vaddr_t va) -{ - volatile pt_entry_t *pde; - - if (!(pde = pmap_pde_get(pm->pm_pdir, va))) - return (0); - - return (pmap_pte_get(pde, va)); -} - -#ifdef DDB -void -pmap_dump_table(pa_space_t space, vaddr_t sva) -{ - pa_space_t sp; - - for (sp = 0; sp <= hppa_sid_max; sp++) { - volatile pt_entry_t *pde; - pt_entry_t pte; - vaddr_t va, pdemask; - u_int32_t *pd; - - if (((int)space >= 0 && sp != space) || - !(pd = pmap_sdir_get(sp))) - continue; - - for (pdemask = 1, va = sva ? sva : 0; - va < 0xfffff000; va += PAGE_SIZE) { - if (pdemask != (va & PDE_MASK)) { - pdemask = va & PDE_MASK; - if (!(pde = pmap_pde_get(pd, va))) { - va = pdemask + (~PDE_MASK + 1); - va -= PAGE_SIZE; - continue; - } - printf("%x:%8p:\n", sp, pde); - } - - if (!(pte = pmap_pte_get(pde, va))) - continue; - - printf("0x%08lx-0x%08x:%b\n", va, pte & ~PAGE_MASK, - TLB_PROT(pte & PAGE_MASK), TLB_BITS); - } - } -} - -void -pmap_dump_pv(paddr_t pa) -{ - struct vm_page *pg; - struct pv_entry *pve; - - pg = PHYS_TO_VM_PAGE(pa); - if (pg != NULL) { - for (pve = pg->mdpage.pvh_list; pve; pve = pve->pv_next) - printf("%x:%lx\n", pve->pv_pmap->pm_space, pve->pv_va); - } -} -#endif - -int -pmap_check_alias(struct vm_page *pg, vaddr_t va, pt_entry_t pte) -{ - struct pv_entry *pve; - int ret = 0; - - /* check for non-equ aliased mappings */ - mtx_enter(&pg->mdpage.pvh_mtx); - for (pve = pg->mdpage.pvh_list; pve; pve = pve->pv_next) { - pte |= pmap_vp_find(pve->pv_pmap, pve->pv_va); - if ((va & HPPA_PGAOFF) != (pve->pv_va & HPPA_PGAOFF) && - (pte & PTE_PROT(TLB_GATEWAY)) == 0 && - (pte & PTE_PROT(TLB_WRITE))) { -#ifdef PMAPDEBUG - printf("pmap_check_alias: " - "aliased writable mapping 0x%x:0x%lx\n", - pve->pv_pmap->pm_space, pve->pv_va); -#endif - ret++; - } - } - mtx_leave(&pg->mdpage.pvh_mtx); - - return (ret); -} - -static __inline struct pv_entry * -pmap_pv_alloc(void) -{ - struct pv_entry *pv; - - DPRINTF(PDB_FOLLOW|PDB_PV, ("pmap_pv_alloc()\n")); - - pv = pool_get(&pmap_pv_pool, PR_NOWAIT); - - DPRINTF(PDB_FOLLOW|PDB_PV, ("pmap_pv_alloc: %p\n", pv)); - - return (pv); -} - -static __inline void -pmap_pv_free(struct pv_entry *pv) -{ - if (pv->pv_ptp) - pmap_pde_release(pv->pv_pmap, pv->pv_va, pv->pv_ptp); - - pool_put(&pmap_pv_pool, pv); -} - -static __inline void -pmap_pv_enter(struct vm_page *pg, struct pv_entry *pve, struct pmap *pm, - vaddr_t va, struct vm_page *pdep) -{ - DPRINTF(PDB_FOLLOW|PDB_PV, ("pmap_pv_enter(%p, %p, %p, 0x%lx, %p)\n", - pg, pve, pm, va, pdep)); - pve->pv_pmap = pm; - pve->pv_va = va; - pve->pv_ptp = pdep; - mtx_enter(&pg->mdpage.pvh_mtx); - pve->pv_next = pg->mdpage.pvh_list; - pg->mdpage.pvh_list = pve; - mtx_leave(&pg->mdpage.pvh_mtx); -} - -static __inline struct pv_entry * -pmap_pv_remove(struct vm_page *pg, struct pmap *pmap, vaddr_t va) -{ - struct pv_entry **pve, *pv; - - mtx_enter(&pg->mdpage.pvh_mtx); - for (pv = *(pve = &pg->mdpage.pvh_list); - pv; pv = *(pve = &(*pve)->pv_next)) - if (pv->pv_pmap == pmap && pv->pv_va == va) { - *pve = pv->pv_next; - break; - } - mtx_leave(&pg->mdpage.pvh_mtx); - return (pv); -} - -void -pmap_bootstrap(vaddr_t vstart) -{ - extern int resvphysmem, etext, __rodata_end, __data_start; - extern u_int *ie_mem; - extern paddr_t hppa_vtop; - vaddr_t va, addr = round_page(vstart), eaddr; - vsize_t size; - struct pmap *kpm; - int npdes, nkpdes; - - DPRINTF(PDB_FOLLOW|PDB_INIT, ("pmap_bootstrap(0x%lx)\n", vstart)); - - uvm_setpagesize(); - - hppa_prot[PROT_NONE] = TLB_AR_NA; - hppa_prot[PROT_READ] = TLB_AR_R; - hppa_prot[PROT_WRITE] = TLB_AR_RW; - hppa_prot[PROT_READ | PROT_WRITE] = TLB_AR_RW; - hppa_prot[PROT_EXEC] = TLB_AR_X; - hppa_prot[PROT_READ | PROT_EXEC] = TLB_AR_RX; - hppa_prot[PROT_WRITE | PROT_EXEC] = TLB_AR_RWX; - hppa_prot[PROT_READ | PROT_WRITE | PROT_EXEC] = TLB_AR_RWX; - - /* - * Initialize kernel pmap - */ - kpm = &kernel_pmap_store; - bzero(kpm, sizeof(*kpm)); - uvm_obj_init(&kpm->pm_obj, &pmap_pager, 1); - kpm->pm_space = HPPA_SID_KERNEL; - kpm->pm_pid = HPPA_PID_KERNEL; - kpm->pm_pdir_pg = NULL; - kpm->pm_pdir = (u_int32_t *)addr; - bzero((void *)addr, PAGE_SIZE); - fdcache(HPPA_SID_KERNEL, addr, PAGE_SIZE); - addr += PAGE_SIZE; - - /* - * Allocate various tables and structures. - */ - - mtctl(addr, CR_VTOP); - hppa_vtop = addr; - size = round_page((hppa_sid_max + 1) * 4); - bzero((void *)addr, size); - fdcache(HPPA_SID_KERNEL, addr, size); - DPRINTF(PDB_INIT, ("vtop: 0x%lx @ 0x%lx\n", size, addr)); - addr += size; - pmap_sdir_set(HPPA_SID_KERNEL, kpm->pm_pdir); - - ie_mem = (u_int *)addr; - addr += 0x8000; - -#ifdef USE_HPT - if (pmap_hptsize) { - struct vp_entry *hptp; - int i, error; - - /* must be aligned to the size XXX */ - if (addr & (pmap_hptsize - 1)) - addr += pmap_hptsize; - addr &= ~(pmap_hptsize - 1); - - bzero((void *)addr, pmap_hptsize); - for (hptp = (struct vp_entry *)addr, i = pmap_hptsize / 16; i--;) - hptp[i].vp_tag = 0xffff; - pmap_hpt = addr; - addr += pmap_hptsize; - - DPRINTF(PDB_INIT, ("hpt_table: 0x%x @ %p\n", - pmap_hptsize, addr)); - - if ((error = (cpu_hpt_init)(pmap_hpt, pmap_hptsize)) < 0) { - printf("WARNING: HPT init error %d -- DISABLED\n", - error); - pmap_hpt = 0; - } else - DPRINTF(PDB_INIT, - ("HPT: installed for %d entries @ 0x%x\n", - pmap_hptsize / sizeof(struct vp_entry), addr)); - } -#endif - - /* XXX PCXS needs this inserted into an IBTLB */ - /* and can block-map the whole phys w/ another */ - - /* - * We use separate mappings for the first 4MB of kernel text - * and whetever is left to avoid the mapping to cover kernel - * data. - */ - for (va = 0; va < (vaddr_t)&etext; va += size) { - size = (vaddr_t)&etext - va; - if (size > 4 * 1024 * 1024) - size = 4 * 1024 * 1024; - - if (btlb_insert(HPPA_SID_KERNEL, va, va, &size, - pmap_sid2pid(HPPA_SID_KERNEL) | - pmap_prot(pmap_kernel(), PROT_READ | PROT_EXEC)) < 0) { - printf("WARNING: cannot block map kernel text\n"); - break; - } - } - - if (&__rodata_end < &__data_start) { - physical_steal = (vaddr_t)&__rodata_end; - physical_end = (vaddr_t)&__data_start; - DPRINTF(PDB_INIT, ("physpool: 0x%lx @ 0x%lx\n", - physical_end - physical_steal, physical_steal)); - } - - /* kernel virtual is the last gig of the moohicans */ - nkpdes = physmem >> 14; /* at least 16/gig for kmem */ - if (nkpdes < 4) - nkpdes = 4; /* ... but no less than four */ - nkpdes += HPPA_IOLEN / PDE_SIZE; /* ... and io space too */ - npdes = nkpdes + (physmem + atop(PDE_SIZE) - 1) / atop(PDE_SIZE); - - /* map the pdes */ - for (va = 0; npdes--; va += PDE_SIZE, addr += PAGE_SIZE) { - - /* last nkpdes are for the kernel virtual */ - if (npdes == nkpdes - 1) - va = SYSCALLGATE; - if (npdes == HPPA_IOLEN / PDE_SIZE - 1) - va = HPPA_IOBEGIN; - /* now map the pde for the physmem */ - bzero((void *)addr, PAGE_SIZE); - fdcache(HPPA_SID_KERNEL, addr, PAGE_SIZE); - DPRINTF(PDB_INIT|PDB_VP, - ("pde premap 0x%lx 0x%lx\n", va, addr)); - pmap_pde_set(kpm, va, addr); - kpm->pm_stats.resident_count++; /* count PTP as resident */ - } - - resvphysmem = atop(addr); - eaddr = physmem - atop(round_page(MSGBUFSIZE)); - DPRINTF(PDB_INIT, ("physmem: 0x%x - 0x%lx\n", resvphysmem, eaddr)); - uvm_page_physload(0, eaddr, resvphysmem, eaddr, 0); - - /* TODO optimize/inline the kenter */ - for (va = 0; va < ptoa(physmem); va += PAGE_SIZE) { - extern struct user *proc0paddr; - vm_prot_t prot = PROT_READ | PROT_WRITE; - - if (va < (vaddr_t)&etext) - prot = PROT_READ | PROT_EXEC; - else if (va < (vaddr_t)&__rodata_end) - prot = PROT_READ; - else if (va == (vaddr_t)proc0paddr + USPACE) - prot = PROT_NONE; - - pmap_kenter_pa(va, va, prot); - } - - DPRINTF(PDB_INIT, ("bootstrap: mapped %p - 0x%lx\n", &etext, va)); -} - -void -pmap_init(void) -{ - DPRINTF(PDB_FOLLOW|PDB_INIT, ("pmap_init()\n")); - - pool_init(&pmap_pmap_pool, sizeof(struct pmap), 0, IPL_NONE, 0, - "pmappl", NULL); - pool_init(&pmap_pv_pool, sizeof(struct pv_entry), 0, IPL_VM, 0, - "pmappv", NULL); - pool_setlowat(&pmap_pv_pool, pmap_pvlowat); - pool_sethiwat(&pmap_pv_pool, pmap_pvlowat * 32); - - pmap_initialized = 1; - - /* - * map SysCall gateways page once for everybody - * NB: we'll have to remap the phys memory - * if we have any at SYSCALLGATE address (; - */ - { - volatile pt_entry_t *pde; - - if (!(pde = pmap_pde_get(pmap_kernel()->pm_pdir, SYSCALLGATE)) && - !(pde = pmap_pde_alloc(pmap_kernel(), SYSCALLGATE, NULL))) - panic("pmap_init: cannot allocate pde"); - - pmap_pte_set(pde, SYSCALLGATE, (paddr_t)&gateway_page | - PTE_PROT(TLB_GATE_PROT)); - } - - DPRINTF(PDB_FOLLOW|PDB_INIT, ("pmap_init(): done\n")); -} - -void -pmap_virtual_space(vaddr_t *startp, vaddr_t *endp) -{ - *startp = SYSCALLGATE + PAGE_SIZE; - *endp = VM_MAX_KERNEL_ADDRESS; -} - -struct pmap * -pmap_create(void) -{ - struct pmap *pmap; - pa_space_t space; - - DPRINTF(PDB_FOLLOW|PDB_PMAP, ("pmap_create()\n")); - - pmap = pool_get(&pmap_pmap_pool, PR_WAITOK); - - mtx_init(&pmap->pm_mtx, IPL_VM); - - uvm_obj_init(&pmap->pm_obj, &pmap_pager, 1); - - for (space = 1 + arc4random_uniform(hppa_sid_max); - pmap_sdir_get(space); space = (space + 1) % hppa_sid_max); - - if ((pmap->pm_pdir_pg = pmap_pagealloc(NULL, 0)) == NULL) - panic("pmap_create: no pages"); - pmap->pm_ptphint = NULL; - pmap->pm_pdir = (u_int32_t *)VM_PAGE_TO_PHYS(pmap->pm_pdir_pg); - pmap_sdir_set(space, pmap->pm_pdir); - - pmap->pm_space = space; - pmap->pm_pid = (space + 1) << 1; - - pmap->pm_stats.resident_count = 1; - pmap->pm_stats.wired_count = 0; - - return (pmap); -} - -void -pmap_destroy(struct pmap *pmap) -{ - paddr_t pa; - int refs; - - DPRINTF(PDB_FOLLOW|PDB_PMAP, ("pmap_destroy(%p)\n", pmap)); - - refs = atomic_dec_int_nv(&pmap->pm_obj.uo_refs); - if (refs > 0) - return; - - KASSERT(RBT_EMPTY(uvm_objtree, &pmap->pm_obj.memt)); - - pmap_sdir_set(pmap->pm_space, 0); - - pa = VM_PAGE_TO_PHYS(pmap->pm_pdir_pg); - pdcache(HPPA_SID_KERNEL, pa, PAGE_SIZE); - pdtlb(HPPA_SID_KERNEL, pa); - uvm_pagefree(pmap->pm_pdir_pg); - - pmap->pm_pdir_pg = NULL; - pool_put(&pmap_pmap_pool, pmap); -} - -/* - * Add a reference to the specified pmap. - */ -void -pmap_reference(struct pmap *pmap) -{ - DPRINTF(PDB_FOLLOW|PDB_PMAP, ("pmap_reference(%p)\n", pmap)); - - atomic_inc_int(&pmap->pm_obj.uo_refs); -} - -int -pmap_enter(struct pmap *pmap, vaddr_t va, paddr_t pa, vm_prot_t prot, int flags) -{ - volatile pt_entry_t *pde; - pt_entry_t pte; - struct vm_page *pg, *ptp = NULL; - struct pv_entry *pve = NULL; - boolean_t wired = (flags & PMAP_WIRED) != 0; - - DPRINTF(PDB_FOLLOW|PDB_ENTER, - ("pmap_enter(%p, 0x%lx, 0x%lx, 0x%x, 0x%x)\n", - pmap, va, pa, prot, flags)); - pmap_lock(pmap); - - if (!(pde = pmap_pde_get(pmap->pm_pdir, va)) && - !(pde = pmap_pde_alloc(pmap, va, &ptp))) { - if (flags & PMAP_CANFAIL) { - pmap_unlock(pmap); - return (ENOMEM); - } - panic("pmap_enter: cannot allocate pde"); - } - - if (!ptp) - ptp = pmap_pde_ptp(pmap, pde); - - if ((pte = pmap_pte_get(pde, va))) { - DPRINTF(PDB_ENTER, - ("pmap_enter: remapping 0x%x -> 0x%lx\n", pte, pa)); - - pmap_pte_flush(pmap, va, pte); - if (wired && !(pte & PTE_PROT(TLB_WIRED))) - pmap->pm_stats.wired_count++; - else if (!wired && (pte & PTE_PROT(TLB_WIRED))) - pmap->pm_stats.wired_count--; - - if (PTE_PAGE(pte) == pa) { - DPRINTF(PDB_FOLLOW|PDB_ENTER, - ("pmap_enter: same page\n")); - goto enter; - } - - pg = PHYS_TO_VM_PAGE(PTE_PAGE(pte)); - if (pg != NULL) { - pve = pmap_pv_remove(pg, pmap, va); - atomic_setbits_int(&pg->pg_flags, pmap_pvh_attrs(pte)); - } - } else { - DPRINTF(PDB_ENTER, - ("pmap_enter: new mapping 0x%lx -> 0x%lx\n", va, pa)); - pte = PTE_PROT(TLB_REFTRAP); - pmap->pm_stats.resident_count++; - if (wired) - pmap->pm_stats.wired_count++; - if (ptp) - ptp->wire_count++; - } - - if (pmap_initialized && (pg = PHYS_TO_VM_PAGE(PTE_PAGE(pa)))) { - if (!pve && !(pve = pmap_pv_alloc())) { - if (flags & PMAP_CANFAIL) { - pmap_unlock(pmap); - return (ENOMEM); - } - panic("pmap_enter: no pv entries available"); - } - pte |= PTE_PROT(pmap_prot(pmap, prot)); - if (pmap_check_alias(pg, va, pte)) - pmap_page_remove(pg); - pmap_pv_enter(pg, pve, pmap, va, ptp); - } else if (pve) - pmap_pv_free(pve); - -enter: - /* preserve old ref & mod */ - pte = pa | PTE_PROT(pmap_prot(pmap, prot)) | - (pte & PTE_PROT(TLB_UNCACHABLE|TLB_DIRTY|TLB_REFTRAP)); - if (IS_IOPAGE(pa)) - pte |= PTE_PROT(TLB_UNCACHABLE); - if (wired) - pte |= PTE_PROT(TLB_WIRED); - pmap_pte_set(pde, va, pte); - - DPRINTF(PDB_FOLLOW|PDB_ENTER, ("pmap_enter: leaving\n")); - pmap_unlock(pmap); - - return (0); -} - -void -pmap_remove(struct pmap *pmap, vaddr_t sva, vaddr_t eva) -{ - struct pv_entry *pve; - volatile pt_entry_t *pde; - pt_entry_t pte; - struct vm_page *pg, *ptp; - vaddr_t pdemask; - int batch; - - DPRINTF(PDB_FOLLOW|PDB_REMOVE, - ("pmap_remove(%p, 0x%lx, 0x%lx)\n", pmap, sva, eva)); - pmap_lock(pmap); - - for (batch = 0; sva < eva; sva += PAGE_SIZE) { - pdemask = sva & PDE_MASK; - if (!(pde = pmap_pde_get(pmap->pm_pdir, sva))) { - sva = pdemask + (~PDE_MASK + 1) - PAGE_SIZE; - continue; - } - if (pdemask == sva) { - if (sva + (~PDE_MASK + 1) <= eva) - batch = 1; - else - batch = 0; - } - - if ((pte = pmap_pte_get(pde, sva))) { - - /* TODO measure here the speed tradeoff - * for flushing whole 4M vs per-page - * in case of non-complete pde fill - */ - pmap_pte_flush(pmap, sva, pte); - if (pte & PTE_PROT(TLB_WIRED)) - pmap->pm_stats.wired_count--; - pmap->pm_stats.resident_count--; - - /* iff properly accounted pde will be dropped anyway */ - if (!batch) - pmap_pte_set(pde, sva, 0); - - if (pmap_initialized && - (pg = PHYS_TO_VM_PAGE(PTE_PAGE(pte)))) { - atomic_setbits_int(&pg->pg_flags, - pmap_pvh_attrs(pte)); - if ((pve = pmap_pv_remove(pg, pmap, sva))) - pmap_pv_free(pve); - } else { - if (IS_IOPAGE(PTE_PAGE(pte))) { - ptp = pmap_pde_ptp(pmap, pde); - if (ptp != NULL) - pmap_pde_release(pmap, sva, ptp); - } - } - } - } - - DPRINTF(PDB_FOLLOW|PDB_REMOVE, ("pmap_remove: leaving\n")); - pmap_unlock(pmap); -} - -void -pmap_page_write_protect(struct vm_page *pg) -{ - struct pv_entry *pve; - int attrs; - - DPRINTF(PDB_FOLLOW|PDB_BITS, ("pmap_page_write_protect(%p)\n", pg)); - - attrs = 0; - mtx_enter(&pg->mdpage.pvh_mtx); - for (pve = pg->mdpage.pvh_list; pve; pve = pve->pv_next) { - struct pmap *pmap = pve->pv_pmap; - vaddr_t va = pve->pv_va; - volatile pt_entry_t *pde; - pt_entry_t opte, pte; - - if ((pde = pmap_pde_get(pmap->pm_pdir, va))) { - opte = pte = pmap_pte_get(pde, va); - if (pte & TLB_GATEWAY) - continue; - pte &= ~TLB_WRITE; - attrs |= pmap_pvh_attrs(pte); - - if (opte != pte) { - pmap_pte_flush(pmap, va, opte); - pmap_pte_set(pde, va, pte); - } - } - } - mtx_leave(&pg->mdpage.pvh_mtx); - if (attrs != (PG_PMAP_REF | PG_PMAP_MOD)) - atomic_clearbits_int(&pg->pg_flags, - attrs ^(PG_PMAP_REF | PG_PMAP_MOD)); - if (attrs != 0) - atomic_setbits_int(&pg->pg_flags, attrs); -} - -void -pmap_write_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) -{ - struct vm_page *pg; - volatile pt_entry_t *pde; - pt_entry_t pte; - u_int tlbprot, pdemask; - - DPRINTF(PDB_FOLLOW|PDB_PMAP, - ("pmap_write_protect(%p, %lx, %lx, %x)\n", pmap, sva, eva, prot)); - pmap_lock(pmap); - - sva = trunc_page(sva); - tlbprot = PTE_PROT(pmap_prot(pmap, prot)); - - for (pdemask = 1; sva < eva; sva += PAGE_SIZE) { - if (pdemask != (sva & PDE_MASK)) { - pdemask = sva & PDE_MASK; - if (!(pde = pmap_pde_get(pmap->pm_pdir, sva))) { - sva = pdemask + (~PDE_MASK + 1) - PAGE_SIZE; - continue; - } - } - if ((pte = pmap_pte_get(pde, sva))) { - - DPRINTF(PDB_PMAP, - ("pmap_write_protect: va=0x%lx pte=0x%x\n", - sva, pte)); - /* - * Determine if mapping is changing. - * If not, nothing to do. - */ - if ((pte & PTE_PROT(TLB_AR_MASK)) == tlbprot) - continue; - - pg = PHYS_TO_VM_PAGE(PTE_PAGE(pte)); - if (pg != NULL) { - atomic_setbits_int(&pg->pg_flags, - pmap_pvh_attrs(pte)); - } - - pmap_pte_flush(pmap, sva, pte); - pte &= ~PTE_PROT(TLB_AR_MASK); - pte |= tlbprot; - pmap_pte_set(pde, sva, pte); - } - } - - pmap_unlock(pmap); -} - -void -pmap_page_remove(struct vm_page *pg) -{ - struct pv_entry *pve; - - DPRINTF(PDB_FOLLOW|PDB_PV, ("pmap_page_remove(%p)\n", pg)); - - if (pg->mdpage.pvh_list == NULL) - return; - - mtx_enter(&pg->mdpage.pvh_mtx); - while ((pve = pg->mdpage.pvh_list)) { - struct pmap *pmap = pve->pv_pmap; - vaddr_t va = pve->pv_va; - volatile pt_entry_t *pde; - pt_entry_t pte; - u_int attrs; - - pg->mdpage.pvh_list = pve->pv_next; - pmap_reference(pmap); - mtx_leave(&pg->mdpage.pvh_mtx); - - pmap_lock(pmap); - pde = pmap_pde_get(pmap->pm_pdir, va); - pte = pmap_pte_get(pde, va); - attrs = pmap_pvh_attrs(pte); - - pmap_pte_flush(pmap, va, pte); - if (pte & PTE_PROT(TLB_WIRED)) - pmap->pm_stats.wired_count--; - pmap->pm_stats.resident_count--; - - pmap_pte_set(pde, va, 0); - pmap_unlock(pmap); - - pmap_destroy(pmap); - pmap_pv_free(pve); - atomic_setbits_int(&pg->pg_flags, attrs); - mtx_enter(&pg->mdpage.pvh_mtx); - } - mtx_leave(&pg->mdpage.pvh_mtx); - - DPRINTF(PDB_FOLLOW|PDB_PV, ("pmap_page_remove: leaving\n")); -} - -void -pmap_unwire(struct pmap *pmap, vaddr_t va) -{ - volatile pt_entry_t *pde; - pt_entry_t pte = 0; - - DPRINTF(PDB_FOLLOW|PDB_PMAP, ("pmap_unwire(%p, 0x%lx)\n", pmap, va)); - pmap_lock(pmap); - - if ((pde = pmap_pde_get(pmap->pm_pdir, va))) { - pte = pmap_pte_get(pde, va); - - if (pte & PTE_PROT(TLB_WIRED)) { - pte &= ~PTE_PROT(TLB_WIRED); - pmap->pm_stats.wired_count--; - pmap_pte_set(pde, va, pte); - } - } - - DPRINTF(PDB_FOLLOW|PDB_PMAP, ("pmap_unwire: leaving\n")); - pmap_unlock(pmap); - -#ifdef DIAGNOSTIC - if (!pte) - panic("pmap_unwire: invalid va 0x%lx", va); -#endif -} - -boolean_t -pmap_changebit(struct vm_page *pg, u_int set, u_int clear) -{ - struct pv_entry *pve; - pt_entry_t res; - int attrs; - - DPRINTF(PDB_FOLLOW|PDB_BITS, - ("pmap_changebit(%p, %x, %x)\n", pg, set, clear)); - - res = 0; - attrs = 0; - mtx_enter(&pg->mdpage.pvh_mtx); - for (pve = pg->mdpage.pvh_list; pve; pve = pve->pv_next) { - struct pmap *pmap = pve->pv_pmap; - vaddr_t va = pve->pv_va; - volatile pt_entry_t *pde; - pt_entry_t opte, pte; - - if ((pde = pmap_pde_get(pmap->pm_pdir, va))) { - opte = pte = pmap_pte_get(pde, va); -#ifdef PMAPDEBUG - if (!pte) { - printf("pmap_changebit: zero pte for 0x%lx\n", - va); - continue; - } -#endif - pte &= ~clear; - pte |= set; - attrs |= pmap_pvh_attrs(pte); - res |= pmap_pvh_attrs(opte); - - if (opte != pte) { - pmap_pte_flush(pmap, va, opte); - pmap_pte_set(pde, va, pte); - } - } - } - mtx_leave(&pg->mdpage.pvh_mtx); - if (attrs != (PG_PMAP_REF | PG_PMAP_MOD)) - atomic_clearbits_int(&pg->pg_flags, - attrs ^(PG_PMAP_REF | PG_PMAP_MOD)); - if (attrs != 0) - atomic_setbits_int(&pg->pg_flags, attrs); - - return ((res & (clear | set)) != 0); -} - -boolean_t -pmap_testbit(struct vm_page *pg, int bit) -{ - struct pv_entry *pve; - pt_entry_t pte; - boolean_t ret; - - DPRINTF(PDB_FOLLOW|PDB_BITS, ("pmap_testbit(%p, %x)\n", pg, bit)); - - mtx_enter(&pg->mdpage.pvh_mtx); - for (pve = pg->mdpage.pvh_list; !(pg->pg_flags & bit) && pve; - pve = pve->pv_next) { - pte = pmap_vp_find(pve->pv_pmap, pve->pv_va); - atomic_setbits_int(&pg->pg_flags, pmap_pvh_attrs(pte)); - } - mtx_leave(&pg->mdpage.pvh_mtx); - ret = ((pg->pg_flags & bit) != 0); - - return ret; -} - -boolean_t -pmap_extract(struct pmap *pmap, vaddr_t va, paddr_t *pap) -{ - pt_entry_t pte; - - DPRINTF(PDB_FOLLOW|PDB_EXTRACT, ("pmap_extract(%p, %lx)\n", pmap, va)); - - pmap_lock(pmap); - pte = pmap_vp_find(pmap, va); - pmap_unlock(pmap); - - if (pte) { - if (pap) - *pap = (pte & ~PGOFSET) | (va & PGOFSET); - return (TRUE); - } - - return (FALSE); -} - -void -pmap_activate(struct proc *p) -{ - struct pmap *pmap = p->p_vmspace->vm_map.pmap; - struct pcb *pcb = &p->p_addr->u_pcb; - - pcb->pcb_space = pmap->pm_space; -} - -void -pmap_deactivate(struct proc *p) -{ - -} - -static __inline void -pmap_flush_page(struct vm_page *pg, int purge) -{ - struct pv_entry *pve; - - /* purge cache for all possible mappings for the pa */ - mtx_enter(&pg->mdpage.pvh_mtx); - for (pve = pg->mdpage.pvh_list; pve; pve = pve->pv_next) { - if (purge) - pdcache(pve->pv_pmap->pm_space, pve->pv_va, PAGE_SIZE); - else - fdcache(pve->pv_pmap->pm_space, pve->pv_va, PAGE_SIZE); - ficache(pve->pv_pmap->pm_space, pve->pv_va, PAGE_SIZE); - pdtlb(pve->pv_pmap->pm_space, pve->pv_va); - pitlb(pve->pv_pmap->pm_space, pve->pv_va); - } - mtx_leave(&pg->mdpage.pvh_mtx); -} - -void -pmap_zero_page(struct vm_page *pg) -{ - paddr_t pa = VM_PAGE_TO_PHYS(pg); - - DPRINTF(PDB_FOLLOW|PDB_PHYS, ("pmap_zero_page(%lx)\n", pa)); - - pmap_flush_page(pg, 1); - bzero((void *)pa, PAGE_SIZE); - fdcache(HPPA_SID_KERNEL, pa, PAGE_SIZE); - pdtlb(HPPA_SID_KERNEL, pa); -} - -void -pmap_copy_page(struct vm_page *srcpg, struct vm_page *dstpg) -{ - paddr_t spa = VM_PAGE_TO_PHYS(srcpg); - paddr_t dpa = VM_PAGE_TO_PHYS(dstpg); - DPRINTF(PDB_FOLLOW|PDB_PHYS, ("pmap_copy_page(%lx, %lx)\n", spa, dpa)); - - pmap_flush_page(srcpg, 0); - pmap_flush_page(dstpg, 1); - bcopy((void *)spa, (void *)dpa, PAGE_SIZE); - pdcache(HPPA_SID_KERNEL, spa, PAGE_SIZE); - fdcache(HPPA_SID_KERNEL, dpa, PAGE_SIZE); - pdtlb(HPPA_SID_KERNEL, spa); - pdtlb(HPPA_SID_KERNEL, dpa); -} - -void -pmap_kenter_pa(vaddr_t va, paddr_t pa, vm_prot_t prot) -{ - volatile pt_entry_t *pde; - pt_entry_t pte, opte; - - DPRINTF(PDB_FOLLOW|PDB_ENTER, - ("pmap_kenter_pa(%lx, %lx, %x)\n", va, pa, prot)); - - if (!(pde = pmap_pde_get(pmap_kernel()->pm_pdir, va)) && - !(pde = pmap_pde_alloc(pmap_kernel(), va, NULL))) - panic("pmap_kenter_pa: cannot allocate pde for va=0x%lx", va); - opte = pmap_pte_get(pde, va); - pte = pa | PTE_PROT(TLB_WIRED | TLB_REFTRAP | - pmap_prot(pmap_kernel(), prot)); - if (IS_IOPAGE(pa)) - pte |= PTE_PROT(TLB_UNCACHABLE); - if (opte) - pmap_pte_flush(pmap_kernel(), va, opte); - pmap_pte_set(pde, va, pte); - pmap_kernel()->pm_stats.wired_count++; - pmap_kernel()->pm_stats.resident_count++; - -#ifdef PMAPDEBUG - { - struct vm_page *pg; - - if (pmap_initialized && (pg = PHYS_TO_VM_PAGE(PTE_PAGE(pte)))) { - if (pmap_check_alias(pg, va, pte)) - db_enter(); - } - } -#endif - DPRINTF(PDB_FOLLOW|PDB_ENTER, ("pmap_kenter_pa: leaving\n")); -} - -void -pmap_kremove(vaddr_t va, vsize_t size) -{ - struct pv_entry *pve; - vaddr_t eva, pdemask; - volatile pt_entry_t *pde; - pt_entry_t pte; - struct vm_page *pg; - - DPRINTF(PDB_FOLLOW|PDB_REMOVE, - ("pmap_kremove(%lx, %lx)\n", va, size)); -#ifdef PMAPDEBUG - if (va < ptoa(physmem)) { - printf("pmap_kremove(%lx, %lx): unmapping physmem\n", va, size); - return; - } -#endif - - for (pdemask = 1, eva = va + size; va < eva; va += PAGE_SIZE) { - if (pdemask != (va & PDE_MASK)) { - pdemask = va & PDE_MASK; - if (!(pde = pmap_pde_get(pmap_kernel()->pm_pdir, va))) { - va = pdemask + (~PDE_MASK + 1) - PAGE_SIZE; - continue; - } - } - if (!(pte = pmap_pte_get(pde, va))) { -#ifdef DEBUG - printf("pmap_kremove: unmapping unmapped 0x%x\n", va); -#endif - continue; - } - - pmap_pte_flush(pmap_kernel(), va, pte); - pmap_pte_set(pde, va, 0); - if (pmap_initialized && (pg = PHYS_TO_VM_PAGE(PTE_PAGE(pte)))) { - atomic_setbits_int(&pg->pg_flags, pmap_pvh_attrs(pte)); - /* just in case we have enter/kenter mismatch */ - if ((pve = pmap_pv_remove(pg, pmap_kernel(), va))) - pmap_pv_free(pve); - } - } - - DPRINTF(PDB_FOLLOW|PDB_REMOVE, ("pmap_kremove: leaving\n")); -} - -void -pmap_proc_iflush(struct process *pr, vaddr_t va, vsize_t len) -{ - pmap_t pmap = vm_map_pmap(&pr->ps_vmspace->vm_map); - - fdcache(pmap->pm_space, va, len); - sync_caches(); - ficache(pmap->pm_space, va, len); - sync_caches(); -} - -struct vm_page * -pmap_unmap_direct(vaddr_t va) -{ - fdcache(HPPA_SID_KERNEL, va, PAGE_SIZE); - pdtlb(HPPA_SID_KERNEL, va); - return (PHYS_TO_VM_PAGE(va)); -} diff --git a/sys/arch/hppa/hppa/process_machdep.c b/sys/arch/hppa/hppa/process_machdep.c deleted file mode 100644 index 5b90009e4..000000000 --- a/sys/arch/hppa/hppa/process_machdep.c +++ /dev/null @@ -1,177 +0,0 @@ -/* $OpenBSD: process_machdep.c,v 1.21 2012/08/29 18:58:45 kettenis Exp $ */ - -/* - * Copyright (c) 1999-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include -#include - -#include -#include -#include - -int -process_read_regs(struct proc *p, struct reg *regs) -{ - struct trapframe *tf = p->p_md.md_regs; - - regs->r_regs[ 0] = tf->tf_ipsw; - regs->r_regs[ 1] = tf->tf_r1; - regs->r_regs[ 2] = tf->tf_rp; - regs->r_regs[ 3] = tf->tf_r3; - regs->r_regs[ 4] = tf->tf_r4; - regs->r_regs[ 5] = tf->tf_r5; - regs->r_regs[ 6] = tf->tf_r6; - regs->r_regs[ 7] = tf->tf_r7; - regs->r_regs[ 8] = tf->tf_r8; - regs->r_regs[ 9] = tf->tf_r9; - regs->r_regs[10] = tf->tf_r10; - regs->r_regs[11] = tf->tf_r11; - regs->r_regs[12] = tf->tf_r12; - regs->r_regs[13] = tf->tf_r13; - regs->r_regs[14] = tf->tf_r14; - regs->r_regs[15] = tf->tf_r15; - regs->r_regs[16] = tf->tf_r16; - regs->r_regs[17] = tf->tf_r17; - regs->r_regs[18] = tf->tf_r18; - regs->r_regs[19] = tf->tf_t4; - regs->r_regs[20] = tf->tf_t3; - regs->r_regs[21] = tf->tf_t2; - regs->r_regs[22] = tf->tf_t1; - regs->r_regs[23] = tf->tf_arg3; - regs->r_regs[24] = tf->tf_arg2; - regs->r_regs[25] = tf->tf_arg1; - regs->r_regs[26] = tf->tf_arg0; - regs->r_regs[27] = tf->tf_dp; - regs->r_regs[28] = tf->tf_ret0; - regs->r_regs[29] = tf->tf_ret1; - regs->r_regs[30] = tf->tf_sp; - regs->r_regs[31] = tf->tf_r31; - - regs->r_sar = tf->tf_sar; - - regs->r_pcsqh = tf->tf_iisq_head; - regs->r_pcsqt = tf->tf_iisq_tail; - regs->r_pcoqh = tf->tf_iioq_head; - regs->r_pcoqt = tf->tf_iioq_tail; - - regs->r_sr0 = tf->tf_sr0; - regs->r_sr1 = tf->tf_sr1; - regs->r_sr2 = tf->tf_sr2; - regs->r_sr3 = tf->tf_sr3; - regs->r_sr4 = tf->tf_sr4; - regs->r_sr5 = tf->tf_sr5; - regs->r_sr6 = tf->tf_sr6; - regs->r_sr7 = tf->tf_sr7; - - regs->r_cr26 = 0; - regs->r_cr27 = tf->tf_cr27; - - return (0); -} - -int -process_read_fpregs(struct proc *p, struct fpreg *fpregs) -{ - fpu_proc_save(p); - - bcopy(&p->p_addr->u_pcb.pcb_fpstate->hfp_regs, fpregs, 32 * 8); - - return (0); -} - -#ifdef PTRACE - -int -process_write_regs(struct proc *p, struct reg *regs) -{ - struct trapframe *tf = p->p_md.md_regs; - - tf->tf_r1 = regs->r_regs[ 1]; - tf->tf_rp = regs->r_regs[ 2]; - tf->tf_r3 = regs->r_regs[ 3]; - tf->tf_r4 = regs->r_regs[ 4]; - tf->tf_r5 = regs->r_regs[ 5]; - tf->tf_r6 = regs->r_regs[ 6]; - tf->tf_r7 = regs->r_regs[ 7]; - tf->tf_r8 = regs->r_regs[ 8]; - tf->tf_r9 = regs->r_regs[ 9]; - tf->tf_r10 = regs->r_regs[10]; - tf->tf_r11 = regs->r_regs[11]; - tf->tf_r12 = regs->r_regs[12]; - tf->tf_r13 = regs->r_regs[13]; - tf->tf_r14 = regs->r_regs[14]; - tf->tf_r15 = regs->r_regs[15]; - tf->tf_r16 = regs->r_regs[16]; - tf->tf_r17 = regs->r_regs[17]; - tf->tf_r18 = regs->r_regs[18]; - tf->tf_t4 = regs->r_regs[19]; - tf->tf_t3 = regs->r_regs[20]; - tf->tf_t2 = regs->r_regs[21]; - tf->tf_t1 = regs->r_regs[22]; - tf->tf_arg3 = regs->r_regs[23]; - tf->tf_arg2 = regs->r_regs[24]; - tf->tf_arg1 = regs->r_regs[25]; - tf->tf_arg0 = regs->r_regs[26]; - tf->tf_dp = regs->r_regs[27]; - tf->tf_ret0 = regs->r_regs[28]; - tf->tf_ret1 = regs->r_regs[29]; - tf->tf_sp = regs->r_regs[30]; - tf->tf_r31 = regs->r_regs[31]; - - tf->tf_sar = regs->r_sar; - - tf->tf_iioq_head = regs->r_pcoqh | HPPA_PC_PRIV_USER; - tf->tf_iioq_tail = regs->r_pcoqt | HPPA_PC_PRIV_USER; - - return (0); -} - -int -process_write_fpregs(struct proc *p, struct fpreg *fpregs) -{ - fpu_proc_flush(p); - - bcopy(fpregs, &p->p_addr->u_pcb.pcb_fpstate->hfp_regs, 32 * 8); - - return (0); -} - -/* process_sstep() is in trap.c */ - -int -process_set_pc(struct proc *p, caddr_t addr) -{ - p->p_md.md_regs->tf_iioq_head = (register_t)addr | HPPA_PC_PRIV_USER; - p->p_md.md_regs->tf_iioq_tail = p->p_md.md_regs->tf_iioq_head + 4; - - return (0); -} - -#endif /* PTRACE */ diff --git a/sys/arch/hppa/hppa/sys_machdep.c b/sys/arch/hppa/hppa/sys_machdep.c deleted file mode 100644 index 4e9b75314..000000000 --- a/sys/arch/hppa/hppa/sys_machdep.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $OpenBSD: sys_machdep.c,v 1.3 2003/06/02 23:27:46 millert Exp $ */ - -/* - * Copyright (c) 1982, 1986, 1993 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)sys_machdep.c 8.2 (Berkeley) 1/13/94 - */ - -#include -#include - -#include -#include - -int -sys_sysarch(p, v, retval) - struct proc *p; - void *v; - register_t *retval; -{ - struct sys_sysarch_args /* { - syscallarg(int) op; - syscallarg(char *) parms; - } */ *uap = v; - int error = 0; - - switch (SCARG(uap, op)) { - default: - error = EINVAL; - break; - } - return (error); -} diff --git a/sys/arch/hppa/hppa/trap.c b/sys/arch/hppa/hppa/trap.c deleted file mode 100644 index bebd3c072..000000000 --- a/sys/arch/hppa/hppa/trap.c +++ /dev/null @@ -1,965 +0,0 @@ -/* $OpenBSD: trap.c,v 1.161 2023/02/11 23:07:26 deraadt Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -/* #define TRAPDEBUG */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -#ifdef DDB -#ifdef TRAPDEBUG -#include -#else -#include -#endif -#endif - -static __inline int inst_store(u_int ins) { - return (ins & 0xf0000000) == 0x60000000 || /* st */ - (ins & 0xf4000200) == 0x24000200 || /* fst/cst */ - (ins & 0xfc000200) == 0x0c000200 || /* stby */ - (ins & 0xfc0003c0) == 0x0c0001c0; /* ldcw */ -} - -int pcxs_unaligned(u_int opcode, vaddr_t va); -#ifdef PTRACE -void ss_clear_breakpoints(struct proc *p); -#endif - -void ast(struct proc *); - -/* single-step breakpoint */ -#define SSBREAKPOINT (HPPA_BREAK_KERNEL | (HPPA_BREAK_SS << 13)) - -const char *trap_type[] = { - "invalid", - "HPMC", - "power failure", - "recovery counter", - "external interrupt", - "LPMC", - "ITLB miss fault", - "instruction protection", - "Illegal instruction", - "break instruction", - "privileged operation", - "privileged register", - "overflow", - "conditional", - "assist exception", - "DTLB miss", - "ITLB non-access miss", - "DTLB non-access miss", - "data protection/rights/alignment", - "data break", - "TLB dirty", - "page reference", - "assist emulation", - "higher-priv transfer", - "lower-priv transfer", - "taken branch", - "data access rights", - "data protection", - "unaligned data ref", -}; -int trap_types = sizeof(trap_type)/sizeof(trap_type[0]); - -#define frame_regmap(tf,r) (((u_int *)(tf))[hppa_regmap[(r)]]) -u_char hppa_regmap[32] = { - offsetof(struct trapframe, tf_pad[0]) / 4, /* r0 XXX */ - offsetof(struct trapframe, tf_r1) / 4, - offsetof(struct trapframe, tf_rp) / 4, - offsetof(struct trapframe, tf_r3) / 4, - offsetof(struct trapframe, tf_r4) / 4, - offsetof(struct trapframe, tf_r5) / 4, - offsetof(struct trapframe, tf_r6) / 4, - offsetof(struct trapframe, tf_r7) / 4, - offsetof(struct trapframe, tf_r8) / 4, - offsetof(struct trapframe, tf_r9) / 4, - offsetof(struct trapframe, tf_r10) / 4, - offsetof(struct trapframe, tf_r11) / 4, - offsetof(struct trapframe, tf_r12) / 4, - offsetof(struct trapframe, tf_r13) / 4, - offsetof(struct trapframe, tf_r14) / 4, - offsetof(struct trapframe, tf_r15) / 4, - offsetof(struct trapframe, tf_r16) / 4, - offsetof(struct trapframe, tf_r17) / 4, - offsetof(struct trapframe, tf_r18) / 4, - offsetof(struct trapframe, tf_t4) / 4, - offsetof(struct trapframe, tf_t3) / 4, - offsetof(struct trapframe, tf_t2) / 4, - offsetof(struct trapframe, tf_t1) / 4, - offsetof(struct trapframe, tf_arg3) / 4, - offsetof(struct trapframe, tf_arg2) / 4, - offsetof(struct trapframe, tf_arg1) / 4, - offsetof(struct trapframe, tf_arg0) / 4, - offsetof(struct trapframe, tf_dp) / 4, - offsetof(struct trapframe, tf_ret0) / 4, - offsetof(struct trapframe, tf_ret1) / 4, - offsetof(struct trapframe, tf_sp) / 4, - offsetof(struct trapframe, tf_r31) / 4, -}; - -void -ast(struct proc *p) -{ - if (p->p_md.md_astpending) { - p->p_md.md_astpending = 0; - uvmexp.softs++; - mi_ast(p, curcpu()->ci_want_resched); - } - -} - -void -trap(int type, struct trapframe *frame) -{ - struct proc *p = curproc; - vaddr_t va; - struct vm_map *map; - struct vmspace *vm; - register vm_prot_t access_type; - register pa_space_t space; - union sigval sv; - u_int opcode; - int ret, trapnum; - const char *tts; -#ifdef DIAGNOSTIC - int oldcpl = curcpu()->ci_cpl; -#endif - - trapnum = type & ~T_USER; - opcode = frame->tf_iir; - if (trapnum <= T_EXCEPTION || trapnum == T_HIGHERPL || - trapnum == T_LOWERPL || trapnum == T_TAKENBR || - trapnum == T_IDEBUG || trapnum == T_PERFMON) { - va = frame->tf_iioq_head; - space = frame->tf_iisq_head; - access_type = PROT_EXEC; - } else { - va = frame->tf_ior; - space = frame->tf_isr; - if (va == frame->tf_iioq_head) - access_type = PROT_EXEC; - else if (inst_store(opcode)) - access_type = PROT_WRITE; - else - access_type = PROT_READ; - } - - if (frame->tf_flags & TFF_LAST) - p->p_md.md_regs = frame; - - if (trapnum > trap_types) - tts = "reserved"; - else - tts = trap_type[trapnum]; - -#ifdef TRAPDEBUG - if (trapnum != T_INTERRUPT && trapnum != T_IBREAK) - db_printf("trap: %x, %s for %x:%x at %x:%x, fl=%x, fp=%p\n", - type, tts, space, va, frame->tf_iisq_head, - frame->tf_iioq_head, frame->tf_flags, frame); - else if (trapnum == T_IBREAK) - db_printf("trap: break instruction %x:%x at %x:%x, fp=%p\n", - break5(opcode), break13(opcode), - frame->tf_iisq_head, frame->tf_iioq_head, frame); - - { - extern int etext; - if (frame < (struct trapframe *)&etext) { - printf("trap: bogus frame ptr %p\n", frame); - goto dead_end; - } - } -#endif - if (trapnum != T_INTERRUPT) { - uvmexp.traps++; - mtctl(frame->tf_eiem, CR_EIEM); - } - - if (type & T_USER) - refreshcreds(p); - - switch (type) { - case T_NONEXIST: - case T_NONEXIST | T_USER: - /* we've got screwed up by the central scrutinizer */ - printf("trap: elvis has just left the building!\n"); - goto dead_end; - - case T_RECOVERY: - case T_RECOVERY | T_USER: - /* XXX will implement later */ - printf("trap: handicapped"); - goto dead_end; - -#ifdef DIAGNOSTIC - case T_EXCEPTION: - panic("FPU/SFU emulation botch"); - - /* these just can't happen ever */ - case T_PRIV_OP: - case T_PRIV_REG: - /* these just can't make it to the trap() ever */ - case T_HPMC: - case T_HPMC | T_USER: -#endif - case T_IBREAK: - case T_DATALIGN: - case T_DBREAK: - dead_end: -#ifdef DDB - if (db_ktrap(type, va, frame)) { - if (type == T_IBREAK) { - /* skip break instruction */ - frame->tf_iioq_head = frame->tf_iioq_tail; - frame->tf_iioq_tail += 4; - } - return; - } -#else - if (type == T_DATALIGN || type == T_DPROT) - panic ("trap: %s at 0x%lx", tts, va); - else - panic ("trap: no debugger for \"%s\" (%d)", tts, type); -#endif - break; - - case T_IBREAK | T_USER: - case T_DBREAK | T_USER: { - int code = TRAP_BRKPT; - -#ifdef PTRACE - KERNEL_LOCK(); - ss_clear_breakpoints(p); - if (opcode == SSBREAKPOINT) - code = TRAP_TRACE; - KERNEL_UNLOCK(); -#endif - /* pass to user debugger */ - sv.sival_int = va; - trapsignal(p, SIGTRAP, type & ~T_USER, code, sv); - } - break; - -#ifdef PTRACE - case T_TAKENBR | T_USER: - KERNEL_LOCK(); - ss_clear_breakpoints(p); - KERNEL_UNLOCK(); - /* pass to user debugger */ - sv.sival_int = va; - trapsignal(p, SIGTRAP, type & ~T_USER, TRAP_TRACE, sv); - break; -#endif - - case T_EXCEPTION | T_USER: { - struct hppa_fpstate *hfp; - u_int64_t *fpp; - u_int32_t *pex; - int i, flt; - - hfp = (struct hppa_fpstate *)frame->tf_cr30; - fpp = (u_int64_t *)&hfp->hfp_regs; - - pex = (u_int32_t *)&fpp[0]; - for (i = 0, pex++; i < 7 && !*pex; i++, pex++); - flt = 0; - if (i < 7) { - u_int32_t stat = HPPA_FPU_OP(*pex); - if (stat & HPPA_FPU_UNMPL) - flt = FPE_FLTINV; - else if (stat & (HPPA_FPU_V << 1)) - flt = FPE_FLTINV; - else if (stat & (HPPA_FPU_Z << 1)) - flt = FPE_FLTDIV; - else if (stat & (HPPA_FPU_I << 1)) - flt = FPE_FLTRES; - else if (stat & (HPPA_FPU_O << 1)) - flt = FPE_FLTOVF; - else if (stat & (HPPA_FPU_U << 1)) - flt = FPE_FLTUND; - /* still left: under/over-flow w/ inexact */ - - /* cleanup exceptions (XXX deliver all ?) */ - while (i++ < 7) - *pex++ = 0; - } - /* reset the trap flag, as if there was none */ - fpp[0] &= ~(((u_int64_t)HPPA_FPU_T) << 32); - - sv.sival_int = va; - trapsignal(p, SIGFPE, type & ~T_USER, flt, sv); - } - break; - - case T_EMULATION: - panic("trap: emulation trap in the kernel"); - break; - - case T_EMULATION | T_USER: - sv.sival_int = va; - trapsignal(p, SIGILL, type & ~T_USER, ILL_COPROC, sv); - break; - - case T_OVERFLOW | T_USER: - sv.sival_int = va; - trapsignal(p, SIGFPE, type & ~T_USER, FPE_INTOVF, sv); - break; - - case T_CONDITION | T_USER: - sv.sival_int = va; - trapsignal(p, SIGFPE, type & ~T_USER, FPE_INTDIV, sv); - break; - - case T_PRIV_OP | T_USER: - sv.sival_int = va; - trapsignal(p, SIGILL, type & ~T_USER, ILL_PRVOPC, sv); - break; - - case T_PRIV_REG | T_USER: - /* - * On PCXS processors, attempting to read control registers - * cr26 and cr27 from userland causes a ``privileged register'' - * trap. Later processors do not restrict read accesses to - * these registers. - */ - if (cpu_type == hpcxs && - (opcode & (0xfc1fffe0 | (0x1e << 21))) == - (0x000008a0 | (0x1a << 21))) { /* mfctl %cr{26,27}, %r# */ - register_t cr; - - if (((opcode >> 21) & 0x1f) == 27) - cr = frame->tf_cr27; /* cr27 */ - else - cr = 0; /* cr26 */ - frame_regmap(frame, opcode & 0x1f) = cr; - frame->tf_ipsw |= PSL_N; - } else { - sv.sival_int = va; - trapsignal(p, SIGILL, type & ~T_USER, ILL_PRVREG, sv); - } - break; - - /* these should never got here */ - case T_HIGHERPL | T_USER: - case T_LOWERPL | T_USER: - case T_DATAPID | T_USER: - sv.sival_int = va; - trapsignal(p, SIGSEGV, access_type, SEGV_ACCERR, sv); - break; - - /* - * On PCXS processors, traps T_DATACC, T_DATAPID and T_DATALIGN - * are shared. We need to sort out the unaligned access situation - * first, before handling this trap as T_DATACC. - */ - case T_DPROT | T_USER: - if (cpu_type == hpcxs) { - if (pcxs_unaligned(opcode, va)) - goto datalign_user; - else - goto datacc; - } - - sv.sival_int = va; - trapsignal(p, SIGSEGV, access_type, SEGV_ACCERR, sv); - break; - - case T_ITLBMISSNA: - case T_ITLBMISSNA | T_USER: - case T_DTLBMISSNA: - case T_DTLBMISSNA | T_USER: - if (space == HPPA_SID_KERNEL) - map = kernel_map; - else { - vm = p->p_vmspace; - map = &vm->vm_map; - } - - if ((opcode & 0xfc003fc0) == 0x04001340) { - /* lpa failure case */ - frame_regmap(frame, opcode & 0x1f) = 0; - frame->tf_ipsw |= PSL_N; - } else if ((opcode & 0xfc001f80) == 0x04001180) { - int pl; - - /* dig probe[rw]i? insns */ - if (opcode & 0x2000) - pl = (opcode >> 16) & 3; - else - pl = frame_regmap(frame, - (opcode >> 16) & 0x1f) & 3; - - KERNEL_LOCK(); - - if ((type & T_USER && space == HPPA_SID_KERNEL) || - (frame->tf_iioq_head & 3) != pl || - (type & T_USER && va >= VM_MAXUSER_ADDRESS) || - uvm_fault(map, trunc_page(va), 0, - opcode & 0x40? PROT_WRITE : PROT_READ)) { - frame_regmap(frame, opcode & 0x1f) = 0; - frame->tf_ipsw |= PSL_N; - } - - KERNEL_UNLOCK(); - } else if (type & T_USER) { - sv.sival_int = va; - trapsignal(p, SIGILL, type & ~T_USER, ILL_ILLTRP, sv); - } else - panic("trap: %s @ 0x%lx:0x%lx for 0x%x:0x%lx irr 0x%08x", - tts, frame->tf_iisq_head, frame->tf_iioq_head, - space, va, opcode); - break; - - case T_IPROT | T_USER: - case T_TLB_DIRTY: - case T_TLB_DIRTY | T_USER: - case T_DATACC: - case T_DATACC | T_USER: -datacc: - case T_ITLBMISS: - case T_ITLBMISS | T_USER: - case T_DTLBMISS: - case T_DTLBMISS | T_USER: - if (type & T_USER) { - if (!uvm_map_inentry(p, &p->p_spinentry, PROC_STACK(p), - "[%s]%d/%d sp=%lx inside %lx-%lx: not MAP_STACK\n", - uvm_map_inentry_sp, p->p_vmspace->vm_map.sserial)) - goto out; - } - - /* - * it could be a kernel map for exec_map faults - */ - if (space == HPPA_SID_KERNEL) - map = kernel_map; - else { - vm = p->p_vmspace; - map = &vm->vm_map; - } - - /* - * user faults out of user addr space are always a fail, - * this happens on va >= VM_MAXUSER_ADDRESS, where - * space id will be zero and therefore cause - * a misbehave lower in the code. - * - * also check that faulted space id matches the curproc. - */ - if ((type & T_USER && va >= VM_MAXUSER_ADDRESS) || - (type & T_USER && map->pmap->pm_space != space)) { - sv.sival_int = va; - trapsignal(p, SIGSEGV, access_type, SEGV_MAPERR, sv); - break; - } - - KERNEL_LOCK(); - ret = uvm_fault(map, trunc_page(va), 0, access_type); - KERNEL_UNLOCK(); - - /* - * If this was a stack access we keep track of the maximum - * accessed stack size. Also, if uvm_fault gets a protection - * failure it is due to accessing the stack region outside - * the current limit and we need to reflect that as an access - * error. - */ - if (ret == 0 && space != HPPA_SID_KERNEL) - uvm_grow(p, va); - - if (ret != 0) { - if (type & T_USER) { - int signal, sicode; - - signal = SIGSEGV; - sicode = SEGV_MAPERR; - if (ret == EACCES) - sicode = SEGV_ACCERR; - if (ret == EIO) { - signal = SIGBUS; - sicode = BUS_OBJERR; - } - sv.sival_int = va; - trapsignal(p, signal, access_type, sicode, sv); - } else { - if (p && p->p_addr->u_pcb.pcb_onfault) { - frame->tf_iioq_tail = 4 + - (frame->tf_iioq_head = - p->p_addr->u_pcb.pcb_onfault); -#ifdef DDB - frame->tf_iir = 0; -#endif - } else { - panic("trap: " - "uvm_fault(%p, %lx, 0, %d): %d", - map, va, access_type, ret); - } - } - } - break; - - case T_DATAPID: - /* This should never happen, unless within spcopy() */ - if (p && p->p_addr->u_pcb.pcb_onfault) { - frame->tf_iioq_tail = 4 + - (frame->tf_iioq_head = - p->p_addr->u_pcb.pcb_onfault); -#ifdef DDB - frame->tf_iir = 0; -#endif - } else - goto dead_end; - break; - - case T_DATALIGN | T_USER: -datalign_user: - sv.sival_int = va; - trapsignal(p, SIGBUS, access_type, BUS_ADRALN, sv); - break; - - case T_INTERRUPT: - case T_INTERRUPT | T_USER: - cpu_intr(frame); - break; - - case T_CONDITION: - panic("trap: divide by zero in the kernel"); - break; - - case T_ILLEGAL: - case T_ILLEGAL | T_USER: - /* see if it's a SPOP1,,0 */ - if ((opcode & 0xfffffe00) == 0x10000200) { - frame_regmap(frame, opcode & 0x1f) = 0; - frame->tf_ipsw |= PSL_N; - break; - } - if (type & T_USER) { - sv.sival_int = va; - trapsignal(p, SIGILL, type & ~T_USER, ILL_ILLOPC, sv); - break; - } - /* FALLTHROUGH */ - - /* - * On PCXS processors, traps T_DATACC, T_DATAPID and T_DATALIGN - * are shared. We need to sort out the unaligned access situation - * first, before handling this trap as T_DATACC. - */ - case T_DPROT: - if (cpu_type == hpcxs) { - if (pcxs_unaligned(opcode, va)) - goto dead_end; - else - goto datacc; - } - /* FALLTHROUGH to unimplemented */ - - case T_LOWERPL: - case T_IPROT: - case T_OVERFLOW: - case T_HIGHERPL: - case T_TAKENBR: - case T_POWERFAIL: - case T_LPMC: - case T_PAGEREF: - /* FALLTHROUGH to unimplemented */ - default: -#ifdef TRAPDEBUG - if (db_ktrap(type, va, frame)) - return; -#endif - panic("trap: unimplemented \'%s\' (%d)", tts, trapnum); - } - -#ifdef DIAGNOSTIC - if (curcpu()->ci_cpl != oldcpl) - printf("WARNING: SPL (%d) NOT LOWERED ON " - "TRAP (%d) EXIT\n", curcpu()->ci_cpl, trapnum); -#endif - - if (trapnum != T_INTERRUPT) - splx(curcpu()->ci_cpl); /* process softints */ - - /* - * in case we were interrupted from the syscall gate page - * treat this as we were not really running user code no more - * for weird things start to happen on return to the userland - * and also see a note in locore.S:TLABEL(all) - */ - if ((type & T_USER) && !(frame->tf_iisq_head == HPPA_SID_KERNEL && - (frame->tf_iioq_head & ~PAGE_MASK) == SYSCALLGATE)) { - ast(p); -out: - userret(p); - } -} - -void -child_return(void *arg) -{ - struct proc *p = (struct proc *)arg; - struct trapframe *tf = p->p_md.md_regs; - - /* - * Set up return value registers as libc:fork() expects - */ - tf->tf_ret0 = 0; - tf->tf_t1 = 0; /* errno */ - - KERNEL_UNLOCK(); - - ast(p); - - mi_child_return(p); -} - -#ifdef PTRACE - -#include - -int ss_get_value(struct proc *p, vaddr_t addr, u_int *value); -int ss_put_value(struct proc *p, vaddr_t addr, u_int value); - -int -ss_get_value(struct proc *p, vaddr_t addr, u_int *value) -{ - struct uio uio; - struct iovec iov; - - iov.iov_base = (caddr_t)value; - iov.iov_len = sizeof(u_int); - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = (off_t)addr; - uio.uio_resid = sizeof(u_int); - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_rw = UIO_READ; - uio.uio_procp = curproc; - return (process_domem(curproc, p->p_p, &uio, PT_READ_I)); -} - -int -ss_put_value(struct proc *p, vaddr_t addr, u_int value) -{ - struct uio uio; - struct iovec iov; - - iov.iov_base = (caddr_t)&value; - iov.iov_len = sizeof(u_int); - uio.uio_iov = &iov; - uio.uio_iovcnt = 1; - uio.uio_offset = (off_t)addr; - uio.uio_resid = sizeof(u_int); - uio.uio_segflg = UIO_SYSSPACE; - uio.uio_rw = UIO_WRITE; - uio.uio_procp = curproc; - return (process_domem(curproc, p->p_p, &uio, PT_WRITE_I)); -} - -void -ss_clear_breakpoints(struct proc *p) -{ - /* Restore original instructions. */ - if (p->p_md.md_bpva != 0) { - ss_put_value(p, p->p_md.md_bpva, p->p_md.md_bpsave[0]); - ss_put_value(p, p->p_md.md_bpva + 4, p->p_md.md_bpsave[1]); - p->p_md.md_bpva = 0; - } -} - -int -process_sstep(struct proc *p, int sstep) -{ - int error; - - ss_clear_breakpoints(p); - - if (sstep == 0) { - p->p_md.md_regs->tf_ipsw &= ~PSL_T; - return (0); - } - - /* - * Don't touch the syscall gateway page. Instead, insert a - * breakpoint where we're supposed to return. - */ - if ((p->p_md.md_regs->tf_iioq_tail & ~PAGE_MASK) == SYSCALLGATE) - p->p_md.md_bpva = p->p_md.md_regs->tf_r31 & ~HPPA_PC_PRIV_MASK; - else - p->p_md.md_bpva = p->p_md.md_regs->tf_iioq_tail & ~HPPA_PC_PRIV_MASK; - - /* - * Insert two breakpoint instructions; the first one might be - * nullified. Of course we need to save two instruction - * first. - */ - - error = ss_get_value(p, p->p_md.md_bpva, &p->p_md.md_bpsave[0]); - if (error) - return (error); - error = ss_get_value(p, p->p_md.md_bpva + 4, &p->p_md.md_bpsave[1]); - if (error) - return (error); - - error = ss_put_value(p, p->p_md.md_bpva, SSBREAKPOINT); - if (error) - return (error); - error = ss_put_value(p, p->p_md.md_bpva + 4, SSBREAKPOINT); - if (error) - return (error); - - if ((p->p_md.md_regs->tf_iioq_tail & ~PAGE_MASK) != SYSCALLGATE) - p->p_md.md_regs->tf_ipsw |= PSL_T; - else - p->p_md.md_regs->tf_ipsw &= ~PSL_T; - - return (0); -} - -#endif /* PTRACE */ - -void syscall(struct trapframe *frame); - -/* - * call actual syscall routine - */ -void -syscall(struct trapframe *frame) -{ - struct proc *p = curproc; - const struct sysent *callp; - int retq, code, argsize, argoff, error, indirect = -1; - register_t args[8], rval[2]; -#ifdef DIAGNOSTIC - int oldcpl = curcpu()->ci_cpl; -#endif - - uvmexp.syscalls++; - - if (!USERMODE(frame->tf_iioq_head)) - panic("syscall"); - - p->p_md.md_regs = frame; - - argoff = 4; retq = 0; - switch (code = frame->tf_t1) { - case SYS_syscall: - indirect = code; - code = frame->tf_arg0; - args[0] = frame->tf_arg1; - args[1] = frame->tf_arg2; - args[2] = frame->tf_arg3; - argoff = 3; - break; - default: - args[0] = frame->tf_arg0; - args[1] = frame->tf_arg1; - args[2] = frame->tf_arg2; - args[3] = frame->tf_arg3; - break; - } - - callp = sysent; - if (code < 0 || code >= SYS_MAXSYSCALL) - callp += SYS_syscall; - else - callp += code; - - if ((argsize = callp->sy_argsize)) { - register_t *s, *e, t; - int i; - - argsize -= argoff * 4; - if (argsize > 0) { - i = argsize / 4; - if ((error = copyin((void *)(frame->tf_sp + - HPPA_FRAME_ARG(4 + i - 1)), args + argoff, - argsize))) - goto bad; - /* reverse the args[] entries */ - s = args + argoff; - e = s + i - 1; - while (s < e) { - t = *s; - *s = *e; - *e = t; - s++, e--; - } - } - - /* - * System calls with 64-bit arguments need a word swap - * due to the order of the arguments on the stack. - */ - i = 0; - switch (code) { - case SYS_lseek: retq = 0; - case SYS_truncate: - case SYS_ftruncate: i = 2; break; - case SYS_preadv: - case SYS_pwritev: - case SYS_pread: - case SYS_pwrite: i = 4; break; - case SYS_mquery: - case SYS_mmap: i = 6; break; - } - - if (i) { - t = args[i]; - args[i] = args[i + 1]; - args[i + 1] = t; - } - } - - rval[0] = 0; - rval[1] = frame->tf_ret1; - - error = mi_syscall(p, code, indirect, callp, args, rval); - - switch (error) { - case 0: - frame->tf_ret0 = rval[0]; - frame->tf_ret1 = rval[!retq]; - frame->tf_t1 = 0; - break; - case ERESTART: - frame->tf_iioq_head -= 12; - frame->tf_iioq_tail -= 12; - case EJUSTRETURN: - break; - default: - bad: - frame->tf_t1 = error; - frame->tf_ret0 = error; - frame->tf_ret1 = 0; - break; - } - - ast(p); - - mi_syscall_return(p, code, error, rval); - -#ifdef DIAGNOSTIC - if (curcpu()->ci_cpl != oldcpl) { - printf("WARNING: SPL (0x%x) NOT LOWERED ON " - "syscall(0x%x, 0x%lx, 0x%lx, 0x%lx...) EXIT, PID %d\n", - curcpu()->ci_cpl, code, args[0], args[1], args[2], - p->p_p->ps_pid); - curcpu()->ci_cpl = oldcpl; - } -#endif - splx(curcpu()->ci_cpl); /* process softints */ -} - -/* - * Decide if opcode `opcode' accessing virtual address `va' caused an - * unaligned trap. Returns zero if the access is correctly aligned. - * Used on PCXS processors to sort out exception causes. - */ -int -pcxs_unaligned(u_int opcode, vaddr_t va) -{ - u_int mbz_bits; - - /* - * Exit early if the va is obviously aligned enough. - */ - if ((va & 0x0f) == 0) - return 0; - - mbz_bits = 0; - - /* - * Only load and store instructions can cause unaligned access. - * There are three opcode patterns to look for: - * - canonical load/store - * - load/store short or indexed - * - coprocessor load/store - */ - - if ((opcode & 0xd0000000) == 0x40000000) { - switch ((opcode >> 26) & 0x03) { - case 0x00: /* ldb, stb */ - mbz_bits = 0x00; - break; - case 0x01: /* ldh, sth */ - mbz_bits = 0x01; - break; - case 0x02: /* ldw, stw */ - case 0x03: /* ldwm, stwm */ - mbz_bits = 0x03; - break; - } - } else - - if ((opcode & 0xfc000000) == 0x0c000000) { - switch ((opcode >> 6) & 0x0f) { - case 0x01: /* ldhx, ldhs */ - mbz_bits = 0x01; - break; - case 0x02: /* ldwx, ldws */ - mbz_bits = 0x03; - break; - case 0x07: /* ldcwx, ldcws */ - mbz_bits = 0x0f; - break; - case 0x09: - if ((opcode & (1 << 12)) != 0) /* sths */ - mbz_bits = 0x01; - break; - case 0x0a: - if ((opcode & (1 << 12)) != 0) /* stws */ - mbz_bits = 0x03; - break; - } - } else - - if ((opcode & 0xf4000000) == 0x24000000) { - if ((opcode & (1 << 27)) != 0) { - /* cldwx, cstwx, cldws, cstws */ - mbz_bits = 0x03; - } else { - /* clddx, cstdx, cldds, cstds */ - mbz_bits = 0x07; - } - } - - return (va & mbz_bits); -} diff --git a/sys/arch/hppa/hppa/vm_machdep.c b/sys/arch/hppa/hppa/vm_machdep.c deleted file mode 100644 index 17a864cc7..000000000 --- a/sys/arch/hppa/hppa/vm_machdep.c +++ /dev/null @@ -1,201 +0,0 @@ -/* $OpenBSD: vm_machdep.c,v 1.85 2022/10/25 15:15:38 guenther Exp $ */ - -/* - * Copyright (c) 1999-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -extern struct pool hppa_fppl; - -void -cpu_fork(struct proc *p1, struct proc *p2, void *stack, void *tcb, - void (*func)(void *), void *arg) -{ - struct pcb *pcbp; - struct trapframe *tf; - register_t sp; - -#ifdef DIAGNOSTIC - if (round_page(sizeof(struct user)) > NBPG) - panic("USPACE too small for user"); -#endif - fpu_proc_save(p1); - - pcbp = &p2->p_addr->u_pcb; - bcopy(&p1->p_addr->u_pcb, pcbp, sizeof(*pcbp)); - /* space is cached for the copy{in,out}'s pleasure */ - pcbp->pcb_space = p2->p_vmspace->vm_map.pmap->pm_space; - pcbp->pcb_fpstate = pool_get(&hppa_fppl, PR_WAITOK); - *pcbp->pcb_fpstate = *p1->p_addr->u_pcb.pcb_fpstate; - /* reset any of the pending FPU exceptions from parent */ - pcbp->pcb_fpstate->hfp_regs.fpr_regs[0] = - HPPA_FPU_FORK(pcbp->pcb_fpstate->hfp_regs.fpr_regs[0]); - pcbp->pcb_fpstate->hfp_regs.fpr_regs[1] = 0; - pcbp->pcb_fpstate->hfp_regs.fpr_regs[2] = 0; - pcbp->pcb_fpstate->hfp_regs.fpr_regs[3] = 0; - - p2->p_md.md_bpva = p1->p_md.md_bpva; - p2->p_md.md_bpsave[0] = p1->p_md.md_bpsave[0]; - p2->p_md.md_bpsave[1] = p1->p_md.md_bpsave[1]; - - sp = (register_t)p2->p_addr + NBPG; - p2->p_md.md_regs = tf = (struct trapframe *)sp; - sp += sizeof(struct trapframe); - bcopy(p1->p_md.md_regs, tf, sizeof(*tf)); - - tf->tf_cr30 = (paddr_t)pcbp->pcb_fpstate; - - tf->tf_sr0 = tf->tf_sr1 = tf->tf_sr2 = tf->tf_sr3 = - tf->tf_sr4 = tf->tf_sr5 = tf->tf_sr6 = - tf->tf_iisq_head = tf->tf_iisq_tail = - p2->p_vmspace->vm_map.pmap->pm_space; - tf->tf_pidr1 = tf->tf_pidr2 = pmap_sid2pid(tf->tf_sr0); - - /* - * theoretically these could be inherited from the father, - * but just in case. - */ - tf->tf_sr7 = HPPA_SID_KERNEL; - mfctl(CR_EIEM, tf->tf_eiem); - tf->tf_ipsw = PSL_C | PSL_Q | PSL_P | PSL_D | PSL_I /* | PSL_L */ | - (curcpu()->ci_psw & PSL_O); - - /* - * If specified, give the child a different stack and/or TCB - */ - if (stack != NULL) - setstack(tf, (u_long)stack, 0); /* XXX ignore error? */ - if (tcb != NULL) - tf->tf_cr27 = (u_long)tcb; - - /* - * Build stack frames for the cpu_switchto & co. - */ - sp += HPPA_FRAME_SIZE; - *(register_t*)(sp - HPPA_FRAME_SIZE) = 0; - *(register_t*)(sp + HPPA_FRAME_CRP) = (register_t)&proc_trampoline; - *(register_t*)(sp) = (sp - HPPA_FRAME_SIZE); - - sp += HPPA_FRAME_SIZE + 16*4; /* frame + callee-saved registers */ - *HPPA_FRAME_CARG(0, sp) = (register_t)arg; - *HPPA_FRAME_CARG(1, sp) = KERNMODE(func); - pcbp->pcb_ksp = sp; -} - -void -cpu_exit(struct proc *p) -{ - struct pcb *pcb = &p->p_addr->u_pcb; - - fpu_proc_flush(p); - - pool_put(&hppa_fppl, pcb->pcb_fpstate); - - pmap_deactivate(p); - sched_exit(p); -} - -struct kmem_va_mode kv_physwait = { - .kv_map = &phys_map, - .kv_wait = 1, -}; - -/* - * Map an IO request into kernel virtual address space. - */ -void -vmapbuf(struct buf *bp, vsize_t len) -{ - struct kmem_dyn_mode kd_prefer = { .kd_waitok = 1 }; - struct pmap *pm = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map); - vaddr_t kva, uva; - vsize_t size, off; - -#ifdef DIAGNOSTIC - if ((bp->b_flags & B_PHYS) == 0) - panic("vmapbuf"); -#endif - bp->b_saveaddr = bp->b_data; - uva = trunc_page((vaddr_t)bp->b_data); - off = (vaddr_t)bp->b_data - uva; - size = round_page(off + len); - - kd_prefer.kd_prefer = uva; - kva = (vaddr_t)km_alloc(size, &kv_physwait, &kp_none, &kd_prefer); - bp->b_data = (caddr_t)(kva + off); - while (size > 0) { - paddr_t pa; - - if (pmap_extract(pm, uva, &pa) == FALSE) - panic("vmapbuf: null page frame"); - else - pmap_kenter_pa(kva, pa, PROT_READ | PROT_WRITE); - uva += PAGE_SIZE; - kva += PAGE_SIZE; - size -= PAGE_SIZE; - } - pmap_update(pmap_kernel()); -} - -/* - * Unmap IO request from the kernel virtual address space. - */ -void -vunmapbuf(struct buf *bp, vsize_t len) -{ - vaddr_t addr, off; - -#ifdef DIAGNOSTIC - if ((bp->b_flags & B_PHYS) == 0) - panic("vunmapbuf"); -#endif - addr = trunc_page((vaddr_t)bp->b_data); - off = (vaddr_t)bp->b_data - addr; - len = round_page(off + len); - pmap_kremove(addr, len); - pmap_update(pmap_kernel()); - km_free((void *)addr, len, &kv_physwait, &kp_none); - bp->b_data = bp->b_saveaddr; - bp->b_saveaddr = NULL; -} diff --git a/sys/arch/hppa/hppa/wscons_machdep.c b/sys/arch/hppa/hppa/wscons_machdep.c deleted file mode 100644 index 7e58a4f0f..000000000 --- a/sys/arch/hppa/hppa/wscons_machdep.c +++ /dev/null @@ -1,90 +0,0 @@ -/* $OpenBSD: wscons_machdep.c,v 1.7 2004/10/05 19:27:55 mickey Exp $ */ - -/* - * Copyright (c) 2002-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include - -#include - -#include "wsdisplay.h" -#if NWSDISPLAY > 0 -#include -#endif - -#include "wskbd.h" -#if NWSKBD > 0 -#include -#endif - -cons_decl(ws); - -void -wscnprobe(struct consdev *cp) -{ - /* - * Due to various device probe restrictions, the wscons console - * can never be enabled early during boot. - * It will be enabled as soon as enough wscons components get - * attached. - * So do nothing there, the switch will occur in - * wsdisplay_emul_attach() later. - */ -} - -void -wscninit(struct consdev *cp) -{ -} - -void -wscnputc(dev_t dev, int i) -{ -#if NWSDISPLAY > 0 - wsdisplay_cnputc(dev, i); -#endif -} - -int -wscngetc(dev_t dev) -{ -#if NWSKBD > 0 - return (wskbd_cngetc(dev)); -#else - return (0); -#endif -} - -void -wscnpollc(dev_t dev, int on) -{ -#if NWSKBD > 0 - wskbd_cnpollc(dev, on); -#endif -} diff --git a/sys/arch/hppa/include/_float.h b/sys/arch/hppa/include/_float.h deleted file mode 100644 index 11a907c15..000000000 --- a/sys/arch/hppa/include/_float.h +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: _float.h,v 1.1 2012/06/26 16:12:44 deraadt Exp $ */ - -/* - * Copyright (c) 1989 Regents of the University of California. - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - */ - -#ifndef _MACHINE__FLOAT_H_ -#define _MACHINE__FLOAT_H_ - -#define __FLT_RADIX 2 -#define __FLT_ROUNDS __flt_rounds() -#define __FLT_EVAL_METHOD 0 /* no promotions */ - -#define __FLT_MANT_DIG 24 -#define __FLT_EPSILON 1.19209290E-07F -#define __FLT_DIG 6 -#define __FLT_MIN_EXP (-125) -#define __FLT_MIN 1.17549435E-38F -#define __FLT_MIN_10_EXP (-37) -#define __FLT_MAX_EXP 128 -#define __FLT_MAX 3.40282347E+38F -#define __FLT_MAX_10_EXP 38 - -#define __DBL_MANT_DIG 53 -#define __DBL_EPSILON 2.2204460492503131E-16 -#define __DBL_DIG 15 -#define __DBL_MIN_EXP (-1021) -#define __DBL_MIN 2.2250738585072014E-308 -#define __DBL_MIN_10_EXP (-307) -#define __DBL_MAX_EXP 1024 -#define __DBL_MAX 1.7976931348623157E+308 -#define __DBL_MAX_10_EXP 308 - -#define __LDBL_MANT_DIG DBL_MANT_DIG -#define __LDBL_EPSILON DBL_EPSILON -#define __LDBL_DIG DBL_DIG -#define __LDBL_MIN_EXP DBL_MIN_EXP -#define __LDBL_MIN DBL_MIN -#define __LDBL_MIN_10_EXP DBL_MIN_10_EXP -#define __LDBL_MAX_EXP DBL_MAX_EXP -#define __LDBL_MAX DBL_MAX -#define __LDBL_MAX_10_EXP DBL_MAX_10_EXP - -#define __DECIMAL_DIG 17 - -#endif /* _MACHINE__FLOAT_H_ */ diff --git a/sys/arch/hppa/include/_types.h b/sys/arch/hppa/include/_types.h deleted file mode 100644 index 80d46e03d..000000000 --- a/sys/arch/hppa/include/_types.h +++ /dev/null @@ -1,146 +0,0 @@ -/* $OpenBSD: _types.h,v 1.27 2022/12/06 00:40:09 cheloha Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)types.h 8.3 (Berkeley) 1/5/94 - * @(#)ansi.h 8.2 (Berkeley) 1/4/94 - */ - -#ifndef _MACHINE__TYPES_H_ -#define _MACHINE__TYPES_H_ - -#define __HAVE_CLOCKINTR - -#if defined(_KERNEL) -typedef struct label_t { - long val[19]; -} label_t; -#endif - -/* - * _ALIGN(p) rounds p (pointer or byte index) up to a correctly-aligned - * value for all data types (int, long, ...). The result is an - * unsigned long and must be cast to any desired pointer type. - * - * _ALIGNED_POINTER is a boolean macro that checks whether an address - * is valid to fetch data elements of type t from on this architecture. - * This does not reflect the optimal alignment, just the possibility - * (within reasonable limits). - */ -#define _ALIGNBYTES 7 -#define _STACKALIGNBYTES _ALIGNBYTES -#define _ALIGN(p) (((unsigned long)(p) + _ALIGNBYTES) & ~_ALIGNBYTES) -#define _ALIGNED_POINTER(p,t) ((((unsigned long)(p)) & (sizeof(t) - 1)) == 0) -#define _MAX_PAGE_SHIFT 12 /* same as PAGE_SHIFT */ - -typedef unsigned long hppa_hpa_t; /* XXX */ -typedef unsigned long hppa_spa_t; /* XXX */ -typedef unsigned int pa_space_t; /* XXX */ - -/* 7.18.1.1 Exact-width integer types */ -typedef signed char __int8_t; -typedef unsigned char __uint8_t; -typedef short __int16_t; -typedef unsigned short __uint16_t; -typedef int __int32_t; -typedef unsigned int __uint32_t; -typedef long long __int64_t; -typedef unsigned long long __uint64_t; - -/* 7.18.1.2 Minimum-width integer types */ -typedef __int8_t __int_least8_t; -typedef __uint8_t __uint_least8_t; -typedef __int16_t __int_least16_t; -typedef __uint16_t __uint_least16_t; -typedef __int32_t __int_least32_t; -typedef __uint32_t __uint_least32_t; -typedef __int64_t __int_least64_t; -typedef __uint64_t __uint_least64_t; - -/* 7.18.1.3 Fastest minimum-width integer types */ -typedef __int32_t __int_fast8_t; -typedef __uint32_t __uint_fast8_t; -typedef __int32_t __int_fast16_t; -typedef __uint32_t __uint_fast16_t; -typedef __int32_t __int_fast32_t; -typedef __uint32_t __uint_fast32_t; -typedef __int64_t __int_fast64_t; -typedef __uint64_t __uint_fast64_t; -#define __INT_FAST8_MIN INT32_MIN -#define __INT_FAST16_MIN INT32_MIN -#define __INT_FAST32_MIN INT32_MIN -#define __INT_FAST64_MIN INT64_MIN -#define __INT_FAST8_MAX INT32_MAX -#define __INT_FAST16_MAX INT32_MAX -#define __INT_FAST32_MAX INT32_MAX -#define __INT_FAST64_MAX INT64_MAX -#define __UINT_FAST8_MAX UINT32_MAX -#define __UINT_FAST16_MAX UINT32_MAX -#define __UINT_FAST32_MAX UINT32_MAX -#define __UINT_FAST64_MAX UINT64_MAX - -/* 7.18.1.4 Integer types capable of holding object pointers */ -typedef long __intptr_t; -typedef unsigned long __uintptr_t; - -/* 7.18.1.5 Greatest-width integer types */ -typedef __int64_t __intmax_t; -typedef __uint64_t __uintmax_t; - -/* Register size */ -typedef long __register_t; - -/* VM system types */ -typedef unsigned long __vaddr_t; -typedef unsigned long __paddr_t; -typedef unsigned long __vsize_t; -typedef unsigned long __psize_t; - -/* Standard system types */ -typedef double __double_t; -typedef float __float_t; -typedef long __ptrdiff_t; -typedef unsigned long __size_t; -typedef long __ssize_t; -#if defined(__GNUC__) && __GNUC__ >= 3 -typedef __builtin_va_list __va_list; -#else -typedef double __va_list; -#endif - -/* Wide character support types */ -#ifndef __cplusplus -typedef int __wchar_t; -#endif -typedef int __wint_t; -typedef int __rune_t; -typedef void * __wctrans_t; -typedef void * __wctype_t; - -#endif /* _MACHINE__TYPES_H_ */ diff --git a/sys/arch/hppa/include/asm.h b/sys/arch/hppa/include/asm.h deleted file mode 100644 index 1ca875cb8..000000000 --- a/sys/arch/hppa/include/asm.h +++ /dev/null @@ -1,271 +0,0 @@ -/* $OpenBSD: asm.h,v 1.19 2017/06/23 09:55:10 mpi Exp $ */ - -/* - * Copyright (c) 1990,1991,1994 The University of Utah and - * the Computer Systems Laboratory (CSL). All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: asm.h 1.8 94/12/14$ - */ - -#ifndef _MACHINE_ASM_H_ -#define _MACHINE_ASM_H_ - -/* - * hppa assembler definitions - */ - -/* - * Hardware General Registers - */ -r0 .reg %r0 -r1 .reg %r1 -r2 .reg %r2 -r3 .reg %r3 -r4 .reg %r4 -r5 .reg %r5 -r6 .reg %r6 -r7 .reg %r7 -r8 .reg %r8 -r9 .reg %r9 -r10 .reg %r10 -r11 .reg %r11 -r12 .reg %r12 -r13 .reg %r13 -r14 .reg %r14 -r15 .reg %r15 -r16 .reg %r16 -r17 .reg %r17 -r18 .reg %r18 -r19 .reg %r19 -r20 .reg %r20 -r21 .reg %r21 -r22 .reg %r22 -r23 .reg %r23 -r24 .reg %r24 -r25 .reg %r25 -r26 .reg %r26 -r27 .reg %r27 -r28 .reg %r28 -r29 .reg %r29 -r30 .reg %r30 -r31 .reg %r31 - -/* - * Hardware Space Registers - */ -sr0 .reg %sr0 -sr1 .reg %sr1 -sr2 .reg %sr2 -sr3 .reg %sr3 -sr4 .reg %sr4 -sr5 .reg %sr5 -sr6 .reg %sr6 -sr7 .reg %sr7 - -/* - * Hardware Floating Point Registers - */ -fr0 .reg %fr0 -fr1 .reg %fr1 -fr2 .reg %fr2 -fr3 .reg %fr3 -fr4 .reg %fr4 -fr5 .reg %fr5 -fr6 .reg %fr6 -fr7 .reg %fr7 -fr8 .reg %fr8 -fr9 .reg %fr9 -fr10 .reg %fr10 -fr11 .reg %fr11 -fr12 .reg %fr12 -fr13 .reg %fr13 -fr14 .reg %fr14 -fr15 .reg %fr15 -fr16 .reg %fr16 -fr17 .reg %fr17 -fr18 .reg %fr18 -fr19 .reg %fr19 -fr20 .reg %fr20 -fr21 .reg %fr21 -fr22 .reg %fr22 -fr23 .reg %fr23 -fr24 .reg %fr24 -fr25 .reg %fr25 -fr26 .reg %fr26 -fr27 .reg %fr27 -fr28 .reg %fr28 -fr29 .reg %fr29 -fr30 .reg %fr30 -fr31 .reg %fr31 - -/* - * Hardware Control Registers - */ -cr0 .reg %cr0 -cr8 .reg %cr8 -cr9 .reg %cr9 -cr10 .reg %cr10 -cr11 .reg %cr11 -cr12 .reg %cr12 -cr13 .reg %cr13 -cr14 .reg %cr14 -cr15 .reg %cr15 -cr16 .reg %cr16 -cr17 .reg %cr17 -cr18 .reg %cr18 -cr19 .reg %cr19 -cr20 .reg %cr20 -cr21 .reg %cr21 -cr22 .reg %cr22 -cr23 .reg %cr23 -cr24 .reg %cr24 -cr25 .reg %cr25 -cr26 .reg %cr26 -cr27 .reg %cr27 -cr28 .reg %cr28 -cr29 .reg %cr29 -cr30 .reg %cr30 -cr31 .reg %cr31 - -rctr .reg %cr0 -pidr1 .reg %cr8 -pidr2 .reg %cr9 -ccr .reg %cr10 -sar .reg %cr11 -pidr3 .reg %cr12 -pidr4 .reg %cr13 -iva .reg %cr14 -eiem .reg %cr15 -itmr .reg %cr16 -pcsq .reg %cr17 -pcoq .reg %cr18 -iir .reg %cr19 -isr .reg %cr20 -ior .reg %cr21 -ipsw .reg %cr22 -eirr .reg %cr23 -tr0 .reg %cr24 -vtop .reg %cr25 -tr1 .reg %cr25 -tr2 .reg %cr26 -tr3 .reg %cr27 -tr4 .reg %cr28 -tr5 .reg %cr29 -tr6 .reg %cr30 -tr7 .reg %cr31 - -/* - * Calling Convention - */ -rp .reg %r2 -arg3 .reg %r23 -arg2 .reg %r24 -arg1 .reg %r25 -arg0 .reg %r26 -dp .reg %r27 -ret0 .reg %r28 -ret1 .reg %r29 -sl .reg %r29 -sp .reg %r30 - -/* - * Temporary registers - */ -t1 .reg %r22 -t2 .reg %r21 -t3 .reg %r20 -t4 .reg %r19 - -/* - * Temporary space registers - */ -ts1 .reg %sr2 - -/* - * Space Registers - SW Conventions - */ -sret .reg %sr1 ; return value -sarg .reg %sr1 ; argument - -/* - * Floating Point Registers - SW Conventions - */ -farg0 .reg %fr5 -farg1 .reg %fr6 -farg2 .reg %fr7 -farg3 .reg %fr8 -fret .reg %fr4 - -/* - * Temporary floating point registers - */ -tf1 .reg %fr11 -tf2 .reg %fr10 -tf3 .reg %fr9 -tf4 .reg %fr8 - -#ifdef __STDC__ -#define __CONCAT(a,b) a ## b -#else -#define __CONCAT(a,b) a/**/b -#endif - -#if defined(PROF) || defined(GPROF) -#define _PROF_PROLOGUE !\ -1: !\ - stw rp, HPPA_FRAME_CRP(sr0,sp) !\ - stw arg0, HPPA_FRAME_ARG(0)(sr0,sp) !\ - stw arg1, HPPA_FRAME_ARG(1)(sr0,sp) !\ - stw arg2, HPPA_FRAME_ARG(2)(sr0,sp) !\ - stw arg3, HPPA_FRAME_ARG(3)(sr0,sp) !\ - ldo HPPA_FRAME_SIZE(sp), sp !\ - copy rp, arg0 !\ - bl 2f, arg1 !\ - depi 0, 31, 2, arg1 !\ -2: !\ - bl _mcount, rp !\ - ldo 1b - 2b(arg1), arg1 !\ - ldo -HPPA_FRAME_SIZE(sp), sp !\ - ldw HPPA_FRAME_ARG(3)(sr0,sp), arg3 !\ - ldw HPPA_FRAME_ARG(2)(sr0,sp), arg2 !\ - ldw HPPA_FRAME_ARG(1)(sr0,sp), arg1 !\ - ldw HPPA_FRAME_ARG(0)(sr0,sp), arg0 !\ - ldw HPPA_FRAME_CRP(sr0,sp) ,rp -#else -#define _PROF_PROLOGUE -#endif - -#define LEAF_ENTRY(x) ! .text ! .align 4 !\ - .export x, entry ! .label x ! .proc !\ - .callinfo frame=0,no_calls,save_rp !\ - .entry ! _PROF_PROLOGUE - -#define ENTRY(x,n) ! .text ! .align 4 !\ - .export x, entry ! .label x ! .proc !\ - .callinfo frame=n,calls, save_rp, save_sp !\ - .entry ! _PROF_PROLOGUE - -#define ALTENTRY(x) ! .export x, entry ! .label x -#define EXIT(x) ! .exit ! .procend ! .size x, .-x - -#define BSS(n,s) ! .data ! .label n ! .comm s - -#define STRONG_ALIAS(alias,sym) ! .global alias ! .set alias, sym -#define WEAK_ALIAS(alias,sym) ! .weak alias ! .set alias, sym - -#endif /* _MACHINE_ASM_H_ */ diff --git a/sys/arch/hppa/include/atomic.h b/sys/arch/hppa/include/atomic.h deleted file mode 100644 index b7ecc3c2c..000000000 --- a/sys/arch/hppa/include/atomic.h +++ /dev/null @@ -1,266 +0,0 @@ -/* $OpenBSD: atomic.h,v 1.12 2023/04/10 04:21:20 jsg Exp $ */ - -/* Public Domain */ - -#ifndef _MACHINE_ATOMIC_H_ -#define _MACHINE_ATOMIC_H_ - -#if defined(_KERNEL) - -typedef volatile u_int __cpu_simple_lock_t __attribute__((__aligned__(16))); - -#define __SIMPLELOCK_LOCKED 0 -#define __SIMPLELOCK_UNLOCKED 1 - -static inline void -__cpu_simple_lock_init(__cpu_simple_lock_t *l) -{ - *l = __SIMPLELOCK_UNLOCKED; -} - -static inline unsigned int -__cpu_simple_lock_ldcws(__cpu_simple_lock_t *l) -{ - unsigned int o; - - asm volatile("ldcws 0(%2), %0" : "=&r" (o), "+m" (l) : "r" (l)); - - return (o); -} - -static inline int -__cpu_simple_lock_try(__cpu_simple_lock_t *l) -{ - return (__cpu_simple_lock_ldcws(l) == __SIMPLELOCK_UNLOCKED); -} - -static inline void -__cpu_simple_lock(__cpu_simple_lock_t *l) -{ - while (!__cpu_simple_lock_ldcws(l)) - ; -} - -static inline void -__cpu_simple_unlock(__cpu_simple_lock_t *l) -{ - *l = __SIMPLELOCK_UNLOCKED; -} - -#ifdef MULTIPROCESSOR -extern __cpu_simple_lock_t atomic_lock; -#define ATOMIC_LOCK __cpu_simple_lock(&atomic_lock); -#define ATOMIC_UNLOCK __cpu_simple_unlock(&atomic_lock); -#else -#define ATOMIC_LOCK -#define ATOMIC_UNLOCK -#endif - -static inline register_t -atomic_enter(void) -{ - register_t eiem; - - __asm volatile("mfctl %%cr15, %0": "=r" (eiem)); - __asm volatile("mtctl %r0, %cr15"); - ATOMIC_LOCK; - - return (eiem); -} - -static inline void -atomic_leave(register_t eiem) -{ - ATOMIC_UNLOCK; - __asm volatile("mtctl %0, %%cr15":: "r" (eiem)); -} - -static inline unsigned int -_atomic_cas_uint(volatile unsigned int *uip, unsigned int o, unsigned int n) -{ - register_t eiem; - unsigned int rv; - - eiem = atomic_enter(); - rv = *uip; - if (rv == o) - *uip = n; - atomic_leave(eiem); - - return (rv); -} -#define atomic_cas_uint(_p, _o, _n) _atomic_cas_uint((_p), (_o), (_n)) - -static inline unsigned long -_atomic_cas_ulong(volatile unsigned long *uip, unsigned long o, unsigned long n) -{ - register_t eiem; - unsigned long rv; - - eiem = atomic_enter(); - rv = *uip; - if (rv == o) - *uip = n; - atomic_leave(eiem); - - return (rv); -} -#define atomic_cas_ulong(_p, _o, _n) _atomic_cas_ulong((_p), (_o), (_n)) - -static inline void * -_atomic_cas_ptr(volatile void *uip, void *o, void *n) -{ - register_t eiem; - void * volatile *uipp = (void * volatile *)uip; - void *rv; - - eiem = atomic_enter(); - rv = *uipp; - if (rv == o) - *uipp = n; - atomic_leave(eiem); - - return (rv); -} -#define atomic_cas_ptr(_p, _o, _n) _atomic_cas_ptr((_p), (_o), (_n)) - -static inline unsigned int -_atomic_swap_uint(volatile unsigned int *uip, unsigned int n) -{ - register_t eiem; - unsigned int rv; - - eiem = atomic_enter(); - rv = *uip; - *uip = n; - atomic_leave(eiem); - - return (rv); -} -#define atomic_swap_uint(_p, _n) _atomic_swap_uint((_p), (_n)) - -static inline unsigned long -_atomic_swap_ulong(volatile unsigned long *uip, unsigned long n) -{ - register_t eiem; - unsigned long rv; - - eiem = atomic_enter(); - rv = *uip; - *uip = n; - atomic_leave(eiem); - - return (rv); -} -#define atomic_swap_ulong(_p, _n) _atomic_swap_ulong((_p), (_n)) - -static inline void * -_atomic_swap_ptr(volatile void *uip, void *n) -{ - register_t eiem; - void * volatile *uipp = (void * volatile *)uip; - void *rv; - - eiem = atomic_enter(); - rv = *uipp; - *uipp = n; - atomic_leave(eiem); - - return (rv); -} -#define atomic_swap_ptr(_p, _n) _atomic_swap_ptr((_p), (_n)) - -static __inline unsigned int -_atomic_add_int_nv(volatile unsigned int *uip, unsigned int v) -{ - register_t eiem; - unsigned int rv; - - eiem = atomic_enter(); - rv = *uip + v; - *uip = rv; - atomic_leave(eiem); - - return (rv); -} -#define atomic_add_int_nv(_uip, _v) _atomic_add_int_nv((_uip), (_v)) -#define atomic_sub_int_nv(_uip, _v) _atomic_add_int_nv((_uip), 0 - (_v)) - -static __inline unsigned long -_atomic_add_long_nv(volatile unsigned long *uip, unsigned long v) -{ - register_t eiem; - unsigned long rv; - - eiem = atomic_enter(); - rv = *uip + v; - *uip = rv; - atomic_leave(eiem); - - return (rv); -} -#define atomic_add_long_nv(_uip, _v) _atomic_add_long_nv((_uip), (_v)) -#define atomic_sub_long_nv(_uip, _v) _atomic_add_long_nv((_uip), 0 - (_v)) - -static __inline void -atomic_setbits_int(volatile unsigned int *uip, unsigned int v) -{ - register_t eiem; - - eiem = atomic_enter(); - *uip |= v; - atomic_leave(eiem); -} - -static __inline void -atomic_clearbits_int(volatile unsigned int *uip, unsigned int v) -{ - register_t eiem; - - eiem = atomic_enter(); - *uip &= ~v; - atomic_leave(eiem); -} - -static __inline void -atomic_setbits_long(volatile unsigned long *uip, unsigned long v) -{ - register_t eiem; - - eiem = atomic_enter(); - *uip |= v; - atomic_leave(eiem); -} - -static __inline void -atomic_clearbits_long(volatile unsigned long *uip, unsigned long v) -{ - register_t eiem; - - eiem = atomic_enter(); - *uip &= ~v; - atomic_leave(eiem); -} - -#endif /* defined(_KERNEL) */ - -/* - * Although the PA-RISC 2.0 architecture allows an implementation to - * be weakly ordered, all PA-RISC processors to date implement a - * strong memory ordering model. So all we need is a compiler - * barrier. - */ - -static inline void -__insn_barrier(void) -{ - __asm volatile("" : : : "memory"); -} - -#define membar_enter() __insn_barrier() -#define membar_exit() __insn_barrier() -#define membar_producer() __insn_barrier() -#define membar_consumer() __insn_barrier() -#define membar_sync() __insn_barrier() - -#endif /* _MACHINE_ATOMIC_H_ */ diff --git a/sys/arch/hppa/include/autoconf.h b/sys/arch/hppa/include/autoconf.h deleted file mode 100644 index ec0398439..000000000 --- a/sys/arch/hppa/include/autoconf.h +++ /dev/null @@ -1,83 +0,0 @@ -/* $OpenBSD: autoconf.h,v 1.24 2021/03/11 11:16:57 jsg Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include - -struct confargs { - const char *ca_name; /* device name/description */ - bus_space_tag_t ca_iot; /* io tag */ - bus_dma_tag_t ca_dmatag; /* DMA tag */ - struct device_path ca_dp; /* device_path as found by pdc_scan */ - hppa_hpa_t ca_hpa; /* module HPA */ - u_int ca_hpasz; /* module HPA size (if avail) */ - hppa_hpa_t ca_hpamask; /* mask for modules on the bus */ - int ca_irq; /* module IRQ */ - struct iodc_data ca_type; /* iodc-specific type description */ - struct pdc_iodc_read *ca_pdc_iodc_read; - int ca_naddrs; /* number of valid addr ents */ - struct { - hppa_hpa_t addr; - u_int size; - } ca_addrs[16]; /* 16 is ought to be enough */ - -}; - -#define hppacf_off cf_loc[0] -#define hppacf_irq cf_loc[1] - -/* this is used for hppa_knownmodules table - * describing known to this port modules, - * system boards, cpus, fpus and busses - */ -struct hppa_mod_info { - int mi_type; - int mi_sv; - const char *mi_name; -}; - -extern void (*cold_hook)(int); -#define HPPA_COLD_COLD 0 -#define HPPA_COLD_HOT 1 -#define HPPA_COLD_OFF 2 - -struct device; - -const char *hppa_mod_info(int, int); -void pdc_scanbus(struct device *, struct confargs *, int, hppa_hpa_t hpa, - int); -int mbprint(void *, const char *); -int mbsubmatch(struct device *, void *, void *); -int cpu_intr_findirq(void); -void *cpu_intr_map(void *v, int pri, int irq, int (*handler)(void *), - void *arg, const char *name); -void *cpu_intr_establish(int pri, int irq, int (*handler)(void *), - void *arg, const char *name); -int clock_intr(void *); - -void dumpconf(void); diff --git a/sys/arch/hppa/include/bus.h b/sys/arch/hppa/include/bus.h deleted file mode 100644 index c4dbd6835..000000000 --- a/sys/arch/hppa/include/bus.h +++ /dev/null @@ -1,427 +0,0 @@ -/* $OpenBSD: bus.h,v 1.32 2017/05/08 00:27:45 dlg Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#ifndef _MACHINE_BUS_H_ -#define _MACHINE_BUS_H_ - -#include - -/* addresses in bus space */ -typedef u_long bus_addr_t; -typedef u_long bus_size_t; - -/* access methods for bus space */ -typedef u_long bus_space_handle_t; - -struct hppa_bus_space_tag { - void *hbt_cookie; - - int (*hbt_map)(void *v, bus_addr_t addr, bus_size_t size, - int flags, bus_space_handle_t *bshp); - void (*hbt_unmap)(void *v, bus_space_handle_t bsh, bus_size_t size); - int (*hbt_subregion)(void *v, bus_space_handle_t bsh, - bus_size_t offset, bus_size_t size, - bus_space_handle_t *nbshp); - int (*hbt_alloc)(void *v, bus_addr_t rstart, bus_addr_t rend, - bus_size_t size, bus_size_t align, bus_size_t boundary, - int flags, bus_addr_t *addrp, bus_space_handle_t *bshp); - void (*hbt_free)(void *, bus_space_handle_t, bus_size_t); - void (*hbt_barrier)(void *v, bus_space_handle_t h, - bus_size_t o, bus_size_t l, int op); - void *(*hbt_vaddr)(void *v, bus_space_handle_t h); - - u_int8_t (*hbt_r1)(void *, bus_space_handle_t, bus_size_t); - u_int16_t (*hbt_r2)(void *, bus_space_handle_t, bus_size_t); - u_int32_t (*hbt_r4)(void *, bus_space_handle_t, bus_size_t); - u_int64_t (*hbt_r8)(void *, bus_space_handle_t, bus_size_t); - - void (*hbt_w1)(void *, bus_space_handle_t, bus_size_t, u_int8_t); - void (*hbt_w2)(void *, bus_space_handle_t, bus_size_t, u_int16_t); - void (*hbt_w4)(void *, bus_space_handle_t, bus_size_t, u_int32_t); - void (*hbt_w8)(void *, bus_space_handle_t, bus_size_t, u_int64_t); - - void (*hbt_rm_1)(void *v, bus_space_handle_t h, - bus_size_t o, u_int8_t *a, bus_size_t c); - void (*hbt_rm_2)(void *v, bus_space_handle_t h, - bus_size_t o, u_int16_t *a, bus_size_t c); - void (*hbt_rm_4)(void *v, bus_space_handle_t h, - bus_size_t o, u_int32_t *a, bus_size_t c); - void (*hbt_rm_8)(void *v, bus_space_handle_t h, - bus_size_t o, u_int64_t *a, bus_size_t c); - - void (*hbt_wm_1)(void *v, bus_space_handle_t h, bus_size_t o, - const u_int8_t *a, bus_size_t c); - void (*hbt_wm_2)(void *v, bus_space_handle_t h, bus_size_t o, - const u_int16_t *a, bus_size_t c); - void (*hbt_wm_4)(void *v, bus_space_handle_t h, bus_size_t o, - const u_int32_t *a, bus_size_t c); - void (*hbt_wm_8)(void *v, bus_space_handle_t h, bus_size_t o, - const u_int64_t *a, bus_size_t c); - - void (*hbt_sm_1)(void *v, bus_space_handle_t h, bus_size_t o, - u_int8_t vv, bus_size_t c); - void (*hbt_sm_2)(void *v, bus_space_handle_t h, bus_size_t o, - u_int16_t vv, bus_size_t c); - void (*hbt_sm_4)(void *v, bus_space_handle_t h, bus_size_t o, - u_int32_t vv, bus_size_t c); - void (*hbt_sm_8)(void *v, bus_space_handle_t h, bus_size_t o, - u_int64_t vv, bus_size_t c); - - void (*hbt_rrm_2)(void *v, bus_space_handle_t h, - bus_size_t o, u_int8_t *a, bus_size_t c); - void (*hbt_rrm_4)(void *v, bus_space_handle_t h, - bus_size_t o, u_int8_t *a, bus_size_t c); - void (*hbt_rrm_8)(void *v, bus_space_handle_t h, - bus_size_t o, u_int8_t *a, bus_size_t c); - - void (*hbt_wrm_2)(void *v, bus_space_handle_t h, - bus_size_t o, const u_int8_t *a, bus_size_t c); - void (*hbt_wrm_4)(void *v, bus_space_handle_t h, - bus_size_t o, const u_int8_t *a, bus_size_t c); - void (*hbt_wrm_8)(void *v, bus_space_handle_t h, - bus_size_t o, const u_int8_t *a, bus_size_t c); - - void (*hbt_rr_1)(void *v, bus_space_handle_t h, - bus_size_t o, u_int8_t *a, bus_size_t c); - void (*hbt_rr_2)(void *v, bus_space_handle_t h, - bus_size_t o, u_int16_t *a, bus_size_t c); - void (*hbt_rr_4)(void *v, bus_space_handle_t h, - bus_size_t o, u_int32_t *a, bus_size_t c); - void (*hbt_rr_8)(void *v, bus_space_handle_t h, - bus_size_t o, u_int64_t *a, bus_size_t c); - - void (*hbt_wr_1)(void *v, bus_space_handle_t h, - bus_size_t o, const u_int8_t *a, bus_size_t c); - void (*hbt_wr_2)(void *v, bus_space_handle_t h, - bus_size_t o, const u_int16_t *a, bus_size_t c); - void (*hbt_wr_4)(void *v, bus_space_handle_t h, - bus_size_t o, const u_int32_t *a, bus_size_t c); - void (*hbt_wr_8)(void *v, bus_space_handle_t h, - bus_size_t o, const u_int64_t *a, bus_size_t c); - - void (*hbt_rrr_2)(void *v, bus_space_handle_t h, - bus_size_t o, u_int8_t *a, bus_size_t c); - void (*hbt_rrr_4)(void *v, bus_space_handle_t h, - bus_size_t o, u_int8_t *a, bus_size_t c); - void (*hbt_rrr_8)(void *v, bus_space_handle_t h, - bus_size_t o, u_int8_t *a, bus_size_t c); - - void (*hbt_wrr_2)(void *v, bus_space_handle_t h, - bus_size_t o, const u_int8_t *a, bus_size_t c); - void (*hbt_wrr_4)(void *v, bus_space_handle_t h, - bus_size_t o, const u_int8_t *a, bus_size_t c); - void (*hbt_wrr_8)(void *v, bus_space_handle_t h, - bus_size_t o, const u_int8_t *a, bus_size_t c); - - void (*hbt_sr_1)(void *v, bus_space_handle_t h, - bus_size_t o, u_int8_t vv, bus_size_t c); - void (*hbt_sr_2)(void *v, bus_space_handle_t h, - bus_size_t o, u_int16_t vv, bus_size_t c); - void (*hbt_sr_4)(void *v, bus_space_handle_t h, - bus_size_t o, u_int32_t vv, bus_size_t c); - void (*hbt_sr_8)(void *v, bus_space_handle_t h, - bus_size_t o, u_int64_t vv, bus_size_t c); - - void (*hbt_cp_1)(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c); - void (*hbt_cp_2)(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c); - void (*hbt_cp_4)(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c); - void (*hbt_cp_8)(void *v, bus_space_handle_t h1, bus_size_t o1, - bus_space_handle_t h2, bus_size_t o2, bus_size_t c); -}; -typedef const struct hppa_bus_space_tag *bus_space_tag_t; -extern const struct hppa_bus_space_tag hppa_bustag; - -/* flags for bus space map functions */ -#define BUS_SPACE_MAP_CACHEABLE 0x0001 -#define BUS_SPACE_MAP_LINEAR 0x0002 -#define BUS_SPACE_MAP_READONLY 0x0004 -#define BUS_SPACE_MAP_PREFETCHABLE 0x0008 - -/* bus access routines */ - -#define bus_space_map(t,a,c,ca,hp) \ - (((t)->hbt_map)((t)->hbt_cookie,(a),(c),(ca),(hp))) -#define bus_space_unmap(t,h,c) \ - (((t)->hbt_unmap)((t)->hbt_cookie,(h),(c))) -#define bus_space_subregion(t,h,o,c,hp) \ - (((t)->hbt_subregion)((t)->hbt_cookie,(h),(o),(c),(hp))) -#define bus_space_alloc(t,b,e,c,al,bn,ca,ap,hp) \ - (((t)->hbt_alloc)((t)->hbt_cookie,(b),(e),(c),(al),(bn),(ca),(ap),(hp))) -#define bus_space_free(t,h,c) \ - (((t)->hbt_free)((t)->hbt_cookie,(h),(c))) - -#define bus_space_read_1(t,h,o) (((t)->hbt_r1)((t)->hbt_cookie,(h),(o))) -#define bus_space_read_2(t,h,o) (((t)->hbt_r2)((t)->hbt_cookie,(h),(o))) -#define bus_space_read_4(t,h,o) (((t)->hbt_r4)((t)->hbt_cookie,(h),(o))) -#define bus_space_read_8(t,h,o) (((t)->hbt_r8)((t)->hbt_cookie,(h),(o))) - -#define bus_space_write_1(t,h,o,v) (((t)->hbt_w1)((t)->hbt_cookie,(h),(o),(v))) -#define bus_space_write_2(t,h,o,v) (((t)->hbt_w2)((t)->hbt_cookie,(h),(o),(v))) -#define bus_space_write_4(t,h,o,v) (((t)->hbt_w4)((t)->hbt_cookie,(h),(o),(v))) -#define bus_space_write_8(t,h,o,v) (((t)->hbt_w8)((t)->hbt_cookie,(h),(o),(v))) - -#define bus_space_read_multi_1(t,h,o,a,c) \ - (((t)->hbt_rm_1)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_read_multi_2(t,h,o,a,c) \ - (((t)->hbt_rm_2)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_read_multi_4(t,h,o,a,c) \ - (((t)->hbt_rm_4)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_read_multi_8(t,h,o,a,c) \ - (((t)->hbt_rm_8)((t)->hbt_cookie, (h), (o), (a), (c))) - -#define bus_space_write_multi_1(t,h,o,a,c) \ - (((t)->hbt_wm_1)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_write_multi_2(t,h,o,a,c) \ - (((t)->hbt_wm_2)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_write_multi_4(t,h,o,a,c) \ - (((t)->hbt_wm_4)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_write_multi_8(t,h,o,a,c) \ - (((t)->hbt_wm_8)((t)->hbt_cookie, (h), (o), (a), (c))) - -#define bus_space_set_multi_1(t,h,o,v,c) \ - (((t)->hbt_sm_1)((t)->hbt_cookie, (h), (o), (v), (c))) -#define bus_space_set_multi_2(t,h,o,v,c) \ - (((t)->hbt_sm_2)((t)->hbt_cookie, (h), (o), (v), (c))) -#define bus_space_set_multi_4(t,h,o,v,c) \ - (((t)->hbt_sm_4)((t)->hbt_cookie, (h), (o), (v), (c))) -#define bus_space_set_multi_8(t,h,o,v,c) \ - (((t)->hbt_sm_8)((t)->hbt_cookie, (h), (o), (v), (c))) - -#define bus_space_read_raw_multi_2(t, h, o, a, c) \ - (((t)->hbt_rrm_2)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_read_raw_multi_4(t, h, o, a, c) \ - (((t)->hbt_rrm_4)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_read_raw_multi_8(t, h, o, a, c) \ - (((t)->hbt_rrm_8)((t)->hbt_cookie, (h), (o), (a), (c))) - -#define bus_space_write_raw_multi_2(t, h, o, a, c) \ - (((t)->hbt_wrm_2)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_write_raw_multi_4(t, h, o, a, c) \ - (((t)->hbt_wrm_4)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_write_raw_multi_8(t, h, o, a, c) \ - (((t)->hbt_wrm_8)((t)->hbt_cookie, (h), (o), (a), (c))) - -#define bus_space_read_region_1(t, h, o, a, c) \ - (((t)->hbt_rr_1)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_read_region_2(t, h, o, a, c) \ - (((t)->hbt_rr_2)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_read_region_4(t, h, o, a, c) \ - (((t)->hbt_rr_4)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_read_region_8(t, h, o, a, c) \ - (((t)->hbt_rr_8)((t)->hbt_cookie, (h), (o), (a), (c))) - -#define bus_space_write_region_1(t, h, o, a, c) \ - (((t)->hbt_wr_1)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_write_region_2(t, h, o, a, c) \ - (((t)->hbt_wr_2)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_write_region_4(t, h, o, a, c) \ - (((t)->hbt_wr_4)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_write_region_8(t, h, o, a, c) \ - (((t)->hbt_wr_8)((t)->hbt_cookie, (h), (o), (a), (c))) - -#define bus_space_read_raw_region_2(t, h, o, a, c) \ - (((t)->hbt_rrr_2)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_read_raw_region_4(t, h, o, a, c) \ - (((t)->hbt_rrr_4)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_read_raw_region_8(t, h, o, a, c) \ - (((t)->hbt_rrr_8)((t)->hbt_cookie, (h), (o), (a), (c))) - -#define bus_space_write_raw_region_2(t, h, o, a, c) \ - (((t)->hbt_wrr_2)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_write_raw_region_4(t, h, o, a, c) \ - (((t)->hbt_wrr_4)((t)->hbt_cookie, (h), (o), (a), (c))) -#define bus_space_write_raw_region_8(t, h, o, a, c) \ - (((t)->hbt_wrr_8)((t)->hbt_cookie, (h), (o), (a), (c))) - -#define bus_space_set_region_1(t, h, o, v, c) \ - (((t)->hbt_sr_1)((t)->hbt_cookie, (h), (o), (v), (c))) -#define bus_space_set_region_2(t, h, o, v, c) \ - (((t)->hbt_sr_2)((t)->hbt_cookie, (h), (o), (v), (c))) -#define bus_space_set_region_4(t, h, o, v, c) \ - (((t)->hbt_sr_4)((t)->hbt_cookie, (h), (o), (v), (c))) -#define bus_space_set_region_8(t, h, o, v, c) \ - (((t)->hbt_sr_8)((t)->hbt_cookie, (h), (o), (v), (c))) - -#define bus_space_copy_1(t, h1, o1, h2, o2, c) \ - (((t)->hbt_cp_1)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c))) -#define bus_space_copy_2(t, h1, o1, h2, o2, c) \ - (((t)->hbt_cp_2)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c))) -#define bus_space_copy_4(t, h1, o1, h2, o2, c) \ - (((t)->hbt_cp_4)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c))) -#define bus_space_copy_8(t, h1, o1, h2, o2, c) \ - (((t)->hbt_cp_8)((t)->hbt_cookie, (h1), (o1), (h2), (o2), (c))) - -#define BUS_SPACE_BARRIER_READ 0x01 -#define BUS_SPACE_BARRIER_WRITE 0x02 - -#define bus_space_barrier(t,h,o,l,op) \ - ((t)->hbt_barrier((t)->hbt_cookie, (h), (o), (l), (op))) -#define bus_space_vaddr(t,h) \ - ((t)->hbt_vaddr((t)->hbt_cookie, (h))) - -#define BUS_DMA_WAITOK 0x0000 /* safe to sleep (pseudo-flag) */ -#define BUS_DMA_NOWAIT 0x0001 /* not safe to sleep */ -#define BUS_DMA_ALLOCNOW 0x0002 /* perform resource allocation now */ -#define BUS_DMA_COHERENT 0x0004 /* hint: map memory DMA coherent */ -#define BUS_DMA_BUS1 0x0020 /* placeholders for bus functions... */ -#define BUS_DMA_BUS2 0x0040 -#define BUS_DMA_BUS3 0x0080 -#define BUS_DMA_BUS4 0x0100 -#define BUS_DMA_STREAMING 0x0200 /* hint: sequential, unidirectional */ -#define BUS_DMA_READ 0x0400 /* mapping is device -> memory only */ -#define BUS_DMA_WRITE 0x0800 /* mapping is memory -> device only */ -#define BUS_DMA_ZERO 0x1000 /* zero memory in dmamem_alloc */ -#define BUS_DMA_64BIT 0x2000 /* device handles 64bit dva */ - -/* Forwards needed by prototypes below. */ -struct mbuf; -struct proc; -struct uio; - -/* Operations performed by bus_dmamap_sync(). */ -#define BUS_DMASYNC_POSTREAD 0x01 -#define BUS_DMASYNC_POSTWRITE 0x02 -#define BUS_DMASYNC_PREREAD 0x04 -#define BUS_DMASYNC_PREWRITE 0x08 - -typedef const struct hppa_bus_dma_tag *bus_dma_tag_t; -typedef struct hppa_bus_dmamap *bus_dmamap_t; - -/* - * bus_dma_segment_t - * - * Describes a single contiguous DMA transaction. Values - * are suitable for programming into DMA registers. - */ -struct hppa_bus_dma_segment { - vaddr_t _ds_va; /* needed for syncing */ - - bus_addr_t ds_addr; /* DMA address */ - bus_size_t ds_len; /* length of transfer */ -}; -typedef struct hppa_bus_dma_segment bus_dma_segment_t; - -/* - * bus_dma_tag_t - * - * A machine-dependent opaque type describing the implementation of - * DMA for a given bus. - */ - -struct hppa_bus_dma_tag { - void *_cookie; /* cookie used in the guts */ - - /* - * DMA mapping methods. - */ - int (*_dmamap_create)(void *, bus_size_t, int, - bus_size_t, bus_size_t, int, bus_dmamap_t *); - void (*_dmamap_destroy)(void *, bus_dmamap_t); - int (*_dmamap_load)(void *, bus_dmamap_t, void *, - bus_size_t, struct proc *, int); - int (*_dmamap_load_mbuf)(void *, bus_dmamap_t, - struct mbuf *, int); - int (*_dmamap_load_uio)(void *, bus_dmamap_t, - struct uio *, int); - int (*_dmamap_load_raw)(void *, bus_dmamap_t, - bus_dma_segment_t *, int, bus_size_t, int); - void (*_dmamap_unload)(void *, bus_dmamap_t); - void (*_dmamap_sync)(void *, bus_dmamap_t, bus_addr_t, - bus_size_t, int); - - /* - * DMA memory utility functions. - */ - int (*_dmamem_alloc)(void *, bus_size_t, bus_size_t, - bus_size_t, bus_dma_segment_t *, int, int *, int); - void (*_dmamem_free)(void *, bus_dma_segment_t *, int); - int (*_dmamem_map)(void *, bus_dma_segment_t *, - int, size_t, caddr_t *, int); - void (*_dmamem_unmap)(void *, caddr_t, size_t); - paddr_t (*_dmamem_mmap)(void *, bus_dma_segment_t *, - int, off_t, int, int); -}; - -#define bus_dmamap_create(t, s, n, m, b, f, p) \ - (*(t)->_dmamap_create)((t)->_cookie, (s), (n), (m), (b), (f), (p)) -#define bus_dmamap_destroy(t, p) \ - (*(t)->_dmamap_destroy)((t)->_cookie, (p)) -#define bus_dmamap_load(t, m, b, s, p, f) \ - (*(t)->_dmamap_load)((t)->_cookie, (m), (b), (s), (p), (f)) -#define bus_dmamap_load_mbuf(t, m, b, f) \ - (*(t)->_dmamap_load_mbuf)((t)->_cookie, (m), (b), (f)) -#define bus_dmamap_load_uio(t, m, u, f) \ - (*(t)->_dmamap_load_uio)((t)->_cookie, (m), (u), (f)) -#define bus_dmamap_load_raw(t, m, sg, n, s, f) \ - (*(t)->_dmamap_load_raw)((t)->_cookie, (m), (sg), (n), (s), (f)) -#define bus_dmamap_unload(t, p) \ - (*(t)->_dmamap_unload)((t)->_cookie, (p)) -#define bus_dmamap_sync(t, p, a, l, o) \ - (void)((t)->_dmamap_sync ? \ - (*(t)->_dmamap_sync)((t)->_cookie, (p), (a), (l), (o)) : (void)0) - -#define bus_dmamem_alloc(t, s, a, b, sg, n, r, f) \ - (*(t)->_dmamem_alloc)((t)->_cookie, (s), (a), (b), (sg), (n), (r), (f)) -#define bus_dmamem_free(t, sg, n) \ - (*(t)->_dmamem_free)((t)->_cookie, (sg), (n)) -#define bus_dmamem_map(t, sg, n, s, k, f) \ - (*(t)->_dmamem_map)((t)->_cookie, (sg), (n), (s), (k), (f)) -#define bus_dmamem_unmap(t, k, s) \ - (*(t)->_dmamem_unmap)((t)->_cookie, (k), (s)) -#define bus_dmamem_mmap(t, sg, n, o, p, f) \ - (*(t)->_dmamem_mmap)((t)->_cookie, (sg), (n), (o), (p), (f)) - -/* - * bus_dmamap_t - * - * Describes a DMA mapping. - */ -struct hppa_bus_dmamap { - /* - * PRIVATE MEMBERS: not for use by machine-independent code. - */ - bus_size_t _dm_size; /* largest DMA transfer mappable */ - int _dm_segcnt; /* number of segs this map can map */ - bus_size_t _dm_maxsegsz; /* largest possible segment */ - bus_size_t _dm_boundary; /* don't cross this */ - int _dm_flags; /* misc. flags */ - - void *_dm_cookie; /* cookie for bus-specific functions */ - - /* - * PUBLIC MEMBERS: these are used by machine-independent code. - */ - bus_size_t dm_mapsize; /* size of the mapping */ - int dm_nsegs; /* # valid segments in mapping */ - bus_dma_segment_t dm_segs[1]; /* segments; variable length */ -}; - -#endif /* _MACHINE_BUS_H_ */ diff --git a/sys/arch/hppa/include/cdefs.h b/sys/arch/hppa/include/cdefs.h deleted file mode 100644 index 6fae9372f..000000000 --- a/sys/arch/hppa/include/cdefs.h +++ /dev/null @@ -1,43 +0,0 @@ -/* $OpenBSD: cdefs.h,v 1.10 2013/03/28 17:30:45 martynas Exp $ */ - -/* - * Copyright (c) 1995, 1996 Carnegie-Mellon University. - * All rights reserved. - * - * Author: Chris G. Demetriou - * - * Permission to use, copy, modify and distribute this software and - * its documentation is hereby granted, provided that both the copyright - * notice and this permission notice appear in all copies of the - * software, derivative works or modified versions, and any portions - * thereof, and that both notices appear in supporting documentation. - * - * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" - * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND - * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * Carnegie Mellon requests users of this software to return to - * - * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU - * School of Computer Science - * Carnegie Mellon University - * Pittsburgh PA 15213-3890 - * - * any improvements or extensions that they make and grant Carnegie the - * rights to redistribute these changes. - */ - -#ifndef _MACHINE_CDEFS_H_ -#define _MACHINE_CDEFS_H_ - -#define __strong_alias(alias,sym) \ - __asm__(".export " __STRING(alias) ", entry\n\t.global " \ - __STRING(alias) "\n\t" __STRING(alias) " = " __STRING(sym)) -#define __weak_alias(alias,sym) \ - __asm__(".export " __STRING(alias) ", entry\n\t.weak " \ - __STRING(alias) "\n\t" __STRING(alias) " = " __STRING(sym)) -#define __warn_references(sym,msg) \ - __asm__(".section .gnu.warning." __STRING(sym) \ - "\n\t.ascii \"" msg "\"\n\t.text") - -#endif /* !_MACHINE_CDEFS_H_ */ diff --git a/sys/arch/hppa/include/conf.h b/sys/arch/hppa/include/conf.h deleted file mode 100644 index 48a78709f..000000000 --- a/sys/arch/hppa/include/conf.h +++ /dev/null @@ -1,38 +0,0 @@ -/* $OpenBSD: conf.h,v 1.6 2011/11/14 14:29:53 deraadt Exp $ */ - -/* - * Copyright (c) 1998-2005 Michael Shalayeff - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _MACHINE_CONF_H_ -#define _MACHINE_CONF_H_ - -#include -struct tty; -struct termios; - -cdev_decl(pdc); -int pdcparam(struct tty *, struct termios *); -void pdcstart(struct tty *); - -#define mmread mmrw -#define mmwrite mmrw -cdev_decl(mm); - -cdev_decl(fd); -bdev_decl(fd); - -#endif /* _MACHINE_CONF_H_ */ diff --git a/sys/arch/hppa/include/cpu.h b/sys/arch/hppa/include/cpu.h deleted file mode 100644 index 5ccc82f48..000000000 --- a/sys/arch/hppa/include/cpu.h +++ /dev/null @@ -1,311 +0,0 @@ -/* $OpenBSD: cpu.h,v 1.99 2023/01/31 15:18:54 deraadt Exp $ */ - -/* - * Copyright (c) 2000-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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) 1988-1994, The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: cpu.h 1.19 94/12/16$ - */ - -#ifndef _MACHINE_CPU_H_ -#define _MACHINE_CPU_H_ - -#ifdef _KERNEL -#include -#include -#include -#endif /* _KERNEL */ - -/* - * CPU types and features - */ -#define HPPA_FTRS_TLBU 0x00000001 -#define HPPA_FTRS_BTLBU 0x00000002 -#define HPPA_FTRS_HVT 0x00000004 -#define HPPA_FTRS_W32B 0x00000008 - -#ifndef _LOCORE -#ifdef _KERNEL -#include -#include -#include -#include -#include - -#include - -/* - * Note that the alignment of ci_trap_save is important since we want to keep - * it within a single cache line. As a result, it must be kept as the first - * entry within the cpu_info struct. - */ -struct cpu_info { - register_t ci_trap_save[16]; - - struct device *ci_dev; - int ci_cpuid; - hppa_hpa_t ci_hpa; - volatile int ci_flags; - - struct proc *ci_curproc; - paddr_t ci_fpu_state; /* Process FPU state. */ - paddr_t ci_stack; - -#if defined(MULTIPROCESSOR) - struct srp_hazard ci_srp_hazards[SRP_HAZARD_NUM]; -#endif - - register_t ci_psw; /* Processor Status Word. */ - volatile int ci_cpl; - volatile u_long ci_mask; /* Hardware interrupt mask. */ - volatile u_long ci_ipending; - volatile int ci_in_intr; - int ci_want_resched; - - volatile u_long ci_ipi; /* IPIs pending. */ - struct mutex ci_ipi_mtx; - - struct schedstate_percpu ci_schedstate; - u_int32_t ci_randseed; -#ifdef DIAGNOSTIC - int ci_mutex_level; -#endif -#ifdef GPROF - struct gmonparam *ci_gmon; -#endif - struct clockintr_queue ci_queue; - char ci_panicbuf[512]; -} __attribute__((__aligned__(64))); - -#define CPUF_RUNNING 0x0001 /* CPU is running. */ - -#ifdef MULTIPROCESSOR -#define HPPA_MAXCPUS 4 -#else -#define HPPA_MAXCPUS 1 -#endif - -extern struct cpu_info cpu_info[HPPA_MAXCPUS]; - -#define MAXCPUS HPPA_MAXCPUS - -static __inline struct cpu_info * -curcpu(void) -{ - struct cpu_info *ci; - - asm volatile ("mfctl %%cr29, %0" : "=r"(ci)); - - return ci; -} - -#define cpu_number() (curcpu()->ci_cpuid) - -#define CPU_INFO_UNIT(ci) ((ci)->ci_dev ? (ci)->ci_dev->dv_unit : 0) -#define CPU_IS_PRIMARY(ci) ((ci)->ci_cpuid == 0) -#define CPU_IS_RUNNING(ci) ((ci)->ci_flags & CPUF_RUNNING) -#define CPU_INFO_ITERATOR int -#define CPU_INFO_FOREACH(cii, ci) \ - for (cii = 0, ci = &cpu_info[0]; cii < ncpus; cii++, ci++) - -#define CPU_BUSY_CYCLE() do {} while (0) - -/* types */ -enum hppa_cpu_type { - hpcxs, hpcxt, hpcxta, hpcxl, hpcxl2, hpcxu, hpcxu2, hpcxw -}; -extern enum hppa_cpu_type cpu_type; -extern const char *cpu_typename; -extern int cpu_hvers; -#endif -#endif - -/* - * COPR/SFUs - */ -#define HPPA_FPUS 0xc0 -#define HPPA_FPUVER(w) (((w) & 0x003ff800) >> 11) -#define HPPA_FPU_OP(w) ((w) >> 26) -#define HPPA_FPU_UNMPL 0x01 /* exception reg, the rest is << 1 */ -#define HPPA_FPU_ILL 0x80 /* software-only */ -#define HPPA_FPU_I 0x01 -#define HPPA_FPU_U 0x02 -#define HPPA_FPU_O 0x04 -#define HPPA_FPU_Z 0x08 -#define HPPA_FPU_V 0x10 -#define HPPA_FPU_D 0x20 -#define HPPA_FPU_T 0x40 -#define HPPA_FPU_XMASK 0x7f -#define HPPA_FPU_T_POS 25 -#define HPPA_FPU_RM 0x00000600 -#define HPPA_FPU_CQ 0x00fff800 -#define HPPA_FPU_C 0x04000000 -#define HPPA_FPU_FLSH 27 -#define HPPA_FPU_INIT (0) -#define HPPA_FPU_FORK(s) ((s) & ~((u_int64_t)(HPPA_FPU_XMASK)<<32)) -#define HPPA_PMSFUS 0x20 /* ??? */ - -/* - * Exported definitions unique to hp700/PA-RISC cpu support. - */ - -#define HPPA_PGALIAS 0x00400000 -#define HPPA_PGAOFF 0x003fffff - -#define HPPA_IOBEGIN 0xf0000000 -#define HPPA_IOLEN 0x10000000 -#define HPPA_PDC_LOW 0xef000000 -#define HPPA_PDC_HIGH 0xf1000000 -#define HPPA_IOBCAST 0xfffc0000 -#define HPPA_LBCAST 0xfffc0000 -#define HPPA_GBCAST 0xfffe0000 -#define HPPA_FPA 0xfff80000 -#define HPPA_FLEX_DATA 0xfff80001 -#define HPPA_DMA_ENABLE 0x00000001 -#define HPPA_FLEX_MASK 0xfffc0000 -#define HPPA_FLEX_SIZE (1 + ~HPPA_FLEX_MASK) -#define HPPA_FLEX(a) (((a) & HPPA_FLEX_MASK) >> 18) -#define HPPA_SPA_ENABLE 0x00000020 -#define HPPA_NMODSPBUS 64 - -#define clockframe trapframe -#define CLKF_PC(framep) ((framep)->tf_iioq_head) -#define CLKF_INTR(framep) ((framep)->tf_flags & TFF_INTR) -#define CLKF_USERMODE(framep) ((framep)->tf_flags & T_USER) -#define CLKF_SYSCALL(framep) ((framep)->tf_flags & TFF_SYS) - -#define need_proftick(p) setsoftast(p) -#define PROC_PC(p) ((p)->p_md.md_regs->tf_iioq_head & ~HPPA_PC_PRIV_MASK) -#define PROC_STACK(p) ((p)->p_md.md_regs->tf_sp) - -#ifndef _LOCORE -#ifdef _KERNEL - -#define DELAY(x) delay(x) - -extern int (*cpu_desidhash)(void); - -void signotify(struct proc *); -void delay(u_int us); -void hppa_init(paddr_t start); -void trap(int type, struct trapframe *frame); -int spcopy(pa_space_t ssp, const void *src, - pa_space_t dsp, void *dst, size_t size); -int spcopy32(pa_space_t ssp, const uint32_t *src, - pa_space_t dsp, uint32_t *dst); -int spstrcpy(pa_space_t ssp, const void *src, - pa_space_t dsp, void *dst, size_t size, size_t *rsize); -int copy_on_fault(void); -void proc_trampoline(void); -int cpu_dumpsize(void); -int cpu_dump(void); -void cpu_startclock(void); - -static inline unsigned int -cpu_rnd_messybits(void) -{ - unsigned int __itmr; - - __asm volatile("mfctl %1,%0": "=r" (__itmr) : "i" (CR_ITMR)); - - return (__itmr); -} - -#ifdef MULTIPROCESSOR -void cpu_boot_secondary_processors(void); -void cpu_hw_init(void); -void cpu_hatch(void); -void cpu_unidle(struct cpu_info *); -#else -#define cpu_unidle(ci) -#endif - -extern void need_resched(struct cpu_info *); -#define clear_resched(ci) (ci)->ci_want_resched = 0 - -#endif - -/* - * Boot arguments stuff - */ - -#define BOOTARG_LEN PAGE_SIZE -#define BOOTARG_OFF 0x10000 - -/* - * CTL_MACHDEP definitions. - */ -#define CPU_CONSDEV 1 /* dev_t: console terminal device */ -#define CPU_FPU 2 /* int: fpu present/enabled */ -#define CPU_LED_BLINK 3 /* int: twiddle heartbeat LED/LCD */ -#define CPU_MAXID 4 /* number of valid machdep ids */ - -#define CTL_MACHDEP_NAMES { \ - { 0, 0 }, \ - { "console_device", CTLTYPE_STRUCT }, \ - { "fpu", CTLTYPE_INT }, \ - { "led_blink", CTLTYPE_INT }, \ -} - -#ifdef _KERNEL -#include - -#ifdef MULTIPROCESSOR -#include -#endif - -struct blink_led { - void (*bl_func)(void *, int); - void *bl_arg; - SLIST_ENTRY(blink_led) bl_next; -}; - -extern void blink_led_register(struct blink_led *); -#endif - -#define copyinsn(p, v, ip) copyin32((v), (ip)) - -#endif - -#endif /* _MACHINE_CPU_H_ */ diff --git a/sys/arch/hppa/include/cpufunc.h b/sys/arch/hppa/include/cpufunc.h deleted file mode 100644 index 3e46b028c..000000000 --- a/sys/arch/hppa/include/cpufunc.h +++ /dev/null @@ -1,219 +0,0 @@ -/* $OpenBSD: cpufunc.h,v 1.29 2014/03/29 18:09:29 guenther Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ -/* - * (c) Copyright 1988 HEWLETT-PACKARD COMPANY - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of Hewlett-Packard Company not be - * used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Hewlett-Packard Company makes no representations about the - * suitability of this software for any purpose. - */ -/* - * Copyright (c) 1990,1994 The University of Utah and - * the Computer Systems Laboratory (CSL). All rights reserved. - * - * THE UNIVERSITY OF UTAH AND CSL PROVIDE THIS SOFTWARE IN ITS "AS IS" - * CONDITION, AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES - * WHATSOEVER RESULTING FROM ITS USE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: c_support.s 1.8 94/12/14$ - * Author: Bob Wheeler, University of Utah CSL - */ - -#ifndef _MACHINE_CPUFUNC_H_ -#define _MACHINE_CPUFUNC_H_ - -#include -#include - -#define tlbbtop(b) ((b) >> (PAGE_SHIFT - 5)) -#define tlbptob(p) ((p) << (PAGE_SHIFT - 5)) - -#define hptbtop(b) ((b) >> 17) - -/* Get space register for an address */ -static __inline register_t ldsid(vaddr_t p) { - register_t ret; - __asm volatile("ldsid (%1),%0" : "=r" (ret) : "r" (p)); - return ret; -} - -#define mtctl(v,r) __asm volatile("mtctl %0,%1":: "r" (v), "i" (r)) -#define mfctl(r,v) __asm volatile("mfctl %1,%0": "=r" (v): "i" (r)) - -#define mfcpu(r,v) /* XXX for the lack of the mnemonics */ \ - __asm volatile(".word %1\n\t" \ - "copy %%r22, %0" \ - : "=r" (v) : "i" ((0x14001400 | ((r) << 21) | (22))) \ - : "r22") - -#define mtsp(v,r) __asm volatile("mtsp %0,%1":: "r" (v), "i" (r)) -#define mfsp(r,v) __asm volatile("mfsp %1,%0": "=r" (v): "i" (r)) - -#define ssm(v,r) __asm volatile("ssm %1,%0": "=r" (r): "i" (v)) -#define rsm(v,r) __asm volatile("rsm %1,%0": "=r" (r): "i" (v)) - -/* Move to system mask. Old value of system mask is returned. */ -static __inline register_t -mtsm(register_t mask) { - register_t ret; - __asm volatile("ssm 0,%0\n\t" - "mtsm %1": "=&r" (ret) : "r" (mask)); - return ret; -} - -#define fdce(sp,off) __asm volatile("fdce 0(%0,%1)":: "i" (sp), "r" (off)) -#define fice(sp,off) __asm volatile("fice 0(%0,%1)":: "i" (sp), "r" (off)) -#define sync_caches() __asm volatile(\ - "sync\n\tnop\n\tnop\n\tnop\n\tnop\n\tnop\n\tnop\n\tnop":::"memory") - -static __inline void -iitlba(u_int pg, pa_space_t sp, vaddr_t va) -{ - mtsp(sp, 1); - __asm volatile("iitlba %0,(%%sr1, %1)":: "r" (pg), "r" (va)); -} - -static __inline void -idtlba(u_int pg, pa_space_t sp, vaddr_t va) -{ - mtsp(sp, 1); - __asm volatile("idtlba %0,(%%sr1, %1)":: "r" (pg), "r" (va)); -} - -static __inline void -iitlbp(u_int prot, pa_space_t sp, vaddr_t va) -{ - mtsp(sp, 1); - __asm volatile("iitlbp %0,(%%sr1, %1)":: "r" (prot), "r" (va)); -} - -static __inline void -idtlbp(u_int prot, pa_space_t sp, vaddr_t va) -{ - mtsp(sp, 1); - __asm volatile("idtlbp %0,(%%sr1, %1)":: "r" (prot), "r" (va)); -} - -static __inline void -pitlb(pa_space_t sp, vaddr_t va) -{ - mtsp(sp, 1); - __asm volatile("pitlb %%r0(%%sr1, %0)":: "r" (va)); -} - -static __inline void -pdtlb(pa_space_t sp, vaddr_t va) -{ - mtsp(sp, 1); - __asm volatile("pdtlb %%r0(%%sr1, %0)":: "r" (va)); -} - -static __inline void -pitlbe(pa_space_t sp, vaddr_t va) -{ - mtsp(sp, 1); - __asm volatile("pitlbe %%r0(%%sr1, %0)":: "r" (va)); -} - -static __inline void -pdtlbe(pa_space_t sp, vaddr_t va) -{ - mtsp(sp, 1); - __asm volatile("pdtlbe %%r0(%%sr1, %0)":: "r" (va)); -} - -#ifdef USELEDS -#define PALED_NETSND 0x01 -#define PALED_NETRCV 0x02 -#define PALED_DISK 0x04 -#define PALED_HEARTBEAT 0x08 -#define PALED_LOADMASK 0xf0 - -#define PALED_DATA 0x01 -#define PALED_STROBE 0x02 - -extern volatile u_int8_t *machine_ledaddr; -extern int machine_ledword, machine_leds; - -static __inline void -ledctl(int on, int off, int toggle) -{ - if (machine_ledaddr) { - int r; - - if (on) - machine_leds |= on; - if (off) - machine_leds &= ~off; - if (toggle) - machine_leds ^= toggle; - - r = ~machine_leds; /* it seems they should be reversed */ - - if (machine_ledword) - *machine_ledaddr = r; - else { - register int b; - for (b = 0x80; b; b >>= 1) { - *machine_ledaddr = (r & b)? PALED_DATA : 0; - DELAY(1); - *machine_ledaddr = ((r & b)? PALED_DATA : 0) | - PALED_STROBE; - } - } - } -} -#endif - -#ifdef _KERNEL -extern int (*cpu_hpt_init)(vaddr_t hpt, vsize_t hptsize); - -void fpu_save(vaddr_t va); -void fpu_exit(void); -void ficache(pa_space_t sp, vaddr_t va, vsize_t size); -void fdcache(pa_space_t sp, vaddr_t va, vsize_t size); -void pdcache(pa_space_t sp, vaddr_t va, vsize_t size); -void ficacheall(void); -void fdcacheall(void); -void ptlball(void); -int btlb_insert(pa_space_t space, vaddr_t va, paddr_t pa, vsize_t *lenp, u_int prot); -hppa_hpa_t cpu_gethpa(int n); -void eaio_l2(int i); -#endif - -#endif /* _MACHINE_CPUFUNC_H_ */ diff --git a/sys/arch/hppa/include/db_machdep.h b/sys/arch/hppa/include/db_machdep.h deleted file mode 100644 index c8f70a653..000000000 --- a/sys/arch/hppa/include/db_machdep.h +++ /dev/null @@ -1,93 +0,0 @@ -/* $OpenBSD: db_machdep.h,v 1.23 2022/02/15 00:27:11 jsg Exp $ */ - -/* - * Copyright (c) 1998-2005 Michael Shalayeff - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _MACHINE_DB_MACHDEP_H_ -#define _MACHINE_DB_MACHDEP_H_ - -#include - -/* types the generic ddb module needs */ -typedef long db_expr_t; - -typedef struct trapframe db_regs_t; -extern db_regs_t ddb_regs; - -#define PC_REGS(regs) ((vaddr_t)(regs)->tf_iioq_head) -#define SET_PC_REGS(regs, value) \ -do { \ - (regs)->tf_iioq_tail = 4 + \ - ((regs)->tf_iioq_head = (value)); \ -} while (0) - -/* Breakpoint related definitions */ -#define BKPT_INST 0x00010000 /* break 0,8 */ -#define BKPT_SIZE sizeof(int) -#define BKPT_SET(inst) BKPT_INST - -#define IS_BREAKPOINT_TRAP(type, code) ((type) == T_IBREAK) -#define IS_WATCHPOINT_TRAP(type, code) ((type) == T_DBREAK) - -#define FIXUP_PC_AFTER_BREAK(regs) ((regs)->tf_iioq_head -= sizeof(int)) - -#define DB_VALID_BREAKPOINT(addr) db_valid_breakpoint(addr) - -static __inline int inst_call(u_int ins) { - return (ins & 0xfc00e000) == 0xe8000000 || - (ins & 0xfc00e000) == 0xe8004000 || - (ins & 0xfc000000) == 0xe4000000; -} -static __inline int inst_branch(u_int ins) { - return (ins & 0xf0000000) == 0xe0000000 || - (ins & 0xf0000000) == 0xc0000000 || - (ins & 0xf0000000) == 0xa0000000 || - (ins & 0xf0000000) == 0x80000000; -} -static __inline int inst_return(u_int ins) { - return (ins & 0xfc00e000) == 0xe800c000 || - (ins & 0xfc000000) == 0xe0000000; -} -static __inline int inst_trap_return(u_int ins) { - return (ins & 0xfc001fff) == 0x00000c00 || /* rfi */ - (ins & 0xfc001fff) == 0x00000ca0; /* rfir */ -} - -#if 0 -#define db_clear_single_step(r) ((r)->tf_flags &= ~(PSL_Z)) -#define db_set_single_step(r) ((r)->tf_flags |= (PSL_Z)) -#else -#define SOFTWARE_SSTEP 1 -#define SOFTWARE_SSTEP_EMUL 1 - -static __inline vaddr_t -next_instr_address(vaddr_t addr, int b) { - return (addr + 4); -} - -#define branch_taken(ins,pc,f,regs) branch_taken1(ins, pc, regs) -static __inline vaddr_t -branch_taken1(int ins, vaddr_t pc, db_regs_t *regs) { - return (pc); -} - -#endif - -int db_valid_breakpoint(vaddr_t); -int db_ktrap(int, int, db_regs_t *); - -#endif /* _MACHINE_DB_MACHDEP_H_ */ diff --git a/sys/arch/hppa/include/disklabel.h b/sys/arch/hppa/include/disklabel.h deleted file mode 100644 index 041946f86..000000000 --- a/sys/arch/hppa/include/disklabel.h +++ /dev/null @@ -1,131 +0,0 @@ -/* $OpenBSD: disklabel.h,v 1.24 2015/09/30 15:13:54 krw Exp $ */ - -/* - * Copyright (c) 1994 Christopher G. Demetriou - * 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. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Christopher G. Demetriou. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * 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. - */ - -#ifndef _MACHINE_DISKLABEL_H_ -#define _MACHINE_DISKLABEL_H_ - -#define LABELSECTOR 1 /* sector containing label */ -#define LABELOFFSET 0 /* offset of label in sector */ -#define MAXPARTITIONS 16 /* number of partitions */ - -/* - * volume header for "LIF" format volumes - */ -struct lifvol { - short vol_id; - char vol_label[6]; - u_int vol_addr; - short vol_oct; - short vol_dummy; - u_int vol_dirsize; - short vol_version; - short vol_zero; - u_int vol_number; - u_int vol_lastvol; - u_int vol_length; - char vol_toc[6]; - char vol_dummy1[198]; - - u_int ipl_addr; - u_int ipl_size; - u_int ipl_entry; - - u_int vol_dummy2; -}; - -struct lifdir { - char dir_name[10]; - u_short dir_type; - u_int dir_addr; - u_int dir_length; - char dir_toc[6]; - short dir_flag; - u_int dir_implement; -}; - -struct lif_load { - int address; - int count; -}; - -#define HPUX_MAGIC 0x8b7f6a3c -#define HPUX_MAXPART 16 -struct hpux_label { - int32_t hl_magic1; - u_int32_t hl_magic; - int32_t hl_version; - struct { - int32_t hlp_blah[2]; - int32_t hlp_start; - int32_t hlp_length; - } hl_parts[HPUX_MAXPART]; - u_int8_t hl_flags[HPUX_MAXPART]; -#define HPUX_PART_ROOT 0x10 -#define HPUX_PART_SWAP 0x14 -#define HPUX_PART_BOOT 0x32 - int32_t hl_blah[3*16]; - u_int16_t hl_boot; - u_int16_t hl_reserved; - int32_t hl_magic2; -}; - -#define LIF_VOL_ID -32768 -#define LIF_VOL_OCT 4096 -#define LIF_DIR_SWAP 0x5243 -#define LIF_DIR_HPLBL 0xa271 -#define LIF_DIR_FS 0xcd38 -#define LIF_DIR_IOMAP 0xcd60 -#define LIF_DIR_HPUX 0xcd80 -#define LIF_DIR_ISL 0xce00 -#define LIF_DIR_PAD 0xcffe -#define LIF_DIR_AUTO 0xcfff -#define LIF_DIR_EST 0xd001 -#define LIF_DIR_TYPE 0xe942 - -#define LIF_DIR_FLAG 0x8001 /* dont ask me! */ -#define LIF_SECTSIZE 256 - -#define LIF_NUMDIR 16 - -#define LIF_VOLSTART 0 -#define LIF_VOLSIZE sizeof(struct lifvol) -#define LIF_DIRSTART 2048 -#define LIF_DIRSIZE (LIF_NUMDIR * sizeof(struct lifdir)) -#define LIF_FILESTART 8192 - -#define btolifs(b) (((b) + (LIF_SECTSIZE - 1)) / LIF_SECTSIZE) -#define lifstob(s) ((s) * LIF_SECTSIZE) -#define lifstodb(s) ((s) * LIF_SECTSIZE / DEV_BSIZE) - -#define MAXLIFSPACE 256 /* 512 byte blocks */ - -#endif /* _MACHINE_DISKLABEL_H_ */ diff --git a/sys/arch/hppa/include/eisa_machdep.h b/sys/arch/hppa/include/eisa_machdep.h deleted file mode 100644 index 5283719f2..000000000 --- a/sys/arch/hppa/include/eisa_machdep.h +++ /dev/null @@ -1,71 +0,0 @@ -/* $OpenBSD: eisa_machdep.h,v 1.4 2011/03/23 16:54:35 pirofti Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#ifndef _MACHINE_EISA_MACHDEP_H_ -#define _MACHINE_EISA_MACHDEP_H_ - -/* - * Types provided to machine-independent EISA code. - */ -typedef struct hppa_eisa_chipset *eisa_chipset_tag_t; -typedef int eisa_intr_handle_t; - -struct hppa_eisa_chipset { - void *ec_v; - - void (*ec_attach_hook)(struct device *, struct device *, - struct eisabus_attach_args *); - int (*ec_intr_map)(void *, u_int, int *); - const char *(*ec_intr_string)(void *, int); - void *(*ec_intr_establish)(void *, int, int, int, - int (*)(void *), void *, const char *); - void (*ec_intr_disestablish)(void *, void *); -}; - -#if 0 -#define EISA_SLOTOFF_PRIMING EISA_SLOTOFF_VID -#define EISA_PRIMING_VID(i) ({ (void)(i), 0xff; }) -#define EISA_PRIMING_PID(i) ({ (void)(i), 0x00; }) -#endif - -/* - * Functions provided to machine-independent EISA code. - */ -#define eisa_attach_hook(p, s, a) \ - (*(a)->eba_ec->ec_attach_hook)((p), (s), (a)) -#define eisa_maxslots(c) 8 -#define eisa_intr_map(c, i, hp) \ - (*(c)->ec_intr_map)((c)->ec_v, (i), (hp)) -#define eisa_intr_string(c, h) \ - (*(c)->ec_intr_string)((c)->ec_v, (h)) -#define eisa_intr_establish(c, h, t, l, f, a, nm) \ - (*(c)->ec_intr_establish)((c)->ec_v, (h), (t), (l), (f), (a), (nm)) -#define eisa_intr_disestablish(c, h) \ - (*(c)->ec_intr_disestablish)((c)->ec_v, (h)) - -#endif /* _MACHINE_EISA_MACHDEP_H_ */ diff --git a/sys/arch/hppa/include/endian.h b/sys/arch/hppa/include/endian.h deleted file mode 100644 index b31fe0802..000000000 --- a/sys/arch/hppa/include/endian.h +++ /dev/null @@ -1,39 +0,0 @@ -/* $OpenBSD: endian.h,v 1.12 2014/07/12 16:25:08 guenther Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#ifndef _MACHINE_ENDIAN_H_ -#define _MACHINE_ENDIAN_H_ - -#define _BYTE_ORDER _BIG_ENDIAN -#define __STRICT_ALIGNMENT - -#ifndef __FROM_SYS__ENDIAN -#include -#endif - -#endif /* !_MACHINE_ENDIAN_H_ */ diff --git a/sys/arch/hppa/include/exec.h b/sys/arch/hppa/include/exec.h deleted file mode 100644 index 7ab682602..000000000 --- a/sys/arch/hppa/include/exec.h +++ /dev/null @@ -1,107 +0,0 @@ -/* $OpenBSD: exec.h,v 1.15 2022/02/21 12:22:21 jsg Exp $ */ - -/* - * Copyright (c) 1994, The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: exec.h 1.3 94/12/16$ - */ - -#ifndef _MACHINE_EXEC_H_ -#define _MACHINE_EXEC_H_ - -/* Size of a page in an object file. */ -#define __LDPGSZ 4096 - -#define ARCH_ELFSIZE 32 - -#define ELF_TARG_CLASS ELFCLASS32 -#define ELF_TARG_DATA ELFDATA2MSB -#define ELF_TARG_MACH EM_PARISC - -/* - * the following MD ELF values definitions are from the: - * "Processor-Specific ELF Supplement for PA-RISC. - * Including HP and HP-UX Extensions. Version 1.43. October 6, 1997" - * http://devrsrc1.external.hp.com/STK/partner/elf-pa.pdf - * - */ - -/* parisc-specific elf flags */ -#define EF_PARISC_TRAPNIL 0x00010000 /* trap on NULL derefs */ -#define EF_PARISC_EXT 0x00020000 /* program uses arch exts */ -#define EF_PARISC_LSB 0x00040000 /* program expects LSB mode */ -#define EF_PARISC_WIDE 0x00080000 /* program expects wide mode */ -#define EF_PARISC_NO_KABP 0x00100000 /* don't allow kernel assisted - branch prediction */ -#define EF_PARISC_LAZYSWAP 0x00200000 /* allow lazy swap allocation - for dynamically allocated - program segments */ -#define EF_PARISC_ARCH 0x0000ffff /* architecture version */ -#define EFA_PARISC_1_0 0x020B -#define EFA_PARISC_1_1 0x0210 -#define EFA_PARISC_2_0 0x0214 - -/* legend: 0 - pa7000, 1 - pa7100, 2 - pa7200, 3 - pa7100LC, 4 - pa8000 */ -#define PARISC_AE_QWSI 0x00000001 /* 0 : enable quadword stores */ -#define PARISC_AE_FPLSU 0x00000002 /* 1: fp load/store to I/O space */ -#define PARISC_AE_RSQRT 0x00000004 /* 0 : reciprocal sqrt */ -#define PARISC_AE_FDCG 0x00000008 /* 0,1: fdc includes graph flushes */ -#define PARISC_AE_HPAR 0x00000010 /* 3,4: half-word add/sub/av */ -#define PARISC_AE_BSW 0x00000020 /* 3,4: half-word shift-add */ -#define PARISC_AE_HPSA 0x00000040 /* 3 : byte-swapping stores */ -#define PARISC_AE_DPR0 0x00000080 /* 2,4: data prefetch via ld to r0 */ - -#define SHN_PARISC_ANSI_COMMON 0xff00 -#define SHN_PARISC_HUGE_COMMON 0xff01 - -/* sh_type */ -#define SHT_PARISC_EXT 0x70000000 /* contains product-specific - extension bits */ -#define SHT_PARISC_UNWIND 0x70000001 /* contains unwind table entries - sh_info contains index of - the code section to which - unwind entries apply */ -#define SHT_PARISC_DOC 0x70000002 /* contains debug info for -O */ -#define SHT_PARISC_ANNOT 0x70000003 /* contains code annotations */ - -/* sh_flags */ -#define SHF_PARISC_SBP 0x80000000 /* contains code compiled for - static branch prediction */ -#define SHF_PARISC_HUGE 0x40000000 /* should be allocated far from gp */ -#define SHF_PARISC_SHORT 0x20000000 /* should be allocated near from gp */ - -#define ELF_PARISC_ARCHEXT ".PARISC.archext" -#define ELF_PARISC_MILLI ".PARISC.milli" -#define ELF_PARISC_UNWIND ".PARISC.unwind" -#define ELF_PARISC_UNWIND_INFO ".PARISC.unwind_info" -#define ELF_PARISC_SDATA ".sdata" -#define ELF_PARISC_NOBITS ".sbss" - -#define STT_PARISC_MILLI 13 /* entry point of a millicode routine */ - -#define PT_PARISC_ARCHEXT 0x70000000 /* segment contains - .PARISC.archext section */ -#define PT_PARISC_UNWIND 0x70000001 /* segment contains - .unwind section */ - -#define PF_PARISC_SBP 0x08000000 /* segment contains code - compiled for static branch prediction */ - -#endif /* _MACHINE_EXEC_H_ */ diff --git a/sys/arch/hppa/include/fenv.h b/sys/arch/hppa/include/fenv.h deleted file mode 100644 index 714905f29..000000000 --- a/sys/arch/hppa/include/fenv.h +++ /dev/null @@ -1,94 +0,0 @@ -/* $OpenBSD: fenv.h,v 1.3 2011/05/25 21:46:49 martynas Exp $ */ - -/* - * Copyright (c) 2011 Martynas Venckus - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _HPPA_FENV_H_ -#define _HPPA_FENV_H_ - -/* - * Each symbol representing a floating point exception expands to an integer - * constant expression with values, such that bitwise-inclusive ORs of _all - * combinations_ of the constants result in distinct values. - * - * We use such values that allow direct bitwise operations on FPU registers. - */ -#define FE_INEXACT 0x01 -#define FE_UNDERFLOW 0x02 -#define FE_OVERFLOW 0x04 -#define FE_DIVBYZERO 0x08 -#define FE_INVALID 0x10 - -/* - * The following symbol is simply the bitwise-inclusive OR of all floating-point - * exception constants defined above. - */ -#define FE_ALL_EXCEPT (FE_INEXACT | FE_UNDERFLOW | FE_OVERFLOW | \ - FE_DIVBYZERO | FE_INVALID) -#define _MASK_SHIFT 27 - -/* - * Each symbol representing the rounding direction, expands to an integer - * constant expression whose value is distinct non-negative value. - * - * We use such values that allow direct bitwise operations on FPU registers. - */ -#define FE_TONEAREST 0x000 -#define FE_TOWARDZERO 0x200 -#define FE_UPWARD 0x400 -#define FE_DOWNWARD 0x600 - -/* - * The following symbol is simply the bitwise-inclusive OR of all floating-point - * rounding direction constants defined above. - */ -#define _ROUND_MASK (FE_TONEAREST | FE_TOWARDZERO | FE_UPWARD | \ - FE_DOWNWARD) - -/* - * fenv_t represents the entire floating-point environment. - */ -typedef unsigned int fenv_t; - -/* - * The following constant represents the default floating-point environment - * (that is, the one installed at program startup) and has type pointer to - * const-qualified fenv_t. - * - * It can be used as an argument to the functions within the header - * that manage the floating-point environment, namely fesetenv() and - * feupdateenv(). - */ -__BEGIN_DECLS -extern fenv_t __fe_dfl_env; -__END_DECLS -#define FE_DFL_ENV ((const fenv_t *)&__fe_dfl_env) - -/* - * fexcept_t represents the floating-point status flags collectively, including - * any status the implementation associates with the flags. - * - * A floating-point status flag is a system variable whose value is set (but - * never cleared) when a floating-point exception is raised, which occurs as a - * side effect of exceptional floating-point arithmetic to provide auxiliary - * information. - * - * A floating-point control mode is a system variable whose value may be set by - * the user to affect the subsequent behavior of floating-point arithmetic. - */ -typedef unsigned int fexcept_t; - -#endif /* !_HPPA_FENV_H_ */ diff --git a/sys/arch/hppa/include/fpu.h b/sys/arch/hppa/include/fpu.h deleted file mode 100644 index 69943cba4..000000000 --- a/sys/arch/hppa/include/fpu.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $OpenBSD: fpu.h,v 1.4 2011/01/08 23:02:04 deraadt Exp $ */ - -/* - * Copyright (c) 2010 Joel Sing - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _MACHINE_FPU_H_ -#define _MACHINE_FPU_H_ - -#include -#include - -struct hppa_fpstate { - struct fpreg hfp_regs; - volatile struct cpu_info *hfp_cpu; /* CPU which FPU state is on. */ -}; - -struct proc; - -void fpu_proc_flush(struct proc *); -void fpu_proc_save(struct proc *); -void fpu_cpu_save(int); - -#endif /* _MACHINE_FPU_H_ */ diff --git a/sys/arch/hppa/include/frame.h b/sys/arch/hppa/include/frame.h deleted file mode 100644 index 288107324..000000000 --- a/sys/arch/hppa/include/frame.h +++ /dev/null @@ -1,145 +0,0 @@ -/* $OpenBSD: frame.h,v 1.19 2012/06/21 00:56:59 guenther Exp $ */ - -/* - * Copyright (c) 1999-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - - -#ifndef _MACHINE_FRAME_H_ -#define _MACHINE_FRAME_H_ - -/* - * Call frame definitions - */ -#define HPPA_FRAME_NARGS (12) -#define HPPA_FRAME_MAXARGS (HPPA_FRAME_NARGS * 4) -#define HPPA_FRAME_ARG(n) (-(32 + 4*((n) + 1))) -#define HPPA_FRAME_CARG(n,sp) ((register_t *)((sp) + HPPA_FRAME_ARG(n))) -#define HPPA_FRAME_SIZE (64) -#define HPPA_FRAME_PSP (-4) -#define HPPA_FRAME_EP (-8) -#define HPPA_FRAME_CLUP (-12) -#define HPPA_FRAME_SL (-16) -#define HPPA_FRAME_CRP (-20) -#define HPPA_FRAME_ERP (-24) -#define HPPA_FRAME_ESR4 (-28) -#define HPPA_FRAME_EDP (-32) - -/* - * Macros to decode processor status word. - */ -#define HPPA_PC_PRIV_MASK 3 -#define HPPA_PC_PRIV_KERN 0 -#define HPPA_PC_PRIV_USER 3 -#define USERMODE(pc) ((((register_t)pc) & HPPA_PC_PRIV_MASK) != HPPA_PC_PRIV_KERN) -#define KERNMODE(pc) (((register_t)pc) & ~HPPA_PC_PRIV_MASK) - -#ifndef _LOCORE -/* - * the trapframe is divided into two parts: - * one is saved while we are in the physical mode (beginning of the trap), - * and should be kept as small as possible, since all the interrupts will - * be lost during this phase, also it must be 64-bytes aligned, per - * pa-risc stack conventions, and its dependencies in the code (; - * the other part is filled out when we are already in the virtual mode, - * are able to catch interrupts (they are kept pending) and perform - * other trap activities (like tlb misses). - */ -struct trapframe { - /* the `physical' part of the trapframe */ - unsigned long tf_t1; /* r22 */ - unsigned long tf_t2; /* r21 */ - unsigned long tf_sp; /* r30 */ - unsigned long tf_t3; /* r20 */ - unsigned long tf_iisq_head; /* cr17 */ - unsigned long tf_iisq_tail; - unsigned long tf_iioq_head; /* cr18 */ - unsigned long tf_iioq_tail; - unsigned long tf_eiem; /* cr15 */ - unsigned long tf_ipsw; /* cr22 */ - unsigned long tf_sr3; - unsigned long tf_pidr1; /* cr8 */ - unsigned long tf_isr; /* cr20 */ - unsigned long tf_ior; /* cr21 */ - unsigned long tf_iir; /* cr19 */ - unsigned long tf_flags; - - /* here starts the `virtual' part */ - unsigned long tf_sar; /* cr11 */ - unsigned long tf_r1; - unsigned long tf_rp; /* r2 */ - unsigned long tf_r3; /* frame pointer when -g */ - unsigned long tf_r4; - unsigned long tf_r5; - unsigned long tf_r6; - unsigned long tf_r7; - unsigned long tf_r8; - unsigned long tf_r9; - unsigned long tf_r10; - unsigned long tf_r11; - unsigned long tf_r12; - unsigned long tf_r13; - unsigned long tf_r14; - unsigned long tf_r15; - unsigned long tf_r16; - unsigned long tf_r17; - unsigned long tf_r18; - unsigned long tf_t4; /* r19 */ - unsigned long tf_arg3; /* r23 */ - unsigned long tf_arg2; /* r24 */ - unsigned long tf_arg1; /* r25 */ - unsigned long tf_arg0; /* r26 */ - unsigned long tf_dp; /* r27 */ - unsigned long tf_ret0; /* r28 */ - unsigned long tf_ret1; /* r29 */ - unsigned long tf_r31; - unsigned long tf_sr0; - unsigned long tf_sr1; - unsigned long tf_sr2; - unsigned long tf_sr4; - unsigned long tf_sr5; - unsigned long tf_sr6; - unsigned long tf_sr7; - unsigned long tf_pidr2; /* cr9 */ - unsigned long tf_pidr3; /* cr12 */ - unsigned long tf_pidr4; /* cr13 */ - unsigned long tf_rctr; /* cr0 */ - unsigned long tf_ccr; /* cr10 */ - unsigned long tf_eirr; /* cr23 - DDB */ - unsigned long tf_vtop; /* cr25 - DDB */ - unsigned long tf_cr27; - unsigned long tf_cr28; /* - DDB */ - unsigned long tf_cr30; /* uaddr */ - - unsigned long tf_pad[3]; /* pad to 256 bytes */ -}; - -#ifdef _KERNEL -int setstack(struct trapframe *, u_long, register_t); -#endif /* _KERNEL */ - -#endif /* !_LOCORE */ - -#endif /* !_MACHINE_FRAME_H_ */ diff --git a/sys/arch/hppa/include/hil_machdep.h b/sys/arch/hppa/include/hil_machdep.h deleted file mode 100644 index 3762b7f47..000000000 --- a/sys/arch/hppa/include/hil_machdep.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: hil_machdep.h,v 1.2 2003/06/02 23:27:46 millert Exp $ */ - -/* - * Copyright (c) 1988 University of Utah. - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * from: Utah $Hdr: hilreg.h 1.10 92/01/21$ - * - * @(#)hilreg.h 8.1 (Berkeley) 6/10/93 - */ - -/* - * HP 9000/700-series specific HIL definitions - */ - -#define HILP_RSTHOLD 0 /* (W) reset hold (and serial #3) */ -#define HILP_DATA 2048 /* (R/W) data port */ -#define HILP_CMD 2049 /* (R/W) status and control port */ -#define HILP_STAT HILP_CMD -#define HILP_RSTREL 3072 /* (W) reset release (and serial #3) */ - -#define HILMAPSIZE 4096 /* size for bus_space_map() call */ - -#define HILBUFSIZE 40 /* size of interrupt poll buffer */ diff --git a/sys/arch/hppa/include/ieee.h b/sys/arch/hppa/include/ieee.h deleted file mode 100644 index d9d263abe..000000000 --- a/sys/arch/hppa/include/ieee.h +++ /dev/null @@ -1,124 +0,0 @@ -/* $OpenBSD: ieee.h,v 1.3 2008/09/07 20:36:06 martynas Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This software was developed by the Computer Systems Engineering group - * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and - * contributed to Berkeley. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * - * 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)ieee.h 8.1 (Berkeley) 6/11/93 - */ - -/* - * ieee.h defines the machine-dependent layout of the machine's IEEE - * floating point. It does *not* define (yet?) any of the rounding - * mode bits, exceptions, and so forth. - */ - -/* - * Define the number of bits in each fraction and exponent. - * - * k k+1 - * Note that 1.0 x 2 == 0.1 x 2 and that denorms are represented - * - * (-exp_bias+1) - * as fractions that look like 0.fffff x 2 . This means that - * - * -126 - * the number 0.10000 x 2 , for instance, is the same as the normalized - * - * -127 -128 - * float 1.0 x 2 . Thus, to represent 2 , we need one leading zero - * - * -129 - * in the fraction; to represent 2 , we need two, and so on. This - * - * (-exp_bias-fracbits+1) - * implies that the smallest denormalized number is 2 - * - * for whichever format we are talking about: for single precision, for - * - * -126 -149 - * instance, we get .00000000000000000000001 x 2 , or 1.0 x 2 , and - * - * -149 == -127 - 23 + 1. - */ -#define SNG_EXPBITS 8 -#define SNG_FRACBITS 23 - -#define DBL_EXPBITS 11 -#define DBL_FRACHBITS 20 -#define DBL_FRACLBITS 32 -#define DBL_FRACBITS 52 - -#ifdef notyet -#define E80_EXPBITS 15 -#define E80_FRACBITS 64 -#endif - -struct ieee_single { - u_int sng_sign:1; - u_int sng_exp:8; - u_int sng_frac:23; -}; - -struct ieee_double { - u_int dbl_sign:1; - u_int dbl_exp:11; - u_int dbl_frach:20; - u_int dbl_fracl; -}; - -/* - * Floats whose exponent is in [1..INFNAN) (of whatever type) are - * `normal'. Floats whose exponent is INFNAN are either Inf or NaN. - * Floats whose exponent is zero are either zero (iff all fraction - * bits are zero) or subnormal values. - * - * A NaN is a `signalling NaN' if its QUIETNAN bit is clear in its - * high fraction; if the bit is set, it is a `quiet NaN'. - */ -#define SNG_EXP_INFNAN 255 -#define DBL_EXP_INFNAN 2047 - -#if 0 -#define SNG_QUIETNAN (1 << 22) -#define DBL_QUIETNAN (1 << 19) -#endif - -/* - * Exponent biases. - */ -#define SNG_EXP_BIAS 127 -#define DBL_EXP_BIAS 1023 diff --git a/sys/arch/hppa/include/ieeefp.h b/sys/arch/hppa/include/ieeefp.h deleted file mode 100644 index 8a74f5481..000000000 --- a/sys/arch/hppa/include/ieeefp.h +++ /dev/null @@ -1,24 +0,0 @@ -/* $OpenBSD: ieeefp.h,v 1.3 2011/03/23 16:54:35 pirofti Exp $ */ - -/* - * Written by Miodrag Vallat. Public domain. - */ - -#ifndef _MACHINE_IEEEFP_H_ -#define _MACHINE_IEEEFP_H_ - -typedef int fp_except; -#define FP_X_INV 0x10 /* invalid operation exception */ -#define FP_X_DZ 0x08 /* divide-by-zero exception */ -#define FP_X_OFL 0x04 /* overflow exception */ -#define FP_X_UFL 0x02 /* underflow exception */ -#define FP_X_IMP 0x01 /* imprecise (loss of precision) */ - -typedef enum { - FP_RN=0, /* round to nearest representable number */ - FP_RZ=1, /* round to zero (truncate) */ - FP_RP=2, /* round toward positive infinity */ - FP_RM=3 /* round toward negative infinity */ -} fp_rnd; - -#endif /* _MACHINE_IEEEFP_H_ */ diff --git a/sys/arch/hppa/include/intr.h b/sys/arch/hppa/include/intr.h deleted file mode 100644 index eba861f57..000000000 --- a/sys/arch/hppa/include/intr.h +++ /dev/null @@ -1,180 +0,0 @@ -/* $OpenBSD: intr.h,v 1.44 2018/01/13 15:18:11 mpi Exp $ */ - -/* - * Copyright (c) 2002-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#ifndef _MACHINE_INTR_H_ -#define _MACHINE_INTR_H_ - -#include - -#define CPU_NINTS 32 -#define NIPL 17 - -#define IPL_NONE 0 -#define IPL_SOFTCLOCK 1 -#define IPL_SOFTNET 2 -#define IPL_BIO 3 -#define IPL_NET 4 -#define IPL_SOFTTTY 5 -#define IPL_TTY 6 -#define IPL_VM 7 -#define IPL_AUDIO 8 -#define IPL_CLOCK 9 -#define IPL_STATCLOCK 10 -#define IPL_SCHED 10 -#define IPL_HIGH 10 -#define IPL_IPI 11 -#define IPL_NESTED 12 /* pseudo-level for sub-tables */ - -#define IPL_MPFLOOR IPL_AUDIO -#define IPL_MPSAFE 0 /* no "mpsafe" interrupts */ - -#define IST_NONE 0 -#define IST_PULSE 1 -#define IST_EDGE 2 -#define IST_LEVEL 3 - -#ifdef MULTIPROCESSOR -#define HPPA_IPI_NOP 0 -#define HPPA_IPI_HALT 1 -#define HPPA_IPI_FPU_SAVE 2 -#define HPPA_IPI_FPU_FLUSH 3 -#define HPPA_NIPI 4 -#endif - -#if !defined(_LOCORE) && defined(_KERNEL) - -extern volatile u_long imask[NIPL]; - -#ifdef DIAGNOSTIC -void splassert_fail(int, int, const char *); -extern int splassert_ctl; -void splassert_check(int, const char *); -#define splassert(__wantipl) do { \ - if (splassert_ctl > 0) { \ - splassert_check(__wantipl, __func__); \ - } \ -} while (0) -#define splsoftassert(__wantipl) splassert(__wantipl) -#else -#define splassert(__wantipl) do { /* nada */ } while (0) -#define splsoftassert(__wantipl) do { /* nada */ } while (0) -#endif /* DIAGNOSTIC */ - -void cpu_intr_init(void); -void cpu_intr(void *); - -void intr_barrier(void *); - -static __inline int -spllower(int ncpl) -{ - register int arg0 asm("r26") = ncpl; - register int ret0 asm("r28"); - - __asm volatile("break %1, %2" - : "=r" (ret0) - : "i" (HPPA_BREAK_KERNEL), "i" (HPPA_BREAK_SPLLOWER), "r" (arg0) - : "memory"); - - return (ret0); -} - -static __inline int -splraise(int ncpl) -{ - struct cpu_info *ci = curcpu(); - int ocpl = ci->ci_cpl; - - if (ocpl < ncpl) - ci->ci_cpl = ncpl; - __asm volatile ("sync" : : : "memory"); - - return (ocpl); -} - -static __inline void -splx(int ncpl) -{ - (void)spllower(ncpl); -} - -static __inline register_t -hppa_intr_disable(void) -{ - register_t eiem; - - __asm volatile("mfctl %%cr15, %0": "=r" (eiem)); - __asm volatile("mtctl %r0, %cr15"); - - return eiem; -} - -static __inline void -hppa_intr_enable(register_t eiem) -{ - __asm volatile("mtctl %0, %%cr15":: "r" (eiem)); -} - -#define splsoftclock() splraise(IPL_SOFTCLOCK) -#define splsoftnet() splraise(IPL_SOFTNET) -#define splbio() splraise(IPL_BIO) -#define splnet() splraise(IPL_NET) -#define splsofttty() splraise(IPL_SOFTTTY) -#define spltty() splraise(IPL_TTY) -#define splvm() splraise(IPL_VM) -#define splaudio() splraise(IPL_AUDIO) -#define splclock() splraise(IPL_CLOCK) -#define splsched() splraise(IPL_SCHED) -#define splstatclock() splraise(IPL_STATCLOCK) -#define splhigh() splraise(IPL_HIGH) -#define splipi() splraise(IPL_IPI) -#define spl0() spllower(IPL_NONE) - -#define SOFTINT_MASK ((1 << (IPL_SOFTCLOCK - 1)) | \ - (1 << (IPL_SOFTNET - 1)) | (1 << (IPL_SOFTTTY - 1))) - -#ifdef MULTIPROCESSOR -void hppa_ipi_init(struct cpu_info *); -int hppa_ipi_send(struct cpu_info *, u_long); -int hppa_ipi_broadcast(u_long); -#endif - -#define setsoftast(p) (p->p_md.md_astpending = 1) - -void *softintr_establish(int, void (*)(void *), void *); -void softintr_disestablish(void *); -void softintr_schedule(void *); - -#ifdef MULTIPROCESSOR -void hppa_ipi_init(struct cpu_info *); -int hppa_ipi_intr(void *arg); -int hppa_ipi_send(struct cpu_info *, u_long); -#endif - -#endif /* !_LOCORE && _KERNEL */ -#endif /* _MACHINE_INTR_H_ */ diff --git a/sys/arch/hppa/include/iomod.h b/sys/arch/hppa/include/iomod.h deleted file mode 100644 index 23a870f0b..000000000 --- a/sys/arch/hppa/include/iomod.h +++ /dev/null @@ -1,414 +0,0 @@ -/* $OpenBSD: iomod.h,v 1.19 2009/02/06 17:26:21 miod Exp $ */ - -/* - * Copyright (c) 2000-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 mt Xinu, Inc. All rights reserved. - * Copyright (c) 1990,1991,1992,1994 University of Utah. All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * Copyright (c) 1990 mt Xinu, Inc. - * This file may be freely distributed in any form as long as - * this copyright notice is included. - * MTXINU, THE UNIVERSITY OF UTAH, AND CSL PROVIDE THIS SOFTWARE ``AS - * IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, - * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: iomod.h 1.6 94/12/14$ - * Author: Jeff Forys (CSS), Dave Slattengren (mtXinu) - */ - -#ifndef _MACHINE_IOMOD_H_ -#define _MACHINE_IOMOD_H_ - -#include - -/* - * Structures and definitions for I/O Modules on HP-PA (9000/800). - * - * Memory layout: - * - * 0x00000000 +---------------------------------+ - * | Page Zero | - * 0x00000800 + - - - - - - - - - - - - - - - - + - * | | - * | | - * | Memory Address Space | - * | | - * | | - * 0xEF000000 +---------------------------------+ - * | | - * | PDC Address Space | - * | | - * 0xF1000000 +---------------------------------+ - * | | - * | | - * | I/O Address Space | - * | | - * | | - * 0xFFF80000 + - - - - - - - - - - - - - - - - + - * | Fixed Physical Address Space | - * 0xFFFC0000 + - - - - - - - - - - - - - - - - + - * | Local Broadcast Address Space | - * 0xFFFE0000 + - - - - - - - - - - - - - - - - + - * | Global Broadcast Address Space | - * 0xFFFFFFFF +---------------------------------+ - * - * "Memory Address Space" is used by memory modules, - * "Page Zero" is described below. - * "PDC Address Space" is used by Processor-Dependent Code. - * "I/O Address Space" is used by I/O modules (and is not cached), - * "Fixed Physical" is used by modules on the central bus, - * "Local Broadcast" is used to reach all modules on the same bus, and - * "Global Broadcast" is used to reach all modules (thru bus converters). - * - * SPA space (see below) ranges from 0xF1000000 thru 0xFFFC0000. - */ - -#define PDC_LOW 0xEF000000 /* define some ranges */ -#define PDC_HIGH 0xF1000000 -#define FPA_LOW 0xFFF80000 -#define FPA_HIGH 0xFFFC0000 -#define SPA_LOW 0xF1000000 -#define SPA_HIGH 0xFFFC0000 -#define SGC_LOW 0xF4000000 -#define SGC_HIGH 0xFA000000 - -#define FPA_IOMOD ((FPA_HIGH-FPA_LOW)/sizeof(struct iomod)) -#define MAXMODBUS ((int)(FPA_IOMOD)) /* maximum modules/bus */ - -/* size of HPA space for any device */ -#define IOMOD_HPASIZE 0x1000 - -/* ASP prom offset for an lan stattion id */ -#define ASP_PROM (0xf0810000) - -/* offset to the device-specific registers, - * basically sizeof(struct iomod) (see later) - */ -#define IOMOD_DEVOFFSET 0x800 - -#if !defined(_LOCORE) - -/* - * The first 2K of Soft Physical Address space on the Initial Memory Module - * is aptly called "page zero". The following structure defines the format - * of page zero. Individual members of this structure should be accessed - * as "PAGE0->member". - */ - -#define PAGE0 ((struct pagezero *)0) /* can't get any lower than this! */ - -struct pagezero { - /* [0x000] Initialize Vectors */ - int ivec_special; /* must be zero */ - u_int ivec_mempf; /* powerfail recovery software */ - u_int ivec_toc; /* exec'd after Transfer Of Control */ - u_int ivec_toclen; /* bytes of ivec_toc code */ - u_int ivec_rendz; /* exec'd after Rendezvous Signal */ - u_int ivec_mempflen; /* bytes of ivec_mempf code */ - u_int ivec_resv[2]; /* (reserved) */ - u_int ivec_mbz; /* must be zero */ - u_int ivec_resv2[7]; /* (reserved) */ - - /* [0x040] Processor Dependent */ - union { - u_int pd_Resv1[112]; /* (reserved) processor dependent */ - struct { /* Viper-specific data */ - u_int v_Resv1[39]; - u_int v_Ctrlcpy; /* copy of Viper `vi_control' */ - u_int v_Resv2[72]; - } pd_Viper; - } pz_Pdep; - - /* [0x200] IODC Data Area Descriptors - use PDC_ALLOC to allocate these memory regions */ - u_int iodc_cons_base; /* */ - u_int iodc_cons_size; /* */ - u_int iodc_kbrd_base; /* */ - u_int iodc_kbrd_size; /* */ - u_int iodc_boot_base; /* */ - u_int iodc_boot_size; /* */ - - /* [0x218] */ - u_int resv1[0x41]; - - /* [0x31C] Capability Flags */ - u_int cap_flags; /* system capabilities */ -#define HPPA_CAP_WIDESCSI 0x00000001 - - /* [0x320] Keyboard Extensions */ - u_int kbrd_ext[2]; - - /* [0x328] Boot Device Extensions */ - u_int boot_ext[2]; - - /* [0x330] Console/Display Extensions */ - u_int cons_ext[2]; - - /* [0x338] Initial Memory Module Extensions */ - u_int imm_ext[2]; - - /* [0x340] Memory Configuration */ - u_int memc_cont_l; /* memc_cont low part */ - u_int memc_phsize_l; /* memc_phsize low part */ - u_int memc_adsize_l; /* memc_adsize low part */ - u_int memc_resv; /* (reserved) */ - u_int memc_cont; /* bytes of contiguous valid memory */ - u_int memc_phsize; /* bytes of valid physical memory */ - u_int memc_adsize; /* bytes of SPA space used by PDC */ - u_int memc_hpa_h; /* HPA of CPU (high) */ - - /* [0x360] Miscellaneous */ - struct boot_err mem_be[8]; /* boot errors (see above) */ - u_int mem_free; /* first free phys. memory location */ - u_int mem_hpa; /* HPA of CPU */ - u_int mem_pdc; /* PDC entry point */ - u_int mem_10msec; /* # of Interval Timer ticks in 10msec*/ - - /* [0x390] Initial Memory Module */ - u_int imm_hpa; /* HPA of Initial Memory module */ - u_int imm_soft_boot; /* 0 == hard boot, 1 == soft boot */ - u_int imm_spa_size; /* bytes of SPA in IMM */ - u_int imm_max_mem; /* bytes of mem in IMM (<= spa_size) */ - - /* [0x3A0] Boot Console/Display, Device, and Keyboard */ - struct pz_device mem_cons; /* description of console device */ - struct pz_device mem_boot; /* description of boot device */ - struct pz_device mem_kbd; /* description of keyboard device */ - - /* [0x430] Reserved */ - u_int resv2[116]; /* (reserved) */ - - /* [0x600] Processor Dependent */ - u_int pd_resv2[128]; /* (reserved) processor dependent */ -}; -#define v_ctrlcpy pz_Pdep.pd_Viper.v_Ctrlcpy - - -/* - * Every module has 4K-bytes of address space associated with it. - * A Hard Physical Address (HPA) can be broken down as follows. - * - * Since this is an I/O space, the high 4 bits are always 1's. - * - * The "flex" address specifies which bus a module is on; there are - * 256K-bytes of HPA space for each bus, however only values from - * 64 - 1022 are valid for the "flex" field (1022 designates the - * central bus). The "flex" addr is set at bus configuration time. - * - * The "fixed" address specifies a particular module on the same - * bus (i.e. among modules with the same "flex" address). This - * value can also be found in "device_path.dp_mod" in "pdc.h". - * - * A modules HPA space consists of 2 pages; the "up" bit specifies - * which of these pages is being addressed. In general, the lower - * page is privileged and the upper page it module-type dependent. - * - */ - -struct hpa { - u_int hpa_ones: 4, /* must be 1's; this is an I/O space addr */ - hpa_flex:10, /* bus address for this module */ - hpa_fixed:6, /* location of module on bus */ - hpa_up : 1, /* 1 == upper page, 0 == lower page */ - hpa_set : 5, /* register set */ - hpa_reg : 4, /* register number within a register set */ - hpa_zeros:2; /* must be 0's; addrs are word aligned */ -}; - - -/* - * Certain modules require additional memory (i.e. more than that - * provided by the HPA space). A Soft Physical Address (SPA) can be - * broken down as follows, on a module-type specific basis (either - * Memory SPA or I/O SPA). - * - * SPA space must be a power of 2, and aligned accordingly. The IODC - * provides all information needed by software to configure SPA space - * for a particular module. - */ - -struct memspa { - u_int spa_page:21, /* page of memory */ - spa_off :11; /* offset into memory page */ -}; - -struct iospa { - u_int spa_ones: 4, /* must be 1's; this is an I/O space addr */ - spa_iopg:17, /* page in I/O address space */ - spa_set : 5, /* register set */ - spa_reg : 4, /* register number within a register set */ - spa_mode: 2; /* aligned according to bus transaction mode */ -}; - - -/* - * It is possible to send a command to all modules on a particular bus - * (local broadcast), or all modules (global broadcast). A Broadcast - * Physical Address (BPA) can be broken down as follows. - * - * Read and Clear transactions are not allowed in BPA space. All pages - * in BPA space are privileged. - */ - -struct bpa { - u_int bpa_ones:14, /* must be 1's; this is in BPA space */ - bpa_gbl : 1, /* 0 == local, 1 == global broadcast */ - bpa_page: 6, /* page in local/global BPA space */ - bpa_set : 5, /* register set */ - bpa_reg : 4, /* register number within a register set */ - bpa_zeros:2; /* must be 0's; addrs are word aligned */ -}; - - -/* - * All I/O and Memory modules have 4K-bytes of HPA space associated with - * it (described above), however not all modules implement every register. - * The first 2K-bytes of registers are "privileged". - * - * (WO) == Write Only, (RO) == Read Only - */ - -struct iomod { -/* SRS (Supervisor Register Set) */ - u_int io_eir; /* (WO) interrupt CPU; set bits in EIR CR */ - u_int io_eim; /* (WO) External Interrupt Message address */ - u_int io_dc_rw; /* write address of IODC to read IODC data */ - u_int io_ii_rw; /* read/clear external intrpt msg (bit-26) */ - u_int io_dma_link; /* pointer to "next quad" in DMA chain */ - u_int io_dma_command; /* (RO) chain command to exec on "next quad" */ - u_int io_dma_address; /* (RO) start of DMA */ - u_int io_dma_count; /* (RO) number of bytes remaining to xfer */ - u_int io_flex; /* (WO) HPA flex addr, LSB: bus master flag */ - u_int io_spa; /* (WO) SPA space; 0-20:addr, 24-31:iodc_spa */ - u_int resv1[2]; /* (reserved) */ - u_int io_command; /* (WO) module commands (see below) */ - u_int io_status; /* (RO) error returns (see below) */ - u_int io_control; /* memory err logging (bit-9), bc forwarding */ - u_int io_test; /* (RO) self-test information */ -/* ARS (Auxiliary Register Set) */ - u_int io_err_sadd; /* (RO) slave bus error or memory error addr */ - u_int chain_addr; /* start address of chain RAM */ - u_int sub_mask_clr; /* ignore intrpts on sub-channel (bitmask) */ - u_int sub_mask_set; /* service intrpts on sub-channel (bitmask) */ - u_int diagnostic; /* diagnostic use (reserved) */ - u_int resv2[2]; /* (reserved) */ - u_int nmi_address; /* address to send data to when NMI detected */ - u_int nmi_data; /* NMI data to be sent */ - u_int resv3[3]; /* (reserved) */ - u_int io_mem_low; /* bottom of memory address range */ - u_int io_mem_high; /* top of memory address range */ - u_int io_io_low; /* bottom of I/O HPA address Range */ - u_int io_io_high; /* top of I/O HPA address Range */ - - u_int priv_trs[160]; /* TRSes (Type-dependent Reg Sets) */ - - u_int priv_hvrs[320]; /* HVRSes (HVERSION-dependent Register Sets) */ - - u_int hvrs[512]; /* HVRSes (HVERSION-dependent Register Sets) */ -}; -#endif /* !_LOCORE */ - -/* primarily for a "reboot" and "_rtt" routines */ -#define iomod_command (4*12) - -/* io_flex */ -#define DMA_ENABLE 0x1 /* flex register enable DMA bit */ - -/* io_spa */ -#define IOSPA(spa,iodc_data) \ - ((volatile caddr_t) \ - (spa | iodc_data.iodc_spa_shift | iodc_data.iodc_spa_enb << 5 | \ - iodc_data.iodc_spa_pack << 6 | iodc_data.iodc_spa_io << 7)) - -/* io_command */ -#define CMD_STOP 0 /* halt any I/O, enable diagnostic access */ -#define CMD_FLUSH 1 /* abort DMA */ -#define CMD_CHAIN 2 /* initiate DMA */ -#define CMD_CLEAR 3 /* clear errors */ -#define CMD_RESET 5 /* reset any module */ - -/* io_status */ -#define IO_ERR_MEM_SL 0x10000 /* SPA space lost or corrupted */ -#define IO_ERR_MEM_SE 0x00200 /* severity: minor */ -#define IO_ERR_MEM_HE 0x00100 /* severity: affects invalid parts */ -#define IO_ERR_MEM_FE 0x00080 /* severity: bad */ -#define IO_ERR_MEM_RY 0x00040 /* IO_COMMAND register ready for command */ -#define IO_ERR_DMA_DG 0x00010 /* module in diagnostic mode */ -#define IO_ERR_DMA_PW 0x00004 /* Power Failing */ -#define IO_ERR_DMA_PL 0x00002 /* Power Lost */ -#define IO_ERR_VAL(x) (((x) >> 10) & 0x3f) -#define IO_ERR_DEPEND 0 /* unspecified error */ -#define IO_ERR_SPA 1 /* (module-type specific) */ -#define IO_ERR_INTERNAL 2 /* (module-type specific) */ -#define IO_ERR_MODE 3 /* invalid mode or address space mapping */ -#define IO_ERR_ERROR_M 4 /* bus error (master detect) */ -#define IO_ERR_DPARITY_S 5 /* data parity (slave detect) */ -#define IO_ERR_PROTO_M 6 /* protocol error (master detect) */ -#define IO_ERR_ADDRESS 7 /* no slave acknowledgement in transaction */ -#define IO_ERR_MORE 8 /* device transferred more data than expected */ -#define IO_ERR_LESS 9 /* device transferred less data than expected */ -#define IO_ERR_SAPARITY 10 /* slave address phase parity */ -#define IO_ERR_MAPARITY 11 /* master address phase parity */ -#define IO_ERR_MDPARITY 12 /* mode phase parity */ -#define IO_ERR_STPARITY 13 /* status phase parity */ -#define IO_ERR_CMD 14 /* unimplemented I/O Command */ -#define IO_ERR_BUS 15 /* generic bus error */ -#define IO_ERR_CORR 24 /* correctable memory error */ -#define IO_ERR_UNCORR 25 /* uncorrectable memory error */ -#define IO_ERR_MAP 26 /* equivalent to IO_ERR_CORR */ -#define IO_ERR_LINK 28 /* Bus Converter "link" (connection) error */ -#define IO_ERR_CCMD 32 /* Illegal DMA command */ -#define IO_ERR_ERROR_S 52 /* bus error (slave detect) */ -#define IO_ERR_DPARITY_M 53 /* data parity (master detect) */ -#define IO_ERR_PROTOCOL 54 /* protocol error (slave detect) */ -#define IO_ERR_SELFTEST 58 /* (module-type specific) */ -#define IO_ERR_BUSY 59 /* slave was busy too often or too long */ -#define IO_ERR_RETRY 60 /* "busied" transaction not retried soon enough */ -#define IO_ERR_ACCESS 61 /* illegal register access */ -#define IO_ERR_IMPROP 62 /* "improper" data written */ -#define IO_ERR_UNKNOWN 63 - -/* io_control (memory) */ -#define IO_CTL_MEMINIT 0x0 /* prevent some bus errors during memory init */ -#define IO_CTL_MEMOKAY 0x100 /* enable all bus error logging */ - -/* io_spa */ -#define SPA_ENABLE 0x20 /* io_spa register enable spa bit */ - -#endif /* _MACHINE_IOMOD_H_ */ diff --git a/sys/arch/hppa/include/isa_machdep.h b/sys/arch/hppa/include/isa_machdep.h deleted file mode 100644 index 71ea8984d..000000000 --- a/sys/arch/hppa/include/isa_machdep.h +++ /dev/null @@ -1,59 +0,0 @@ -/* $OpenBSD: isa_machdep.h,v 1.4 2011/03/23 16:54:35 pirofti Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#ifndef _MACHINE_ISA_MACHDEP_H_ -#define _MACHINE_ISA_MACHDEP_H_ -/* - * Types provided to machine-independent ISA code. - */ -typedef struct hppa_isa_chipset *isa_chipset_tag_t; - -struct hppa_isa_chipset { - void *ic_v; - - void (*ic_attach_hook)(struct device *, struct device *, - struct isabus_attach_args *); - void *(*ic_intr_establish)(void *, int, int, int, - int (*)(void *), void *, const char *); - void (*ic_intr_disestablish)(void *, void *); - int (*ic_intr_check)(void *, int, int); -}; - -/* - * Functions provided to machine-independent ISA code. - */ -#define isa_attach_hook(p, s, a) \ - (*(a)->iba_ic->ic_attach_hook)((p), (s), (a)) -#define isa_intr_establish(c, i, t, l, f, a, nm) \ - (*(c)->ic_intr_establish)((c)->ic_v, (i), (t), (l), (f), (a), (nm)) -#define isa_intr_disestablish(c, h) \ - (*(c)->ic_intr_disestablish)((c)->ic_v, (h)) -#define isa_intr_check(c, i, t) \ - (*(c)->ic_intr_check)((c)->ic_v, (i), (t)) - -#endif /* _MACHINE_ISA_MACHDEP_H_ */ diff --git a/sys/arch/hppa/include/kcore.h b/sys/arch/hppa/include/kcore.h deleted file mode 100644 index 2903204d4..000000000 --- a/sys/arch/hppa/include/kcore.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $OpenBSD: kcore.h,v 1.2 2004/04/07 18:24:19 mickey Exp $ */ - -/* - * Copyright (c) 1999 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#ifndef _MACHINE_KCORE_H_ -#define _MACHINE_KCORE_H_ - -typedef -struct cpu_kcore_hdr { - int dummy; -} cpu_kcore_hdr_t; - -#endif /* _MACHINE_KCORE_H_ */ diff --git a/sys/arch/hppa/include/limits.h b/sys/arch/hppa/include/limits.h deleted file mode 100644 index 2b5d7cb06..000000000 --- a/sys/arch/hppa/include/limits.h +++ /dev/null @@ -1,54 +0,0 @@ -/* $OpenBSD: limits.h,v 1.14 2015/04/30 13:42:08 millert Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)limits.h 8.3 (Berkeley) 1/4/94 - */ - -#ifndef _MACHINE_LIMITS_H_ -#define _MACHINE_LIMITS_H_ - -#include - -#if __POSIX_VISIBLE || __XPG_VISIBLE -#define SSIZE_MAX LONG_MAX /* max value for a ssize_t */ -#endif - -#if __BSD_VISIBLE -#define SIZE_T_MAX ULONG_MAX /* max value for a size_t (historic) */ - -/* GCC requires that quad constants be written as expressions. */ -#define UQUAD_MAX ((u_quad_t)0-1) /* max value for a uquad_t */ - /* max value for a quad_t */ -#define QUAD_MAX ((quad_t)(UQUAD_MAX >> 1)) -#define QUAD_MIN (-QUAD_MAX-1) /* min value for a quad_t */ - -#endif /* __BSD_VISIBLE */ - -#endif /* _MACHINE_LIMITS_H_ */ diff --git a/sys/arch/hppa/include/loadfile_machdep.h b/sys/arch/hppa/include/loadfile_machdep.h deleted file mode 100644 index bfb659f36..000000000 --- a/sys/arch/hppa/include/loadfile_machdep.h +++ /dev/null @@ -1,80 +0,0 @@ -/* $OpenBSD: loadfile_machdep.h,v 1.6 2011/03/23 16:54:35 pirofti Exp $ */ - -/*- - * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas and Jason R. Thorpe. - * - * 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. - */ - -#ifndef _MACHINE_LOADFILE_MACHDEP_H_ -#define _MACHINE_LOADFILE_MACHDEP_H_ - -#define BOOT_ELF -#define BOOT_ELF32 -#define BOOT_ELF64 - -/* Keep a default ELFSIZE */ -#define ELFSIZE 32 - -#define LOAD_KERNEL LOAD_ALL -#define COUNT_KERNEL COUNT_ALL - -#ifdef _STANDALONE - -#define LOADADDR(a) ((u_int)(a) + offset) -#define ALIGNENTRY(a) 0 -#define READ(f, b, c) pread((f), (void *)LOADADDR(b), (c)) -#define BCOPY(s, d, c) vpbcopy((s), (void *)LOADADDR(d), (c)) -#define BZERO(d, c) pbzero((void *)LOADADDR(d), (c)) -#define WARN(a) (void)(printf a, \ - printf((errno ? ": %s\n" : "\n"), \ - strerror(errno))) -#define PROGRESS(a) (void) printf a -#define ALLOC(a) alloc(a) -#define FREE(a, b) free(a, b) - -#define vpbcopy bcopy -#define pbzero bzero -#define pread read - -#else - -#define LOADADDR(a) (((u_int)(a)) + offset) -#define ALIGNENTRY(a) ((u_int)(a)) -#define READ(f, b, c) read((f), (void *)LOADADDR(b), (c)) -#define BCOPY(s, d, c) memcpy((void *)LOADADDR(d), (void *)(s), (c)) -#define BZERO(d, c) memset((void *)LOADADDR(d), 0, (c)) -#define WARN(a) warn a -#define PROGRESS(a) /* nothing */ -#define ALLOC(a) malloc(a) -#define FREE(a, b) free(a) - -ssize_t vread(int, u_long, u_long *, size_t); -void vcopy(u_long, u_long, u_long *, size_t); -void vzero(u_long, u_long *, size_t); - -#endif -#endif /* ! _MACHINE_LOADFILE_MACHDEP_H_ */ diff --git a/sys/arch/hppa/include/mplock.h b/sys/arch/hppa/include/mplock.h deleted file mode 100644 index b0c2d7299..000000000 --- a/sys/arch/hppa/include/mplock.h +++ /dev/null @@ -1,74 +0,0 @@ -/* $OpenBSD: mplock.h,v 1.5 2019/04/23 13:35:12 visa Exp $ */ - -/* - * Copyright (c) 2004 Niklas Hallqvist. 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. - */ - -#ifndef _MACHINE_MPLOCK_H_ -#define _MACHINE_MPLOCK_H_ - -/* - * Really simple spinlock implementation with recursive capabilities. - * Correctness is paramount, no fancyness allowed. - */ - -#define MPL_LOCKED 0 -#define MPL_UNLOCKED 1 - -struct __mp_lock { - volatile int mpl_lock[4]; - volatile struct cpu_info *mpl_cpu; - volatile long mpl_count; -#ifdef WITNESS - struct lock_object mpl_lock_obj; -#endif -}; - -#ifndef _LOCORE - -void ___mp_lock_init(struct __mp_lock *); -void __mp_lock(struct __mp_lock *); -void __mp_unlock(struct __mp_lock *); -int __mp_release_all(struct __mp_lock *); -int __mp_release_all_but_one(struct __mp_lock *); -void __mp_acquire_count(struct __mp_lock *, int); -int __mp_lock_held(struct __mp_lock *, struct cpu_info *); - -#ifdef WITNESS - -void _mp_lock_init(struct __mp_lock *, const struct lock_type *); - -#define __mp_lock_init(mpl) do { \ - static const struct lock_type __lock_type = { .lt_name = #mpl };\ - _mp_lock_init((mpl), &__lock_type); \ -} while (0) - -#else /* WITNESS */ - -#define __mp_lock_init ___mp_lock_init - -#endif /* WITNESS */ - -#endif - -#endif /* !_MACHINE_MPLOCK_H */ diff --git a/sys/arch/hppa/include/mutex.h b/sys/arch/hppa/include/mutex.h deleted file mode 100644 index 0aa8d1b32..000000000 --- a/sys/arch/hppa/include/mutex.h +++ /dev/null @@ -1,93 +0,0 @@ -/* $OpenBSD: mutex.h,v 1.9 2018/01/13 15:18:11 mpi Exp $ */ - -/* - * Copyright (c) 2004 Artur Grabowski - * 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. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED ``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. - */ - -#ifndef _MACHINE_MUTEX_H_ -#define _MACHINE_MUTEX_H_ - -#include - -#define MUTEX_UNLOCKED { 1, 1, 1, 1 } - -/* Note: mtx_lock must be 16-byte aligned. */ -struct mutex { -#ifdef MULTIPROCESSOR - volatile int mtx_lock[4]; -#endif - int mtx_wantipl; - int mtx_oldipl; - volatile void *mtx_owner; -#ifdef WITNESS - struct lock_object mtx_lock_obj; -#endif -}; - -/* - * To prevent lock ordering problems with the kernel lock, we need to - * make sure we block all interrupts that can grab the kernel lock. - * The simplest way to achieve this is to make sure mutexes always - * raise the interrupt priority level to the highest level that has - * interrupts that grab the kernel lock. - */ -#ifdef MULTIPROCESSOR -#define __MUTEX_IPL(ipl) \ - (((ipl) > IPL_NONE && (ipl) < IPL_MPFLOOR) ? IPL_MPFLOOR : (ipl)) -#ifdef WITNESS -#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { MUTEX_UNLOCKED, __MUTEX_IPL((ipl)), 0, NULL, \ - MTX_LO_INITIALIZER(name, flags) } -#else /* WITNESS */ -#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { MUTEX_UNLOCKED, __MUTEX_IPL((ipl)), 0, NULL } -#endif /* WITNESS */ -#else /* MULTIPROCESSOR */ -#define __MUTEX_IPL(ipl) (ipl) -#define MUTEX_INITIALIZER_FLAGS(ipl, name, flags) \ - { __MUTEX_IPL((ipl)), 0, NULL } -#endif /* MULTIPROCESSOR */ - -void __mtx_init(struct mutex *, int); -#define _mtx_init(mtx, ipl) __mtx_init((mtx), __MUTEX_IPL((ipl))) - -#ifdef DIAGNOSTIC -#define MUTEX_ASSERT_LOCKED(mtx) do { \ - if ((mtx)->mtx_owner != curcpu()) \ - panic("mutex %p not held in %s", (mtx), __func__); \ -} while (0) - -#define MUTEX_ASSERT_UNLOCKED(mtx) do { \ - if ((mtx)->mtx_owner == curcpu()) \ - panic("mutex %p held in %s", (mtx), __func__); \ -} while (0) -#else -#define MUTEX_ASSERT_LOCKED(mtx) do { } while (0) -#define MUTEX_ASSERT_UNLOCKED(mtx) do { } while (0) -#endif - -#define MUTEX_LOCK_OBJECT(mtx) (&(mtx)->mtx_lock_obj) -#define MUTEX_OLDIPL(mtx) (mtx)->mtx_oldipl - -#endif diff --git a/sys/arch/hppa/include/param.h b/sys/arch/hppa/include/param.h deleted file mode 100644 index 355b349c6..000000000 --- a/sys/arch/hppa/include/param.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $OpenBSD: param.h,v 1.48 2022/09/10 20:35:28 miod Exp $ */ - -/* - * Copyright (c) 1988-1994, The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - */ - -#ifndef _MACHINE_PARAM_H_ -#define _MACHINE_PARAM_H_ - -#ifdef _KERNEL -#include -#include -#endif - -#define _MACHINE hppa -#define MACHINE "hppa" -#define _MACHINE_ARCH hppa -#define MACHINE_ARCH "hppa" -#define MID_MACHINE MID_HPUX800 - -#define PAGE_SHIFT 12 -#define PAGE_SIZE (1 << PAGE_SHIFT) -#define PAGE_MASK (PAGE_SIZE - 1) - -#define KERNBASE 0x00000000 /* start of kernel virtual */ - -#ifdef _KERNEL - -#define NBPG PAGE_SIZE /* bytes/page */ -#define PGSHIFT PAGE_SHIFT /* LOG2(PAGE_SIZE) */ -#define PGOFSET PAGE_MASK /* byte offset into page */ - -#define UPAGES 4 /* pages of u-area */ -#define USPACE (UPAGES * PAGE_SIZE) /* total size of u-area */ -#define USPACE_ALIGN 0 /* u-area alignment 0-none */ - -#define NMBCLUSTERS (32 * 1024) /* max cluster allocation */ - -#ifndef MSGBUFSIZE -#define MSGBUFSIZE (2 * PAGE_SIZE) /* default message buffer size */ -#endif - -/* - * Maximum size of the kernel malloc arena in PAGE_SIZE-sized - * logical pages. - */ -#define NKMEMPAGES_MAX_DEFAULT ((128 * 1024 * 1024) >> PAGE_SHIFT) - -#endif /* _KERNEL */ - -#define MACHINE_STACK_GROWS_UP 1 /* stack grows to higher addresses */ - -#endif /* _MACHINE_PARAM_H_ */ diff --git a/sys/arch/hppa/include/pcb.h b/sys/arch/hppa/include/pcb.h deleted file mode 100644 index 1c1a92928..000000000 --- a/sys/arch/hppa/include/pcb.h +++ /dev/null @@ -1,43 +0,0 @@ -/* $OpenBSD: pcb.h,v 1.16 2015/05/05 02:13:46 guenther Exp $ */ - -/* - * Copyright (c) 1999-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#ifndef _MACHINE_PCB_H_ -#define _MACHINE_PCB_H_ - -#include -#include - -struct pcb { - struct hppa_fpstate *pcb_fpstate; /* not in the trapframe */ - - u_int32_t pcb_ksp; /* kernel sp for ctxsw */ - u_int32_t pcb_onfault; /* SW copy fault handler */ - pa_space_t pcb_space; /* copy pmap_space, for asm's sake */ -}; - -#endif /* _MACHINE_PCB_H_ */ diff --git a/sys/arch/hppa/include/pci_machdep.h b/sys/arch/hppa/include/pci_machdep.h deleted file mode 100644 index 7e3d77b6f..000000000 --- a/sys/arch/hppa/include/pci_machdep.h +++ /dev/null @@ -1,102 +0,0 @@ -/* $OpenBSD: pci_machdep.h,v 1.12 2016/05/04 14:30:00 kettenis Exp $ */ - -/* - * Copyright (c) 2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#ifndef _MACHINE_PCI_MACHDEP_H_ -#define _MACHINE_PCI_MACHDEP_H_ - -/* - * Types provided to machine-independent PCI code - */ -typedef struct hppa_pci_chipset_tag *pci_chipset_tag_t; -typedef u_long pcitag_t; -typedef u_long pci_intr_handle_t; - -struct pci_attach_args; - -struct hppa_pci_chipset_tag { - void *_cookie; - void (*pc_attach_hook)(struct device *, - struct device *, struct pcibus_attach_args *); - int (*pc_bus_maxdevs)(void *, int); - pcitag_t (*pc_make_tag)(void *, int, int, int); - void (*pc_decompose_tag)(void *, pcitag_t, int *, - int *, int *); - int (*pc_conf_size)(void *, pcitag_t); - pcireg_t (*pc_conf_read)(void *, pcitag_t, int); - void (*pc_conf_write)(void *, pcitag_t, int, pcireg_t); - - int (*pc_intr_map)(struct pci_attach_args *, - pci_intr_handle_t *); - const char *(*pc_intr_string)(void *, pci_intr_handle_t); - void *(*pc_intr_establish)(void *, pci_intr_handle_t, - int, int (*)(void *), void *, const char *); - void (*pc_intr_disestablish)(void *, void *); - - void *(*pc_alloc_parent)(struct device *, - struct pci_attach_args *, int); -}; - -/* - * Functions provided to machine-independent PCI code. - */ -#define pci_attach_hook(p, s, pba) \ - (*(pba)->pba_pc->pc_attach_hook)((p), (s), (pba)) -#define pci_bus_maxdevs(c, b) \ - (*(c)->pc_bus_maxdevs)((c)->_cookie, (b)) -#define pci_make_tag(c, b, d, f) \ - (*(c)->pc_make_tag)((c)->_cookie, (b), (d), (f)) -#define pci_decompose_tag(c, t, bp, dp, fp) \ - (*(c)->pc_decompose_tag)((c)->_cookie, (t), (bp), (dp), (fp)) -#define pci_conf_size(c, t) \ - (*(c)->pc_conf_size)((c)->_cookie, (t)) -#define pci_conf_read(c, t, r) \ - (*(c)->pc_conf_read)((c)->_cookie, (t), (r)) -#define pci_conf_write(c, t, r, v) \ - (*(c)->pc_conf_write)((c)->_cookie, (t), (r), (v)) -#define pci_intr_map(p, ihp) \ - (*(p)->pa_pc->pc_intr_map)((p), (ihp)) -#define pci_intr_map_msi(p, ihp) (-1) -#define pci_intr_map_msix(p, vec, ihp) (-1) -#define pci_intr_line(c, ih) (ih) -#define pci_intr_string(c, ih) \ - (*(c)->pc_intr_string)((c)->_cookie, (ih)) -#define pci_intr_establish(c, ih, l, h, a, nm) \ - (*(c)->pc_intr_establish)((c)->_cookie, (ih), (l), (h), (a), (nm)) -#define pci_intr_disestablish(c, iv) \ - (*(c)->pc_intr_disestablish)((c)->_cookie, (iv)) -#define pci_probe_device_hook(c, a) (0) - -#define pci_min_powerstate(c, t) (PCI_PMCSR_STATE_D3) -#define pci_set_powerstate_md(c, t, s, p) - -#define pciide_machdep_compat_intr_establish(a, b, c, d, e) (NULL) -#define pciide_machdep_compat_intr_disestablish(a, b) ((void)(a), (void)(b)) - -#define pci_dev_postattach(a, b) - -#endif /* _MACHINE_PCI_MACHDEP_H_ */ diff --git a/sys/arch/hppa/include/pdc.h b/sys/arch/hppa/include/pdc.h deleted file mode 100644 index da1296050..000000000 --- a/sys/arch/hppa/include/pdc.h +++ /dev/null @@ -1,782 +0,0 @@ -/* $OpenBSD: pdc.h,v 1.37 2021/03/11 11:16:57 jsg Exp $ */ - -/* - * Copyright (c) 1990 mt Xinu, Inc. All rights reserved. - * Copyright (c) 1990,1991,1992,1994 University of Utah. All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * Copyright (c) 1990 mt Xinu, Inc. - * This file may be freely distributed in any form as long as - * this copyright notice is included. - * MTXINU, THE UNIVERSITY OF UTAH, AND CSL PROVIDE THIS SOFTWARE ``AS - * IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, - * WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND - * FITNESS FOR A PARTICULAR PURPOSE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: pdc.h 1.12 94/12/14$ - * Author: Jeff Forys (CSS), Dave Slattengren (mtXinu) - */ - -#ifndef _MACHINE_PDC_H_ -#define _MACHINE_PDC_H_ - -/* - * Definitions for interaction with "Processor Dependent Code", - * which is a set of ROM routines used to provide information to the OS. - * Also includes definitions for the layout of "Page Zero" memory when - * boot code is invoked. - * - * Glossary: - * PDC: Processor Dependent Code (ROM or copy of ROM). - * IODC: I/O Dependent Code (module-type dependent code). - * IPL: Boot program (loaded into memory from boot device). - * HPA: Hard Physical Address (hardwired address). - * SPA: Soft Physical Address (reconfigurable address). - * - * - * - * - * Definitions for talking to IODC (I/O Dependent Code). - * - * The PDC is used to load I/O Dependent Code from a particular module. - * I/O Dependent Code is module-type dependent software which provides - * a uniform way to identify, initialize, and access a module (and in - * some cases, their devices). - */ - -/* - * Our Initial Memory Module is laid out as follows. - * - * 0x000 +--------------------+ - * | Page Zero (iomod.h)| - * 0x800 +--------------------+ - * | | - * | | - * | PDC | - * | | - * | | - * MEM_FREE +--------------------+ - * | | - * | Console IODC | - * | | - * MEM_FREE+64k +--------------------+ - * | | - * | Boot Device IODC | - * | | - * IPL_START +--------------------+ - * | | - * | IPL Code or Kernel | - * | | - * +--------------------+ - * - * Restrictions: - * MEM_FREE (pagezero.mem_free) can be no greater than 32K. - * The PDC may use up to MEM_FREE + 32K (for Console & Boot IODC). - * IPL_START must be less than or equal to 64K. - * - * The IPL (boot) Code is immediately relocated to RELOC (check - * "../stand/Makefile") to make way for the Kernel. - */ - -#define IODC_MAXSIZE (16 * 4 * 1024) /* maximum size of IODC */ -#define IODC_MINIOSIZ 64 /* minimum buffer size for IODC call */ -#define IODC_MAXIOSIZ (64 * 1024) /* maximum buffer size for IODC call */ -#define IODC_IOSIZ (16 * 1024) - -#define PDC_ALIGNMENT __attribute__ ((__aligned__(64))) -#define PDC_STACKSIZE (4 * PAGE_SIZE) - -/* - * The PDC Entry Points and their arguments... - */ - -#define PDC_POW_FAIL 1 /* prepare for power failure */ -#define PDC_POW_FAIL_DFLT 0 - -#define PDC_CHASSIS 2 /* update chassis display (see below) */ -#define PDC_CHASSIS_DISP 0 /* update display */ -#define PDC_CHASSIS_WARN 1 /* return warnings */ -#define PDC_CHASSIS_ALL 2 /* update display & return warnings */ -#define PDC_CHASSIS_INFO 128 /* return led/lcd info */ - -#define PDC_PIM 3 /* access Processor Internal Memory */ -#define PDC_PIM_HPMC 0 /* read High Pri Mach Chk data */ -#define PDC_PIM_SIZE 1 /* return size */ -#define PDC_PIM_LPMC 2 /* read Low Pri Mach Chk data */ -#define PDC_PIM_SBD 3 /* read soft boot data */ -#define PDC_PIM_TOC 4 /* read TOC data (used to use HPMC) */ - -#define PDC_MODEL 4 /* processor model number info */ -#define PDC_MODEL_INFO 0 /* processor model number info */ -#define PDC_MODEL_BOOTID 1 /* set BOOT_ID of processor */ -#define PDC_MODEL_COMP 2 /* return component version numbers */ -#define PDC_MODEL_MODEL 3 /* return system model information */ -#define PDC_MODEL_ENSPEC 4 /* enable product-specific instrs */ -#define PDC_MODEL_DISPEC 5 /* disable product-specific instrs */ -#define PDC_MODEL_CPUID 6 /* return CPU versions */ -#define PDC_MODEL_CPBALITIES 7 /* return capabilities */ -#define PDC_MODEL_GETBOOTOPTS 8 /* return boot test options */ -#define PDC_MODEL_SETBOOTOPTS 9 /* set boot test options */ - -#define PDC_CACHE 5 /* return cache and TLB params */ -#define PDC_CACHE_DFLT 0 /* return parameters */ -#define PDC_CACHE_SETCS 1 /* set coherence state */ -#define PDC_CACHE_GETSPIDB 2 /* get space-id bits */ - -#define PDC_HPA 6 /* return HPA of processor */ -#define PDC_HPA_DFLT 0 -#define PDC_HPA_MODULES 1 - -#define PDC_COPROC 7 /* return co-processor configuration */ -#define PDC_COPROC_DFLT 0 - -#define PDC_IODC 8 /* talk to IODC */ -#define PDC_IODC_READ 0 /* read IODC entry point */ -#define IODC_DATA 0 /* get first 16 bytes from mod IODC */ -#define IODC_INIT 3 /* initialize (see options below) */ -#define IODC_INIT_FIRST 2 /* find first device on module */ -#define IODC_INIT_NEXT 3 /* find subsequent devices on module */ -#define IODC_INIT_ALL 4 /* initialize module and device */ -#define IODC_INIT_DEV 5 /* initialize device */ -#define IODC_INIT_MOD 6 /* initialize module */ -#define IODC_INIT_MSG 9 /* return error message(s) */ -#define IODC_INIT_STR 20 /* find device w/ spec in string */ -#define IODC_IO 4 /* perform I/O (see options below) */ -#define IODC_IO_READ 0 /* read from boot device */ -#define IODC_IO_WRITE 1 /* write to boot device */ -#define IODC_IO_CONSIN 2 /* read from console */ -#define IODC_IO_CONSOUT 3 /* write to conosle */ -#define IODC_IO_CLOSE 4 /* close device */ -#define IODC_IO_MSG 9 /* return error message(s) */ -#define IODC_SPA 5 /* get extended SPA information */ -#define IODC_SPA_DFLT 0 /* return SPA information */ -#define IODC_TEST 8 /* perform self tests */ -#define IODC_TEST_INFO 0 /* return test information */ -#define IODC_TEST_STEP 1 /* execute a particular test */ -#define IODC_TEST_TEST 2 /* describe a test section */ -#define IODC_TEST_MSG 9 /* return error message(s) */ -#define PDC_IODC_NINIT 2 /* non-destructive init */ -#define PDC_IODC_DINIT 3 /* destructive init */ -#define PDC_IODC_MEMERR 4 /* check for memory errors */ -#define PDC_IODC_IMEMMASTER 5 /* interlieved memory master ID */ - -#define PDC_TOD 9 /* access time-of-day clock */ -#define PDC_TOD_READ 0 /* read TOD clock */ -#define PDC_TOD_WRITE 1 /* write TOD clock */ -#define PDC_TOD_ITIMER 2 /* calibrate Interval Timer (CR16) */ - -#define PDC_STABLE 10 /* access Stable Storage (SS) */ -#define PDC_STABLE_READ 0 /* read SS */ -#define PDC_STABLE_WRITE 1 /* write SS */ -#define PDC_STABLE_SIZE 2 /* return size of SS */ -#define PDC_STABLE_VRFY 3 /* verify contents of SS */ -#define PDC_STABLE_INIT 4 /* initialize SS */ - -#define PDC_NVM 11 /* access Non-Volatile Memory (NVM) */ -#define PDC_NVM_READ 0 /* read NVM */ -#define PDC_NVM_WRITE 1 /* write NVM */ -#define PDC_NVM_SIZE 2 /* return size of NVM */ -#define PDC_NVM_VRFY 3 /* verify contents of NVM */ -#define PDC_NVM_INIT 4 /* initialize NVM */ - -#define PDC_ADD_VALID 12 /* check address for validity */ -#define PDC_ADD_VALID_DFLT 0 - -#define PDC_BUS_BAD 13 /* verify Error Detection Circuitry (EDC) */ -#define PDC_BUS_BAD_DLFT 0 - -#define PDC_DEBUG 14 /* return address of PDC debugger */ -#define PDC_DEBUG_DFLT 0 - -#define PDC_INSTR 15 /* return instr that invokes PDCE_CHECK */ -#define PDC_INSTR_DFLT 0 - -#define PDC_PROC 16 /* stop currently executing processor */ -#define PDC_PROC_STOP 0 -#define PDC_PROC_RENDEZVOUS 1 - -#define PDC_CONF 17 /* (de)configure a module */ -#define PDC_CONF_DECONF 0 /* deconfigure module */ -#define PDC_CONF_RECONF 1 /* reconfigure module */ -#define PDC_CONF_INFO 2 /* get config information */ - -#define PDC_BLOCK_TLB 18 /* Manage Block TLB entries (BTLB) */ -#define PDC_BTLB_DEFAULT 0 /* Return BTLB configuration info */ -#define PDC_BTLB_INSERT 1 /* Insert a BTLB entry */ -#define PDC_BTLB_PURGE 2 /* Purge a BTLB entry */ -#define PDC_BTLB_PURGE_ALL 3 /* Purge all BTLB entries */ - -#define PDC_TLB 19 /* Manage Hardware TLB handling */ -#define PDC_TLB_INFO 0 /* Return HW-TLB configuration info */ -#define PDC_TLB_CONFIG 1 /* Set HW-TLB pdir base and size */ - -#define PDC_TLB_CURRPDE 1 /* cr28 points to current pde on miss */ -#define PDC_TLB_RESERVD 3 /* reserved */ -#define PDC_TLB_NEXTPDE 5 /* cr28 points to next pde on miss */ -#define PDC_TLB_WORD3 7 /* cr28 is word 3 of 16 byte pde */ - -#define PDC_PSW 21 /* manage default values of configurable psw bits */ -#define PDC_PSW_GETMASK 0 /* get mask */ -#define PDC_PSW_DEFAULTS 1 /* get default bits values */ -#define PDC_PSW_SETDEFAULTS 2 /* set default bits values */ - -#define PDC_SYSMAP 22 /* map system modules */ -#define PDC_SYSMAP_FIND 0 /* find module by index */ -#define PDC_SYSMAP_ADDR 1 /* fetch list of addresses */ -#define PDC_SYSMAP_HPA 2 /* get hpa from devpath */ - -#define PDC_SOFT_POWER 23 /* support for soft power switch */ -#define PDC_SOFT_POWER_INFO 0 /* get info about soft power switch */ -#define PDC_SOFT_POWER_ENABLE 1 /* enable/disable soft power switch */ - -#define PDC_PAT_CELL 64 /* cell operations */ -#define PDC_PAT_CELL_GETID 0 /* get cell id number */ -#define PDC_PAT_CELL_GETINFO 1 /* get cell info */ -#define PDC_PAT_CELL_MODULE 2 /* get module info */ -#define PDC_PAT_IOVIEW 0 -#define PDC_PAT_PAVIEW 1 - -#define PDC_PAT_CHASSIS 65 /* chassis log ops */ -#define PDC_PAT_CHASSIS_WRITE 0 -#define PDC_PAT_CHASSIS_READ 1 - -#define PDC_PAT_CPU 67 - -#define PDC_PAT_EVENT 68 - -#define PDC_PAT_HPMC 70 - -#define PDC_PAT_IO 71 /* online services for IO modules */ -#define PDC_PAT_IO_GET_PCI_RTSZ 15 -#define PDC_PAT_IO_GET_PCI_RT 16 - -#define PDC_PAT_MEM 72 - -#define PDC_PAT_NVRAM 73 - -#define PDC_PAT_PROTDOM 74 - -#define PDC_MEMMAP 128 /* hp700: return page information */ -#define PDC_MEMMAP_HPA 0 /* map module # to HPA */ - -#define PDC_EEPROM 129 /* Hversion dependent */ -#define PDC_EEPROM_READ_WORD 0 -#define PDC_EEPROM_WRITE_WORD 1 -#define PDC_EEPROM_READ_BYTE 2 -#define PDC_EEPROM_WRITE_BYTE 3 - -#define PDC_IO 135 -#define PDC_IO_READ_AND_CLEAR_ERRORS 0 -#define PDC_IO_RESET 1 -#define PDC_IO_RESET_DEVICES 2 - -#define PDC_BROADCAST_RESET 136 -#define PDC_DO_RESET 0 -#define PDC_DO_FIRM_TEST_RESET 1 -#define PDC_BR_RECONFIGURATION 2 - -#define PDC_LAN_STATION_ID 138 /* Hversion dependent mechanism for */ -#define PDC_LAN_STATION_ID_READ 0 /* getting the lan station address */ - -#define PDC_PCI_INDEX 147 /* PCI rt access */ -#define PDC_PCI_GET_INT_TBL_SZ 13 -#define PDC_PCI_GET_INT_TBL 14 - -#define PDC_ERR_OK 0 /* operation complete */ -#define PDC_ERR_WARNING 3 /* OK, but warning */ -#define PDC_ERR_NOPROC -1 /* no such procedure */ -#define PDC_ERR_NOPT -2 /* no such option */ -#define PDC_ERR_COMPL -3 /* unable to complete w/o error */ -#define PDC_ERR_EOD -9 /* end of device list */ -#define PDC_ERR_INVAL -10 /* invalid argument */ -#define PDC_ERR_PFAIL -12 /* aborted by powerfail */ - -#if !defined(_LOCORE) - -struct iomod; - -typedef int (*pdcio_t)(int, int, ...); -typedef int (*iodcio_t)(u_int, int, ...); - -/* - * Commonly used PDC calls and the structures they return. - */ - -/* - * Device path specifications used by PDC. - */ -struct device_path { - u_char dp_flags; /* see bit definitions below */ - char dp_bc[6]; /* Bus Converter routing info to a specific */ - /* I/O adaptor (< 0 means none, > 63 resvd) */ - u_char dp_mod; /* fixed field of specified module */ - int dp_layers[6]; /* device-specific info (ctlr #, unit # ...) */ -}; - -struct pdc_model { /* PDC_MODEL */ - u_int hvers; /* hardware version */ - u_int rev : 4; /* zero for all native processors */ - u_int model : 20; /* 4 for all native processors */ - u_int sh : 1; /* shadow registers are present */ - u_int reserved : 2; /* reserved */ - u_int mc : 1; /* module category (A - 0, B - 1) */ - u_int reserved1 : 2; /* reserved */ - u_int pa_lvl : 2; /* PA-RISC level */ - u_int hw_id; /* unique processor hardware identifier */ - u_int boot_id; /* same as hw_id */ - u_int sw_id; /* software security and licensing */ - u_int sw_cap; /* OS capabilities of processor */ - u_int arch_rev; /* architecture revision */ - u_int pot_key; /* potential key */ - u_int curr_key; /* current key */ - int filler1; - u_int filler2[22]; -}; - -struct pdc_cpuid { /* PDC_MODEL_CPUID */ - u_int reserved : 20; - u_int version : 7; /* CPU version */ - u_int revision : 5; /* CPU revision */ - u_int filler[31]; -}; - -struct pdc_getbootopts { /* PDC_MODEL_GETBOOTOPTS */ - u_int cur_test; /* current enabled tests */ - u_int sup_test; /* supported tests */ - u_int def_test; /* default enabled tests */ - u_int filler[29]; -}; - -struct cache_cf { /* PDC_CACHE (for "struct pdc_cache") */ - u_int cc_alias: 4, /* virtual address aliasing boundary */ - cc_block: 4, /* used to determine most efficient stride */ - cc_line : 3, /* max data written by store (16-byte mults) */ - cc_resv1: 2, /* (reserved) */ - cc_wt : 1, /* D-cache: write-to = 0, write-through = 1 */ - cc_sh : 2, /* separate I and D = 0, shared I and D = 1 */ - cc_cst : 3, /* D-cache: incoherent = 0, coherent = 1 */ - cc_resv2:11, /* (reserved) */ - cc_hvers: 2; /* H-VERSION dependent */ -}; - -struct tlb_cf { /* PDC_CACHE (for "struct pdc_cache") */ - u_int tc_resv1:12, /* (reserved) */ - tc_sh : 2, /* separate I and D = 0, shared I and D = 1 */ - tc_hvers: 1, /* H-VERSION dependent */ - tc_page : 1, /* 2K page size = 0, 4k page size = 1 */ - tc_cst : 3, /* incoherent = 0, coherent = 1 */ - tc_resv2: 5, /* (reserved) */ - tc_assoc: 8; /* associativity of TLB */ -}; - -struct pdc_cache { /* PDC_CACHE */ -/* Instruction cache */ - u_int ic_size; /* size of I-cache (in bytes) */ - struct cache_cf ic_conf;/* cache configuration (see above) */ - u_int ic_base; /* start addr of I-cache (for FICE flush) */ - u_int ic_stride; /* addr incr per i_count iteration (flush) */ - u_int ic_count; /* number of i_loop iterations (flush) */ - u_int ic_loop; /* number of FICE's per addr stride (flush) */ -/* Data cache */ - u_int dc_size; /* size of D-cache (in bytes) */ - struct cache_cf dc_conf;/* cache configuration (see above) */ - u_int dc_base; /* start addr of D-cache (for FDCE flush) */ - u_int dc_stride; /* addr incr per d_count iteration (flush) */ - u_int dc_count; /* number of d_loop iterations (flush) */ - u_int dc_loop; /* number of FDCE's per addr stride (flush) */ -/* Instruction TLB */ - u_int it_size; /* number of entries in I-TLB */ - struct tlb_cf it_conf; /* I-TLB configuration (see above) */ - u_int it_sp_base; /* start space of I-TLB (for PITLBE flush) */ - u_int it_sp_stride; /* space incr per sp_count iteration (flush) */ - u_int it_sp_count; /* number of off_count iterations (flush) */ - u_int it_off_base; /* start offset of I-TLB (for PITLBE flush) */ - u_int it_off_stride; /* offset incr per off_count iteration (flush)*/ - u_int it_off_count; /* number of it_loop iterations/space (flush) */ - u_int it_loop; /* number of PITLBE's per off_stride (flush) */ -/* Data TLB */ - u_int dt_size; /* number of entries in D-TLB */ - struct tlb_cf dt_conf; /* D-TLB configuration (see above) */ - u_int dt_sp_base; /* start space of D-TLB (for PDTLBE flush) */ - u_int dt_sp_stride; /* space incr per sp_count iteration (flush) */ - u_int dt_sp_count; /* number of off_count iterations (flush) */ - u_int dt_off_base; /* start offset of D-TLB (for PDTLBE flush) */ - u_int dt_off_stride; /* offset incr per off_count iteration (flush)*/ - u_int dt_off_count; /* number of dt_loop iterations/space (flush) */ - u_int dt_loop; /* number of PDTLBE's per off_stride (flush) */ - u_int filler[2]; -}; - -struct pdc_spidb { /* PDC_CACHE, PDC_CACHE_GETSPIDB */ - u_int spidR1 : 4; - u_int spidbits : 12; - u_int spidR2 : 16; - u_int filler[31]; -}; - -struct pdc_cst { - u_int cstR1 : 16; - u_int cst : 3; - u_int cstR2 : 13; -}; - -struct pdc_coherence { /* PDC_CACHE, PDC_CACHE_SETCS */ - struct pdc_cst ia; -#define ia_cst ia.cst - struct pdc_cst da; -#define da_cst da.cst - struct pdc_cst ita; -#define ita_cst ita.cst - struct pdc_cst dta; -#define dta_cst dta.cst - u_int filler[28]; -}; - -struct pdc_hpa { /* PDC_HPA */ - u_int hpa; /* HPA of processor */ - int filler1; - u_int filler2[30]; -}; - -struct pdc_coproc { /* PDC_COPROC */ - u_int ccr_enable; /* same format as CCR (CR 10) */ - u_int ccr_present; /* which co-proc's are present (bitset) */ - u_int pad[15]; - u_int fpu_revision; - u_int fpu_model; - u_int filler2[13]; -}; - -struct pdc_tod { /* PDC_TOD, PDC_TOD_READ */ - u_int sec; /* elapsed time since 00:00:00 GMT, 1/1/70 */ - u_int usec; /* accurate to microseconds */ - u_int filler2[30]; -}; - -struct pdc_itimer { /* PDC_TOD_ITIMER */ - u_int calib0; /* double giving itmr freq */ - u_int calib1; - u_int tod_acc; /* TOD accuracy in 1e-9 part */ - u_int cr_acc; /* itmr accuracy in 1e-9 parts */ - u_int filler[28]; -}; - -struct pdc_nvm { /* PDC_NVM */ - u_int hv[9]; /* 0x00: HV dependent */ - struct device_path bootpath; /* 0x24: boot path */ - u_int isl_ver; /* 0x44: ISL revision */ - u_int timestamp; /* 0x48: timestamp */ - u_int lif_ue[12]; /* 0x4c: LIF utility entries */ - u_int eptr; /* 0x7c: entry pointer */ - u_int os_panic[32]; /* 0x80: OS panic info */ -}; - -struct pdc_instr { /* PDC_INSTR */ - u_int instr; /* instruction that invokes PDC mchk entry pt */ - int filler1; - u_int filler2[30]; -}; - -struct pdc_iodc_read { /* PDC_IODC, PDC_IODC_READ */ - int size; /* number of bytes in selected entry point */ - int filler1; - u_int filler2[30]; -}; - -struct pdc_iodc_minit { /* PDC_IODC, PDC_IODC_NINIT or PDC_IODC_DINIT */ - u_int stat; /* HPA.io_status style error returns */ - u_int max_spa; /* size of SPA (in bytes) > max_mem+map_mem */ - u_int max_mem; /* size of "implemented" memory (in bytes) */ - u_int map_mem; /* size of "mappable-only" memory (in bytes) */ - u_int filler[28]; -}; - -struct btlb_info { /* for "struct pdc_btlb" (PDC_BTLB) */ - u_int resv0: 8, /* (reserved) */ - num_i: 8, /* Number of instruction slots */ - num_d: 8, /* Number of data slots */ - num_c: 8; /* Number of combined slots */ -}; - -struct pdc_btlb { /* PDC_BLOCK_TLB */ - u_int min_size; /* Min size in pages */ - u_int max_size; /* Max size in pages */ - struct btlb_info finfo; /* Fixed range info */ - struct btlb_info vinfo; /* Variable range info */ - u_int filler[28]; -}; - -struct pdc_hwtlb { /* PDC_TLB */ - u_int min_size; /* What do these mean? */ - u_int max_size; - u_int filler[30]; -}; - -struct pdc_power_info { /* PDC_SOFT_POWER_INFO */ - u_int addr; /* power register address */ - u_int filler[30]; -}; - -struct pdc_sysmap_find { /* PDC_SYSMAP_FIND */ - u_int hpa; - u_int size; /* pages */ - u_int naddrs; - u_int filler[29]; -}; - -struct pdc_sysmap_addrs { /* PDC_SYSMAP_ADDR */ - u_int hpa; - u_int size; /* pages */ - u_int filler[30]; -}; - -struct pdc_sysmap_hpa { /* PDC_SYSMAP_HPA */ - u_int hpa; - u_int size; - u_int naddrs; - u_int mod; - u_int filler[28]; -}; - -struct pdc_pat_cell_id { /* PDC_PAT_CELL_GETID */ - u_long id; /* cell id */ - u_long loc; /* cell location */ - u_long filler[14]; -}; - -struct pdc_pat_cell_module { /* PDC_PAT_CELL_MODULE */ - u_long chpa; /* config space HPA */ - u_long info; /* module info */ -#define PDC_PAT_CELL_MODTYPE(t) (((t) >> 56) & 0xff) -#define PDC_PAT_CELL_MODDVI(t) (((t) >> 48) & 0xff) -#define PDC_PAT_CELL_MODIOC(t) (((t) >> 40) & 0xff) -#define PDC_PAT_CELL_MODSIZE(t) (((t) & 0xffffff) << PAGE_SHIFT) - u_long loc; /* module location */ - struct device_path dp; /* module path */ - u_long pad[508]; /* cell module gedoens */ -}; - -struct pdc_pat_io_num { /* PDC_PAT_IO */ - u_int num; - u_int filler[31]; -}; - -struct pdc_pat_pci_rt { /* PDC_PAT_IO_GET_PCI_RT */ - u_int8_t type; /* 0x8b */ - u_int8_t len; - u_int8_t itype; /* 0 -- vectored int */ - u_int8_t trigger; /* polarity/level */ - u_int8_t pin; /* PCI pin number */ - u_int8_t bus; - u_int8_t seg; /* reserved */ - u_int8_t line; - u_int64_t addr; /* io sapic address */ -}; - -struct pdc_memmap { /* PDC_MEMMAP */ - u_int hpa; /* HPA for module */ - u_int morepages; /* additional IO pages */ - u_int filler[30]; -}; - -struct pdc_lan_station_id { /* PDC_LAN_STATION_ID */ - u_int8_t addr[6]; - u_int8_t filler1[2]; - u_int filler2[30]; -}; - -/* - * The PDC_CHASSIS is a strange bird. The format for updating the display - * is as follows: - * - * 0 11 12 14 15 16 19 20 23 24 27 28 31 - * +-------+----------+-------+--------+--------+--------+--------+ - * | R | OS State | Blank | Hex1 | Hex2 | Hex3 | Hex4 | - * +-------+----------+-------+--------+--------+--------+--------+ - * - * Unfortunately, someone forgot to tell the hardware designers that - * there was supposed to be a hex display somewhere. The result is, - * you can only toggle 5 LED's and the fault light. - * - * Interesting values for Hex1-Hex4 and the resulting LED displays: - * - * FnFF CnFF: - * 0 - - - - - Counts in binary from 0x0 - 0xF - * 2 o - - - - for corresponding values of `n'. - * 4 o o - - - - * 6 o o o - - - * 8 o o o o - - * A o o o o o - * - * If the "Blank" bit is set, the display should be made blank. - * The values for "OS State" are defined below. - */ - -#define PDC_CHASSIS_BAR 0xF0FF /* create a bar graph with LEDs */ -#define PDC_CHASSIS_CNT 0xC0FF /* count with LEDs */ - -#define PDC_OSTAT(os) (((os) & 0x7) << 17) -#define PDC_OSTAT_OFF 0x0 /* all off */ -#define PDC_OSTAT_FAULT 0x1 /* the red LED of death */ -#define PDC_OSTAT_TEST 0x2 /* self test */ -#define PDC_OSTAT_BOOT 0x3 /* boot program running */ -#define PDC_OSTAT_SHUT 0x4 /* shutdown in progress */ -#define PDC_OSTAT_WARN 0x5 /* battery dying, etc */ -#define PDC_OSTAT_RUN 0x6 /* OS running */ -#define PDC_OSTAT_ON 0x7 /* all on */ - -struct pdc_chassis_info { - u_int size; - u_int max_size; - u_int filler[30]; -}; - -struct pdc_chassis_lcd { - u_int model : 16, - width : 16; - u_int cmd_addr; - u_int data_addr; - u_int delay; - u_int8_t line[2]; - u_int8_t enabled; - u_int8_t heartbeat[3]; - u_int8_t disk[3]; - u_int filler[25]; -}; - -/* dp_flags */ -#define PZF_AUTOBOOT 0x80 /* These two are PDC flags for how to locate */ -#define PZF_AUTOSEARCH 0x40 /* the "boot device" */ -#define PZF_TIMER 0x0f /* power of 2 # secs "boot timer" (0 == dflt) */ -#define PZF_BITS "\020\010autoboot\07autosearch" - -/* macros to decode serial parameters out of dp_layers */ -#define PZL_BITS(l) (((l) & 0x03) + 5) -#define PZL_PARITY(l) (((l) & 0x18) >> 3) -#define PZL_SPEED(l) (((l) & 0x3c0) >> 6) -#define PZL_ENCODE(bits, parity, speed) \ - (((bits) - 5) & 0x03) | (((parity) & 0x3) << 3) | \ - (((speed) & 0x0f) << 6) - -/* - * A processors Stable Storage is accessed through the PDC. There are - * at least 96 bytes of stable storage (the device path information may - * or may not exist). However, as far as I know, processors provide at - * least 192 bytes of stable storage. - */ -struct stable_storage { - struct device_path ss_pri_boot; /* (see above) */ - char ss_filenames[32]; - u_short ss_os_version; /* 0 == none, 1 == HP-UX, 2 == MPE-XL */ - char ss_os[22]; /* OS-dependant information */ - char ss_pdc[7]; /* reserved */ - char ss_fast_size; /* how much memory to test. 0xf == all, or */ - /* else it's (256KB << ss_fast_size) */ - struct device_path ss_console; - struct device_path ss_alt_boot; - struct device_path ss_keyboard; -}; - -/* - * Recoverable error indications provided to boot code by the PDC. - * Any non-zero value indicates error. - */ -struct boot_err { - u_int be_resv : 10, /* (reserved) */ - be_fixed : 6, /* module that produced error */ - be_chas : 16; /* error code (interpret as 4 hex digits) */ -}; - -#define HPBE_HBOOT_CORRECTABLE 0 /* hard-boot corrctable error */ -#define HPBE_HBOOT_UNCORRECTBL 1 /* hard-boot uncorrectable error */ -#define HPBE_SBOOT_CORRECTABLE 2 /* soft-boot correctable error */ -#define HPBE_SBOOT_UNCORRECTBL 3 /* soft-boot uncorrectable error */ -#define HPBE_ETEST_MODUNUSABLE 4 /* ENTRY_TEST err: module's unusable */ -#define HPBE_ETEST_MODDEGRADED 5 /* ENTRY_TEST err: module in degraded mode */ - - -/* - * The PDC uses the following structure to completely define an I/O - * module and the interface to its IODC. - */ -typedef -struct pz_device { - struct device_path pz_dp; -#define pz_flags pz_dp.dp_flags -#define pz_bc pz_dp.dp_bc -#define pz_mod pz_dp.dp_mod -#define pz_layers pz_dp.dp_layers - u_int pz_hpa; /* HPA base address of device */ - u_int pz_spa; /* SPA base address (zero if no SPA exists) */ - u_int pz_iodc_io; /* entry point of device's driver routines */ - short pz_resv; /* (reserved) */ - u_short pz_class; /* (see below) */ -} pz_device_t; - -/* pz_class */ -#define PCL_NULL 0 /* illegal */ -#define PCL_RANDOM 1 /* random access (disk) */ -#define PCL_SEQU 2 /* sequential access (tape) */ -#define PCL_DUPLEX 7 /* full-duplex point-to-point (RS-232, Net) */ -#define PCL_KEYBD 8 /* half-duplex input (HIL Keyboard) */ -#define PCL_DISPL 9 /* half-duplex ouptput (display) */ -#define PCL_FC 10 /* fibre channel access media */ -#define PCL_CLASS_MASK 0xf /* XXX class mask */ -#define PCL_NET_MASK 0x1000 /* mask for bootp/tftp device */ - -/* - * The following structure defines what a particular IODC returns when - * given the IODC_DATA argument. - */ -struct iodc_data { - u_int iodc_model: 8, /* hardware model number */ - iodc_revision:8, /* software revision */ - iodc_spa_io: 1, /* 0:memory, 1:device */ - iodc_spa_pack:1, /* 1:packed multiplexor */ - iodc_spa_enb:1, /* 1:has an spa */ - iodc_spa_shift:5, /* power of two # bytes in SPA space */ - iodc_more: 1, /* iodc_data is: 0:8-byte, 1:16-byte */ - iodc_word: 1, /* iodc_data is: 0:byte, 1:word */ - iodc_pf: 1, /* 1:supports powerfail */ - iodc_type: 5; /* see below */ - u_int iodc_sv_rev: 4, /* software version revision number */ - iodc_sv_model:20, /* software interface model # */ - iodc_sv_opt: 8; /* type-specific options */ - u_char iodc_rev; /* revision number of IODC code */ - u_char iodc_dep; /* module-dependent information */ - u_char iodc_rsv[2]; /* reserved */ - u_short iodc_cksum; /* 16-bit checksum of whole IODC */ - u_short iodc_length; /* number of entry points in IODC */ - /* IODC entry points follow... */ -}; - -extern pdcio_t pdc; - -#ifdef _KERNEL -struct consdev; - -extern int kernelmapped; - -void pdc_init(void); -int pdc_call(iodcio_t, int, ...); - -void pdccnprobe(struct consdev *); -void pdccninit(struct consdev *); -int pdccngetc(dev_t); -void pdccnputc(dev_t, int); -void pdccnpollc(dev_t, int); -#endif - -#endif /* !(_LOCORE) */ - -#endif /* _MACHINE_PDC_H_ */ diff --git a/sys/arch/hppa/include/pmap.h b/sys/arch/hppa/include/pmap.h deleted file mode 100644 index e536e403c..000000000 --- a/sys/arch/hppa/include/pmap.h +++ /dev/null @@ -1,167 +0,0 @@ -/* $OpenBSD: pmap.h,v 1.55 2023/04/13 15:23:22 miod Exp $ */ - -/* - * Copyright (c) 2002-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#ifndef _MACHINE_PMAP_H_ -#define _MACHINE_PMAP_H_ - -#include -#include - -#ifdef _KERNEL -#include -#include - -struct pmap { - struct mutex pm_mtx; - struct uvm_object pm_obj; - struct vm_page *pm_ptphint; - struct vm_page *pm_pdir_pg; /* vm_page for pdir */ - volatile u_int32_t *pm_pdir; /* page dir (read-only after create) */ - pa_space_t pm_space; /* space id (read-only after create) */ - u_int pm_pid; /* prot id (read-only after create) */ - - struct pmap_statistics pm_stats; -}; -typedef struct pmap *pmap_t; - -#define HPPA_MAX_PID 0xfffa -#define HPPA_SID_MAX 0x7ffd -#define HPPA_SID_KERNEL 0 -#define HPPA_PID_KERNEL 2 - -#define KERNEL_ACCESS_ID 1 -#define KERNEL_TEXT_PROT (TLB_AR_KRX | (KERNEL_ACCESS_ID << 1)) -#define KERNEL_DATA_PROT (TLB_AR_KRW | (KERNEL_ACCESS_ID << 1)) - -struct pv_entry { /* locked by its list's pvh_lock */ - struct pv_entry *pv_next; - struct pmap *pv_pmap; /* the pmap */ - vaddr_t pv_va; /* the virtual address */ - struct vm_page *pv_ptp; /* the vm_page of the PTP */ -}; - -/* also match the hardware tlb walker definition */ -struct vp_entry { - u_int vp_tag; - u_int vp_tlbprot; - u_int vp_tlbpage; - u_int vp_ptr; -}; - -extern void gateway_page(void); -extern struct pmap kernel_pmap_store; - -#if defined(HP7100LC_CPU) || defined(HP7300LC_CPU) -extern int pmap_hptsize; -extern struct pdc_hwtlb pdc_hwtlb; -#endif - -/* - * pool quickmaps - */ -#define pmap_map_direct(pg) ((vaddr_t)VM_PAGE_TO_PHYS(pg)) -struct vm_page *pmap_unmap_direct(vaddr_t); -#define __HAVE_PMAP_DIRECT - -/* - * according to the parisc manual aliased va's should be - * different by high 12 bits only. - */ -#define PMAP_PREFER -/* pmap prefer alignment */ -#define PMAP_PREFER_ALIGN() (HPPA_PGALIAS) -/* pmap prefer offset within alignment */ -#define PMAP_PREFER_OFFSET(of) ((of) & HPPA_PGAOFF) - -#define pmap_sid2pid(s) (((s) + 1) << 1) -#define pmap_kernel() (&kernel_pmap_store) -#define pmap_resident_count(pmap) ((pmap)->pm_stats.resident_count) -#define pmap_update(pm) (void)(pm) - -#define PG_PMAP_MOD PG_PMAP0 /* modified */ -#define PG_PMAP_REF PG_PMAP1 /* referenced */ - -#define pmap_clear_modify(pg) pmap_changebit(pg, 0, PTE_PROT(TLB_DIRTY)) -#define pmap_clear_reference(pg) pmap_changebit(pg, PTE_PROT(TLB_REFTRAP), 0) -#define pmap_is_modified(pg) pmap_testbit(pg, PG_PMAP_MOD) -#define pmap_is_referenced(pg) pmap_testbit(pg, PG_PMAP_REF) - -#define pmap_unuse_final(p) /* nothing */ -#define pmap_remove_holes(vm) do { /* nothing */ } while (0) - -void pmap_bootstrap(vaddr_t); -boolean_t pmap_changebit(struct vm_page *, pt_entry_t, pt_entry_t); -boolean_t pmap_testbit(struct vm_page *, int); -void pmap_page_write_protect(struct vm_page *); -void pmap_write_protect(struct pmap *, vaddr_t, vaddr_t, vm_prot_t); -void pmap_remove(struct pmap *pmap, vaddr_t sva, vaddr_t eva); -void pmap_page_remove(struct vm_page *pg); - -static __inline int -pmap_prot(struct pmap *pmap, int prot) -{ - extern u_int hppa_prot[]; - return (hppa_prot[prot] | (pmap == pmap_kernel()? 0 : TLB_USER)); -} - -static __inline void -pmap_page_protect(struct vm_page *pg, vm_prot_t prot) -{ - if (prot == PROT_READ) { - pmap_page_write_protect(pg); - } else { - KASSERT(prot == PROT_NONE); - pmap_page_remove(pg); - } -} - -static __inline void -pmap_protect(struct pmap *pmap, vaddr_t sva, vaddr_t eva, vm_prot_t prot) -{ - if (prot != PROT_NONE) - pmap_write_protect(pmap, sva, eva, prot); - else - pmap_remove(pmap, sva, eva); -} - -#endif /* _KERNEL */ - -#if !defined(_LOCORE) -struct pv_entry; -struct vm_page_md { - struct mutex pvh_mtx; - struct pv_entry *pvh_list; /* head of list (locked by pvh_mtx) */ -}; - -#define VM_MDPAGE_INIT(pg) do { \ - mtx_init(&(pg)->mdpage.pvh_mtx, IPL_VM); \ - (pg)->mdpage.pvh_list = NULL; \ -} while (0) -#endif - -#endif /* _MACHINE_PMAP_H_ */ diff --git a/sys/arch/hppa/include/proc.h b/sys/arch/hppa/include/proc.h deleted file mode 100644 index 137e49afa..000000000 --- a/sys/arch/hppa/include/proc.h +++ /dev/null @@ -1,47 +0,0 @@ -/* $OpenBSD: proc.h,v 1.6 2017/04/13 03:52:25 guenther Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)proc.h 7.1 (Berkeley) 5/15/91 - */ - -/* - * Machine-dependent part of the proc structure for hppa. - */ -struct mdproc { - struct trapframe *md_regs; /* registers on current frame */ - volatile int md_astpending; /* AST pending for this process */ - int md_flags; /* machine-dependent flags */ - - vaddr_t md_bpva; - u_int md_bpsave[2]; -}; - -/* md_flags */ - diff --git a/sys/arch/hppa/include/profile.h b/sys/arch/hppa/include/profile.h deleted file mode 100644 index c56a90dcc..000000000 --- a/sys/arch/hppa/include/profile.h +++ /dev/null @@ -1,45 +0,0 @@ -/* $OpenBSD: profile.h,v 1.3 2003/06/02 23:27:46 millert Exp $ */ - -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)profile.h 8.1 (Berkeley) 6/11/93 - */ - -#define _MCOUNT_DECL void _mcount - -#define MCOUNT - -#ifdef _KERNEL -/* - * Note that we assume splhigh() and splx() cannot call mcount() - * recursively. - */ -#define MCOUNT_ENTER s = splhigh() -#define MCOUNT_EXIT splx(s) -#endif /* _KERNEL */ diff --git a/sys/arch/hppa/include/psl.h b/sys/arch/hppa/include/psl.h deleted file mode 100644 index e58327b02..000000000 --- a/sys/arch/hppa/include/psl.h +++ /dev/null @@ -1,105 +0,0 @@ -/* $OpenBSD: psl.h,v 1.11 2021/03/11 11:16:57 jsg Exp $ */ - -/* - * Copyright (c) 1999-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#ifndef _MACHINE_PSL_H_ -#define _MACHINE_PSL_H_ - -/* - * Reference: - * 1. PA-RISC 1.1 Architecture and Instruction Set Manual - * Hewlett Packard, 3rd Edition, February 1994; Part Number 09740-90039 - */ - -/* - * Processor Status Word Bit Positions (in PA-RISC bit order) - */ -#define PSL_Y_POS (0) -#define PSL_Z_POS (1) -#define PSL_SS_POS (3) /* Reserved, Software-defined */ -#define PSL_W_POS (4) -#define PSL_E_POS (5) -#define PSL_S_POS (6) -#define PSL_T_POS (7) -#define PSL_H_POS (8) -#define PSL_L_POS (9) -#define PSL_N_POS (10) -#define PSL_X_POS (11) -#define PSL_B_POS (12) -#define PSL_C_POS (13) -#define PSL_V_POS (14) -#define PSL_M_POS (15) -#define PSL_CB_POS (16) -#define PSL_O_POS (24) -#define PSL_G_POS (25) -#define PSL_F_POS (26) -#define PSL_R_POS (27) -#define PSL_Q_POS (28) -#define PSL_P_POS (29) -#define PSL_D_POS (30) -#define PSL_I_POS (31) - -#define PSL_BITS "\020\001I\002D\003P\004Q\005R\006F\007G\010O" \ - "\021M\022V\023C\024B\025X\026N\027L\030H" \ - "\031T\032S\033E\034W\037Z\040Y" - -/* - * Processor Status Word Bit Values - */ -#define PSL_Y (1 << (31-PSL_Y_POS)) /* Data Debug Trap Disable */ -#define PSL_Z (1 << (31-PSL_Z_POS)) /* Instruction Debug Trap Disable */ -#define PSL_SS (1 << (31-PSL_SS_POS)) /* Reserved; Software Single-Step */ -#define PSL_W (1 << (31-PSL_W_POS)) /* 64bit address decode enable */ -#define PSL_E (1 << (31-PSL_E_POS)) /* Little Endian Memory Access Enable */ -#define PSL_S (1 << (31-PSL_S_POS)) /* Secure Interval Timer */ -#define PSL_T (1 << (31-PSL_T_POS)) /* Taken Branch Trap Enable */ -#define PSL_H (1 << (31-PSL_H_POS)) /* Higher-privilege Transfer Trap Enable */ -#define PSL_L (1 << (31-PSL_L_POS)) /* Lower-privilege Transfer Trap Enable */ -#define PSL_N (1 << (31-PSL_N_POS)) /* Nullify */ -#define PSL_X (1 << (31-PSL_X_POS)) /* Data Memory Break Disable */ -#define PSL_B (1 << (31-PSL_B_POS)) /* Taken Branch */ -#define PSL_C (1 << (31-PSL_C_POS)) /* Instruction Address Translation Enable */ -#define PSL_V (1 << (31-PSL_V_POS)) /* Divide Step Correction */ -#define PSL_M (1 << (31-PSL_M_POS)) /* High-priority Machine Check Mask */ -#define PSL_CB (1 << (31-PSL_CB_POS)) /* Carry/Borrow Bits */ -#define PSL_O (1 << (31-PSL_O_POS)) /* Force strong ordering (2.0) */ -#define PSL_G (1 << (31-PSL_G_POS)) /* Debug Trap Enable */ -#define PSL_F (1 << (31-PSL_F_POS)) /* Performance Monitor Interrupt Unmask */ -#define PSL_R (1 << (31-PSL_R_POS)) /* Recover Counter Enable */ -#define PSL_Q (1 << (31-PSL_Q_POS)) /* Interrupt State Collection Enable */ -#define PSL_P (1 << (31-PSL_P_POS)) /* Protection Identifier Validation Enable */ -#define PSL_D (1 << (31-PSL_D_POS)) /* Data Address Translation Enable */ -#define PSL_I (1 << (31-PSL_I_POS)) /* External Interrupt, Power Failure - Interrupt, and Low-Priority Machine - Check Interrupt unmask */ - -/* - * Frequently Used PSW Values - */ -#define RESET_PSL (PSL_R | PSL_Q | PSL_P | PSL_D | PSL_I) - -#endif /* _MACHINE_PSL_H_ */ diff --git a/sys/arch/hppa/include/pte.h b/sys/arch/hppa/include/pte.h deleted file mode 100644 index a60a236ac..000000000 --- a/sys/arch/hppa/include/pte.h +++ /dev/null @@ -1,72 +0,0 @@ -/* $OpenBSD: pte.h,v 1.14 2023/01/07 10:09:34 kettenis Exp $ */ - -/* - * Copyright (c) 1990,1993,1994 The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: pmap.h 1.24 94/12/14$ - * Author: Mike Hibler, Bob Wheeler, University of Utah CSL, 9/90 - */ - -#ifndef _MACHINE_PTE_H_ -#define _MACHINE_PTE_H_ - -#define PTE_PROT_SHIFT 19 -#define PTE_PROT(tlb) ((tlb) >> PTE_PROT_SHIFT) -#define TLB_PROT(pte) ((pte) << PTE_PROT_SHIFT) -#define PDE_MASK (0xffc00000) -#define PDE_SIZE (0x00400000) -#define PTE_MASK (0x003ff000) -#define PTE_PAGE(pte) ((pte) & ~PAGE_MASK) - -/* TLB access/protection values */ -#define TLB_WIRED 0x40000000 /* software only */ -#define TLB_REFTRAP 0x20000000 -#define TLB_DIRTY 0x10000000 -#define TLB_BREAK 0x08000000 -#define TLB_AR_MASK 0x07f00000 -#define TLB_READ 0x00000000 -#define TLB_WRITE 0x01000000 -#define TLB_EXECUTE 0x02000000 -#define TLB_GATEWAY 0x04000000 -#define TLB_USER 0x00f00000 -/* no execute access at any PL; no GATEWAY promotion */ -#define TLB_AR_NA 0x07300000 -#define TLB_AR_R TLB_READ -/* execute access at designated PL; no GATEWAY promotion */ -#define TLB_AR_X 0x07000000 -#define TLB_AR_RW TLB_READ|TLB_WRITE -#define TLB_AR_RX TLB_READ|TLB_EXECUTE -#define TLB_AR_RWX TLB_READ|TLB_WRITE|TLB_EXECUTE -#define TLB_UNCACHABLE 0x00080000 -#define TLB_PID_MASK 0x0000fffe - -#define TLB_BITS "\020\024U\031W\032X\033N\034B\035D\036R\037H" - -/* protection for a gateway page */ -#define TLB_GATE_PROT 0x04c00000 - -/* protection for break page */ -#define TLB_BREAK_PROT 0x02c00000 - -#ifndef _LOCORE -typedef u_int32_t pt_entry_t; -#endif - -#endif /* _MACHINE_PTE_H_ */ diff --git a/sys/arch/hppa/include/ptrace.h b/sys/arch/hppa/include/ptrace.h deleted file mode 100644 index f8518bf41..000000000 --- a/sys/arch/hppa/include/ptrace.h +++ /dev/null @@ -1,27 +0,0 @@ -/* $OpenBSD: ptrace.h,v 1.4 2011/11/10 22:48:13 deraadt Exp $ */ - -/* - * Copyright (c) 2005 Michael Shalayeff - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * MD ptrace definitions - */ -#define PT_STEP (PT_FIRSTMACH + 0) -#define PT_GETREGS (PT_FIRSTMACH + 1) -#define PT_SETREGS (PT_FIRSTMACH + 2) -#define PT_GETFPREGS (PT_FIRSTMACH + 3) -#define PT_SETFPREGS (PT_FIRSTMACH + 4) diff --git a/sys/arch/hppa/include/rbus_machdep.h b/sys/arch/hppa/include/rbus_machdep.h deleted file mode 100644 index f3273a9c7..000000000 --- a/sys/arch/hppa/include/rbus_machdep.h +++ /dev/null @@ -1,43 +0,0 @@ -/* $OpenBSD: rbus_machdep.h,v 1.6 2011/11/10 22:48:13 deraadt Exp $ */ - -/* - * Copyright (c) 2005 Michael Shalayeff - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - - -#if !defined _MACHINE_RBUS_MACHDEP_H_ -#define _MACHINE_RBUS_MACHDEP_H_ - -static __inline int -md_space_map(rbus_tag_t rbt, bus_addr_t bpa, bus_size_t size, int flags, - bus_space_handle_t *bshp) -{ - if (bshp) - *(bshp) = bpa; - - return (0); -} - -#define md_space_unmap(rbt,bsh,s,addrp) do { *(addrp) = (bsh); } while (0) - -struct pci_attach_args; - -#define rbus_pccbb_parent_mem(d, p) (*(p)->pa_pc->pc_alloc_parent)((d), (p), 0) -#define rbus_pccbb_parent_io(d, p) (*(p)->pa_pc->pc_alloc_parent)((d), (p), 1) - -#define pccbb_attach_hook(parent, self, pa) /* nothing */ - -#endif /* _MACHINE_RBUS_MACHDEP_H_ */ diff --git a/sys/arch/hppa/include/reg.h b/sys/arch/hppa/include/reg.h deleted file mode 100644 index 663419484..000000000 --- a/sys/arch/hppa/include/reg.h +++ /dev/null @@ -1,205 +0,0 @@ -/* $OpenBSD: reg.h,v 1.12 2012/08/29 18:58:45 kettenis Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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,1994 The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: regs.h 1.6 94/12/14$ - * Author: Bob Wheeler, University of Utah CSL - */ - -#ifndef _MACHINE_REG_H_ -#define _MACHINE_REG_H_ - -/* - * constants for registers for use with the following routines: - * - * void mtctl(reg, value) - move to control register - * int mfctl(reg) - move from control register - * int mtsp(sreg, value) - move to space register - * int mfsr(sreg) - move from space register - */ - -#define CR_RCTR 0 -#define CR_PIDR1 8 -#define CR_PIDR2 9 -#define CR_CCR 10 -#define CR_SAR 11 -#define CR_PIDR3 12 -#define CR_PIDR4 13 -#define CR_IVA 14 -#define CR_EIEM 15 -#define CR_ITMR 16 -#define CR_PCSQ 17 -#define CR_PCOQ 18 -#define CR_IIR 19 -#define CR_ISR 20 -#define CR_IOR 21 -#define CR_IPSW 22 -#define CR_EIRR 23 -#define CR_HPTMASK 24 -#define CR_VTOP 25 -#define CR_TR2 26 -#define CR_TR3 27 -#define CR_HVTP 28 /* points to a faulted HVT slot on LC cpus */ -#define CR_TR5 29 -#define CR_UPADDR 30 /* paddr of U-area of curproc */ -#define CR_TR7 31 - -/* - * Diagnostic registers and bit positions - */ -#define DR_CPUCFG 0 - -#define DR0_PCXS_DHPMC 10 /* r/c D-cache error flag */ -#define DR0_PCXS_ILPMC 14 /* r/c I-cache error flag */ -#define DR0_PCXS_EQWSTO 16 /* r/w enable quad-word stores */ -#define DR0_PCXS_IHE 18 /* r/w I-cache sid hash enable */ -#define DR0_PCXS_DOMAIN 19 -#define DR0_PCXS_DHE 20 /* r/w D-cache sid hash enable */ - -#define DR0_PCXT_DHPMC 10 /* r/c L1 D-cache error flag */ -#define DR0_PCXT_ILPMC 14 /* r/c L1 I-cache error flag */ -#define DR0_PCXT_IHE 18 /* r/w I-cache sid hash enable */ -#define DR0_PCXT_DHE 20 /* r/w D-cache sid hash enable */ - -#define DR0_PCXL_L2IHPMC 6 /* r/c L2 I-cache error flag */ -#define DR0_PCXL_L2IHPMC_DIS 7 /* r/w L2 I-cache hpmc disable mask */ -#define DR0_PCXL_L2DHPMC 8 /* r/c L2 D-cache error flag */ -#define DR0_PCXL_L2DHPMC_DIS 9 /* r/w L2 D-cache hpmc disable mask */ -#define DR0_PCXL_L1IHPMC 10 /* r/c L1 I-cache error flag */ -#define DR0_PCXL_L1IHPMC_DIS 11 /* r/w L1 I-cache hpmc disable mask */ -#define DR0_PCXL_L2PARERR 15 /* r/c L2 Cache parity error (4 bit) */ -#define DR0_PCXL_STORE0 16 /* r/w scratch space */ -#define DR0_PCXL_PFMASK 17 /* r/w power-fail trap mask */ -#define DR0_PCXL_STORE1 18 /* r/w scratch */ -#define DR0_PCXL_FASTMODE 19 /* r 0-fast, 1-slow */ -#define DR0_PCXL_ISTRM_EN 20 /* r/w I-cache streaming enable */ -#define DR0_PCXL_DUAL_DIS 22 /* r/w disable dual-issue (2 bit) */ -#define DR0_PCXL_ENDIAN 23 /* r/w little endian traps */ -#define DR0_PCXL_SOU_EN 24 /* r/w stall-on-use on dc misses */ -#define DR0_PCXL_SHINT_EN 25 /* r/w no-fill on miss store hints */ -#define DR0_PCXL_IPREF_EN 26 /* r/w L2 to L1 I-cache prefetch */ -#define DR0_PCXL_L2DHASH_EN 27 /* r/w L2 D-cache hash enable */ -#define DR0_PCXL_L2IHASH_EN 28 /* r/w L2 I-cache hash enable */ -#define DR0_PCXL_L1ICACHE_EN 29 /* r/w L1 I-cache enable */ -#define DR0_PCXL_HIT 30 /* r Diag cache read hit indication */ -#define DR0_PCXL_PARERR 31 /* r Diag cache read parity error */ - -#define DR0_PCXL2_L1DHPMC 8 /* r/c L1 D-cache error flag */ -#define DR0_PCXL2_L1DHPMC_DIS 9 /* r/w L1 D-cache hpmc disable */ -#define DR0_PCXL2_L2DHPMC 10 /* r/c L1 I-cache error flag */ -#define DR0_PCXL2_L2DHPMC_DIS 11 /* r/w L1 I-cache hpmc disable */ -#define DR0_PCXL2_SCRATCH 12 /* r/w scratch register */ -#define DR0_PCXL2_ACCEL_IO 13 /* /w enable accel IO writes */ -#define DR0_PCXL2_STORE0 16 /* r/w scratch space */ -#define DR0_PCXL2_PFMASK 17 /* r/w power-fail trap mask */ -#define DR0_PCXL2_STORE1 18 /* r/w scratch */ -#define DR0_PCXL2_DCSAFE 19 /* r/w serialize all data cache hangs */ -#define DR0_PCXL2_ISTRM_EN 20 /* r/w I-cache streaming enable */ -#define DR0_PCXL2_DUAL_DIS 22 /* r/w disable dual-issue (2 bit) */ -#define DR0_PCXL2_ENDIAN 23 /* r/w little endian traps */ -#define DR0_PCXL2_SOU_EN 24 /* r/w stall-on-use on dc misses */ -#define DR0_PCXL2_SHINT_EN 25 /* r/w no-fill on miss store hints */ -#define DR0_PCXL2_IPREF_EN 26 /* r/w L2 to L1 I-cache prefetch */ -#define DR0_PCXL2_LMIN_EN 27 /* r/w minor ill insn traps on LIH */ -#define DR0_PCXL2_RMIN_EN 28 /* r/w major ill insn traps on RIH */ -#define DR0_PCXL2_L1CACHE_EN 29 /* r/w L1 I-cache enable */ - -#define DR_DTLB 8 - -#define DR_ITLB 9 - -#define DR0_PCXL2_HTLB_ADDR 24 /* page address of the htlb */ -#define DR0_PCXL2_HTLB_CFG 25 /* htlb config */ -#define DR0_PCXL2_HTLB_P 0 /* r latches power fail signal */ -#define DR0_PCXL2_HTLB_MASK 19 /* w 12bit mask of the hash */ -#define DR0_PCXL2_HTLB_FP 26 /* r/w 3bit FP delay */ -#define DR0_PCXL2_HTLB_I 28 /* r/w disable ITLB htlb lookup */ -#define DR0_PCXL2_HTLB_U 29 /* r/w set cr28 only if tag nomatch */ -#define DR0_PCXL2_HTLB_N 30 /* r/w set cr28 from w3 or w7 (0) */ -#define DR0_PCXL2_HTLB_D 31 /* r/w disable DTLB htlb lookup */ - -#define DR_ITLB_SIZE_1 24 -#define DR_ITLB_SIZE_0 25 - -#define DR_DTLB_SIZE_1 26 -#define DR_DTLB_SIZE_0 27 - -#define CCR_MASK 0xff - -#define HPPA_NREGS (32) -#define HPPA_NFPREGS (33) /* 33rd is used for r0 in fpemul */ - -#ifndef _LOCORE - -struct reg { - uint32_t r_regs[HPPA_NREGS]; /* r0 is psw */ - - uint32_t r_sar; - - uint32_t r_pcsqh; - uint32_t r_pcsqt; - uint32_t r_pcoqh; - uint32_t r_pcoqt; - - uint32_t r_sr0; - uint32_t r_sr1; - uint32_t r_sr2; - uint32_t r_sr3; - uint32_t r_sr4; - uint32_t r_sr5; - uint32_t r_sr6; - uint32_t r_sr7; - - uint32_t r_cr26; - uint32_t r_cr27; -}; - -struct fpreg { - uint64_t fpr_regs[HPPA_NFPREGS]; -}; -#endif /* !_LOCORE */ - -#endif /* _MACHINE_REG_H_ */ diff --git a/sys/arch/hppa/include/reloc.h b/sys/arch/hppa/include/reloc.h deleted file mode 100644 index 8447b9c46..000000000 --- a/sys/arch/hppa/include/reloc.h +++ /dev/null @@ -1,123 +0,0 @@ -/* $OpenBSD: reloc.h,v 1.4 2011/11/10 22:48:13 deraadt Exp $ */ - -/* - * Copyright (c) 1999,2005 Michael Shalayeff - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN - * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _MACHINE_RELOC_H_ -#define _MACHINE_RELOC_H_ - -/* pa1 compatibility */ -#define RELOC_DLTREL21L RELOC_GPREL21L -#define RELOC_DLTREL14R RELOC_GPREL14R -#define RELOC_DLTIND21L RELOC_LTOFF21L -#define RELOC_DLTIND14R RELOC_LTOFF14R -#define RELOC_DLTIND14F RELOC_LTOFF14F -#define RELOC_DLTREL14WR RELOC_GPREL14WR -#define RELOC_DLTREL14DR RELOC_GPREL14DR -#define RELOC_DLTIND14WR RELOC_LTOFF14WR -#define RELOC_DLTIND14DR RELOC_LTOFF14DR - - -enum reloc_type { - RELOC_NONE = 0, - RELOC_DIR32, /* symbol + addend*/ - RELOC_DIR21L, /* LR(symbol, addend) */ - RELOC_DIR17R, /* RR(symbol, addend) */ - RELOC_DIR17F, /* symbol + addend */ - RELOC_DIR14R = 6, /* RR(symbol, addend) */ - RELOC_PCREL32 = 9, /* pa2: symbol - PC - 8 + addend */ - RELOC_PCREL21L, /* L(symbol - PC - 8 + addend */ - RELOC_PCREL17R, /* R(symbol - PC - 8 + addend */ - RELOC_PCREL17F, /* symbol - PC - 8 + addend */ - RELOC_PCREL17C, /* pa1: symbol - PC - 8 + addend */ - RELOC_PCREL14R, /* R(symbol - PC - 8 + addend */ - RELOC_DPREL21L = 18, /* pa1: LR(symbol - GP, addend */ - RELOC_DPREL14WR, /* pa1: RR(symbol - GP, addend */ - RELOC_DPREL14DR, /* pa1: RR(symbol - GP, addend */ - RELOC_DPREL14R, /* pa1: RR(symbol - GP, addend */ - RELOC_GPREL21L = 26, /* LR(symbol - GP, addend */ - RELOC_GPREL14R = 30, /* RR(symbol - GP, addend */ - RELOC_LTOFF21L = 34, /* L(ltoff(symbol + addend)) */ - RELOC_LTOFF14R = 38, /* R(ltoff(symbol + addend)) */ - RELOC_LTOFF14F, /* pa1: ltoff(symbol + addend) */ - RELOC_SETBASE, /* no relocation; base = symbol */ - RELOC_SECREL32, /* symbol - SECT + addend */ - RELOC_BASEREL21L, /* pa1: LR(symbol - base, addend) */ - RELOC_BASEREL17R, /* pa1: RR(symbol - base, addend) */ - RELOC_BASEREL14R = 46, /* pa1: RR(symbol - base, addend) */ - RELOC_SEGBASE = 48, /* no relocation; SB = symbol */ - RELOC_SEGREL32, /* symbol - SB + addend */ - RELOC_PLTOFF21L, /* LR(pltoff(symbol), addend */ - RELOC_PLTOFF14R = 54, /* RR(pltoff(symbol), addend */ - RELOC_PLTOFF14F, /* pa1: pltoff(symbol) + addend */ - RELOC_LTOFF_FPTR32 = 57,/* pa2: ltoff(fptr(symbol + addend)) */ - RELOC_LTOFF_FPTR21L, /* pa2: L(ltoff(fptr(symbol + addend))) */ - RELOC_LTOFF_FPTR14R= 62,/* pa2: R(ltoff(fptr(symbol + addend))) */ - RELOC_FPTR64 = 64, /* pa2: fptr(symbol + addend) */ - RELOC_PLABEL32, /* pa1: fptr(symbol) */ - RELOC_PCREL64 = 72, /* pa2: symbol - PC - 8 + addend */ - RELOC_PCREL22C, /* pa1: symbol - PC - 8 + addend */ - RELOC_PCREL22F, /* symbol - PC - 8 + addend */ - RELOC_PCREL14WR, /* R(symbol - PC - 8 + addend) */ - RELOC_PCREL14DR, /* R(symbol - PC - 8 + addend) */ - RELOC_PCREL16F, /* pa2: symbol - PC - 8 + addend */ - RELOC_PCREL16WF, /* pa2: symbol - PC - 8 + addend */ - RELOC_PCREL16DF, /* pa2: symbol - PC - 8 + addend */ - RELOC_DIR64, /* pa2: symbol + addend */ - RELOC_DIR14WR = 83, /* RR(symbol, addend) */ - RELOC_DIR14DR, /* RR(symbol, addend) */ - RELOC_DIR16F, /* pa2: symbol + addend */ - RELOC_DIR16WF, /* pa2: symbol + addend */ - RELOC_DIR16DF, /* pa2: symbol + addend */ - RELOC_GPREL64, /* pa2: symbol - GP + addend */ - RELOC_GPREL14WR = 91, /* RR(symbol - GP, addend) */ - RELOC_GPREL14DR, /* RR(symbol - GP, addend) */ - RELOC_GPREL16F, /* pa2: symbol - GP + addend */ - RELOC_GPREL16WF, /* pa2: symbol - GP + addend */ - RELOC_GPREL16DF, /* pa2: symbol - GP + addend */ - RELOC_LTOFF64 = 96, /* pa2: ltoff(symbol + addend) */ - RELOC_LTOFF14WR = 99, /* R(ltoff(symbol + addend)) */ - RELOC_LTOFF14DR, /* R(ltoff(symbol + addend)) */ - RELOC_LTOFF16F, /* pa2: ltoff(symbol + addend) */ - RELOC_LTOFF16WF, /* pa2: ltoff(symbol + addend) */ - RELOC_LTOFF16DF, /* pa2: ltoff(symbol + addend) */ - RELOC_SECREL64, /* pa2: symbol - SECT + addend */ - RELOC_BASEREL14WR=107, /* pa1: RR(symbol - base, addend */ - RELOC_BASEREL14DR, /* pa1: RR(symbol - base, addend */ - RELOC_SEGREL64 = 112, /* pa2: symbol - SB + addend */ - RELOC_PLTOFF14WR =115, /* RR(pltoff(symbol) + addend) */ - RELOC_PLTOFF14DR, /* RR(pltoff(symbol) + addend) */ - RELOC_PLTOFF16F, /* pa2: pltoff(symbol) + addend */ - RELOC_PLTOFF16WF, /* pa2: pltoff(symbol) + addend */ - RELOC_PLTOFF16DF, /* pa2: pltoff(symbol) + addend */ - RELOC_LTOFF_FPTR64, /* pa2: ltoff(fptr(symbol + addend)) */ - RELOC_LTOFF_FPTR14WR=123,/* pa2: R(ltoff(fptr(symbol + addend) */ - RELOC_LTOFF_FPTR14DR, /* pa2: R(ltoff(fptr(symbol + addend) */ - RELOC_LTOFF_FPTR16F, /* pa2: ltoff(fptr(symbol + addend)) */ - RELOC_LTOFF_FPTR16WF, /* pa2: ltoff(fptr(symbol + addend)) */ - RELOC_LTOFF_FPTR16DF, /* pa2: ltoff(fptr(symbol + addend)) */ - RELOC_LORESERVE, /* reserved for environment-specific use */ - RELOC_COPY = 128, - RELOC_IPLT, - RELOC_EPLT, - RELOC_GDATA, - RELOC_JMPSLOT, - RELOC_RELATIVE, - RELOC_HIRESERVE = 255 -}; - -#endif /* _MACHINE_RELOC_H_ */ diff --git a/sys/arch/hppa/include/setjmp.h b/sys/arch/hppa/include/setjmp.h deleted file mode 100644 index 60b8bb666..000000000 --- a/sys/arch/hppa/include/setjmp.h +++ /dev/null @@ -1,7 +0,0 @@ -/* $OpenBSD: setjmp.h,v 1.1 1998/08/28 19:56:05 mickey Exp $ */ - -/* - * machine/setjmp.h: machine dependent setjmp-related information. - */ - -#define _JBLEN 48 /* size, in longs, of a jmp_buf */ diff --git a/sys/arch/hppa/include/signal.h b/sys/arch/hppa/include/signal.h deleted file mode 100644 index 850e56acc..000000000 --- a/sys/arch/hppa/include/signal.h +++ /dev/null @@ -1,62 +0,0 @@ -/* $OpenBSD: signal.h,v 1.12 2016/05/10 18:39:44 deraadt Exp $ */ - -/* - * Copyright (c) 1994, The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: signal.h 1.3 94/12/16$ - */ - -#ifndef _MACHINE_SIGNAL_H_ -#define _MACHINE_SIGNAL_H_ - -#include - -/* - * Machine-dependent signal definitions - */ - -typedef int sig_atomic_t; - -#ifdef _KERNEL -#include -#endif - -#if __BSD_VISIBLE || __XPG_VISIBLE >= 420 -/* - * Information pushed on stack when a signal is delivered. - * This is used by the kernel to restore state following - * execution of the signal handler. It is also made available - * to the handler to allow it to restore state properly if - * a non-standard exit is performed. - */ -struct sigcontext { - unsigned long __sc_unused; - long sc_mask; /* signal mask to restore XXX should be int */ - unsigned long sc_ps; /* psl to restore */ - unsigned long sc_fp; /* fp to restore */ - unsigned long sc_pcoqh; /* pc offset queue (head) to restore */ - unsigned long sc_pcoqt; /* pc offset queue (tail) to restore */ - unsigned long sc_resv[2]; - unsigned long sc_regs[32]; - unsigned long sc_fpregs[64]; - long sc_cookie; -}; -#endif /* __BSD_VISIBLE || __XPG_VISIBLE >= 420 */ -#endif /* !_MACHINE_SIGNAL_H_ */ diff --git a/sys/arch/hppa/include/som.h b/sys/arch/hppa/include/som.h deleted file mode 100644 index 0c063b01f..000000000 --- a/sys/arch/hppa/include/som.h +++ /dev/null @@ -1,148 +0,0 @@ -/* $OpenBSD: som.h,v 1.4 2004/04/07 18:24:20 mickey Exp $ */ - -/* - * Copyright (c) 1998 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#ifndef _MACHINE_SOM_H_ -#define _MACHINE_SOM_H_ - -/* system_id */ -#define SOM_BSD 800 -#define SOM_PA10 0x20b -#define SOM_PA11 0x210 -#define SOM_PA12 0x211 -#define SOM_PA20 0x214 - -/* a_magic */ -#define SOM_MAGIC 0x107 -#define SOM_SHARED 0x108 -#define SOM_DEMAND 0x10B - -#define SOM_BADMAGIC(fh) \ - ((fh)->system_id != SOM_PA10 && \ - (fh)->system_id != SOM_PA11 && \ - (fh)->system_id != SOM_PA12 && \ - (fh)->system_id != SOM_PA20) - -struct som_filehdr { - u_short system_id; - u_short a_magic; - u_int version_id; - u_int time_secs; /* sys time (zero if unused) */ - u_int time_nsecs; - u_int ep_space; /* ep space */ - u_int ep_subspace; - u_int entry; /* how is it different from a_entry? */ - u_int aux_loc; /* aux header location */ - u_int aux_size; - u_int som_length; /* entire image length */ - u_int dp; /* dp presumed at compilation time */ - u_int space_loc; /* space dictionary location */ - u_int space_total; /* N of entries in the space dict */ - u_int subspace_loc; /* subspace dict location */ - u_int subspace_total; /* N of entries in the subspace dict */ - u_int ld_fixup_loc; /* space ref array (relocs?) */ - u_int ld_fixup_total; /* N of space ref records */ - u_int space_str_loc; /* {,sub}space string table location */ - u_int space_str_size; /* size of the above */ - u_int init_loc; /* init ptrs location */ - u_int init_total; /* N of entries in the above */ - u_int dict_loc; /* module dictionary location */ - u_int dict_total; /* number of modules */ - u_int sym_loc; /* symbol table location */ - u_int sym_total; /* N of symbols */ - u_int fixup_loc; /* fixpup reqs location */ - u_int fixup_total; /* N of the fixup reqs */ - u_int strings_loc; /* string table location */ - u_int strings_size; /* size of the strings table */ - u_int unloadable_loc; /* unloadable spaces location */ - u_int unloadable_size; /* size of the unloadable spaces */ - u_int checksum; /* header checksum? */ -}; - -struct som_exec_aux { - u_int mandatory : 1; - u_int copy : 1; - u_int append : 1; - u_int ignore : 1; - u_int reserved : 12; - u_int type : 16; - u_int length; - long a_tsize; - long a_tmem; - long a_tfile; - long a_dsize; - long a_dmem; - long a_dfile; - long a_bsize; - long a_entry; - long a_flags; - long a_bfill; -}; - -struct som_sym { - u_int sym_type : 8; - u_int sym_scope : 4; - u_int sym_chklevel : 3; - u_int sym_qualify : 1; - u_int sym_ifrozen : 1; - u_int sym_resident : 1; - u_int sym_is_common : 1; - u_int sym_dup_common : 1; - u_int sym_xleast : 2; - u_int sym_arg_reloc : 10; - union { - char *n_name; - u_int n_strx; - } sym_name, sym_qualifier_name; - u_int sym_info; - u_int sym_value; - -}; - -/* sym_type */ -#define SOM_ST_NULL 0 -#define SOM_ST_ABS 1 -#define SOM_ST_DATA 2 -#define SOM_ST_CODE 3 -#define SOM_ST_PRI_PROG 4 -#define SOM_ST_SEC_PROG 5 -#define SOM_ST_ENTRY 6 -#define SOM_ST_STORAGE 7 -#define SOM_ST_STUB 8 -#define SOM_ST_MODULE 9 -#define SOM_ST_SYM_EXT 10 -#define SOM_ST_ARG_EXT 11 -#define SOM_ST_MILLICODE 12 -#define SOM_ST_PLABEL 13 - -/* sym_scope */ -#define SOM_SS_UNSAT 0 -#define SOM_SS_EXTERNAL 1 -#define SOM_SS_GLOBAL 2 -#define SOM_SS_UNIVERSAL 3 - -#endif /* _MACHINE_SOM_H_ */ diff --git a/sys/arch/hppa/include/spinlock.h b/sys/arch/hppa/include/spinlock.h deleted file mode 100644 index c1082e5d0..000000000 --- a/sys/arch/hppa/include/spinlock.h +++ /dev/null @@ -1,10 +0,0 @@ -/* $OpenBSD: spinlock.h,v 1.5 2017/09/05 02:40:54 guenther Exp $ */ - -#ifndef _MACHINE_SPINLOCK_H_ -#define _MACHINE_SPINLOCK_H_ - -#define _ATOMIC_LOCK_UNLOCKED (1) -#define _ATOMIC_LOCK_LOCKED (0) -typedef long _atomic_lock_t __attribute__((__aligned__(16))); - -#endif diff --git a/sys/arch/hppa/include/tcb.h b/sys/arch/hppa/include/tcb.h deleted file mode 100644 index 171787caf..000000000 --- a/sys/arch/hppa/include/tcb.h +++ /dev/null @@ -1,46 +0,0 @@ -/* $OpenBSD: tcb.h,v 1.2 2011/11/08 15:39:50 kettenis Exp $ */ - -/* - * Copyright (c) 2011 Philip Guenther - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _MACHINE_TCB_H_ -#define _MACHINE_TCB_H_ - -#ifdef _KERNEL - -#define TCB_GET(p) \ - ((void *)(p)->p_md.md_regs->tf_cr27) -#define TCB_SET(p, addr) \ - ((p)->p_md.md_regs->tf_cr27 = (unsigned)(addr)) - -#else /* _KERNEL */ - -/* ELF TLS ABI calls for small TCB, with static TLS data after it */ -#define TLS_VARIANT 1 - -/* Get a pointer to the TCB itself */ -static inline void * -__hppa_get_tcb(void) -{ - void *val; - __asm__ ("mfctl %%cr27, %0" : "=r" (val)); - return val; -} -#define TCB_GET() __hppa_get_tcb() - -#endif /* _KERNEL */ - -#endif /* _MACHINE_TCB_H_ */ diff --git a/sys/arch/hppa/include/timetc.h b/sys/arch/hppa/include/timetc.h deleted file mode 100644 index be5be950d..000000000 --- a/sys/arch/hppa/include/timetc.h +++ /dev/null @@ -1,23 +0,0 @@ -/* $OpenBSD: timetc.h,v 1.1 2020/07/06 13:33:07 pirofti Exp $ */ -/* - * Copyright (c) 2020 Paul Irofti - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef _MACHINE_TIMETC_H_ -#define _MACHINE_TIMETC_H_ - -#define TC_LAST 0 - -#endif /* _MACHINE_TIMETC_H_ */ diff --git a/sys/arch/hppa/include/trap.h b/sys/arch/hppa/include/trap.h deleted file mode 100644 index 7c21380f4..000000000 --- a/sys/arch/hppa/include/trap.h +++ /dev/null @@ -1,110 +0,0 @@ -/* $OpenBSD: trap.h,v 1.12 2005/05/26 04:34:52 kettenis Exp $ */ - -/* - * Copyright (c) 1999-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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. - */ - -#ifndef _MACHINE_TRAP_H_ -#define _MACHINE_TRAP_H_ - -/* - * This is PA-RISC trap types per 1.1 specs, see .c files for references. - */ -#define T_NONEXIST 0 /* invalid interrupt vector */ -#define T_HPMC 1 /* high priority machine check */ -#define T_POWERFAIL 2 /* power failure */ -#define T_RECOVERY 3 /* recovery counter */ -#define T_INTERRUPT 4 /* external interrupt */ -#define T_LPMC 5 /* low-priority machine check */ -#define T_ITLBMISS 6 /* instruction TLB miss fault */ -#define T_IPROT 7 /* instruction protection */ -#define T_ILLEGAL 8 /* Illegal instruction */ -#define T_IBREAK 9 /* break instruction */ -#define T_PRIV_OP 10 /* privileged operation */ -#define T_PRIV_REG 11 /* privileged register */ -#define T_OVERFLOW 12 /* overflow */ -#define T_CONDITION 13 /* conditional */ -#define T_EXCEPTION 14 /* assist exception */ -#define T_DTLBMISS 15 /* data TLB miss */ -#define T_ITLBMISSNA 16 /* ITLB non-access miss */ -#define T_DTLBMISSNA 17 /* DTLB non-access miss */ -#define T_DPROT 18 /* data protection/rights/alignment <7100 */ -#define T_DBREAK 19 /* data break */ -#define T_TLB_DIRTY 20 /* TLB dirty bit */ -#define T_PAGEREF 21 /* page reference */ -#define T_EMULATION 22 /* assist emulation */ -#define T_HIGHERPL 23 /* higher-privelege transfer */ -#define T_LOWERPL 24 /* lower-privilege transfer */ -#define T_TAKENBR 25 /* taken branch */ -#define T_DATACC 26 /* data access rights >=7100 */ -#define T_DATAPID 27 /* data protection ID >=7100 */ -#define T_DATALIGN 28 /* unaligned data ref */ -#define T_PERFMON 29 /* performance monitor interrupt */ -#define T_IDEBUG 30 /* debug SFU interrupt */ -#define T_DDEBUG 31 /* debug SFU interrupt */ - -/* - * Reserved range for traps is 0-63, place user flag at 6th bit - */ -#define T_USER_POS 25 -#define T_USER (1 << (31 - T_USER_POS)) - -/* - * Various trap frame flags. - */ -#define TFF_LAST_POS 0 -#define TFF_ITLB_POS 1 -#define TFF_SYS_POS 2 -#define TFF_INTR_POS 3 - -#define TFF_LAST (1 << (31 - TFF_LAST_POS)) -#define TFF_ITLB (1 << (31 - TFF_ITLB_POS)) -#define TFF_SYS (1 << (31 - TFF_SYS_POS)) -#define TFF_INTR (1 << (31 - TFF_INTR_POS)) - -/* - * Define this for pretty printings of trapflags. - */ -#define T_BITS "\020\07user\036intr\037itlb\040last" - -/* - * These are break instruction entry points. - */ -/* im5 */ -#define HPPA_BREAK_KERNEL 0 -/* im13 */ -#define HPPA_BREAK_SS 4 -#define HPPA_BREAK_KGDB 5 -#define HPPA_BREAK_GET_PSW 9 -#define HPPA_BREAK_SET_PSW 10 -#define HPPA_BREAK_SPLLOWER 11 - -/* - * break instruction decoding. - */ -#define break5(i) ((i) & 0x1f) -#define break13(i) (((i) >> 13) & 0x1fff) - -#endif /* _MACHINE_TRAP_H_ */ diff --git a/sys/arch/hppa/include/vmparam.h b/sys/arch/hppa/include/vmparam.h deleted file mode 100644 index 9a61bcd4c..000000000 --- a/sys/arch/hppa/include/vmparam.h +++ /dev/null @@ -1,90 +0,0 @@ -/* $OpenBSD: vmparam.h,v 1.47 2015/11/01 20:09:59 miod Exp $ */ - -/* - * Copyright (c) 1988-1994, The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * Permission to use, copy, modify and distribute this software is hereby - * granted provided that (1) source code retains these copyright, permission, - * and disclaimer notices, and (2) redistributions including binaries - * reproduce the notices in supporting documentation, and (3) all advertising - * materials mentioning features or use of this software display the following - * acknowledgement: ``This product includes software developed by the - * Computer Systems Laboratory at the University of Utah.'' - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: vmparam.h 1.16 94/12/16$ - */ - -#ifndef _MACHINE_VMPARAM_H_ -#define _MACHINE_VMPARAM_H_ - -/* - * Machine dependent constants for HP PA - */ -#define USRSTACK 0x78000000UL /* start (bottom) of user stack */ -#define SYSCALLGATE 0xC0000000 /* syscall gateway page */ - -/* - * Virtual memory related constants, all in bytes - */ -#ifndef MAXTSIZ -#define MAXTSIZ (512*1024*1024UL) /* max text size */ -#endif -#ifndef DFLDSIZ -#define DFLDSIZ (16*1024*1024) /* initial data size limit */ -#endif -#ifndef MAXDSIZ -#define MAXDSIZ (1*1024*1024*1024UL) /* max data size */ -#endif -#ifndef BRKSIZ -#define BRKSIZ MAXDSIZ /* heap gap size */ -#endif -#ifndef DFLSSIZ -#define DFLSSIZ (2*1024*1024) /* initial stack size limit */ -#endif -#ifndef MAXSSIZ -#define MAXSSIZ (32*1024*1024UL) /* max stack size */ -#endif - -#define STACKGAP_RANDOM 256*1024 - -#ifndef USRIOSIZE -#define USRIOSIZE ((2*HPPA_PGALIAS)/PAGE_SIZE) /* 8mb */ -#endif - -/* - * PTEs for system V style shared memory. - * This is basically slop for kmempt which we actually allocate (malloc) from. - */ -#ifndef SHMMAXPGS -#define SHMMAXPGS 8192 /* 32mb */ -#endif - -/* user/kernel map constants */ -#define VM_MIN_ADDRESS ((vaddr_t)PAGE_SIZE) -#define VM_MAXUSER_ADDRESS ((vaddr_t)0xc0000000) -#define VM_MAX_ADDRESS VM_MAXUSER_ADDRESS -#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0xc0001000) -#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xef000000) - -/* use a small range for PIE to minimize mmap pressure */ -#define VM_PIE_MIN_ADDR PAGE_SIZE -#define VM_PIE_MAX_ADDR 0x40000UL - -/* virtual sizes (bytes) for various kernel submaps */ -#define VM_PHYS_SIZE (USRIOSIZE*PAGE_SIZE) - -#define VM_PHYSSEG_MAX 1 /* this many physmem segments */ -#define VM_PHYSSEG_STRAT VM_PSTRAT_RANDOM - -#define VM_PHYSSEG_NOADD /* XXX until uvm code is fixed */ - -#endif /* _MACHINE_VMPARAM_H_ */ diff --git a/sys/arch/hppa/spmath/cnv_float.h b/sys/arch/hppa/spmath/cnv_float.h deleted file mode 100644 index 739fb7140..000000000 --- a/sys/arch/hppa/spmath/cnv_float.h +++ /dev/null @@ -1,312 +0,0 @@ -/* $OpenBSD: cnv_float.h,v 1.9 2003/04/10 17:27:58 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)cnv_float.h: Revision: 2.9.88.1 Date: 93/12/07 15:05:29 */ - -/* - * Some more constants - */ -#define SGL_FX_MAX_EXP 30 -#define DBL_FX_MAX_EXP 62 -#define QUAD_FX_MAX_EXP 126 - - -#define Dintp1(object) (object) -#define Dintp2(object) (object) - -#define Qintp0(object) (object) -#define Qintp1(object) (object) -#define Qintp2(object) (object) -#define Qintp3(object) (object) - - -/* - * These macros will be used specifically by the convert instructions. - * - * - * Single format macros - */ - -#define Sgl_to_dbl_exponent(src_exponent,dest) \ - Deposit_dexponent(dest,src_exponent+(DBL_BIAS-SGL_BIAS)) - -#define Sgl_to_dbl_mantissa(src_mantissa,destA,destB) \ - Deposit_dmantissap1(destA,src_mantissa>>3); \ - Dmantissap2(destB) = src_mantissa << 29 - -#define Sgl_isinexact_to_fix(sgl_value,exponent) \ - ((exponent < (SGL_P - 1)) ? \ - (Sall(sgl_value) << (SGL_EXP_LENGTH + 1 + exponent)) : FALSE) - -#define Int_isinexact_to_sgl(int_value) (int_value << (33 - SGL_EXP_LENGTH)) - -#define Sgl_roundnearest_from_int(int_value,sgl_value) \ - if (int_value & 1<<(SGL_EXP_LENGTH - 2)) /* round bit */ \ - if ((int_value << (34 - SGL_EXP_LENGTH)) || Slow(sgl_value)) \ - Sall(sgl_value)++ - -#define Dint_isinexact_to_sgl(dint_valueA,dint_valueB) \ - ((Dintp1(dint_valueA) << (33 - SGL_EXP_LENGTH)) || Dintp2(dint_valueB)) - -#define Sgl_roundnearest_from_dint(dint_valueA,dint_valueB,sgl_value) \ - if (Dintp1(dint_valueA) & 1<<(SGL_EXP_LENGTH - 2)) \ - if ((Dintp1(dint_valueA) << (34 - SGL_EXP_LENGTH)) || \ - Dintp2(dint_valueB) || Slow(sgl_value)) Sall(sgl_value)++ - -#define Dint_isinexact_to_dbl(dint_value) \ - (Dintp2(dint_value) << (33 - DBL_EXP_LENGTH)) - -#define Dbl_roundnearest_from_dint(dint_opndB,dbl_opndA,dbl_opndB) \ - if (Dintp2(dint_opndB) & 1<<(DBL_EXP_LENGTH - 2)) \ - if ((Dintp2(dint_opndB) << (34 - DBL_EXP_LENGTH)) || Dlowp2(dbl_opndB)) \ - if ((++Dallp2(dbl_opndB))==0) Dallp1(dbl_opndA)++ - -#define Sgl_isone_roundbit(sgl_value,exponent) \ - ((Sall(sgl_value) << (SGL_EXP_LENGTH + 1 + exponent)) >> 31) - -#define Sgl_isone_stickybit(sgl_value,exponent) \ - (exponent < (SGL_P - 2) ? \ - Sall(sgl_value) << (SGL_EXP_LENGTH + 2 + exponent) : FALSE) - - -/* - * Double format macros - */ - -#define Dbl_to_sgl_exponent(src_exponent,dest) \ - dest = src_exponent + (SGL_BIAS - DBL_BIAS) - -#define Dbl_to_sgl_mantissa(srcA,srcB,dest,inexact,guard,sticky,odd) \ - Shiftdouble(Dmantissap1(srcA),Dmantissap2(srcB),29,dest); \ - guard = Dbit3p2(srcB); \ - sticky = Dallp2(srcB)<<4; \ - inexact = guard | sticky; \ - odd = Dbit2p2(srcB) - -#define Dbl_to_sgl_denormalized(srcA,srcB,exp,dest,inexact,guard,sticky,odd,tiny) \ - Deposit_dexponent(srcA,1); \ - tiny = TRUE; \ - if (exp >= -2) { \ - if (exp == 0) { \ - inexact = Dallp2(srcB) << 3; \ - guard = inexact >> 31; \ - sticky = inexact << 1; \ - Shiftdouble(Dmantissap1(srcA),Dmantissap2(srcB),29,dest); \ - odd = dest << 31; \ - if (inexact) { \ - switch(Rounding_mode()) { \ - case ROUNDPLUS: \ - if (Dbl_iszero_sign(srcA)) { \ - dest++; \ - if (Sgl_isone_hidden(dest)) \ - tiny = FALSE; \ - dest--; \ - } \ - break; \ - case ROUNDMINUS: \ - if (Dbl_isone_sign(srcA)) { \ - dest++; \ - if (Sgl_isone_hidden(dest)) \ - tiny = FALSE; \ - dest--; \ - } \ - break; \ - case ROUNDNEAREST: \ - if (guard && (sticky || odd)) { \ - dest++; \ - if (Sgl_isone_hidden(dest)) \ - tiny = FALSE; \ - dest--; \ - } \ - break; \ - } \ - } \ - /* shift right by one to get correct result */ \ - guard = odd; \ - sticky = inexact; \ - inexact |= guard; \ - dest >>= 1; \ - Deposit_dsign(srcA,0); \ - Shiftdouble(Dallp1(srcA),Dallp2(srcB),30,dest); \ - odd = dest << 31; \ - } \ - else { \ - inexact = Dallp2(srcB) << (2 + exp); \ - guard = inexact >> 31; \ - sticky = inexact << 1; \ - Deposit_dsign(srcA,0); \ - if (exp == -2) dest = Dallp1(srcA); \ - else Variable_shift_double(Dallp1(srcA),Dallp2(srcB),30-exp,dest); \ - odd = dest << 31; \ - } \ - } \ - else { \ - Deposit_dsign(srcA,0); \ - if (exp > (1 - SGL_P)) { \ - dest = Dallp1(srcA) >> (- 2 - exp); \ - inexact = Dallp1(srcA) << (34 + exp); \ - guard = inexact >> 31; \ - sticky = (inexact << 1) | Dallp2(srcB); \ - inexact |= Dallp2(srcB); \ - odd = dest << 31; \ - } \ - else { \ - dest = 0; \ - inexact = Dallp1(srcA) | Dallp2(srcB); \ - if (exp == (1 - SGL_P)) { \ - guard = Dhidden(srcA); \ - sticky = Dmantissap1(srcA) | Dallp2(srcB); \ - } \ - else { \ - guard = 0; \ - sticky = inexact; \ - } \ - odd = 0; \ - } \ - } \ - exp = 0 - -#define Dbl_isinexact_to_fix(dbl_valueA,dbl_valueB,exponent) \ - (exponent < (DBL_P-33) ? \ - Dallp2(dbl_valueB) || Dallp1(dbl_valueA) << (DBL_EXP_LENGTH+1+exponent) : \ - (exponent < (DBL_P-1) ? Dallp2(dbl_valueB) << (exponent + (33-DBL_P)) : \ - FALSE)) - -#define Dbl_isoverflow_to_int(exponent,dbl_valueA,dbl_valueB) \ - ((exponent > SGL_FX_MAX_EXP + 1) || Dsign(dbl_valueA)==0 || \ - Dmantissap1(dbl_valueA)!=0 || (Dallp2(dbl_valueB)>>21)!=0 ) - -#define Dbl_isone_roundbit(dbl_valueA,dbl_valueB,exponent) \ - ((exponent < (DBL_P - 33) ? \ - Dallp1(dbl_valueA) >> ((30 - DBL_EXP_LENGTH) - exponent) : \ - Dallp2(dbl_valueB) >> ((DBL_P - 2) - exponent)) & 1) - -#define Dbl_isone_stickybit(dbl_valueA,dbl_valueB,exponent) \ - (exponent < (DBL_P-34) ? \ - (Dallp2(dbl_valueB) || Dallp1(dbl_valueA)<<(DBL_EXP_LENGTH+2+exponent)) : \ - (exponent<(DBL_P-2) ? (Dallp2(dbl_valueB) << (exponent + (34-DBL_P))) : \ - FALSE)) - - -/* Int macros */ - -#define Int_from_sgl_mantissa(sgl_value,exponent) \ - Sall(sgl_value) = \ - (unsigned)(Sall(sgl_value) << SGL_EXP_LENGTH)>>(31 - exponent) - -#define Int_from_dbl_mantissa(dbl_valueA,dbl_valueB,exponent) \ - Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),22,Dallp1(dbl_valueA)); \ - if (exponent < 31) Dallp1(dbl_valueA) >>= 30 - exponent; \ - else Dallp1(dbl_valueA) <<= 1 - -#define Int_negate(int_value) int_value = -int_value - - -/* Dint macros */ - -#define Dint_from_sgl_mantissa(sgl_value,exponent,dresultA,dresultB) \ - {Sall(sgl_value) <<= SGL_EXP_LENGTH; /* left-justify */ \ - if (exponent <= 31) { \ - Dintp1(dresultA) = 0; \ - Dintp2(dresultB) = (unsigned)Sall(sgl_value) >> (31 - exponent); \ - } \ - else { \ - Dintp1(dresultA) = Sall(sgl_value) >> (63 - exponent); \ - Dintp2(dresultB) = Sall(sgl_value) << (exponent - 31); \ - }} - - -#define Dint_from_dbl_mantissa(dbl_valueA,dbl_valueB,exponent,destA,destB) \ - {if (exponent < 32) { \ - Dintp1(destA) = 0; \ - if (exponent <= 20) \ - Dintp2(destB) = Dallp1(dbl_valueA) >> (20-exponent); \ - else Variable_shift_double(Dallp1(dbl_valueA),Dallp2(dbl_valueB), \ - 52-exponent,Dintp2(destB)); \ - } \ - else { \ - if (exponent <= 52) { \ - Dintp1(destA) = Dallp1(dbl_valueA) >> (52-exponent); \ - if (exponent == 52) Dintp2(destB) = Dallp2(dbl_valueB); \ - else Variable_shift_double(Dallp1(dbl_valueA),Dallp2(dbl_valueB), \ - 52-exponent,Dintp2(destB)); \ - } \ - else { \ - Variable_shift_double(Dallp1(dbl_valueA),Dallp2(dbl_valueB), \ - 84-exponent,Dintp1(destA)); \ - Dintp2(destB) = Dallp2(dbl_valueB) << (exponent-52); \ - } \ - }} - -#define Dint_setzero(dresultA,dresultB) \ - Dintp1(dresultA) = 0; \ - Dintp2(dresultB) = 0 - -#define Dint_setone_sign(dresultA,dresultB) \ - Dintp1(dresultA) = ~Dintp1(dresultA); \ - if ((Dintp2(dresultB) = -Dintp2(dresultB)) == 0) Dintp1(dresultA)++ - -#define Dint_set_minint(dresultA,dresultB) \ - Dintp1(dresultA) = 1<<31; \ - Dintp2(dresultB) = 0 - -#define Dint_isone_lowp2(dresultB) (Dintp2(dresultB) & 01) - -#define Dint_increment(dresultA,dresultB) \ - if ((++Dintp2(dresultB))==0) Dintp1(dresultA)++ - -#define Dint_decrement(dresultA,dresultB) \ - if ((Dintp2(dresultB)--)==0) Dintp1(dresultA)-- - -#define Dint_negate(dresultA,dresultB) \ - Dintp1(dresultA) = ~Dintp1(dresultA); \ - if ((Dintp2(dresultB) = -Dintp2(dresultB))==0) Dintp1(dresultA)++ - -#define Dint_copyfromptr(src,destA,destB) \ - Dintp1(destA) = src->wd0; \ - Dintp2(destB) = src->wd1 -#define Dint_copytoptr(srcA,srcB,dest) \ - dest->wd0 = Dintp1(srcA); \ - dest->wd1 = Dintp2(srcB) - - -/* other macros */ - -#define Find_ms_one_bit(value, position) \ - { \ - int var; \ - for (var = 8; var >= 1; var >>= 1) { \ - if (value >> (32 - position)) \ - position -= var; \ - else position += var; \ - } \ - if ((value >> (32 - position)) == 0) \ - position--; \ - else position -= 2; \ - } - -int sgl_to_sgl_fcnvfx(sgl_floating_point *, sgl_floating_point *, sgl_floating_point *, unsigned int *); -int sgl_to_dbl_fcnvfx(sgl_floating_point *, sgl_floating_point *, dbl_integer *, unsigned int *); -int dbl_to_sgl_fcnvfx(dbl_floating_point *, dbl_floating_point *, int *, unsigned int *); -int dbl_to_dbl_fcnvfx(dbl_floating_point *, dbl_floating_point *, dbl_integer *, unsigned int *); - -int sgl_to_sgl_fcnvfxt(sgl_floating_point *, sgl_floating_point *, int *, unsigned int *); -int sgl_to_dbl_fcnvfxt(sgl_floating_point *, sgl_floating_point *, dbl_integer *, unsigned int *); -int dbl_to_sgl_fcnvfxt(dbl_floating_point *, dbl_floating_point *, int *, unsigned int *); -int dbl_to_dbl_fcnvfxt(dbl_floating_point *, dbl_floating_point *, dbl_integer *, unsigned int *); - -int sgl_to_sgl_fcnvxf(int *, int *, sgl_floating_point *, unsigned int *); -int sgl_to_dbl_fcnvxf(int *, int *, dbl_floating_point *, unsigned int *); -int dbl_to_sgl_fcnvxf(dbl_integer *, dbl_integer *, sgl_floating_point *, unsigned int *); -int dbl_to_dbl_fcnvxf(dbl_integer *, dbl_integer *, dbl_floating_point *, unsigned int *); diff --git a/sys/arch/hppa/spmath/dbl_float.h b/sys/arch/hppa/spmath/dbl_float.h deleted file mode 100644 index 369f0c882..000000000 --- a/sys/arch/hppa/spmath/dbl_float.h +++ /dev/null @@ -1,540 +0,0 @@ -/* $OpenBSD: dbl_float.h,v 1.13 2021/03/11 11:16:57 jsg Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)dbl_float.h: Revision: 2.9.88.1 Date: 93/12/07 15:05:32 */ - -/************************************** - * Declare double precision functions * - **************************************/ - -/* 32-bit word grabbing functions */ -#define Dbl_firstword(value) Dallp1(value) -#define Dbl_secondword(value) Dallp2(value) -#define Dbl_thirdword(value) dummy_location -#define Dbl_fourthword(value) dummy_location - -#define Dbl_sign(object) Dsign(object) -#define Dbl_exponent(object) Dexponent(object) -#define Dbl_signexponent(object) Dsignexponent(object) -#define Dbl_mantissap1(object) Dmantissap1(object) -#define Dbl_mantissap2(object) Dmantissap2(object) -#define Dbl_exponentmantissap1(object) Dexponentmantissap1(object) -#define Dbl_allp1(object) Dallp1(object) -#define Dbl_allp2(object) Dallp2(object) - -/* dbl_and_signs ands the sign bits of each argument and puts the result - * into the first argument. dbl_or_signs ors those same sign bits */ -#define Dbl_and_signs( src1dst, src2) \ - Dallp1(src1dst) = (Dallp1(src2)|~(1<<31)) & Dallp1(src1dst) -#define Dbl_or_signs( src1dst, src2) \ - Dallp1(src1dst) = (Dallp1(src2)&(1<<31)) | Dallp1(src1dst) - -/* The hidden bit is always the low bit of the exponent */ -#define Dbl_clear_exponent_set_hidden(srcdst) Deposit_dexponent(srcdst,1) -#define Dbl_clear_signexponent_set_hidden(srcdst) \ - Deposit_dsignexponent(srcdst,1) -#define Dbl_clear_sign(srcdst) Dallp1(srcdst) &= ~(1<<31) -#define Dbl_clear_signexponent(srcdst) \ - Dallp1(srcdst) &= Dmantissap1((unsigned)-1) - -/* Exponent field for doubles has already been cleared and may be - * included in the shift. Here we need to generate two double width - * variable shifts. The insignificant bits can be ignored. - * MTSAR f(varamount) - * VSHD srcdst.high,srcdst.low => srcdst.low - * VSHD 0,srcdst.high => srcdst.high - * This is very difficult to model with C expressions since the shift amount - * could exceed 32. */ -/* varamount must be less than 64 */ -#define Dbl_rightshift(srcdstA, srcdstB, varamount) \ - {if((varamount) >= 32) { \ - Dallp2(srcdstB) = Dallp1(srcdstA) >> (varamount-32); \ - Dallp1(srcdstA)=0; \ - } \ - else if(varamount > 0) { \ - Variable_shift_double(Dallp1(srcdstA), Dallp2(srcdstB), \ - (varamount), Dallp2(srcdstB)); \ - Dallp1(srcdstA) >>= varamount; \ - } } -/* varamount must be less than 64 */ -#define Dbl_rightshift_exponentmantissa(srcdstA, srcdstB, varamount) \ - {if((varamount) >= 32) { \ - Dallp2(srcdstB) = Dexponentmantissap1(srcdstA) >> ((varamount)-32); \ - Dallp1(srcdstA) &= (1<<31); /* clear exponentmantissa field */ \ - } \ - else if(varamount > 0) { \ - Variable_shift_double(Dexponentmantissap1(srcdstA), Dallp2(srcdstB), \ - (varamount), Dallp2(srcdstB)); \ - Deposit_dexponentmantissap1(srcdstA, \ - (Dexponentmantissap1(srcdstA)>>(varamount))); \ - } } -/* varamount must be less than 64 */ -#define Dbl_leftshift(srcdstA, srcdstB, varamount) \ - {if((varamount) >= 32) { \ - Dallp1(srcdstA) = Dallp2(srcdstB) << (varamount-32); \ - Dallp2(srcdstB)=0; \ - } \ - else { \ - if ((varamount) > 0) { \ - Dallp1(srcdstA) = (Dallp1(srcdstA) << (varamount)) | \ - (Dallp2(srcdstB) >> (32-(varamount))); \ - Dallp2(srcdstB) <<= varamount; \ - } \ - } } -#define Dbl_leftshiftby1_withextent(lefta,leftb,right,resulta,resultb) \ - Shiftdouble(Dallp1(lefta), Dallp2(leftb), 31, Dallp1(resulta)); \ - Shiftdouble(Dallp2(leftb), Extall(right), 31, Dallp2(resultb)) - -#define Dbl_rightshiftby1_withextent(leftb,right,dst) \ - Extall(dst) = (Dallp2(leftb) << 31) | ((unsigned)Extall(right) >> 1) | \ - Extlow(right) - -#define Dbl_arithrightshiftby1(srcdstA,srcdstB) \ - Shiftdouble(Dallp1(srcdstA),Dallp2(srcdstB),1,Dallp2(srcdstB));\ - Dallp1(srcdstA) = (int)Dallp1(srcdstA) >> 1 - -/* Sign extend the sign bit with an integer destination */ -#define Dbl_signextendedsign(value) Dsignedsign(value) - -#define Dbl_isone_hidden(dbl_value) (Is_dhidden(dbl_value)!=0) -/* Singles and doubles may include the sign and exponent fields. The - * hidden bit and the hidden overflow must be included. */ -#define Dbl_increment(dbl_valueA,dbl_valueB) \ - if( (Dallp2(dbl_valueB) += 1) == 0 ) Dallp1(dbl_valueA) += 1 -#define Dbl_increment_mantissa(dbl_valueA,dbl_valueB) \ - if( (Dmantissap2(dbl_valueB) += 1) == 0 ) \ - Deposit_dmantissap1(dbl_valueA,dbl_valueA+1) -#define Dbl_decrement(dbl_valueA,dbl_valueB) \ - if( Dallp2(dbl_valueB) == 0 ) Dallp1(dbl_valueA) -= 1; \ - Dallp2(dbl_valueB) -= 1 - -#define Dbl_isone_sign(dbl_value) (Is_dsign(dbl_value)!=0) -#define Dbl_isone_hiddenoverflow(dbl_value) (Is_dhiddenoverflow(dbl_value)!=0) -#define Dbl_isone_lowmantissap1(dbl_valueA) (Is_dlowp1(dbl_valueA)!=0) -#define Dbl_isone_lowmantissap2(dbl_valueB) (Is_dlowp2(dbl_valueB)!=0) -#define Dbl_isone_signaling(dbl_value) (Is_dsignaling(dbl_value)!=0) -#define Dbl_is_signalingnan(dbl_value) (Dsignalingnan(dbl_value)==0xfff) -#define Dbl_isnotzero(dbl_valueA,dbl_valueB) \ - (Dallp1(dbl_valueA) || Dallp2(dbl_valueB)) -#define Dbl_isnotzero_hiddenhigh7mantissa(dbl_value) \ - (Dhiddenhigh7mantissa(dbl_value)!=0) -#define Dbl_isnotzero_exponent(dbl_value) (Dexponent(dbl_value)!=0) -#define Dbl_isnotzero_mantissa(dbl_valueA,dbl_valueB) \ - (Dmantissap1(dbl_valueA) || Dmantissap2(dbl_valueB)) -#define Dbl_isnotzero_mantissap1(dbl_valueA) (Dmantissap1(dbl_valueA)!=0) -#define Dbl_isnotzero_mantissap2(dbl_valueB) (Dmantissap2(dbl_valueB)!=0) -#define Dbl_isnotzero_exponentmantissa(dbl_valueA,dbl_valueB) \ - (Dexponentmantissap1(dbl_valueA) || Dmantissap2(dbl_valueB)) -#define Dbl_isnotzero_low4p2(dbl_value) (Dlow4p2(dbl_value)!=0) -#define Dbl_iszero(dbl_valueA,dbl_valueB) (Dallp1(dbl_valueA)==0 && \ - Dallp2(dbl_valueB)==0) -#define Dbl_iszero_allp1(dbl_value) (Dallp1(dbl_value)==0) -#define Dbl_iszero_allp2(dbl_value) (Dallp2(dbl_value)==0) -#define Dbl_iszero_hidden(dbl_value) (Is_dhidden(dbl_value)==0) -#define Dbl_iszero_hiddenoverflow(dbl_value) (Is_dhiddenoverflow(dbl_value)==0) -#define Dbl_iszero_hiddenhigh3mantissa(dbl_value) \ - (Dhiddenhigh3mantissa(dbl_value)==0) -#define Dbl_iszero_hiddenhigh7mantissa(dbl_value) \ - (Dhiddenhigh7mantissa(dbl_value)==0) -#define Dbl_iszero_sign(dbl_value) (Is_dsign(dbl_value)==0) -#define Dbl_iszero_exponent(dbl_value) (Dexponent(dbl_value)==0) -#define Dbl_iszero_mantissa(dbl_valueA,dbl_valueB) \ - (Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0) -#define Dbl_iszero_exponentmantissa(dbl_valueA,dbl_valueB) \ - (Dexponentmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0) -#define Dbl_isinfinity_exponent(dbl_value) \ - (Dexponent(dbl_value)==DBL_INFINITY_EXPONENT) -#define Dbl_isnotinfinity_exponent(dbl_value) \ - (Dexponent(dbl_value)!=DBL_INFINITY_EXPONENT) -#define Dbl_isinfinity(dbl_valueA,dbl_valueB) \ - (Dexponent(dbl_valueA)==DBL_INFINITY_EXPONENT && \ - Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0) -#define Dbl_isnan(dbl_valueA,dbl_valueB) \ - (Dexponent(dbl_valueA)==DBL_INFINITY_EXPONENT && \ - (Dmantissap1(dbl_valueA)!=0 || Dmantissap2(dbl_valueB)!=0)) -#define Dbl_isnotnan(dbl_valueA,dbl_valueB) \ - (Dexponent(dbl_valueA)!=DBL_INFINITY_EXPONENT || \ - (Dmantissap1(dbl_valueA)==0 && Dmantissap2(dbl_valueB)==0)) - -#define Dbl_islessthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \ - (Dallp1(dbl_op1a) < Dallp1(dbl_op2a) || \ - (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \ - Dallp2(dbl_op1b) < Dallp2(dbl_op2b))) -#define Dbl_isgreaterthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \ - (Dallp1(dbl_op1a) > Dallp1(dbl_op2a) || \ - (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \ - Dallp2(dbl_op1b) > Dallp2(dbl_op2b))) -#define Dbl_isnotlessthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \ - (Dallp1(dbl_op1a) > Dallp1(dbl_op2a) || \ - (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \ - Dallp2(dbl_op1b) >= Dallp2(dbl_op2b))) -#define Dbl_isnotgreaterthan(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \ - (Dallp1(dbl_op1a) < Dallp1(dbl_op2a) || \ - (Dallp1(dbl_op1a) == Dallp1(dbl_op2a) && \ - Dallp2(dbl_op1b) <= Dallp2(dbl_op2b))) -#define Dbl_isequal(dbl_op1a,dbl_op1b,dbl_op2a,dbl_op2b) \ - ((Dallp1(dbl_op1a) == Dallp1(dbl_op2a)) && \ - (Dallp2(dbl_op1b) == Dallp2(dbl_op2b))) - -#define Dbl_leftshiftby8(dbl_valueA,dbl_valueB) \ - Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),24,Dallp1(dbl_valueA)); \ - Dallp2(dbl_valueB) <<= 8 -#define Dbl_leftshiftby7(dbl_valueA,dbl_valueB) \ - Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),25,Dallp1(dbl_valueA)); \ - Dallp2(dbl_valueB) <<= 7 -#define Dbl_leftshiftby4(dbl_valueA,dbl_valueB) \ - Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),28,Dallp1(dbl_valueA)); \ - Dallp2(dbl_valueB) <<= 4 -#define Dbl_leftshiftby3(dbl_valueA,dbl_valueB) \ - Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),29,Dallp1(dbl_valueA)); \ - Dallp2(dbl_valueB) <<= 3 -#define Dbl_leftshiftby2(dbl_valueA,dbl_valueB) \ - Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),30,Dallp1(dbl_valueA)); \ - Dallp2(dbl_valueB) <<= 2 -#define Dbl_leftshiftby1(dbl_valueA,dbl_valueB) \ - Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),31,Dallp1(dbl_valueA)); \ - Dallp2(dbl_valueB) <<= 1 - -#define Dbl_rightshiftby8(dbl_valueA,dbl_valueB) \ - Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),8,Dallp2(dbl_valueB)); \ - Dallp1(dbl_valueA) >>= 8 -#define Dbl_rightshiftby4(dbl_valueA,dbl_valueB) \ - Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),4,Dallp2(dbl_valueB)); \ - Dallp1(dbl_valueA) >>= 4 -#define Dbl_rightshiftby2(dbl_valueA,dbl_valueB) \ - Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),2,Dallp2(dbl_valueB)); \ - Dallp1(dbl_valueA) >>= 2 -#define Dbl_rightshiftby1(dbl_valueA,dbl_valueB) \ - Shiftdouble(Dallp1(dbl_valueA),Dallp2(dbl_valueB),1,Dallp2(dbl_valueB)); \ - Dallp1(dbl_valueA) >>= 1 - -/* This magnitude comparison uses the signless first words and - * the regular part2 words. The comparison is graphically: - * - * 1st greater? ------------- - * | - * 1st less?-----------------+--------- - * | | - * 2nd greater or equal----->| | - * False True - */ -#define Dbl_ismagnitudeless(leftB,rightB,signlessleft,signlessright) \ - ((signlessleft <= signlessright) && \ - ( (signlessleft < signlessright) || (Dallp2(leftB)wd0; \ - Dallp2(destb) = src->wd1 -#define Dbl_copytoptr(srca,srcb,dest) \ - dest->wd0 = Dallp1(srca); \ - dest->wd1 = Dallp2(srcb) - -/* An infinity is represented with the max exponent and a zero mantissa */ -#define Dbl_setinfinity_exponent(dbl_value) \ - Deposit_dexponent(dbl_value,DBL_INFINITY_EXPONENT) -#define Dbl_setinfinity_exponentmantissa(dbl_valueA,dbl_valueB) \ - Deposit_dexponentmantissap1(dbl_valueA, \ - (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH)))); \ - Dmantissap2(dbl_valueB) = 0 -#define Dbl_setinfinitypositive(dbl_valueA,dbl_valueB) \ - Dallp1(dbl_valueA) \ - = (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))); \ - Dmantissap2(dbl_valueB) = 0 -#define Dbl_setinfinitynegative(dbl_valueA,dbl_valueB) \ - Dallp1(dbl_valueA) = (1<<31) | \ - (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))); \ - Dmantissap2(dbl_valueB) = 0 -#define Dbl_setinfinity(dbl_valueA,dbl_valueB,sign) \ - Dallp1(dbl_valueA) = (sign << 31) | \ - (DBL_INFINITY_EXPONENT << (32-(1+DBL_EXP_LENGTH))); \ - Dmantissap2(dbl_valueB) = 0 - -#define Dbl_sethigh4bits(dbl_value, extsign) Deposit_dhigh4p1(dbl_value,extsign) -#define Dbl_set_sign(dbl_value,sign) Deposit_dsign(dbl_value,sign) -#define Dbl_invert_sign(dbl_value) Deposit_dsign(dbl_value,~Dsign(dbl_value)) -#define Dbl_setone_sign(dbl_value) Deposit_dsign(dbl_value,1) -#define Dbl_setone_lowmantissap2(dbl_value) Deposit_dlowp2(dbl_value,1) -#define Dbl_setzero_sign(dbl_value) Dallp1(dbl_value) &= 0x7fffffff -#define Dbl_setzero_exponent(dbl_value) \ - Dallp1(dbl_value) &= 0x800fffff -#define Dbl_setzero_mantissa(dbl_valueA,dbl_valueB) \ - Dallp1(dbl_valueA) &= 0xfff00000; \ - Dallp2(dbl_valueB) = 0 -#define Dbl_setzero_mantissap1(dbl_value) Dallp1(dbl_value) &= 0xfff00000 -#define Dbl_setzero_mantissap2(dbl_value) Dallp2(dbl_value) = 0 -#define Dbl_setzero_exponentmantissa(dbl_valueA,dbl_valueB) \ - Dallp1(dbl_valueA) &= 0x80000000; \ - Dallp2(dbl_valueB) = 0 -#define Dbl_setzero_exponentmantissap1(dbl_valueA) \ - Dallp1(dbl_valueA) &= 0x80000000 -#define Dbl_setzero(dbl_valueA,dbl_valueB) \ - Dallp1(dbl_valueA) = 0; Dallp2(dbl_valueB) = 0 -#define Dbl_setzerop1(dbl_value) Dallp1(dbl_value) = 0 -#define Dbl_setzerop2(dbl_value) Dallp2(dbl_value) = 0 -#define Dbl_setnegativezero(dbl_value) \ - Dallp1(dbl_value) = 1U << 31; Dallp2(dbl_value) = 0 -#define Dbl_setnegativezerop1(dbl_value) Dallp1(dbl_value) = 1U << 31 - -/* Use the following macro for both overflow & underflow conditions */ -#define ovfl - -#define unfl + -#define Dbl_setwrapped_exponent(dbl_value,exponent,op) \ - Deposit_dexponent(dbl_value,(exponent op DBL_WRAP)) - -#define Dbl_setlargestpositive(dbl_valueA,dbl_valueB) \ - Dallp1(dbl_valueA) = ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \ - | ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 ); \ - Dallp2(dbl_valueB) = 0xFFFFFFFF -#define Dbl_setlargestnegative(dbl_valueA,dbl_valueB) \ - Dallp1(dbl_valueA) = ((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \ - | ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 ) | (1<<31); \ - Dallp2(dbl_valueB) = 0xFFFFFFFF -#define Dbl_setlargest_exponentmantissa(dbl_valueA,dbl_valueB) \ - Deposit_dexponentmantissap1(dbl_valueA, \ - (((DBL_EMAX+DBL_BIAS) << (32-(1+DBL_EXP_LENGTH))) \ - | ((1<<(32-(1+DBL_EXP_LENGTH))) - 1 ))); \ - Dallp2(dbl_valueB) = 0xFFFFFFFF - -#define Dbl_setnegativeinfinity(dbl_valueA,dbl_valueB) \ - Dallp1(dbl_valueA) = ((1<= 32 ) \ - { \ - /* Big shift requires examining the portion shift off \ - the end to properly set inexact. */ \ - if(shift < 64) \ - { \ - if(shift > 32) \ - { \ - Variable_shift_double(Dallp1(srcdstA),Dallp2(srcdstB), \ - shift-32, Extall(extent)); \ - if(Dallp2(srcdstB) << (64 - (shift))) Ext_setone_low(extent); \ - } \ - else Extall(extent) = Dallp2(srcdstB); \ - Dallp2(srcdstB) = Dallp1(srcdstA) >> (shift - 32); \ - } \ - else \ - { \ - Extall(extent) = Dallp1(srcdstA); \ - if(Dallp2(srcdstB)) Ext_setone_low(extent); \ - Dallp2(srcdstB) = 0; \ - } \ - Dallp1(srcdstA) = 0; \ - } \ - else \ - { \ - /* Small alignment is simpler. Extension is easily set. */ \ - if (shift > 0) \ - { \ - Extall(extent) = Dallp2(srcdstB) << (32 - (shift)); \ - Variable_shift_double(Dallp1(srcdstA),Dallp2(srcdstB),shift, \ - Dallp2(srcdstB)); \ - Dallp1(srcdstA) >>= shift; \ - } \ - else Extall(extent) = 0; \ - } - -/* - * Here we need to shift the result right to correct for an overshift - * (due to the exponent becoming negative) during normalization. - */ -#define Dbl_fix_overshift(srcdstA,srcdstB,shift,extent) \ - Extall(extent) = Dallp2(srcdstB) << (32 - (shift)); \ - Dallp2(srcdstB) = (Dallp1(srcdstA) << (32 - (shift))) | \ - (Dallp2(srcdstB) >> (shift)); \ - Dallp1(srcdstA) = Dallp1(srcdstA) >> shift - -#define Dbl_hiddenhigh3mantissa(dbl_value) Dhiddenhigh3mantissa(dbl_value) -#define Dbl_hidden(dbl_value) Dhidden(dbl_value) -#define Dbl_lowmantissap2(dbl_value) Dlowp2(dbl_value) - -/* The left argument is never smaller than the right argument */ -#define Dbl_subtract(lefta,leftb,righta,rightb,resulta,resultb) \ - if( Dallp2(rightb) > Dallp2(leftb) ) Dallp1(lefta)--; \ - Dallp2(resultb) = Dallp2(leftb) - Dallp2(rightb); \ - Dallp1(resulta) = Dallp1(lefta) - Dallp1(righta) - -/* Subtract right augmented with extension from left augmented with zeros and - * store into result and extension. */ -#define Dbl_subtract_withextension(lefta,leftb,righta,rightb,extent,resulta,resultb) \ - Dbl_subtract(lefta,leftb,righta,rightb,resulta,resultb); \ - if( (Extall(extent) = 0-Extall(extent)) ) \ - { \ - if((Dallp2(resultb)--) == 0) Dallp1(resulta)--; \ - } - -#define Dbl_addition(lefta,leftb,righta,rightb,resulta,resultb) \ - /* If the sum of the low words is less than either source, then \ - * an overflow into the next word occurred. */ \ - Dallp1(resulta) = Dallp1(lefta) + Dallp1(righta); \ - if((Dallp2(resultb) = Dallp2(leftb) + Dallp2(rightb)) < Dallp2(rightb)) \ - Dallp1(resulta)++ - -#define Dbl_xortointp1(left,right,result) \ - result = Dallp1(left) XOR Dallp1(right) - -#define Dbl_xorfromintp1(left,right,result) \ - Dallp1(result) = left XOR Dallp1(right) - -#define Dbl_swap_lower(left,right) \ - Dallp2(left) = Dallp2(left) XOR Dallp2(right); \ - Dallp2(right) = Dallp2(left) XOR Dallp2(right); \ - Dallp2(left) = Dallp2(left) XOR Dallp2(right) - -/* Need to Initialize */ -#define Dbl_makequietnan(desta,destb) \ - Dallp1(desta) = ((DBL_EMAX+DBL_BIAS)+1)<< (32-(1+DBL_EXP_LENGTH)) \ - | (1<<(32-(1+DBL_EXP_LENGTH+2))); \ - Dallp2(destb) = 0 -#define Dbl_makesignalingnan(desta,destb) \ - Dallp1(desta) = ((DBL_EMAX+DBL_BIAS)+1)<< (32-(1+DBL_EXP_LENGTH)) \ - | (1<<(32-(1+DBL_EXP_LENGTH+1))); \ - Dallp2(destb) = 0 - -#define Dbl_normalize(dbl_opndA,dbl_opndB,exponent) \ - while(Dbl_iszero_hiddenhigh7mantissa(dbl_opndA)) { \ - Dbl_leftshiftby8(dbl_opndA,dbl_opndB); \ - exponent -= 8; \ - } \ - if(Dbl_iszero_hiddenhigh3mantissa(dbl_opndA)) { \ - Dbl_leftshiftby4(dbl_opndA,dbl_opndB); \ - exponent -= 4; \ - } \ - while(Dbl_iszero_hidden(dbl_opndA)) { \ - Dbl_leftshiftby1(dbl_opndA,dbl_opndB); \ - exponent -= 1; \ - } - -#define Twoword_add(src1dstA,src1dstB,src2A,src2B) \ - /* \ - * want this macro to generate: \ - * ADD src1dstB,src2B,src1dstB; \ - * ADDC src1dstA,src2A,src1dstA; \ - */ \ - if ((src1dstB) + (src2B) < (src1dstB)) Dallp1(src1dstA)++; \ - Dallp1(src1dstA) += (src2A); \ - Dallp2(src1dstB) += (src2B) - -#define Twoword_subtract(src1dstA,src1dstB,src2A,src2B) \ - /* \ - * want this macro to generate: \ - * SUB src1dstB,src2B,src1dstB; \ - * SUBB src1dstA,src2A,src1dstA; \ - */ \ - if ((src1dstB) < (src2B)) Dallp1(src1dstA)--; \ - Dallp1(src1dstA) -= (src2A); \ - Dallp2(src1dstB) -= (src2B) - -#define Dbl_setoverflow(resultA,resultB) \ - /* set result to infinity or largest number */ \ - switch (Rounding_mode()) { \ - case ROUNDPLUS: \ - if (Dbl_isone_sign(resultA)) { \ - Dbl_setlargestnegative(resultA,resultB); \ - } \ - else { \ - Dbl_setinfinitypositive(resultA,resultB); \ - } \ - break; \ - case ROUNDMINUS: \ - if (Dbl_iszero_sign(resultA)) { \ - Dbl_setlargestpositive(resultA,resultB); \ - } \ - else { \ - Dbl_setinfinitynegative(resultA,resultB); \ - } \ - break; \ - case ROUNDNEAREST: \ - Dbl_setinfinity_exponentmantissa(resultA,resultB); \ - break; \ - case ROUNDZERO: \ - Dbl_setlargest_exponentmantissa(resultA,resultB); \ - } - -#define Dbl_denormalize(opndp1,opndp2,exponent,guard,sticky,inexact) \ - Dbl_clear_signexponent_set_hidden(opndp1); \ - if (exponent >= (1-DBL_P)) { \ - if (exponent >= -31) { \ - guard = (Dallp2(opndp2) >> (-(exponent))) & 1; \ - if (exponent < 0) sticky |= Dallp2(opndp2) << (32+exponent); \ - if (exponent > -31) { \ - Variable_shift_double(opndp1,opndp2,1-exponent,opndp2); \ - Dallp1(opndp1) >>= 1-exponent; \ - } \ - else { \ - Dallp2(opndp2) = Dallp1(opndp1); \ - Dbl_setzerop1(opndp1); \ - } \ - } \ - else { \ - guard = (Dallp1(opndp1) >> (-32-(exponent))) & 1; \ - if (exponent == -32) sticky |= Dallp2(opndp2); \ - else sticky |= (Dallp2(opndp2) | Dallp1(opndp1) << (64+(exponent))); \ - Dallp2(opndp2) = Dallp1(opndp1) >> (-31-(exponent)); \ - Dbl_setzerop1(opndp1); \ - } \ - inexact = guard | sticky; \ - } \ - else { \ - guard = 0; \ - sticky |= (Dallp1(opndp1) | Dallp2(opndp2)); \ - Dbl_setzero(opndp1,opndp2); \ - inexact = sticky; \ - } - - -int dbl_fadd(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *); -int dbl_fcmp(dbl_floating_point *, dbl_floating_point *, unsigned int, unsigned int *); -int dbl_fdiv(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *); -int dbl_fmpy(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *); -int dbl_frem(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *); -int dbl_fsqrt(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *); -int dbl_fsub(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *); - -int sgl_to_dbl_fcnvff(sgl_floating_point *, sgl_floating_point *, dbl_floating_point *, unsigned int *); -int dbl_to_sgl_fcnvff(dbl_floating_point *, dbl_floating_point *, sgl_floating_point *, unsigned int *); - -int dbl_frnd(dbl_floating_point *, dbl_floating_point *, dbl_floating_point *, unsigned int *); diff --git a/sys/arch/hppa/spmath/dfadd.c b/sys/arch/hppa/spmath/dfadd.c deleted file mode 100644 index fa253ef21..000000000 --- a/sys/arch/hppa/spmath/dfadd.c +++ /dev/null @@ -1,502 +0,0 @@ -/* $OpenBSD: dfadd.c,v 1.7 2002/11/29 09:27:34 deraadt Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)dfadd.c: Revision: 2.7.88.1 Date: 93/12/07 15:05:35 */ - -#include "float.h" -#include "dbl_float.h" - -/* - * Double_add: add two double precision values. - */ -int -dbl_fadd(leftptr, rightptr, dstptr, status) - dbl_floating_point *leftptr, *rightptr, *dstptr; - unsigned int *status; -{ - register unsigned int signless_upper_left, signless_upper_right, save; - register unsigned int leftp1, leftp2, rightp1, rightp2, extent; - register unsigned int resultp1 = 0, resultp2 = 0; - - register int result_exponent, right_exponent, diff_exponent; - register int sign_save, jumpsize; - register int inexact = FALSE; - register int underflowtrap; - - /* Create local copies of the numbers */ - Dbl_copyfromptr(leftptr,leftp1,leftp2); - Dbl_copyfromptr(rightptr,rightp1,rightp2); - - /* A zero "save" helps discover equal operands (for later), * - * and is used in swapping operands (if needed). */ - Dbl_xortointp1(leftp1,rightp1,/*to*/save); - - /* - * check first operand for NaN's or infinity - */ - if ((result_exponent = Dbl_exponent(leftp1)) == DBL_INFINITY_EXPONENT) - { - if (Dbl_iszero_mantissa(leftp1,leftp2)) - { - if (Dbl_isnotnan(rightp1,rightp2)) - { - if (Dbl_isinfinity(rightp1,rightp2) && save!=0) - { - /* - * invalid since operands are opposite signed infinity's - */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - Set_invalidflag(); - Dbl_makequietnan(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* - * return infinity - */ - Dbl_copytoptr(leftp1,leftp2,dstptr); - return(NOEXCEPTION); - } - } - else - { - /* - * is NaN; signaling or quiet? - */ - if (Dbl_isone_signaling(leftp1)) - { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(leftp1); - } - /* - * is second operand a signaling NaN? - */ - else if (Dbl_is_signalingnan(rightp1)) - { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(rightp1); - Dbl_copytoptr(rightp1,rightp2,dstptr); - return(NOEXCEPTION); - } - /* - * return quiet NaN - */ - Dbl_copytoptr(leftp1,leftp2,dstptr); - return(NOEXCEPTION); - } - } /* End left NaN or Infinity processing */ - /* - * check second operand for NaN's or infinity - */ - if (Dbl_isinfinity_exponent(rightp1)) - { - if (Dbl_iszero_mantissa(rightp1,rightp2)) - { - /* return infinity */ - Dbl_copytoptr(rightp1,rightp2,dstptr); - return(NOEXCEPTION); - } - /* - * is NaN; signaling or quiet? - */ - if (Dbl_isone_signaling(rightp1)) - { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(rightp1); - } - /* - * return quiet NaN - */ - Dbl_copytoptr(rightp1,rightp2,dstptr); - return(NOEXCEPTION); - } /* End right NaN or Infinity processing */ - - /* Invariant: Must be dealing with finite numbers */ - - /* Compare operands by removing the sign */ - Dbl_copytoint_exponentmantissap1(leftp1,signless_upper_left); - Dbl_copytoint_exponentmantissap1(rightp1,signless_upper_right); - - /* sign difference selects add or sub operation. */ - if(Dbl_ismagnitudeless(leftp2,rightp2,signless_upper_left,signless_upper_right)) - { - /* Set the left operand to the larger one by XOR swap * - * First finish the first word using "save" */ - Dbl_xorfromintp1(save,rightp1,/*to*/rightp1); - Dbl_xorfromintp1(save,leftp1,/*to*/leftp1); - Dbl_swap_lower(leftp2,rightp2); - result_exponent = Dbl_exponent(leftp1); - } - /* Invariant: left is not smaller than right. */ - - if((right_exponent = Dbl_exponent(rightp1)) == 0) - { - /* Denormalized operands. First look for zeroes */ - if(Dbl_iszero_mantissa(rightp1,rightp2)) - { - /* right is zero */ - if(Dbl_iszero_exponentmantissa(leftp1,leftp2)) - { - /* Both operands are zeros */ - if(Is_rounding_mode(ROUNDMINUS)) - { - Dbl_or_signs(leftp1,/*with*/rightp1); - } - else - { - Dbl_and_signs(leftp1,/*with*/rightp1); - } - } - else - { - /* Left is not a zero and must be the result. Trapped - * underflows are signaled if left is denormalized. Result - * is always exact. */ - if( (result_exponent == 0) && Is_underflowtrap_enabled() ) - { - /* need to normalize results mantissa */ - sign_save = Dbl_signextendedsign(leftp1); - Dbl_leftshiftby1(leftp1,leftp2); - Dbl_normalize(leftp1,leftp2,result_exponent); - Dbl_set_sign(leftp1,/*using*/sign_save); - Dbl_setwrapped_exponent(leftp1,result_exponent,unfl); - Dbl_copytoptr(leftp1,leftp2,dstptr); - /* inexact = FALSE */ - return(UNDERFLOWEXCEPTION); - } - } - Dbl_copytoptr(leftp1,leftp2,dstptr); - return(NOEXCEPTION); - } - - /* Neither are zeroes */ - Dbl_clear_sign(rightp1); /* Exponent is already cleared */ - if(result_exponent == 0 ) - { - /* Both operands are denormalized. The result must be exact - * and is simply calculated. A sum could become normalized and a - * difference could cancel to a true zero. */ - if( (/*signed*/int) save < 0 ) - { - Dbl_subtract(leftp1,leftp2,/*minus*/rightp1,rightp2, - /*into*/resultp1,resultp2); - if(Dbl_iszero_mantissa(resultp1,resultp2)) - { - if(Is_rounding_mode(ROUNDMINUS)) - { - Dbl_setone_sign(resultp1); - } - else - { - Dbl_setzero_sign(resultp1); - } - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - } - else - { - Dbl_addition(leftp1,leftp2,rightp1,rightp2, - /*into*/resultp1,resultp2); - if(Dbl_isone_hidden(resultp1)) - { - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - } - if(Is_underflowtrap_enabled()) - { - /* need to normalize result */ - sign_save = Dbl_signextendedsign(resultp1); - Dbl_leftshiftby1(resultp1,resultp2); - Dbl_normalize(resultp1,resultp2,result_exponent); - Dbl_set_sign(resultp1,/*using*/sign_save); - Dbl_setwrapped_exponent(resultp1,result_exponent,unfl); - Dbl_copytoptr(resultp1,resultp2,dstptr); - /* inexact = FALSE */ - return(UNDERFLOWEXCEPTION); - } - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - right_exponent = 1; /* Set exponent to reflect different bias - * with denomalized numbers. */ - } - else - { - Dbl_clear_signexponent_set_hidden(rightp1); - } - Dbl_clear_exponent_set_hidden(leftp1); - diff_exponent = result_exponent - right_exponent; - - /* - * Special case alignment of operands that would force alignment - * beyond the extent of the extension. A further optimization - * could special case this but only reduces the path length for this - * infrequent case. - */ - if(diff_exponent > DBL_THRESHOLD) - { - diff_exponent = DBL_THRESHOLD; - } - - /* Align right operand by shifting to right */ - Dbl_right_align(/*operand*/rightp1,rightp2,/*shifted by*/diff_exponent, - /*and lower to*/extent); - - /* Treat sum and difference of the operands separately. */ - if( (/*signed*/int) save < 0 ) - { - /* - * Difference of the two operands. Their can be no overflow. A - * borrow can occur out of the hidden bit and force a post - * normalization phase. - */ - Dbl_subtract_withextension(leftp1,leftp2,/*minus*/rightp1,rightp2, - /*with*/extent,/*into*/resultp1,resultp2); - if(Dbl_iszero_hidden(resultp1)) - { - /* Handle normalization */ - /* A straight forward algorithm would now shift the result - * and extension left until the hidden bit becomes one. Not - * all of the extension bits need participate in the shift. - * Only the two most significant bits (round and guard) are - * needed. If only a single shift is needed then the guard - * bit becomes a significant low order bit and the extension - * must participate in the rounding. If more than a single - * shift is needed, then all bits to the right of the guard - * bit are zeros, and the guard bit may or may not be zero. */ - sign_save = Dbl_signextendedsign(resultp1); - Dbl_leftshiftby1_withextent(resultp1,resultp2,extent,resultp1,resultp2); - - /* Need to check for a zero result. The sign and exponent - * fields have already been zeroed. The more efficient test - * of the full object can be used. - */ - if(Dbl_iszero(resultp1,resultp2)) - /* Must have been "x-x" or "x+(-x)". */ - { - if(Is_rounding_mode(ROUNDMINUS)) Dbl_setone_sign(resultp1); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - result_exponent--; - /* Look to see if normalization is finished. */ - if(Dbl_isone_hidden(resultp1)) - { - if(result_exponent==0) - { - /* Denormalized, exponent should be zero. Left operand * - * was normalized, so extent (guard, round) was zero */ - goto underflow; - } - else - { - /* No further normalization is needed. */ - Dbl_set_sign(resultp1,/*using*/sign_save); - Ext_leftshiftby1(extent); - goto round; - } - } - - /* Check for denormalized, exponent should be zero. Left * - * operand was normalized, so extent (guard, round) was zero */ - if(!(underflowtrap = Is_underflowtrap_enabled()) && - result_exponent==0) goto underflow; - - /* Shift extension to complete one bit of normalization and - * update exponent. */ - Ext_leftshiftby1(extent); - - /* Discover first one bit to determine shift amount. Use a - * modified binary search. We have already shifted the result - * one position right and still not found a one so the remainder - * of the extension must be zero and simplifies rounding. */ - /* Scan bytes */ - while(Dbl_iszero_hiddenhigh7mantissa(resultp1)) - { - Dbl_leftshiftby8(resultp1,resultp2); - if((result_exponent -= 8) <= 0 && !underflowtrap) - goto underflow; - } - /* Now narrow it down to the nibble */ - if(Dbl_iszero_hiddenhigh3mantissa(resultp1)) - { - /* The lower nibble contains the normalizing one */ - Dbl_leftshiftby4(resultp1,resultp2); - if((result_exponent -= 4) <= 0 && !underflowtrap) - goto underflow; - } - /* Select case were first bit is set (already normalized) - * otherwise select the proper shift. */ - if((jumpsize = Dbl_hiddenhigh3mantissa(resultp1)) > 7) - { - /* Already normalized */ - if(result_exponent <= 0) goto underflow; - Dbl_set_sign(resultp1,/*using*/sign_save); - Dbl_set_exponent(resultp1,/*using*/result_exponent); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - Dbl_sethigh4bits(resultp1,/*using*/sign_save); - switch(jumpsize) - { - case 1: - { - Dbl_leftshiftby3(resultp1,resultp2); - result_exponent -= 3; - break; - } - case 2: - case 3: - { - Dbl_leftshiftby2(resultp1,resultp2); - result_exponent -= 2; - break; - } - case 4: - case 5: - case 6: - case 7: - { - Dbl_leftshiftby1(resultp1,resultp2); - result_exponent -= 1; - break; - } - } - if(result_exponent > 0) - { - Dbl_set_exponent(resultp1,/*using*/result_exponent); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); /* Sign bit is already set */ - } - /* Fixup potential underflows */ - underflow: - if(Is_underflowtrap_enabled()) - { - Dbl_set_sign(resultp1,sign_save); - Dbl_setwrapped_exponent(resultp1,result_exponent,unfl); - Dbl_copytoptr(resultp1,resultp2,dstptr); - /* inexact = FALSE */ - return(UNDERFLOWEXCEPTION); - } - /* - * Since we cannot get an inexact denormalized result, - * we can now return. - */ - Dbl_fix_overshift(resultp1,resultp2,(1-result_exponent),extent); - Dbl_clear_signexponent(resultp1); - Dbl_set_sign(resultp1,sign_save); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } /* end if(hidden...)... */ - /* Fall through and round */ - } /* end if(save < 0)... */ - else - { - /* Add magnitudes */ - Dbl_addition(leftp1,leftp2,rightp1,rightp2,/*to*/resultp1,resultp2); - if(Dbl_isone_hiddenoverflow(resultp1)) - { - /* Prenormalization required. */ - Dbl_rightshiftby1_withextent(resultp2,extent,extent); - Dbl_arithrightshiftby1(resultp1,resultp2); - result_exponent++; - } /* end if hiddenoverflow... */ - } /* end else ...add magnitudes... */ - - /* Round the result. If the extension is all zeros,then the result is - * exact. Otherwise round in the correct direction. No underflow is - * possible. If a postnormalization is necessary, then the mantissa is - * all zeros so no shift is needed. */ - round: - if(Ext_isnotzero(extent)) - { - inexact = TRUE; - switch(Rounding_mode()) - { - case ROUNDNEAREST: /* The default. */ - if(Ext_isone_sign(extent)) - { - /* at least 1/2 ulp */ - if(Ext_isnotzero_lower(extent) || - Dbl_isone_lowmantissap2(resultp2)) - { - /* either exactly half way and odd or more than 1/2ulp */ - Dbl_increment(resultp1,resultp2); - } - } - break; - - case ROUNDPLUS: - if(Dbl_iszero_sign(resultp1)) - { - /* Round up positive results */ - Dbl_increment(resultp1,resultp2); - } - break; - - case ROUNDMINUS: - if(Dbl_isone_sign(resultp1)) - { - /* Round down negative results */ - Dbl_increment(resultp1,resultp2); - } - - case ROUNDZERO:; - /* truncate is simple */ - } /* end switch... */ - if(Dbl_isone_hiddenoverflow(resultp1)) result_exponent++; - } - if(result_exponent == DBL_INFINITY_EXPONENT) - { - /* Overflow */ - if(Is_overflowtrap_enabled()) - { - Dbl_setwrapped_exponent(resultp1,result_exponent,ovfl); - Dbl_copytoptr(resultp1,resultp2,dstptr); - if (inexact) { - if (Is_inexacttrap_enabled()) - return(OVERFLOWEXCEPTION | INEXACTEXCEPTION); - else - Set_inexactflag(); - } - return(OVERFLOWEXCEPTION); - } - else - { - inexact = TRUE; - Set_overflowflag(); - Dbl_setoverflow(resultp1,resultp2); - } - } - else Dbl_set_exponent(resultp1,result_exponent); - Dbl_copytoptr(resultp1,resultp2,dstptr); - if(inexact) { - if(Is_inexacttrap_enabled()) - return(INEXACTEXCEPTION); - else - Set_inexactflag(); - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/dfcmp.c b/sys/arch/hppa/spmath/dfcmp.c deleted file mode 100644 index 7416fc7aa..000000000 --- a/sys/arch/hppa/spmath/dfcmp.c +++ /dev/null @@ -1,154 +0,0 @@ -/* $OpenBSD: dfcmp.c,v 1.6 2002/09/20 19:26:59 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)dfcmp.c: Revision: 1.7.88.2 Date: 93/12/08 13:26:38 */ - -#include "float.h" -#include "dbl_float.h" - -/* - * dbl_cmp: compare two values - */ -int -dbl_fcmp(leftptr, rightptr, cond, status) - dbl_floating_point *leftptr, *rightptr; - unsigned int cond; /* The predicate to be tested */ - unsigned int *status; -{ - register unsigned int leftp1, leftp2, rightp1, rightp2; - register int xorresult; - - /* Create local copies of the numbers */ - Dbl_copyfromptr(leftptr,leftp1,leftp2); - Dbl_copyfromptr(rightptr,rightp1,rightp2); - /* - * Test for NaN - */ - if( (Dbl_exponent(leftp1) == DBL_INFINITY_EXPONENT) - || (Dbl_exponent(rightp1) == DBL_INFINITY_EXPONENT) ) - { - /* Check if a NaN is involved. Signal an invalid exception when - * comparing a signaling NaN or when comparing quiet NaNs and the - * low bit of the condition is set */ - if( ((Dbl_exponent(leftp1) == DBL_INFINITY_EXPONENT) - && Dbl_isnotzero_mantissa(leftp1,leftp2) - && (Exception(cond) || Dbl_isone_signaling(leftp1))) - || - ((Dbl_exponent(rightp1) == DBL_INFINITY_EXPONENT) - && Dbl_isnotzero_mantissa(rightp1,rightp2) - && (Exception(cond) || Dbl_isone_signaling(rightp1))) ) - { - if( Is_invalidtrap_enabled() ) { - Set_status_cbit(Unordered(cond)); - return(INVALIDEXCEPTION); - } - else Set_invalidflag(); - Set_status_cbit(Unordered(cond)); - return(NOEXCEPTION); - } - /* All the exceptional conditions are handled, now special case - NaN compares */ - else if( ((Dbl_exponent(leftp1) == DBL_INFINITY_EXPONENT) - && Dbl_isnotzero_mantissa(leftp1,leftp2)) - || - ((Dbl_exponent(rightp1) == DBL_INFINITY_EXPONENT) - && Dbl_isnotzero_mantissa(rightp1,rightp2)) ) - { - /* NaNs always compare unordered. */ - Set_status_cbit(Unordered(cond)); - return(NOEXCEPTION); - } - /* infinities will drop down to the normal compare mechanisms */ - } - /* First compare for unequal signs => less or greater or - * special equal case */ - Dbl_xortointp1(leftp1,rightp1,xorresult); - if( xorresult < 0 ) - { - /* left negative => less, left positive => greater. - * equal is possible if both operands are zeros. */ - if( Dbl_iszero_exponentmantissa(leftp1,leftp2) - && Dbl_iszero_exponentmantissa(rightp1,rightp2) ) - { - Set_status_cbit(Equal(cond)); - } - else if( Dbl_isone_sign(leftp1) ) - { - Set_status_cbit(Lessthan(cond)); - } - else - { - Set_status_cbit(Greaterthan(cond)); - } - } - /* Signs are the same. Treat negative numbers separately - * from the positives because of the reversed sense. */ - else if(Dbl_isequal(leftp1,leftp2,rightp1,rightp2)) - { - Set_status_cbit(Equal(cond)); - } - else if( Dbl_iszero_sign(leftp1) ) - { - /* Positive compare */ - if( Dbl_allp1(leftp1) < Dbl_allp1(rightp1) ) - { - Set_status_cbit(Lessthan(cond)); - } - else if( Dbl_allp1(leftp1) > Dbl_allp1(rightp1) ) - { - Set_status_cbit(Greaterthan(cond)); - } - else - { - /* Equal first parts. Now we must use unsigned compares to - * resolve the two possibilities. */ - if( Dbl_allp2(leftp2) < Dbl_allp2(rightp2) ) - { - Set_status_cbit(Lessthan(cond)); - } - else - { - Set_status_cbit(Greaterthan(cond)); - } - } - } - else - { - /* Negative compare. Signed or unsigned compares - * both work the same. That distinction is only - * important when the sign bits differ. */ - if( Dbl_allp1(leftp1) > Dbl_allp1(rightp1) ) - { - Set_status_cbit(Lessthan(cond)); - } - else if( Dbl_allp1(leftp1) < Dbl_allp1(rightp1) ) - { - Set_status_cbit(Greaterthan(cond)); - } - else - { - /* Equal first parts. Now we must use unsigned compares to - * resolve the two possibilities. */ - if( Dbl_allp2(leftp2) > Dbl_allp2(rightp2) ) - { - Set_status_cbit(Lessthan(cond)); - } - else - { - Set_status_cbit(Greaterthan(cond)); - } - } - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/dfdiv.c b/sys/arch/hppa/spmath/dfdiv.c deleted file mode 100644 index bf29f19f1..000000000 --- a/sys/arch/hppa/spmath/dfdiv.c +++ /dev/null @@ -1,381 +0,0 @@ -/* $OpenBSD: dfdiv.c,v 1.5 2002/05/07 22:19:30 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)dfdiv.c: Revision: 2.11.88.1 Date: 93/12/07 15:05:39 */ - -#include "float.h" -#include "dbl_float.h" - -/* - * Double Precision Floating-point Divide - */ - -int -dbl_fdiv(srcptr1,srcptr2,dstptr,status) - dbl_floating_point *srcptr1, *srcptr2, *dstptr; - unsigned int *status; -{ - register unsigned int opnd1p1, opnd1p2, opnd2p1, opnd2p2; - register unsigned int opnd3p1, opnd3p2, resultp1, resultp2; - register int dest_exponent, count; - register int inexact = FALSE, guardbit = FALSE, stickybit = FALSE; - int is_tiny; - - Dbl_copyfromptr(srcptr1,opnd1p1,opnd1p2); - Dbl_copyfromptr(srcptr2,opnd2p1,opnd2p2); - /* - * set sign bit of result - */ - if (Dbl_sign(opnd1p1) ^ Dbl_sign(opnd2p1)) - Dbl_setnegativezerop1(resultp1); - else Dbl_setzerop1(resultp1); - /* - * check first operand for NaN's or infinity - */ - if (Dbl_isinfinity_exponent(opnd1p1)) { - if (Dbl_iszero_mantissa(opnd1p1,opnd1p2)) { - if (Dbl_isnotnan(opnd2p1,opnd2p2)) { - if (Dbl_isinfinity(opnd2p1,opnd2p2)) { - /* - * invalid since both operands - * are infinity - */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - Set_invalidflag(); - Dbl_makequietnan(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* - * return infinity - */ - Dbl_setinfinity_exponentmantissa(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - } - else { - /* - * is NaN; signaling or quiet? - */ - if (Dbl_isone_signaling(opnd1p1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(opnd1p1); - } - /* - * is second operand a signaling NaN? - */ - else if (Dbl_is_signalingnan(opnd2p1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(opnd2p1); - Dbl_copytoptr(opnd2p1,opnd2p2,dstptr); - return(NOEXCEPTION); - } - /* - * return quiet NaN - */ - Dbl_copytoptr(opnd1p1,opnd1p2,dstptr); - return(NOEXCEPTION); - } - } - /* - * check second operand for NaN's or infinity - */ - if (Dbl_isinfinity_exponent(opnd2p1)) { - if (Dbl_iszero_mantissa(opnd2p1,opnd2p2)) { - /* - * return zero - */ - Dbl_setzero_exponentmantissa(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* - * is NaN; signaling or quiet? - */ - if (Dbl_isone_signaling(opnd2p1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(opnd2p1); - } - /* - * return quiet NaN - */ - Dbl_copytoptr(opnd2p1,opnd2p2,dstptr); - return(NOEXCEPTION); - } - /* - * check for division by zero - */ - if (Dbl_iszero_exponentmantissa(opnd2p1,opnd2p2)) { - if (Dbl_iszero_exponentmantissa(opnd1p1,opnd1p2)) { - /* invalid since both operands are zero */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - Set_invalidflag(); - Dbl_makequietnan(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - if (Is_divisionbyzerotrap_enabled()) - return(DIVISIONBYZEROEXCEPTION); - Set_divisionbyzeroflag(); - Dbl_setinfinity_exponentmantissa(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* - * Generate exponent - */ - dest_exponent = Dbl_exponent(opnd1p1) - Dbl_exponent(opnd2p1) + DBL_BIAS; - - /* - * Generate mantissa - */ - if (Dbl_isnotzero_exponent(opnd1p1)) { - /* set hidden bit */ - Dbl_clear_signexponent_set_hidden(opnd1p1); - } - else { - /* check for zero */ - if (Dbl_iszero_mantissa(opnd1p1,opnd1p2)) { - Dbl_setzero_exponentmantissa(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* is denormalized, want to normalize */ - Dbl_clear_signexponent(opnd1p1); - Dbl_leftshiftby1(opnd1p1,opnd1p2); - Dbl_normalize(opnd1p1,opnd1p2,dest_exponent); - } - /* opnd2 needs to have hidden bit set with msb in hidden bit */ - if (Dbl_isnotzero_exponent(opnd2p1)) { - Dbl_clear_signexponent_set_hidden(opnd2p1); - } - else { - /* is denormalized; want to normalize */ - Dbl_clear_signexponent(opnd2p1); - Dbl_leftshiftby1(opnd2p1,opnd2p2); - while (Dbl_iszero_hiddenhigh7mantissa(opnd2p1)) { - dest_exponent+=8; - Dbl_leftshiftby8(opnd2p1,opnd2p2); - } - if (Dbl_iszero_hiddenhigh3mantissa(opnd2p1)) { - dest_exponent+=4; - Dbl_leftshiftby4(opnd2p1,opnd2p2); - } - while (Dbl_iszero_hidden(opnd2p1)) { - dest_exponent++; - Dbl_leftshiftby1(opnd2p1,opnd2p2); - } - } - - /* Divide the source mantissas */ - - /* - * A non-restoring divide algorithm is used. - */ - Twoword_subtract(opnd1p1,opnd1p2,opnd2p1,opnd2p2); - Dbl_setzero(opnd3p1,opnd3p2); - for (count=1; count <= DBL_P && (opnd1p1 || opnd1p2); count++) { - Dbl_leftshiftby1(opnd1p1,opnd1p2); - Dbl_leftshiftby1(opnd3p1,opnd3p2); - if (Dbl_iszero_sign(opnd1p1)) { - Dbl_setone_lowmantissap2(opnd3p2); - Twoword_subtract(opnd1p1,opnd1p2,opnd2p1,opnd2p2); - } - else { - Twoword_add(opnd1p1, opnd1p2, opnd2p1, opnd2p2); - } - } - if (count <= DBL_P) { - Dbl_leftshiftby1(opnd3p1,opnd3p2); - Dbl_setone_lowmantissap2(opnd3p2); - Dbl_leftshift(opnd3p1,opnd3p2,(DBL_P-count)); - if (Dbl_iszero_hidden(opnd3p1)) { - Dbl_leftshiftby1(opnd3p1,opnd3p2); - dest_exponent--; - } - } - else { - if (Dbl_iszero_hidden(opnd3p1)) { - /* need to get one more bit of result */ - Dbl_leftshiftby1(opnd1p1,opnd1p2); - Dbl_leftshiftby1(opnd3p1,opnd3p2); - if (Dbl_iszero_sign(opnd1p1)) { - Dbl_setone_lowmantissap2(opnd3p2); - Twoword_subtract(opnd1p1,opnd1p2,opnd2p1,opnd2p2); - } - else { - Twoword_add(opnd1p1,opnd1p2,opnd2p1,opnd2p2); - } - dest_exponent--; - } - if (Dbl_iszero_sign(opnd1p1)) guardbit = TRUE; - stickybit = Dbl_allp1(opnd1p1) || Dbl_allp2(opnd1p2); - } - inexact = guardbit | stickybit; - - /* - * round result - */ - if (inexact && (dest_exponent > 0 || Is_underflowtrap_enabled())) { - Dbl_clear_signexponent(opnd3p1); - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(resultp1)) - Dbl_increment(opnd3p1,opnd3p2); - break; - case ROUNDMINUS: - if (Dbl_isone_sign(resultp1)) - Dbl_increment(opnd3p1,opnd3p2); - break; - case ROUNDNEAREST: - if (guardbit && (stickybit || - Dbl_isone_lowmantissap2(opnd3p2))) { - Dbl_increment(opnd3p1,opnd3p2); - } - } - if (Dbl_isone_hidden(opnd3p1)) dest_exponent++; - } - Dbl_set_mantissa(resultp1,resultp2,opnd3p1,opnd3p2); - - /* - * Test for overflow - */ - if (dest_exponent >= DBL_INFINITY_EXPONENT) { - /* trap if OVERFLOWTRAP enabled */ - if (Is_overflowtrap_enabled()) { - /* - * Adjust bias of result - */ - Dbl_setwrapped_exponent(resultp1,dest_exponent,ovfl); - Dbl_copytoptr(resultp1,resultp2,dstptr); - if (inexact) { - if (Is_inexacttrap_enabled()) - return(OVERFLOWEXCEPTION | INEXACTEXCEPTION); - else - Set_inexactflag(); - } - return(OVERFLOWEXCEPTION); - } - Set_overflowflag(); - /* set result to infinity or largest number */ - Dbl_setoverflow(resultp1,resultp2); - inexact = TRUE; - } - /* - * Test for underflow - */ - else if (dest_exponent <= 0) { - /* trap if UNDERFLOWTRAP enabled */ - if (Is_underflowtrap_enabled()) { - /* - * Adjust bias of result - */ - Dbl_setwrapped_exponent(resultp1,dest_exponent,unfl); - Dbl_copytoptr(resultp1,resultp2,dstptr); - if (inexact) { - if (Is_inexacttrap_enabled()) - return(UNDERFLOWEXCEPTION | INEXACTEXCEPTION); - else - Set_inexactflag(); - } - return(UNDERFLOWEXCEPTION); - } - - /* Determine if should set underflow flag */ - is_tiny = TRUE; - if (dest_exponent == 0 && inexact) { - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(resultp1)) { - Dbl_increment(opnd3p1,opnd3p2); - if (Dbl_isone_hiddenoverflow(opnd3p1)) - is_tiny = FALSE; - Dbl_decrement(opnd3p1,opnd3p2); - } - break; - case ROUNDMINUS: - if (Dbl_isone_sign(resultp1)) { - Dbl_increment(opnd3p1,opnd3p2); - if (Dbl_isone_hiddenoverflow(opnd3p1)) - is_tiny = FALSE; - Dbl_decrement(opnd3p1,opnd3p2); - } - break; - case ROUNDNEAREST: - if (guardbit && (stickybit || - Dbl_isone_lowmantissap2(opnd3p2))) { - Dbl_increment(opnd3p1,opnd3p2); - if (Dbl_isone_hiddenoverflow(opnd3p1)) - is_tiny = FALSE; - Dbl_decrement(opnd3p1,opnd3p2); - } - break; - } - } - - /* - * denormalize result or set to signed zero - */ - stickybit = inexact; - Dbl_denormalize(opnd3p1,opnd3p2,dest_exponent,guardbit, - stickybit,inexact); - - /* return rounded number */ - if (inexact) { - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(resultp1)) { - Dbl_increment(opnd3p1,opnd3p2); - } - break; - case ROUNDMINUS: - if (Dbl_isone_sign(resultp1)) { - Dbl_increment(opnd3p1,opnd3p2); - } - break; - case ROUNDNEAREST: - if (guardbit && (stickybit || - Dbl_isone_lowmantissap2(opnd3p2))) { - Dbl_increment(opnd3p1,opnd3p2); - } - break; - } - if (is_tiny) - Set_underflowflag(); - } - Dbl_set_exponentmantissa(resultp1,resultp2,opnd3p1,opnd3p2); - } - else Dbl_set_exponent(resultp1,dest_exponent); - Dbl_copytoptr(resultp1,resultp2,dstptr); - - /* check for inexact */ - if (inexact) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/dfmpy.c b/sys/arch/hppa/spmath/dfmpy.c deleted file mode 100644 index 81b4239be..000000000 --- a/sys/arch/hppa/spmath/dfmpy.c +++ /dev/null @@ -1,371 +0,0 @@ -/* $OpenBSD: dfmpy.c,v 1.6 2015/05/07 01:55:43 jsg Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)dfmpy.c: Revision: 2.11.88.1 Date: 93/12/07 15:05:41 */ - -#include "float.h" -#include "dbl_float.h" - -/* - * Double Precision Floating-point Multiply - */ - -int -dbl_fmpy(srcptr1,srcptr2,dstptr,status) - dbl_floating_point *srcptr1, *srcptr2, *dstptr; - unsigned int *status; -{ - register unsigned int opnd1p1, opnd1p2, opnd2p1, opnd2p2; - register unsigned int opnd3p1, opnd3p2, resultp1, resultp2; - register int dest_exponent, count; - register int inexact = FALSE, guardbit = FALSE, stickybit = FALSE; - int is_tiny; - - Dbl_copyfromptr(srcptr1,opnd1p1,opnd1p2); - Dbl_copyfromptr(srcptr2,opnd2p1,opnd2p2); - - /* - * set sign bit of result - */ - if (Dbl_sign(opnd1p1) ^ Dbl_sign(opnd2p1)) - Dbl_setnegativezerop1(resultp1); - else Dbl_setzerop1(resultp1); - /* - * check first operand for NaN's or infinity - */ - if (Dbl_isinfinity_exponent(opnd1p1)) { - if (Dbl_iszero_mantissa(opnd1p1,opnd1p2)) { - if (Dbl_isnotnan(opnd2p1,opnd2p2)) { - if (Dbl_iszero_exponentmantissa(opnd2p1,opnd2p2)) { - /* - * invalid since operands are infinity - * and zero - */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - Set_invalidflag(); - Dbl_makequietnan(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* - * return infinity - */ - Dbl_setinfinity_exponentmantissa(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - } - else { - /* - * is NaN; signaling or quiet? - */ - if (Dbl_isone_signaling(opnd1p1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(opnd1p1); - } - /* - * is second operand a signaling NaN? - */ - else if (Dbl_is_signalingnan(opnd2p1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(opnd2p1); - Dbl_copytoptr(opnd2p1,opnd2p2,dstptr); - return(NOEXCEPTION); - } - /* - * return quiet NaN - */ - Dbl_copytoptr(opnd1p1,opnd1p2,dstptr); - return(NOEXCEPTION); - } - } - /* - * check second operand for NaN's or infinity - */ - if (Dbl_isinfinity_exponent(opnd2p1)) { - if (Dbl_iszero_mantissa(opnd2p1,opnd2p2)) { - if (Dbl_iszero_exponentmantissa(opnd1p1,opnd1p2)) { - /* invalid since operands are zero & infinity */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - Set_invalidflag(); - Dbl_makequietnan(opnd2p1,opnd2p2); - Dbl_copytoptr(opnd2p1,opnd2p2,dstptr); - return(NOEXCEPTION); - } - /* - * return infinity - */ - Dbl_setinfinity_exponentmantissa(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* - * is NaN; signaling or quiet? - */ - if (Dbl_isone_signaling(opnd2p1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(opnd2p1); - } - /* - * return quiet NaN - */ - Dbl_copytoptr(opnd2p1,opnd2p2,dstptr); - return(NOEXCEPTION); - } - /* - * Generate exponent - */ - dest_exponent = Dbl_exponent(opnd1p1) + Dbl_exponent(opnd2p1) -DBL_BIAS; - - /* - * Generate mantissa - */ - if (Dbl_isnotzero_exponent(opnd1p1)) { - /* set hidden bit */ - Dbl_clear_signexponent_set_hidden(opnd1p1); - } - else { - /* check for zero */ - if (Dbl_iszero_mantissa(opnd1p1,opnd1p2)) { - Dbl_setzero_exponentmantissa(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* is denormalized, adjust exponent */ - Dbl_clear_signexponent(opnd1p1); - Dbl_leftshiftby1(opnd1p1,opnd1p2); - Dbl_normalize(opnd1p1,opnd1p2,dest_exponent); - } - /* opnd2 needs to have hidden bit set with msb in hidden bit */ - if (Dbl_isnotzero_exponent(opnd2p1)) { - Dbl_clear_signexponent_set_hidden(opnd2p1); - } - else { - /* check for zero */ - if (Dbl_iszero_mantissa(opnd2p1,opnd2p2)) { - Dbl_setzero_exponentmantissa(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* is denormalized; want to normalize */ - Dbl_clear_signexponent(opnd2p1); - Dbl_leftshiftby1(opnd2p1,opnd2p2); - Dbl_normalize(opnd2p1,opnd2p2,dest_exponent); - } - - /* Multiply two source mantissas together */ - - /* make room for guard bits */ - Dbl_leftshiftby7(opnd2p1,opnd2p2); - Dbl_setzero(opnd3p1,opnd3p2); - /* - * Four bits at a time are inspected in each loop, and a - * simple shift and add multiply algorithm is used. - */ - for (count=1;count<=DBL_P;count+=4) { - stickybit |= Dlow4p2(opnd3p2); - Dbl_rightshiftby4(opnd3p1,opnd3p2); - if (Dbit28p2(opnd1p2)) { - /* Twoword_add should be an ADDC followed by an ADD. */ - Twoword_add(opnd3p1, opnd3p2, opnd2p1<<3 | opnd2p2>>29, - opnd2p2<<3); - } - if (Dbit29p2(opnd1p2)) { - Twoword_add(opnd3p1, opnd3p2, opnd2p1<<2 | opnd2p2>>30, - opnd2p2<<2); - } - if (Dbit30p2(opnd1p2)) { - Twoword_add(opnd3p1, opnd3p2, opnd2p1<<1 | opnd2p2>>31, - opnd2p2<<1); - } - if (Dbit31p2(opnd1p2)) { - Twoword_add(opnd3p1, opnd3p2, opnd2p1, opnd2p2); - } - Dbl_rightshiftby4(opnd1p1,opnd1p2); - } - if (Dbit3p1(opnd3p1)==0) { - Dbl_leftshiftby1(opnd3p1,opnd3p2); - } - else { - /* result mantissa >= 2. */ - dest_exponent++; - } - /* check for denormalized result */ - while (Dbit3p1(opnd3p1)==0) { - Dbl_leftshiftby1(opnd3p1,opnd3p2); - dest_exponent--; - } - /* - * check for guard, sticky and inexact bits - */ - stickybit |= Dallp2(opnd3p2) << 25; - guardbit = (Dallp2(opnd3p2) << 24) >> 31; - inexact = guardbit | stickybit; - - /* align result mantissa */ - Dbl_rightshiftby8(opnd3p1,opnd3p2); - - /* - * round result - */ - if (inexact && (dest_exponent>0 || Is_underflowtrap_enabled())) { - Dbl_clear_signexponent(opnd3p1); - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(resultp1)) - Dbl_increment(opnd3p1,opnd3p2); - break; - case ROUNDMINUS: - if (Dbl_isone_sign(resultp1)) - Dbl_increment(opnd3p1,opnd3p2); - break; - case ROUNDNEAREST: - if (guardbit && - (stickybit || Dbl_isone_lowmantissap2(opnd3p2))) - Dbl_increment(opnd3p1,opnd3p2); - break; - } - if (Dbl_isone_hidden(opnd3p1)) dest_exponent++; - } - Dbl_set_mantissa(resultp1,resultp2,opnd3p1,opnd3p2); - - /* - * Test for overflow - */ - if (dest_exponent >= DBL_INFINITY_EXPONENT) { - /* trap if OVERFLOWTRAP enabled */ - if (Is_overflowtrap_enabled()) { - /* - * Adjust bias of result - */ - Dbl_setwrapped_exponent(resultp1,dest_exponent,ovfl); - Dbl_copytoptr(resultp1,resultp2,dstptr); - if (inexact) { - if (Is_inexacttrap_enabled()) - return (OVERFLOWEXCEPTION | INEXACTEXCEPTION); - else - Set_inexactflag(); - } - return (OVERFLOWEXCEPTION); - } - inexact = TRUE; - Set_overflowflag(); - /* set result to infinity or largest number */ - Dbl_setoverflow(resultp1,resultp2); - } - /* - * Test for underflow - */ - else if (dest_exponent <= 0) { - /* trap if UNDERFLOWTRAP enabled */ - if (Is_underflowtrap_enabled()) { - /* - * Adjust bias of result - */ - Dbl_setwrapped_exponent(resultp1,dest_exponent,unfl); - Dbl_copytoptr(resultp1,resultp2,dstptr); - if (inexact) { - if (Is_inexacttrap_enabled()) - return (UNDERFLOWEXCEPTION | INEXACTEXCEPTION); - else - Set_inexactflag(); - } - return (UNDERFLOWEXCEPTION); - } - - /* Determine if should set underflow flag */ - is_tiny = TRUE; - if (dest_exponent == 0 && inexact) { - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(resultp1)) { - Dbl_increment(opnd3p1,opnd3p2); - if (Dbl_isone_hiddenoverflow(opnd3p1)) - is_tiny = FALSE; - Dbl_decrement(opnd3p1,opnd3p2); - } - break; - case ROUNDMINUS: - if (Dbl_isone_sign(resultp1)) { - Dbl_increment(opnd3p1,opnd3p2); - if (Dbl_isone_hiddenoverflow(opnd3p1)) - is_tiny = FALSE; - Dbl_decrement(opnd3p1,opnd3p2); - } - break; - case ROUNDNEAREST: - if (guardbit && (stickybit || - Dbl_isone_lowmantissap2(opnd3p2))) { - Dbl_increment(opnd3p1,opnd3p2); - if (Dbl_isone_hiddenoverflow(opnd3p1)) - is_tiny = FALSE; - Dbl_decrement(opnd3p1,opnd3p2); - } - break; - } - } - - /* - * denormalize result or set to signed zero - */ - stickybit = inexact; - Dbl_denormalize(opnd3p1,opnd3p2,dest_exponent,guardbit, - stickybit,inexact); - - /* return zero or smallest number */ - if (inexact) { - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(resultp1)) { - Dbl_increment(opnd3p1,opnd3p2); - } - break; - case ROUNDMINUS: - if (Dbl_isone_sign(resultp1)) { - Dbl_increment(opnd3p1,opnd3p2); - } - break; - case ROUNDNEAREST: - if (guardbit && (stickybit || - Dbl_isone_lowmantissap2(opnd3p2))) { - Dbl_increment(opnd3p1,opnd3p2); - } - break; - } - if (is_tiny) Set_underflowflag(); - } - Dbl_set_exponentmantissa(resultp1,resultp2,opnd3p1,opnd3p2); - } - else Dbl_set_exponent(resultp1,dest_exponent); - /* check for inexact */ - Dbl_copytoptr(resultp1,resultp2,dstptr); - if (inexact) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/dfrem.c b/sys/arch/hppa/spmath/dfrem.c deleted file mode 100644 index fa89e255b..000000000 --- a/sys/arch/hppa/spmath/dfrem.c +++ /dev/null @@ -1,271 +0,0 @@ -/* $OpenBSD: dfrem.c,v 1.5 2002/05/07 22:19:30 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)dfrem.c: Revision: 1.7.88.1 Date: 93/12/07 15:05:43 */ - -#include "float.h" -#include "dbl_float.h" - -/* - * Double Precision Floating-point Remainder - */ -int -dbl_frem(srcptr1,srcptr2,dstptr,status) - dbl_floating_point *srcptr1, *srcptr2, *dstptr; - unsigned int *status; -{ - register unsigned int opnd1p1, opnd1p2, opnd2p1, opnd2p2; - register unsigned int resultp1, resultp2; - register int opnd1_exponent, opnd2_exponent, dest_exponent, stepcount; - register int roundup = FALSE; - - Dbl_copyfromptr(srcptr1,opnd1p1,opnd1p2); - Dbl_copyfromptr(srcptr2,opnd2p1,opnd2p2); - /* - * check first operand for NaN's or infinity - */ - if ((opnd1_exponent = Dbl_exponent(opnd1p1)) == DBL_INFINITY_EXPONENT) { - if (Dbl_iszero_mantissa(opnd1p1,opnd1p2)) { - if (Dbl_isnotnan(opnd2p1,opnd2p2)) { - /* invalid since first operand is infinity */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - Set_invalidflag(); - Dbl_makequietnan(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - } - else { - /* - * is NaN; signaling or quiet? - */ - if (Dbl_isone_signaling(opnd1p1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(opnd1p1); - } - /* - * is second operand a signaling NaN? - */ - else if (Dbl_is_signalingnan(opnd2p1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(opnd2p1); - Dbl_copytoptr(opnd2p1,opnd2p2,dstptr); - return(NOEXCEPTION); - } - /* - * return quiet NaN - */ - Dbl_copytoptr(opnd1p1,opnd1p2,dstptr); - return(NOEXCEPTION); - } - } - /* - * check second operand for NaN's or infinity - */ - if ((opnd2_exponent = Dbl_exponent(opnd2p1)) == DBL_INFINITY_EXPONENT) { - if (Dbl_iszero_mantissa(opnd2p1,opnd2p2)) { - /* - * return first operand - */ - Dbl_copytoptr(opnd1p1,opnd1p2,dstptr); - return(NOEXCEPTION); - } - /* - * is NaN; signaling or quiet? - */ - if (Dbl_isone_signaling(opnd2p1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(opnd2p1); - } - /* - * return quiet NaN - */ - Dbl_copytoptr(opnd2p1,opnd2p2,dstptr); - return(NOEXCEPTION); - } - /* - * check second operand for zero - */ - if (Dbl_iszero_exponentmantissa(opnd2p1,opnd2p2)) { - /* invalid since second operand is zero */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - Set_invalidflag(); - Dbl_makequietnan(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - - /* - * get sign of result - */ - resultp1 = opnd1p1; - - /* - * check for denormalized operands - */ - if (opnd1_exponent == 0) { - /* check for zero */ - if (Dbl_iszero_mantissa(opnd1p1,opnd1p2)) { - Dbl_copytoptr(opnd1p1,opnd1p2,dstptr); - return(NOEXCEPTION); - } - /* normalize, then continue */ - opnd1_exponent = 1; - Dbl_normalize(opnd1p1,opnd1p2,opnd1_exponent); - } - else { - Dbl_clear_signexponent_set_hidden(opnd1p1); - } - if (opnd2_exponent == 0) { - /* normalize, then continue */ - opnd2_exponent = 1; - Dbl_normalize(opnd2p1,opnd2p2,opnd2_exponent); - } - else { - Dbl_clear_signexponent_set_hidden(opnd2p1); - } - - /* find result exponent and divide step loop count */ - dest_exponent = opnd2_exponent - 1; - stepcount = opnd1_exponent - opnd2_exponent; - - /* - * check for opnd1/opnd2 < 1 - */ - if (stepcount < 0) { - /* - * check for opnd1/opnd2 > 1/2 - * - * In this case n will round to 1, so - * r = opnd1 - opnd2 - */ - if (stepcount == -1 && - Dbl_isgreaterthan(opnd1p1,opnd1p2,opnd2p1,opnd2p2)) { - /* set sign */ - Dbl_allp1(resultp1) = ~Dbl_allp1(resultp1); - /* align opnd2 with opnd1 */ - Dbl_leftshiftby1(opnd2p1,opnd2p2); - Dbl_subtract(opnd2p1,opnd2p2,opnd1p1,opnd1p2, - opnd2p1,opnd2p2); - /* now normalize */ - while (Dbl_iszero_hidden(opnd2p1)) { - Dbl_leftshiftby1(opnd2p1,opnd2p2); - dest_exponent--; - } - Dbl_set_exponentmantissa(resultp1,resultp2,opnd2p1,opnd2p2); - goto testforunderflow; - } - /* - * opnd1/opnd2 <= 1/2 - * - * In this case n will round to zero, so - * r = opnd1 - */ - Dbl_set_exponentmantissa(resultp1,resultp2,opnd1p1,opnd1p2); - dest_exponent = opnd1_exponent; - goto testforunderflow; - } - - /* - * Generate result - * - * Do iterative subtract until remainder is less than operand 2. - */ - while (stepcount-- > 0 && (Dbl_allp1(opnd1p1) || Dbl_allp2(opnd1p2))) { - if (Dbl_isnotlessthan(opnd1p1,opnd1p2,opnd2p1,opnd2p2)) { - Dbl_subtract(opnd1p1,opnd1p2,opnd2p1,opnd2p2,opnd1p1,opnd1p2); - } - Dbl_leftshiftby1(opnd1p1,opnd1p2); - } - /* - * Do last subtract, then determine which way to round if remainder - * is exactly 1/2 of opnd2 - */ - if (Dbl_isnotlessthan(opnd1p1,opnd1p2,opnd2p1,opnd2p2)) { - Dbl_subtract(opnd1p1,opnd1p2,opnd2p1,opnd2p2,opnd1p1,opnd1p2); - roundup = TRUE; - } - if (stepcount > 0 || Dbl_iszero(opnd1p1,opnd1p2)) { - /* division is exact, remainder is zero */ - Dbl_setzero_exponentmantissa(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - - /* - * Check for cases where opnd1/opnd2 < n - * - * In this case the result's sign will be opposite that of - * opnd1. The mantissa also needs some correction. - */ - Dbl_leftshiftby1(opnd1p1,opnd1p2); - if (Dbl_isgreaterthan(opnd1p1,opnd1p2,opnd2p1,opnd2p2)) { - Dbl_invert_sign(resultp1); - Dbl_leftshiftby1(opnd2p1,opnd2p2); - Dbl_subtract(opnd2p1,opnd2p2,opnd1p1,opnd1p2,opnd1p1,opnd1p2); - } - /* check for remainder being exactly 1/2 of opnd2 */ - else if (Dbl_isequal(opnd1p1,opnd1p2,opnd2p1,opnd2p2) && roundup) { - Dbl_invert_sign(resultp1); - } - - /* normalize result's mantissa */ - while (Dbl_iszero_hidden(opnd1p1)) { - dest_exponent--; - Dbl_leftshiftby1(opnd1p1,opnd1p2); - } - Dbl_set_exponentmantissa(resultp1,resultp2,opnd1p1,opnd1p2); - - /* - * Test for underflow - */ - testforunderflow: - if (dest_exponent <= 0) { - /* trap if UNDERFLOWTRAP enabled */ - if (Is_underflowtrap_enabled()) { - /* - * Adjust bias of result - */ - Dbl_setwrapped_exponent(resultp1,dest_exponent,unfl); - /* frem is always exact */ - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(UNDERFLOWEXCEPTION); - } - /* - * denormalize result or set to signed zero - */ - if (dest_exponent >= (1 - DBL_P)) { - Dbl_rightshift_exponentmantissa(resultp1,resultp2, - 1-dest_exponent); - } - else { - Dbl_setzero_exponentmantissa(resultp1,resultp2); - } - } - else Dbl_set_exponent(resultp1,dest_exponent); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/dfsqrt.c b/sys/arch/hppa/spmath/dfsqrt.c deleted file mode 100644 index d48f1f681..000000000 --- a/sys/arch/hppa/spmath/dfsqrt.c +++ /dev/null @@ -1,167 +0,0 @@ -/* $OpenBSD: dfsqrt.c,v 1.8 2023/03/08 04:43:07 guenther Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)dfsqrt.c: Revision: 1.9.88.1 Date: 93/12/07 15:05:46 */ - -#include "float.h" -#include "dbl_float.h" - -/* - * Double Floating-point Square Root - */ - -int -dbl_fsqrt(srcptr, null, dstptr, status) - dbl_floating_point *srcptr, *null, *dstptr; - unsigned int *status; -{ - register unsigned int srcp1, srcp2, resultp1, resultp2; - register unsigned int newbitp1, newbitp2, sump1, sump2; - register int src_exponent; - register int guardbit = FALSE, even_exponent; - - Dbl_copyfromptr(srcptr,srcp1,srcp2); - /* - * check source operand for NaN or infinity - */ - if ((src_exponent = Dbl_exponent(srcp1)) == DBL_INFINITY_EXPONENT) { - /* - * is signaling NaN? - */ - if (Dbl_isone_signaling(srcp1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(srcp1); - } - /* - * Return quiet NaN or positive infinity. - * Fall thru to negative test if negative infinity. - */ - if (Dbl_iszero_sign(srcp1) || - Dbl_isnotzero_mantissa(srcp1,srcp2)) { - Dbl_copytoptr(srcp1,srcp2,dstptr); - return(NOEXCEPTION); - } - } - - /* - * check for zero source operand - */ - if (Dbl_iszero_exponentmantissa(srcp1,srcp2)) { - Dbl_copytoptr(srcp1,srcp2,dstptr); - return(NOEXCEPTION); - } - - /* - * check for negative source operand - */ - if (Dbl_isone_sign(srcp1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_makequietnan(srcp1,srcp2); - Dbl_copytoptr(srcp1,srcp2,dstptr); - return(NOEXCEPTION); - } - - /* - * Generate result - */ - if (src_exponent > 0) { - even_exponent = Dbl_hidden(srcp1); - Dbl_clear_signexponent_set_hidden(srcp1); - } - else { - /* normalize operand */ - Dbl_clear_signexponent(srcp1); - src_exponent++; - Dbl_normalize(srcp1,srcp2,src_exponent); - even_exponent = src_exponent & 1; - } - if (even_exponent) { - /* exponent is even */ - /* Add comment here. Explain why odd exponent needs correction */ - Dbl_leftshiftby1(srcp1,srcp2); - } - /* - * Add comment here. Explain following algorithm. - * - * Trust me, it works. - * - */ - Dbl_setzero(resultp1,resultp2); - Dbl_allp1(newbitp1) = 1 << (DBL_P - 32); - Dbl_setzero_mantissap2(newbitp2); - while (Dbl_isnotzero(newbitp1,newbitp2) && Dbl_isnotzero(srcp1,srcp2)) { - Dbl_addition(resultp1,resultp2,newbitp1,newbitp2,sump1,sump2); - if(Dbl_isnotgreaterthan(sump1,sump2,srcp1,srcp2)) { - Dbl_leftshiftby1(newbitp1,newbitp2); - /* update result */ - Dbl_addition(resultp1,resultp2,newbitp1,newbitp2, - resultp1,resultp2); - Dbl_subtract(srcp1,srcp2,sump1,sump2,srcp1,srcp2); - Dbl_rightshiftby2(newbitp1,newbitp2); - } - else { - Dbl_rightshiftby1(newbitp1,newbitp2); - } - Dbl_leftshiftby1(srcp1,srcp2); - } - /* correct exponent for pre-shift */ - if (even_exponent) { - Dbl_rightshiftby1(resultp1,resultp2); - } - - /* check for inexact */ - if (Dbl_isnotzero(srcp1,srcp2)) { - if (!even_exponent & Dbl_islessthan(resultp1,resultp2,srcp1,srcp2)) { - Dbl_increment(resultp1,resultp2); - } - guardbit = Dbl_lowmantissap2(resultp2); - Dbl_rightshiftby1(resultp1,resultp2); - - /* now round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - Dbl_increment(resultp1,resultp2); - break; - case ROUNDNEAREST: - /* stickybit is always true, so guardbit - * is enough to determine rounding */ - if (guardbit) { - Dbl_increment(resultp1,resultp2); - } - break; - } - /* increment result exponent by 1 if mantissa overflowed */ - if (Dbl_isone_hiddenoverflow(resultp1)) src_exponent+=2; - - if (Is_inexacttrap_enabled()) { - Dbl_set_exponent(resultp1, - ((src_exponent-DBL_BIAS)>>1)+DBL_BIAS); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(INEXACTEXCEPTION); - } - else Set_inexactflag(); - } - else { - Dbl_rightshiftby1(resultp1,resultp2); - } - Dbl_set_exponent(resultp1,((src_exponent-DBL_BIAS)>>1)+DBL_BIAS); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/dfsub.c b/sys/arch/hppa/spmath/dfsub.c deleted file mode 100644 index 41120526f..000000000 --- a/sys/arch/hppa/spmath/dfsub.c +++ /dev/null @@ -1,500 +0,0 @@ -/* $OpenBSD: dfsub.c,v 1.7 2002/11/29 09:27:34 deraadt Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)dfsub.c: Revision: 2.8.88.1 Date: 93/12/07 15:05:48 */ - -#include "float.h" -#include "dbl_float.h" - -/* - * Double_subtract: subtract two double precision values. - */ -int -dbl_fsub(leftptr, rightptr, dstptr, status) - dbl_floating_point *leftptr, *rightptr, *dstptr; - unsigned int *status; -{ - register unsigned int signless_upper_left, signless_upper_right, save; - register unsigned int leftp1, leftp2, rightp1, rightp2, extent; - register unsigned int resultp1 = 0, resultp2 = 0; - - register int result_exponent, right_exponent, diff_exponent; - register int sign_save, jumpsize; - register int inexact = FALSE, underflowtrap; - - /* Create local copies of the numbers */ - Dbl_copyfromptr(leftptr,leftp1,leftp2); - Dbl_copyfromptr(rightptr,rightp1,rightp2); - - /* A zero "save" helps discover equal operands (for later), * - * and is used in swapping operands (if needed). */ - Dbl_xortointp1(leftp1,rightp1,/*to*/save); - - /* - * check first operand for NaN's or infinity - */ - if ((result_exponent = Dbl_exponent(leftp1)) == DBL_INFINITY_EXPONENT) - { - if (Dbl_iszero_mantissa(leftp1,leftp2)) - { - if (Dbl_isnotnan(rightp1,rightp2)) - { - if (Dbl_isinfinity(rightp1,rightp2) && save==0) - { - /* - * invalid since operands are same signed infinity's - */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - Set_invalidflag(); - Dbl_makequietnan(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* - * return infinity - */ - Dbl_copytoptr(leftp1,leftp2,dstptr); - return(NOEXCEPTION); - } - } - else - { - /* - * is NaN; signaling or quiet? - */ - if (Dbl_isone_signaling(leftp1)) - { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(leftp1); - } - /* - * is second operand a signaling NaN? - */ - else if (Dbl_is_signalingnan(rightp1)) - { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(rightp1); - Dbl_copytoptr(rightp1,rightp2,dstptr); - return(NOEXCEPTION); - } - /* - * return quiet NaN - */ - Dbl_copytoptr(leftp1,leftp2,dstptr); - return(NOEXCEPTION); - } - } /* End left NaN or Infinity processing */ - /* - * check second operand for NaN's or infinity - */ - if (Dbl_isinfinity_exponent(rightp1)) - { - if (Dbl_iszero_mantissa(rightp1,rightp2)) - { - /* return infinity */ - Dbl_invert_sign(rightp1); - Dbl_copytoptr(rightp1,rightp2,dstptr); - return(NOEXCEPTION); - } - /* - * is NaN; signaling or quiet? - */ - if (Dbl_isone_signaling(rightp1)) - { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(rightp1); - } - /* - * return quiet NaN - */ - Dbl_copytoptr(rightp1,rightp2,dstptr); - return(NOEXCEPTION); - } /* End right NaN or Infinity processing */ - - /* Invariant: Must be dealing with finite numbers */ - - /* Compare operands by removing the sign */ - Dbl_copytoint_exponentmantissap1(leftp1,signless_upper_left); - Dbl_copytoint_exponentmantissap1(rightp1,signless_upper_right); - - /* sign difference selects add or sub operation. */ - if(Dbl_ismagnitudeless(leftp2,rightp2,signless_upper_left,signless_upper_right)) - { - /* Set the left operand to the larger one by XOR swap * - * First finish the first word using "save" */ - Dbl_xorfromintp1(save,rightp1,/*to*/rightp1); - Dbl_xorfromintp1(save,leftp1,/*to*/leftp1); - Dbl_swap_lower(leftp2,rightp2); - result_exponent = Dbl_exponent(leftp1); - Dbl_invert_sign(leftp1); - } - /* Invariant: left is not smaller than right. */ - - if((right_exponent = Dbl_exponent(rightp1)) == 0) - { - /* Denormalized operands. First look for zeroes */ - if(Dbl_iszero_mantissa(rightp1,rightp2)) - { - /* right is zero */ - if(Dbl_iszero_exponentmantissa(leftp1,leftp2)) - { - /* Both operands are zeros */ - Dbl_invert_sign(rightp1); - if(Is_rounding_mode(ROUNDMINUS)) - { - Dbl_or_signs(leftp1,/*with*/rightp1); - } - else - { - Dbl_and_signs(leftp1,/*with*/rightp1); - } - } - else - { - /* Left is not a zero and must be the result. Trapped - * underflows are signaled if left is denormalized. Result - * is always exact. */ - if( (result_exponent == 0) && Is_underflowtrap_enabled() ) - { - /* need to normalize results mantissa */ - sign_save = Dbl_signextendedsign(leftp1); - Dbl_leftshiftby1(leftp1,leftp2); - Dbl_normalize(leftp1,leftp2,result_exponent); - Dbl_set_sign(leftp1,/*using*/sign_save); - Dbl_setwrapped_exponent(leftp1,result_exponent,unfl); - Dbl_copytoptr(leftp1,leftp2,dstptr); - /* inexact = FALSE */ - return(UNDERFLOWEXCEPTION); - } - } - Dbl_copytoptr(leftp1,leftp2,dstptr); - return(NOEXCEPTION); - } - - /* Neither are zeroes */ - Dbl_clear_sign(rightp1); /* Exponent is already cleared */ - if(result_exponent == 0 ) - { - /* Both operands are denormalized. The result must be exact - * and is simply calculated. A sum could become normalized and a - * difference could cancel to a true zero. */ - if( (/*signed*/int) save >= 0 ) - { - Dbl_subtract(leftp1,leftp2,/*minus*/rightp1,rightp2, - /*into*/resultp1,resultp2); - if(Dbl_iszero_mantissa(resultp1,resultp2)) - { - if(Is_rounding_mode(ROUNDMINUS)) - { - Dbl_setone_sign(resultp1); - } - else - { - Dbl_setzero_sign(resultp1); - } - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - } - else - { - Dbl_addition(leftp1,leftp2,rightp1,rightp2, - /*into*/resultp1,resultp2); - if(Dbl_isone_hidden(resultp1)) - { - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - } - if(Is_underflowtrap_enabled()) - { - /* need to normalize result */ - sign_save = Dbl_signextendedsign(resultp1); - Dbl_leftshiftby1(resultp1,resultp2); - Dbl_normalize(resultp1,resultp2,result_exponent); - Dbl_set_sign(resultp1,/*using*/sign_save); - Dbl_setwrapped_exponent(resultp1,result_exponent,unfl); - Dbl_copytoptr(resultp1,resultp2,dstptr); - /* inexact = FALSE */ - return(UNDERFLOWEXCEPTION); - } - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - right_exponent = 1; /* Set exponent to reflect different bias - * with denomalized numbers. */ - } - else - { - Dbl_clear_signexponent_set_hidden(rightp1); - } - Dbl_clear_exponent_set_hidden(leftp1); - diff_exponent = result_exponent - right_exponent; - - /* - * Special case alignment of operands that would force alignment - * beyond the extent of the extension. A further optimization - * could special case this but only reduces the path length for this - * infrequent case. - */ - if(diff_exponent > DBL_THRESHOLD) - { - diff_exponent = DBL_THRESHOLD; - } - - /* Align right operand by shifting to right */ - Dbl_right_align(/*operand*/rightp1,rightp2,/*shifted by*/diff_exponent, - /*and lower to*/extent); - - /* Treat sum and difference of the operands separately. */ - if( (/*signed*/int) save >= 0 ) - { - /* - * Difference of the two operands. Their can be no overflow. A - * borrow can occur out of the hidden bit and force a post - * normalization phase. - */ - Dbl_subtract_withextension(leftp1,leftp2,/*minus*/rightp1,rightp2, - /*with*/extent,/*into*/resultp1,resultp2); - if(Dbl_iszero_hidden(resultp1)) - { - /* Handle normalization */ - /* A straight forward algorithm would now shift the result - * and extension left until the hidden bit becomes one. Not - * all of the extension bits need participate in the shift. - * Only the two most significant bits (round and guard) are - * needed. If only a single shift is needed then the guard - * bit becomes a significant low order bit and the extension - * must participate in the rounding. If more than a single - * shift is needed, then all bits to the right of the guard - * bit are zeros, and the guard bit may or may not be zero. */ - sign_save = Dbl_signextendedsign(resultp1); - Dbl_leftshiftby1_withextent(resultp1,resultp2,extent,resultp1,resultp2); - - /* Need to check for a zero result. The sign and exponent - * fields have already been zeroed. The more efficient test - * of the full object can be used. - */ - if(Dbl_iszero(resultp1,resultp2)) - /* Must have been "x-x" or "x+(-x)". */ - { - if(Is_rounding_mode(ROUNDMINUS)) Dbl_setone_sign(resultp1); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - result_exponent--; - /* Look to see if normalization is finished. */ - if(Dbl_isone_hidden(resultp1)) { - if(result_exponent==0) { - /* Denormalized, exponent should be zero. Left operand * - * was normalized, so extent (guard, round) was zero */ - goto underflow; - } else { - /* No further normalization is needed. */ - Dbl_set_sign(resultp1,/*using*/sign_save); - Ext_leftshiftby1(extent); - goto round; - } - } - - /* Check for denormalized, exponent should be zero. Left * - * operand was normalized, so extent (guard, round) was zero */ - if(!(underflowtrap = Is_underflowtrap_enabled()) && - result_exponent==0) goto underflow; - - /* Shift extension to complete one bit of normalization and - * update exponent. */ - Ext_leftshiftby1(extent); - - /* Discover first one bit to determine shift amount. Use a - * modified binary search. We have already shifted the result - * one position right and still not found a one so the remainder - * of the extension must be zero and simplifies rounding. */ - /* Scan bytes */ - while(Dbl_iszero_hiddenhigh7mantissa(resultp1)) - { - Dbl_leftshiftby8(resultp1,resultp2); - if((result_exponent -= 8) <= 0 && !underflowtrap) - goto underflow; - } - /* Now narrow it down to the nibble */ - if(Dbl_iszero_hiddenhigh3mantissa(resultp1)) - { - /* The lower nibble contains the normalizing one */ - Dbl_leftshiftby4(resultp1,resultp2); - if((result_exponent -= 4) <= 0 && !underflowtrap) - goto underflow; - } - /* Select case were first bit is set (already normalized) - * otherwise select the proper shift. */ - if((jumpsize = Dbl_hiddenhigh3mantissa(resultp1)) > 7) - { - /* Already normalized */ - if(result_exponent <= 0) goto underflow; - Dbl_set_sign(resultp1,/*using*/sign_save); - Dbl_set_exponent(resultp1,/*using*/result_exponent); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - Dbl_sethigh4bits(resultp1,/*using*/sign_save); - switch(jumpsize) - { - case 1: - { - Dbl_leftshiftby3(resultp1,resultp2); - result_exponent -= 3; - break; - } - case 2: - case 3: - { - Dbl_leftshiftby2(resultp1,resultp2); - result_exponent -= 2; - break; - } - case 4: - case 5: - case 6: - case 7: - { - Dbl_leftshiftby1(resultp1,resultp2); - result_exponent -= 1; - break; - } - } - if(result_exponent > 0) - { - Dbl_set_exponent(resultp1,/*using*/result_exponent); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); /* Sign bit is already set */ - } - /* Fixup potential underflows */ - underflow: - if(Is_underflowtrap_enabled()) - { - Dbl_set_sign(resultp1,sign_save); - Dbl_setwrapped_exponent(resultp1,result_exponent,unfl); - Dbl_copytoptr(resultp1,resultp2,dstptr); - /* inexact = FALSE */ - return(UNDERFLOWEXCEPTION); - } - /* - * Since we cannot get an inexact denormalized result, - * we can now return. - */ - Dbl_fix_overshift(resultp1,resultp2,(1-result_exponent),extent); - Dbl_clear_signexponent(resultp1); - Dbl_set_sign(resultp1,sign_save); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } /* end if(hidden...)... */ - /* Fall through and round */ - } /* end if(save >= 0)... */ - else - { - /* Subtract magnitudes */ - Dbl_addition(leftp1,leftp2,rightp1,rightp2,/*to*/resultp1,resultp2); - if(Dbl_isone_hiddenoverflow(resultp1)) - { - /* Prenormalization required. */ - Dbl_rightshiftby1_withextent(resultp2,extent,extent); - Dbl_arithrightshiftby1(resultp1,resultp2); - result_exponent++; - } /* end if hiddenoverflow... */ - } /* end else ...subtract magnitudes... */ - - /* Round the result. If the extension is all zeros,then the result is - * exact. Otherwise round in the correct direction. No underflow is - * possible. If a postnormalization is necessary, then the mantissa is - * all zeros so no shift is needed. */ - round: - if(Ext_isnotzero(extent)) - { - inexact = TRUE; - switch(Rounding_mode()) - { - case ROUNDNEAREST: /* The default. */ - if(Ext_isone_sign(extent)) - { - /* at least 1/2 ulp */ - if(Ext_isnotzero_lower(extent) || - Dbl_isone_lowmantissap2(resultp2)) - { - /* either exactly half way and odd or more than 1/2ulp */ - Dbl_increment(resultp1,resultp2); - } - } - break; - - case ROUNDPLUS: - if(Dbl_iszero_sign(resultp1)) - { - /* Round up positive results */ - Dbl_increment(resultp1,resultp2); - } - break; - - case ROUNDMINUS: - if(Dbl_isone_sign(resultp1)) - { - /* Round down negative results */ - Dbl_increment(resultp1,resultp2); - } - - case ROUNDZERO:; - /* truncate is simple */ - } /* end switch... */ - if(Dbl_isone_hiddenoverflow(resultp1)) result_exponent++; - } - if(result_exponent == DBL_INFINITY_EXPONENT) - { - /* Overflow */ - if(Is_overflowtrap_enabled()) - { - Dbl_setwrapped_exponent(resultp1,result_exponent,ovfl); - Dbl_copytoptr(resultp1,resultp2,dstptr); - if (inexact) { - if (Is_inexacttrap_enabled()) - return(OVERFLOWEXCEPTION | INEXACTEXCEPTION); - else - Set_inexactflag(); - } - return(OVERFLOWEXCEPTION); - } - else - { - inexact = TRUE; - Set_overflowflag(); - Dbl_setoverflow(resultp1,resultp2); - } - } - else Dbl_set_exponent(resultp1,result_exponent); - Dbl_copytoptr(resultp1,resultp2,dstptr); - if(inexact) { - if(Is_inexacttrap_enabled()) - return(INEXACTEXCEPTION); - else - Set_inexactflag(); - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/divsfm.c b/sys/arch/hppa/spmath/divsfm.c deleted file mode 100644 index 96a0c10e3..000000000 --- a/sys/arch/hppa/spmath/divsfm.c +++ /dev/null @@ -1,81 +0,0 @@ -/* $OpenBSD: divsfm.c,v 1.5 2002/05/07 22:19:30 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)divsfm.c: Revision: 1.6.88.1 Date: 93/12/07 15:05:51 */ - -#include "md.h" - -void -divsfm(opnd1,opnd2,result) - int opnd1, opnd2; - struct mdsfu_register *result; -{ - register int sign, op1_sign; - - /* check divisor for zero */ - if (opnd2 == 0) { - overflow = TRUE; - return; - } - - /* get sign of result */ - sign = opnd1 ^ opnd2; - - /* get absolute value of operands */ - if (opnd1 < 0) { - opnd1 = -opnd1; - op1_sign = TRUE; - } - else op1_sign = FALSE; - if (opnd2 < 0) opnd2 = -opnd2; - - /* - * check for overflow - * - * if abs(opnd1) < 0, then opnd1 = -2**31 - * and abs(opnd1) >= abs(opnd2) always - */ - if (opnd1 >= opnd2 || opnd1 < 0) { - /* check for opnd2 = -2**31 */ - if (opnd2 < 0 && opnd1 != opnd2) { - result_hi = 0; /* remainder = 0 */ - result_lo = opnd1 << 1; - } - else { - overflow = TRUE; - return; - } - } - else { - /* do the divide */ - divu(opnd1,0,opnd2,result); - - /* return positive residue */ - if (op1_sign && result_hi) { - result_hi = opnd2 - result_hi; - result_lo++; - } - } - - /* check for overflow */ - if (result_lo < 0) { - overflow = TRUE; - return; - } - overflow = FALSE; - - /* return appropriately signed result */ - if (sign<0) result_lo = -result_lo; - return; -} diff --git a/sys/arch/hppa/spmath/divsfr.c b/sys/arch/hppa/spmath/divsfr.c deleted file mode 100644 index 155060e7c..000000000 --- a/sys/arch/hppa/spmath/divsfr.c +++ /dev/null @@ -1,76 +0,0 @@ -/* $OpenBSD: divsfr.c,v 1.5 2002/05/07 22:19:30 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)divsfr.c: Revision: 1.6.88.1 Date: 93/12/07 15:05:53 */ - -#include "md.h" - -void -divsfr(opnd1,opnd2,result) - int opnd1, opnd2; - struct mdsfu_register *result; -{ - int sign, op1_sign; - - /* check divisor for zero */ - if (opnd2 == 0) { - overflow = TRUE; - return; - } - - /* get sign of result */ - sign = opnd1 ^ opnd2; - - /* get absolute value of operands */ - if (opnd1 < 0) { - opnd1 = -opnd1; - op1_sign = TRUE; - } - else op1_sign = FALSE; - if (opnd2 < 0) opnd2 = -opnd2; - - /* - * check for overflow - * - * if abs(opnd1) < 0, then opnd1 = -2**31 - * and abs(opnd1) >= abs(opnd2) always - */ - if (opnd1 >= opnd2 || opnd1 < 0) { - /* check for opnd2 = -2**31 */ - if (opnd2 < 0 && opnd1 != opnd2) { - result_hi = 0; /* remainder = 0 */ - result_lo = opnd1 << 1; - } - else { - overflow = TRUE; - return; - } - } - else { - /* do the divide */ - divu(opnd1,0,opnd2,result); - } - - /* check for overflow */ - if (result_lo < 0) { - overflow = TRUE; - return; - } - overflow = FALSE; - - /* return appropriately signed remainder and result */ - if (op1_sign) result_hi = -result_hi; - if (sign<0) result_lo = -result_lo; - return; -} diff --git a/sys/arch/hppa/spmath/divsim.c b/sys/arch/hppa/spmath/divsim.c deleted file mode 100644 index 6c8d0b3a9..000000000 --- a/sys/arch/hppa/spmath/divsim.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $OpenBSD: divsim.c,v 1.5 2002/05/07 22:19:30 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)divsim.c: Revision: 1.6.88.1 Date: 93/12/07 15:05:56 */ - -#include "md.h" - -void -divsim(opnd1,opnd2,result) - int opnd1, opnd2; - struct mdsfu_register *result; -{ - int sign, op1_sign; - - /* check divisor for zero */ - if (opnd2 == 0) { - overflow = TRUE; - return; - } - - /* get sign of result */ - sign = opnd1 ^ opnd2; - - /* get absolute value of operands */ - if (opnd1 < 0) { - opnd1 = -opnd1; - op1_sign = TRUE; - } - else op1_sign = FALSE; - if (opnd2 < 0) opnd2 = -opnd2; - - /* check for opnd2 == -2**31 */ - if (opnd2 < 0) { - if (opnd1 == opnd2) { - result_hi = 0; /* remainder = 0 */ - result_lo = 1; - } - else { - result_hi = opnd1; /* remainder = opnd1 */ - result_lo = 0; - } - } - else { - /* do the divide */ - divu(0,opnd1,opnd2,result); - - /* - * check for overflow - * - * at this point, the only way we can get overflow - * is with opnd1 = -2**31 and opnd2 = -1 - */ - if (sign>0 && result_lo<0) { - overflow = TRUE; - return; - } - } - overflow = FALSE; - - /* return positive residue */ - if (op1_sign && result_hi) { - result_hi = opnd2 - result_hi; - if (++result_lo < 0) { - overflow = TRUE; - return; - } - } - - /* return appropriately signed result */ - if (sign<0) result_lo = -result_lo; - return; -} diff --git a/sys/arch/hppa/spmath/divsir.c b/sys/arch/hppa/spmath/divsir.c deleted file mode 100644 index b0babcc86..000000000 --- a/sys/arch/hppa/spmath/divsir.c +++ /dev/null @@ -1,75 +0,0 @@ -/* $OpenBSD: divsir.c,v 1.6 2002/05/07 22:19:30 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)divsir.c: Revision: 1.6.88.1 Date: 93/12/07 15:05:58 */ - -#include "md.h" - -void -divsir(opnd1,opnd2,result) - int opnd1, opnd2; - struct mdsfu_register *result; -{ - int sign, op1_sign; - - /* check divisor for zero */ - if (opnd2 == 0) { - overflow = TRUE; - return; - } - - /* get sign of result */ - sign = opnd1 ^ opnd2; - - /* get absolute value of operands */ - if (opnd1 < 0) { - opnd1 = -opnd1; - op1_sign = TRUE; - } - else op1_sign = FALSE; - if (opnd2 < 0) opnd2 = -opnd2; - - /* check for opnd2 = -2**31 */ - if (opnd2 + opnd2 == 0) { - if (opnd1 == opnd2) { - result_hi = 0; /* remainder = 0 */ - result_lo = 1; - } - else { - result_hi = opnd1; /* remainder = opnd1 */ - result_lo = 0; - } - } - else { - /* do the divide */ - divu(0,opnd1,opnd2,result); - - /* - * check for overflow - * - * at this point, the only way we can get overflow - * is with opnd1 = -2**31 and opnd2 = -1 - */ - if (sign>0 && result_lo<0) { - overflow = TRUE; - return; - } - } - overflow = FALSE; - - /* return appropriately signed remainder and result */ - if (op1_sign) result_hi = -result_hi; - if (sign<0) result_lo = -result_lo; - return; -} diff --git a/sys/arch/hppa/spmath/divu.S b/sys/arch/hppa/spmath/divu.S deleted file mode 100644 index 5e3ef6c4f..000000000 --- a/sys/arch/hppa/spmath/divu.S +++ /dev/null @@ -1,150 +0,0 @@ -/* $OpenBSD: divu.S,v 1.11 2011/04/16 20:52:12 deraadt Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)divu.s: Revision: 1.11.88.1 Date: 93/12/07 15:06:01 */ - -#include -#include - -;************************************************************************ -; Implement an integer divide routine for 32-bit operands and 32-bit quotient -; and remainder with operand values of zero (divisor only) treated specially. -; -;**************************************************************************** -; Definitions -;**************************************************************************** -; -; General registers -; -gr0 .reg %r0 ; General register zero -rem .reg %r3 ; remainder and upper part of dividend -quo .reg %r4 ; quotient and lower part of dividend -dvr .reg %r5 ; divisor -tp .reg %r6 ; temp. reg. - -;****************************************************************************** - .text -LEAF_ENTRY(divu) - stws,ma rem,4(sp) ; save registers on stack - stws,ma quo,4(sp) ; save registers on stack - stws,ma dvr,4(sp) ; save registers on stack - stws,ma tp,4(sp) ; save registers on stack - - addi 0,arg2,dvr ; get divisor - addi 0,arg1,quo ; get lower dividend - addi 0,arg0,rem ; get upper dividend - - comib,>,n 0,dvr,hibit ; check for dvr >= 2**31 - addi -1,gr0,tp ; set V-bit to 1 - ds 0,tp,0 - add quo,quo,quo ; shift msb bit into carry - ds rem,dvr,rem ; 1st divide step, if carry - ; out, msb of quotient = 0 - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 2nd divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 3rd divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 4th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 5th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 6th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 7th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 8th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 9th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 10th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 11th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 12th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 13th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 14th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 15th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 16th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 17th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 18th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 19th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 20th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 21st divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 22nd divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 23rd divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 24th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 25th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 26th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 27th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 28th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 29th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 30th divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 31st divide step - addc quo,quo,quo ; shift quo with/into carry - ds rem,dvr,rem ; 32nd divide step, - addc quo,quo,quo ; shift last quo bit into quo - addb,>=,n rem,0,finish ; branch if pos. rem - add,< dvr,0,0 ; if dvr > 0, add dvr - add,tr rem,dvr,rem ; for correcting rem. - sub rem,dvr,rem ; else subtract dvr -; -; end of divide routine -; -finish stws rem,0(arg3) ; save remainder in high part - ; of result - stws quo,4(arg3) ; save quotient in low part - ; of result - ldws,mb -4(sp),tp ; restore registers - ldws,mb -4(sp),dvr ; restore registers - ldws,mb -4(sp),quo ; restore registers - bv 0(rp) ; return - ldws,mb -4(sp),rem ; restore registers -; -hibit ldo 32(0),tp ; initialize loop counter - add quo,quo,quo ; shift high bit into carry -loop addc rem,rem,rem ; shift in high bit of dvdl - addc,<> 0,0,0 ; if bit shifted out of dvdu, - ; want to do subtract - comb,<<,n rem,dvr,nosub ; if upper dividend > dvr, - sub rem,dvr,rem ; subtract and - add,tr dvr,dvr,0 ; set carry -nosub addi 0,0,0 ; otherwise clear carry - addib,> -1,tp,loop ; inc. counter; finished? - addc quo,quo,quo ; shift bit of result into dvdl - b finish+4 ; finish up - stws rem,0(arg3) ; save remainder in high part - ; of result -EXIT(divu) - - .end diff --git a/sys/arch/hppa/spmath/divufr.c b/sys/arch/hppa/spmath/divufr.c deleted file mode 100644 index aaa98d60d..000000000 --- a/sys/arch/hppa/spmath/divufr.c +++ /dev/null @@ -1,39 +0,0 @@ -/* $OpenBSD: divufr.c,v 1.6 2002/05/07 22:19:30 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)divufr.c: Revision: 1.6.88.1 Date: 93/12/07 15:06:03 */ - -#include "md.h" - -void -divufr(opnd1,opnd2,result) - unsigned int opnd1, opnd2; - struct mdsfu_register *result; -{ - /* check divisor for zero */ - if (opnd2 == 0) { - overflow = TRUE; - return; - } - - /* check for overflow */ - if (opnd1 >= opnd2) { - overflow = TRUE; - return; - } - overflow = FALSE; - - /* do the divide */ - divu(opnd1,0,opnd2,result); -} diff --git a/sys/arch/hppa/spmath/divuir.c b/sys/arch/hppa/spmath/divuir.c deleted file mode 100644 index 1b46c9b70..000000000 --- a/sys/arch/hppa/spmath/divuir.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $OpenBSD: divuir.c,v 1.6 2002/05/07 22:19:30 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)divuir.c: Revision: 1.6.88.1 Date: 93/12/07 15:06:06 */ - -#include "md.h" - -void -divuir(opnd1,opnd2,result) - unsigned int opnd1, opnd2; - struct mdsfu_register *result; -{ - /* get source operands, check divisor for zero */ - if (opnd2 == 0) { - overflow = TRUE; - return; - } - overflow = FALSE; - - /* do the divide */ - divu(0,opnd1,opnd2,result); -} diff --git a/sys/arch/hppa/spmath/fcnvff.c b/sys/arch/hppa/spmath/fcnvff.c deleted file mode 100644 index c6473f43f..000000000 --- a/sys/arch/hppa/spmath/fcnvff.c +++ /dev/null @@ -1,285 +0,0 @@ -/* $OpenBSD: fcnvff.c,v 1.8 2023/03/08 04:43:07 guenther Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)fcnvff.c: Revision: 2.8.88.1 Date: 93/12/07 15:06:09 */ - -#include "float.h" -#include "sgl_float.h" -#include "dbl_float.h" -#include "cnv_float.h" - -/* - * Single Floating-point to Double Floating-point - */ -int -sgl_to_dbl_fcnvff(srcptr, null, dstptr, status) - sgl_floating_point *srcptr, *null; - dbl_floating_point *dstptr; - unsigned int *status; -{ - register unsigned int src, resultp1, resultp2; - register int src_exponent; - - src = *srcptr; - src_exponent = Sgl_exponent(src); - Dbl_allp1(resultp1) = Sgl_all(src); /* set sign of result */ - /* - * Test for NaN or infinity - */ - if (src_exponent == SGL_INFINITY_EXPONENT) { - /* - * determine if NaN or infinity - */ - if (Sgl_iszero_mantissa(src)) { - /* - * is infinity; want to return double infinity - */ - Dbl_setinfinity_exponentmantissa(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - else { - /* - * is NaN; signaling or quiet? - */ - if (Sgl_isone_signaling(src)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - else { - Set_invalidflag(); - Sgl_set_quiet(src); - } - } - /* - * NaN is quiet, return as double NaN - */ - Dbl_setinfinity_exponent(resultp1); - Sgl_to_dbl_mantissa(src,resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - } - /* - * Test for zero or denormalized - */ - if (src_exponent == 0) { - /* - * determine if zero or denormalized - */ - if (Sgl_isnotzero_mantissa(src)) { - /* - * is denormalized; want to normalize - */ - Sgl_clear_signexponent(src); - Sgl_leftshiftby1(src); - Sgl_normalize(src,src_exponent); - Sgl_to_dbl_exponent(src_exponent,resultp1); - Sgl_to_dbl_mantissa(src,resultp1,resultp2); - } - else { - Dbl_setzero_exponentmantissa(resultp1,resultp2); - } - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* - * No special cases, just complete the conversion - */ - Sgl_to_dbl_exponent(src_exponent, resultp1); - Sgl_to_dbl_mantissa(Sgl_mantissa(src), resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); -} - -/* - * Double Floating-point to Single Floating-point - */ -int -dbl_to_sgl_fcnvff(srcptr, null, dstptr, status) - dbl_floating_point *srcptr, *null; - sgl_floating_point *dstptr; - unsigned int *status; -{ - register unsigned int srcp1, srcp2, result; - register int src_exponent, dest_exponent, dest_mantissa; - register int inexact = FALSE, guardbit = FALSE, stickybit = FALSE; - register int lsb_odd = FALSE; - int is_tiny; - - Dbl_copyfromptr(srcptr,srcp1,srcp2); - src_exponent = Dbl_exponent(srcp1); - Sgl_all(result) = Dbl_allp1(srcp1); /* set sign of result */ - /* - * Test for NaN or infinity - */ - if (src_exponent == DBL_INFINITY_EXPONENT) { - /* - * determine if NaN or infinity - */ - if (Dbl_iszero_mantissa(srcp1,srcp2)) { - /* - * is infinity; want to return single infinity - */ - Sgl_setinfinity_exponentmantissa(result); - *dstptr = result; - return(NOEXCEPTION); - } - /* - * is NaN; signaling or quiet? - */ - if (Dbl_isone_signaling(srcp1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - else { - Set_invalidflag(); - /* make NaN quiet */ - Dbl_set_quiet(srcp1); - } - } - /* - * NaN is quiet, return as single NaN - */ - Sgl_setinfinity_exponent(result); - Sgl_set_mantissa(result,Dallp1(srcp1)<<3 | Dallp2(srcp2)>>29); - if (Sgl_iszero_mantissa(result)) Sgl_set_quiet(result); - *dstptr = result; - return(NOEXCEPTION); - } - /* - * Generate result - */ - Dbl_to_sgl_exponent(src_exponent,dest_exponent); - if (dest_exponent > 0) { - Dbl_to_sgl_mantissa(srcp1,srcp2,dest_mantissa,inexact,guardbit, - stickybit,lsb_odd); - } - else { - if (Dbl_iszero_exponentmantissa(srcp1,srcp2)){ - Sgl_setzero_exponentmantissa(result); - *dstptr = result; - return(NOEXCEPTION); - } - if (Is_underflowtrap_enabled()) { - Dbl_to_sgl_mantissa(srcp1,srcp2,dest_mantissa,inexact, - guardbit,stickybit,lsb_odd); - } - else { - /* compute result, determine inexact info, - * and set Underflowflag if appropriate - */ - Dbl_to_sgl_denormalized(srcp1,srcp2,dest_exponent, - dest_mantissa,inexact,guardbit,stickybit,lsb_odd, - is_tiny); - } - } - /* - * Now round result if not exact - */ - if (inexact) { - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(result)) dest_mantissa++; - break; - case ROUNDMINUS: - if (Sgl_isone_sign(result)) dest_mantissa++; - break; - case ROUNDNEAREST: - if (guardbit) { - if (stickybit || lsb_odd) dest_mantissa++; - } - } - } - Sgl_set_exponentmantissa(result,dest_mantissa); - - /* - * check for mantissa overflow after rounding - */ - if ((dest_exponent>0 || Is_underflowtrap_enabled()) && - Sgl_isone_hidden(result)) dest_exponent++; - - /* - * Test for overflow - */ - if (dest_exponent >= SGL_INFINITY_EXPONENT) { - /* trap if OVERFLOWTRAP enabled */ - if (Is_overflowtrap_enabled()) { - /* - * Check for gross overflow - */ - if (dest_exponent >= SGL_INFINITY_EXPONENT+SGL_WRAP) - return(UNIMPLEMENTEDEXCEPTION); - - /* - * Adjust bias of result - */ - Sgl_setwrapped_exponent(result,dest_exponent,ovfl); - *dstptr = result; - if (inexact) { - if (Is_inexacttrap_enabled()) - return(OVERFLOWEXCEPTION|INEXACTEXCEPTION); - else - Set_inexactflag(); - } - return(OVERFLOWEXCEPTION); - } - Set_overflowflag(); - inexact = TRUE; - /* set result to infinity or largest number */ - Sgl_setoverflow(result); - } - /* - * Test for underflow - */ - else if (dest_exponent <= 0) { - /* trap if UNDERFLOWTRAP enabled */ - if (Is_underflowtrap_enabled()) { - /* - * Check for gross underflow - */ - if (dest_exponent <= -(SGL_WRAP)) - return(UNIMPLEMENTEDEXCEPTION); - /* - * Adjust bias of result - */ - Sgl_setwrapped_exponent(result,dest_exponent,unfl); - *dstptr = result; - if (inexact) { - if (Is_inexacttrap_enabled()) - return(UNDERFLOWEXCEPTION|INEXACTEXCEPTION); - else - Set_inexactflag(); - } - return(UNDERFLOWEXCEPTION); - } - /* - * result is denormalized or signed zero - */ - if (inexact && is_tiny) Set_underflowflag(); - - } - else Sgl_set_exponent(result,dest_exponent); - *dstptr = result; - /* - * Trap if inexact trap is enabled - */ - if (inexact) { - if (Is_inexacttrap_enabled()) - return(INEXACTEXCEPTION); - else - Set_inexactflag(); - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/fcnvfx.c b/sys/arch/hppa/spmath/fcnvfx.c deleted file mode 100644 index 6086e38ce..000000000 --- a/sys/arch/hppa/spmath/fcnvfx.c +++ /dev/null @@ -1,481 +0,0 @@ -/* $OpenBSD: fcnvfx.c,v 1.9 2023/03/08 04:43:07 guenther Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)fcnvfx.c: Revision: 2.8.88.2 Date: 93/12/08 13:27:29 */ - -#include "float.h" -#include "sgl_float.h" -#include "dbl_float.h" -#include "cnv_float.h" - -/* - * Single Floating-point to Single Fixed-point - */ -int -sgl_to_sgl_fcnvfx(srcptr, null, dstptr, status) - sgl_floating_point *srcptr, *null; - int *dstptr; - unsigned int *status; -{ - register unsigned int src, temp; - register int src_exponent, result; - register int inexact = FALSE; - - src = *srcptr; - src_exponent = Sgl_exponent(src) - SGL_BIAS; - - /* - * Test for overflow - */ - if (src_exponent > SGL_FX_MAX_EXP) { - /* check for MININT */ - if ((src_exponent > SGL_FX_MAX_EXP + 1) || - Sgl_isnotzero_mantissa(src) || Sgl_iszero_sign(src)) { - if (Sgl_iszero_sign(src)) result = 0x7fffffff; - else result = 0x80000000; - - if (Is_invalidtrap_enabled()) { - return(INVALIDEXCEPTION); - } - Set_invalidflag(); - *dstptr = result; - return(NOEXCEPTION); - } - } - /* - * Generate result - */ - if (src_exponent >= 0) { - temp = src; - Sgl_clear_signexponent_set_hidden(temp); - Int_from_sgl_mantissa(temp,src_exponent); - if (Sgl_isone_sign(src)) result = -Sgl_all(temp); - else result = Sgl_all(temp); - - /* check for inexact */ - if (Sgl_isinexact_to_fix(src,src_exponent)) { - inexact = TRUE; - /* round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(src)) result++; - break; - case ROUNDMINUS: - if (Sgl_isone_sign(src)) result--; - break; - case ROUNDNEAREST: - if (Sgl_isone_roundbit(src,src_exponent)) { - if (Sgl_isone_stickybit(src,src_exponent) - || (Sgl_isone_lowmantissa(temp))) { - if (Sgl_iszero_sign(src)) result++; - else result--; - } - } - } - } - } - else { - result = 0; - - /* check for inexact */ - if (Sgl_isnotzero_exponentmantissa(src)) { - inexact = TRUE; - /* round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(src)) result++; - break; - case ROUNDMINUS: - if (Sgl_isone_sign(src)) result--; - break; - case ROUNDNEAREST: - if (src_exponent == -1) - if (Sgl_isnotzero_mantissa(src)) { - if (Sgl_iszero_sign(src)) result++; - else result--; - } - } - } - } - *dstptr = result; - if (inexact) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(NOEXCEPTION); -} - -/* - * Single Floating-point to Double Fixed-point - */ -int -sgl_to_dbl_fcnvfx(srcptr, null, dstptr, status) - sgl_floating_point *srcptr, *null; - dbl_integer *dstptr; - unsigned int *status; -{ - register int src_exponent, resultp1; - register unsigned int src, temp, resultp2; - register int inexact = FALSE; - - src = *srcptr; - src_exponent = Sgl_exponent(src) - SGL_BIAS; - - /* - * Test for overflow - */ - if (src_exponent > DBL_FX_MAX_EXP) { - /* check for MININT */ - if ((src_exponent > DBL_FX_MAX_EXP + 1) || - Sgl_isnotzero_mantissa(src) || Sgl_iszero_sign(src)) { - if (Sgl_iszero_sign(src)) { - resultp1 = 0x7fffffff; - resultp2 = 0xffffffff; - } - else { - resultp1 = 0x80000000; - resultp2 = 0; - } - - if (Is_invalidtrap_enabled()) { - return(INVALIDEXCEPTION); - } - Set_invalidflag(); - Dint_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - Dint_set_minint(resultp1,resultp2); - Dint_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* - * Generate result - */ - if (src_exponent >= 0) { - temp = src; - Sgl_clear_signexponent_set_hidden(temp); - Dint_from_sgl_mantissa(temp,src_exponent,resultp1,resultp2); - if (Sgl_isone_sign(src)) { - Dint_setone_sign(resultp1,resultp2); - } - - /* check for inexact */ - if (Sgl_isinexact_to_fix(src,src_exponent)) { - inexact = TRUE; - /* round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(src)) { - Dint_increment(resultp1,resultp2); - } - break; - case ROUNDMINUS: - if (Sgl_isone_sign(src)) { - Dint_decrement(resultp1,resultp2); - } - break; - case ROUNDNEAREST: - if (Sgl_isone_roundbit(src,src_exponent)) - if (Sgl_isone_stickybit(src,src_exponent) || - (Dint_isone_lowp2(resultp2))) { - if (Sgl_iszero_sign(src)) { - Dint_increment(resultp1,resultp2); - } - else { - Dint_decrement(resultp1,resultp2); - } - } - } - } - } - else { - Dint_setzero(resultp1,resultp2); - - /* check for inexact */ - if (Sgl_isnotzero_exponentmantissa(src)) { - inexact = TRUE; - /* round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(src)) { - Dint_increment(resultp1,resultp2); - } - break; - case ROUNDMINUS: - if (Sgl_isone_sign(src)) { - Dint_decrement(resultp1,resultp2); - } - break; - case ROUNDNEAREST: - if (src_exponent == -1) - if (Sgl_isnotzero_mantissa(src)) { - if (Sgl_iszero_sign(src)) { - Dint_increment(resultp1,resultp2); - } - else { - Dint_decrement(resultp1,resultp2); - } - } - } - } - } - Dint_copytoptr(resultp1,resultp2,dstptr); - if (inexact) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(NOEXCEPTION); -} - -/* - * Double Floating-point to Single Fixed-point - */ -int -dbl_to_sgl_fcnvfx(srcptr, null, dstptr, status) - dbl_floating_point *srcptr, *null; - int *dstptr; - unsigned int *status; -{ - register unsigned int srcp1,srcp2, tempp1,tempp2; - register int src_exponent, result; - register int inexact = FALSE; - - Dbl_copyfromptr(srcptr,srcp1,srcp2); - src_exponent = Dbl_exponent(srcp1) - DBL_BIAS; - - /* - * Test for overflow - */ - if (src_exponent > SGL_FX_MAX_EXP) { - /* check for MININT */ - if (Dbl_isoverflow_to_int(src_exponent,srcp1,srcp2)) { - if (Dbl_iszero_sign(srcp1)) result = 0x7fffffff; - else result = 0x80000000; - - if (Is_invalidtrap_enabled()) { - return(INVALIDEXCEPTION); - } - Set_invalidflag(); - *dstptr = result; - return(NOEXCEPTION); - } - } - /* - * Generate result - */ - if (src_exponent >= 0) { - tempp1 = srcp1; - tempp2 = srcp2; - Dbl_clear_signexponent_set_hidden(tempp1); - Int_from_dbl_mantissa(tempp1,tempp2,src_exponent); - if (Dbl_isone_sign(srcp1) && (src_exponent <= SGL_FX_MAX_EXP)) - result = -Dbl_allp1(tempp1); - else result = Dbl_allp1(tempp1); - - /* check for inexact */ - if (Dbl_isinexact_to_fix(srcp1,srcp2,src_exponent)) { - inexact = TRUE; - /* round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(srcp1)) - result++; - break; - case ROUNDMINUS: - if (Dbl_isone_sign(srcp1)) result--; - break; - case ROUNDNEAREST: - if (Dbl_isone_roundbit(srcp1,srcp2,src_exponent)) - if (Dbl_isone_stickybit(srcp1,srcp2,src_exponent) || - (Dbl_isone_lowmantissap1(tempp1))) { - if (Dbl_iszero_sign(srcp1)) result++; - else result--; - } - } - /* check for overflow */ - if ((Dbl_iszero_sign(srcp1) && result < 0) || - (Dbl_isone_sign(srcp1) && result > 0)) { - - if (Dbl_iszero_sign(srcp1)) - result = 0x7fffffff; - else - result = 0x80000000; - - if (Is_overflowtrap_enabled()) { - if (Is_inexacttrap_enabled()) - return(OVERFLOWEXCEPTION|INEXACTEXCEPTION); - else Set_inexactflag(); - return(OVERFLOWEXCEPTION); - } - Set_overflowflag(); - *dstptr = result; - if (Is_inexacttrap_enabled() ) - return(INEXACTEXCEPTION); - else Set_inexactflag(); - return(NOEXCEPTION); - } - } - } - else { - result = 0; - - /* check for inexact */ - if (Dbl_isnotzero_exponentmantissa(srcp1,srcp2)) { - inexact = TRUE; - /* round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(srcp1)) result++; - break; - case ROUNDMINUS: - if (Dbl_isone_sign(srcp1)) result--; - break; - case ROUNDNEAREST: - if (src_exponent == -1) - if (Dbl_isnotzero_mantissa(srcp1,srcp2)) { - if (Dbl_iszero_sign(srcp1)) result++; - else result--; - } - } - } - } - *dstptr = result; - if (inexact) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(NOEXCEPTION); -} - -/* - * Double Floating-point to Double Fixed-point - */ -int -dbl_to_dbl_fcnvfx(srcptr, null, dstptr, status) - dbl_floating_point *srcptr, *null; - dbl_integer *dstptr; - unsigned int *status; -{ - register int src_exponent, resultp1; - register unsigned int srcp1, srcp2, tempp1, tempp2, resultp2; - register int inexact = FALSE; - - Dbl_copyfromptr(srcptr,srcp1,srcp2); - src_exponent = Dbl_exponent(srcp1) - DBL_BIAS; - - /* - * Test for overflow - */ - if (src_exponent > DBL_FX_MAX_EXP) { - /* check for MININT */ - if ((src_exponent > DBL_FX_MAX_EXP + 1) || - Dbl_isnotzero_mantissa(srcp1,srcp2) || Dbl_iszero_sign(srcp1)) { - if (Dbl_iszero_sign(srcp1)) { - resultp1 = 0x7fffffff; - resultp2 = 0xffffffff; - } - else { - resultp1 = 0x80000000; - resultp2 = 0; - } - - if (Is_invalidtrap_enabled()) { - return(INVALIDEXCEPTION); - } - Set_invalidflag(); - Dint_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - } - - /* - * Generate result - */ - if (src_exponent >= 0) { - tempp1 = srcp1; - tempp2 = srcp2; - Dbl_clear_signexponent_set_hidden(tempp1); - Dint_from_dbl_mantissa(tempp1,tempp2,src_exponent, - resultp1, resultp2); - if (Dbl_isone_sign(srcp1)) { - Dint_setone_sign(resultp1,resultp2); - } - - /* check for inexact */ - if (Dbl_isinexact_to_fix(srcp1,srcp2,src_exponent)) { - inexact = TRUE; - /* round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(srcp1)) { - Dint_increment(resultp1,resultp2); - } - break; - case ROUNDMINUS: - if (Dbl_isone_sign(srcp1)) { - Dint_decrement(resultp1,resultp2); - } - break; - case ROUNDNEAREST: - if (Dbl_isone_roundbit(srcp1,srcp2,src_exponent)) - if (Dbl_isone_stickybit(srcp1,srcp2,src_exponent) || - (Dint_isone_lowp2(resultp2))) { - if (Dbl_iszero_sign(srcp1)) { - Dint_increment(resultp1,resultp2); - } - else { - Dint_decrement(resultp1,resultp2); - } - } - } - } - } - else { - Dint_setzero(resultp1,resultp2); - - /* check for inexact */ - if (Dbl_isnotzero_exponentmantissa(srcp1,srcp2)) { - inexact = TRUE; - /* round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(srcp1)) { - Dint_increment(resultp1,resultp2); - } - break; - case ROUNDMINUS: - if (Dbl_isone_sign(srcp1)) { - Dint_decrement(resultp1,resultp2); - } - break; - case ROUNDNEAREST: - if (src_exponent == -1) - if (Dbl_isnotzero_mantissa(srcp1,srcp2)) { - if (Dbl_iszero_sign(srcp1)) { - Dint_increment(resultp1,resultp2); - } - else { - Dint_decrement(resultp1,resultp2); - } - } - } - } - } - Dint_copytoptr(resultp1,resultp2,dstptr); - if (inexact) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/fcnvfxt.c b/sys/arch/hppa/spmath/fcnvfxt.c deleted file mode 100644 index dd7817831..000000000 --- a/sys/arch/hppa/spmath/fcnvfxt.c +++ /dev/null @@ -1,291 +0,0 @@ -/* $OpenBSD: fcnvfxt.c,v 1.9 2023/03/08 04:43:07 guenther Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)fcnvfxt.c: Revision: 2.8.88.2 Date: 93/12/08 13:27:34 */ - -#include "float.h" -#include "sgl_float.h" -#include "dbl_float.h" -#include "cnv_float.h" - -/* - * Convert single floating-point to single fixed-point format - * with truncated result - */ -int -sgl_to_sgl_fcnvfxt(srcptr, null, dstptr, status) - sgl_floating_point *srcptr, *null; - int *dstptr; - unsigned int *status; -{ - register unsigned int src, temp; - register int src_exponent, result; - - src = *srcptr; - src_exponent = Sgl_exponent(src) - SGL_BIAS; - - /* - * Test for overflow - */ - if (src_exponent > SGL_FX_MAX_EXP) { - /* check for MININT */ - if ((src_exponent > SGL_FX_MAX_EXP + 1) || - Sgl_isnotzero_mantissa(src) || Sgl_iszero_sign(src)) { - if (Sgl_iszero_sign(src)) result = 0x7fffffff; - else result = 0x80000000; - - if (Is_invalidtrap_enabled()) { - return(INVALIDEXCEPTION); - } - Set_invalidflag(); - *dstptr = result; - return(NOEXCEPTION); - } - } - /* - * Generate result - */ - if (src_exponent >= 0) { - temp = src; - Sgl_clear_signexponent_set_hidden(temp); - Int_from_sgl_mantissa(temp,src_exponent); - if (Sgl_isone_sign(src)) result = -Sgl_all(temp); - else result = Sgl_all(temp); - *dstptr = result; - - /* check for inexact */ - if (Sgl_isinexact_to_fix(src,src_exponent)) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - } - else { - *dstptr = 0; - - /* check for inexact */ - if (Sgl_isnotzero_exponentmantissa(src)) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - } - return(NOEXCEPTION); -} - -/* - * Single Floating-point to Double Fixed-point - */ -int -sgl_to_dbl_fcnvfxt(srcptr, null, dstptr, status) - sgl_floating_point *srcptr, *null; - dbl_integer *dstptr; - unsigned int *status; -{ - register int src_exponent, resultp1; - register unsigned int src, temp, resultp2; - - src = *srcptr; - src_exponent = Sgl_exponent(src) - SGL_BIAS; - - /* - * Test for overflow - */ - if (src_exponent > DBL_FX_MAX_EXP) { - /* check for MININT */ - if ((src_exponent > DBL_FX_MAX_EXP + 1) || - Sgl_isnotzero_mantissa(src) || Sgl_iszero_sign(src)) { - if (Sgl_iszero_sign(src)) { - resultp1 = 0x7fffffff; - resultp2 = 0xffffffff; - } - else { - resultp1 = 0x80000000; - resultp2 = 0; - } - - if (Is_invalidtrap_enabled()) { - return(INVALIDEXCEPTION); - } - Set_invalidflag(); - Dint_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - Dint_set_minint(resultp1,resultp2); - Dint_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - /* - * Generate result - */ - if (src_exponent >= 0) { - temp = src; - Sgl_clear_signexponent_set_hidden(temp); - Dint_from_sgl_mantissa(temp,src_exponent,resultp1,resultp2); - if (Sgl_isone_sign(src)) { - Dint_setone_sign(resultp1,resultp2); - } - Dint_copytoptr(resultp1,resultp2,dstptr); - - /* check for inexact */ - if (Sgl_isinexact_to_fix(src,src_exponent)) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - } - else { - Dint_setzero(resultp1,resultp2); - Dint_copytoptr(resultp1,resultp2,dstptr); - - /* check for inexact */ - if (Sgl_isnotzero_exponentmantissa(src)) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - } - return(NOEXCEPTION); -} - -/* - * Double Floating-point to Single Fixed-point - */ -int -dbl_to_sgl_fcnvfxt(srcptr, null, dstptr, status) - dbl_floating_point *srcptr, *null; - int *dstptr; - unsigned int *status; -{ - register unsigned int srcp1, srcp2, tempp1, tempp2; - register int src_exponent, result; - - Dbl_copyfromptr(srcptr,srcp1,srcp2); - src_exponent = Dbl_exponent(srcp1) - DBL_BIAS; - - /* - * Test for overflow - */ - if (src_exponent > SGL_FX_MAX_EXP) { - /* check for MININT */ - if (Dbl_isoverflow_to_int(src_exponent,srcp1,srcp2)) { - if (Dbl_iszero_sign(srcp1)) result = 0x7fffffff; - else result = 0x80000000; - - if (Is_invalidtrap_enabled()) { - return(INVALIDEXCEPTION); - } - Set_invalidflag(); - *dstptr = result; - return(NOEXCEPTION); - } - } - /* - * Generate result - */ - if (src_exponent >= 0) { - tempp1 = srcp1; - tempp2 = srcp2; - Dbl_clear_signexponent_set_hidden(tempp1); - Int_from_dbl_mantissa(tempp1,tempp2,src_exponent); - if (Dbl_isone_sign(srcp1) && (src_exponent <= SGL_FX_MAX_EXP)) - result = -Dbl_allp1(tempp1); - else result = Dbl_allp1(tempp1); - *dstptr = result; - - /* check for inexact */ - if (Dbl_isinexact_to_fix(srcp1,srcp2,src_exponent)) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - } - else { - *dstptr = 0; - - /* check for inexact */ - if (Dbl_isnotzero_exponentmantissa(srcp1,srcp2)) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - } - return(NOEXCEPTION); -} - -/* - * Double Floating-point to Double Fixed-point - */ -int -dbl_to_dbl_fcnvfxt(srcptr, null, dstptr, status) - dbl_floating_point *srcptr, *null; - dbl_integer *dstptr; - unsigned int *status; -{ - register int src_exponent, resultp1; - register unsigned int srcp1, srcp2, tempp1, tempp2, resultp2; - - Dbl_copyfromptr(srcptr,srcp1,srcp2); - src_exponent = Dbl_exponent(srcp1) - DBL_BIAS; - - /* - * Test for overflow - */ - if (src_exponent > DBL_FX_MAX_EXP) { - /* check for MININT */ - if ((src_exponent > DBL_FX_MAX_EXP + 1) || - Dbl_isnotzero_mantissa(srcp1,srcp2) || Dbl_iszero_sign(srcp1)) { - if (Dbl_iszero_sign(srcp1)) { - resultp1 = 0x7fffffff; - resultp2 = 0xffffffff; - } - else { - resultp1 = 0x80000000; - resultp2 = 0; - } - - if (Is_invalidtrap_enabled()) { - return(INVALIDEXCEPTION); - } - Set_invalidflag(); - Dint_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - } - /* - * Generate result - */ - if (src_exponent >= 0) { - tempp1 = srcp1; - tempp2 = srcp2; - Dbl_clear_signexponent_set_hidden(tempp1); - Dint_from_dbl_mantissa(tempp1,tempp2,src_exponent, - resultp1,resultp2); - if (Dbl_isone_sign(srcp1)) { - Dint_setone_sign(resultp1,resultp2); - } - Dint_copytoptr(resultp1,resultp2,dstptr); - - /* check for inexact */ - if (Dbl_isinexact_to_fix(srcp1,srcp2,src_exponent)) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - } - else { - Dint_setzero(resultp1,resultp2); - Dint_copytoptr(resultp1,resultp2,dstptr); - - /* check for inexact */ - if (Dbl_isnotzero_exponentmantissa(srcp1,srcp2)) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/fcnvxf.c b/sys/arch/hppa/spmath/fcnvxf.c deleted file mode 100644 index 02e891e27..000000000 --- a/sys/arch/hppa/spmath/fcnvxf.c +++ /dev/null @@ -1,347 +0,0 @@ -/* $OpenBSD: fcnvxf.c,v 1.7 2003/04/10 17:27:58 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)fcnvxf.c: Revision: 2.7.88.1 Date: 93/12/07 15:06:16 */ - -#include "float.h" -#include "sgl_float.h" -#include "dbl_float.h" -#include "cnv_float.h" - -/* - * Convert single fixed-point to single floating-point format - */ -int -sgl_to_sgl_fcnvxf(srcptr, null, dstptr, status) - int *srcptr, *null; - sgl_floating_point *dstptr; - unsigned int *status; -{ - register int src, dst_exponent; - register unsigned int result = 0; - - src = *srcptr; - /* - * set sign bit of result and get magnitude of source - */ - if (src < 0) { - Sgl_setone_sign(result); - Int_negate(src); - } - else { - Sgl_setzero_sign(result); - /* Check for zero */ - if (src == 0) { - Sgl_setzero(result); - *dstptr = result; - return(NOEXCEPTION); - } - } - /* - * Generate exponent and normalized mantissa - */ - dst_exponent = 16; /* initialize for normalization */ - /* - * Check word for most significant bit set. Returns - * a value in dst_exponent indicating the bit position, - * between -1 and 30. - */ - Find_ms_one_bit(src,dst_exponent); - /* left justify source, with msb at bit position 1 */ - if (dst_exponent >= 0) src <<= dst_exponent; - else src = 1 << 30; - Sgl_set_mantissa(result, src >> (SGL_EXP_LENGTH-1)); - Sgl_set_exponent(result, 30+SGL_BIAS - dst_exponent); - - /* check for inexact */ - if (Int_isinexact_to_sgl(src)) { - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(result)) - Sgl_increment(result); - break; - case ROUNDMINUS: - if (Sgl_isone_sign(result)) - Sgl_increment(result); - break; - case ROUNDNEAREST: - Sgl_roundnearest_from_int(src,result); - } - if (Is_inexacttrap_enabled()) { - *dstptr = result; - return(INEXACTEXCEPTION); - } - else Set_inexactflag(); - } - *dstptr = result; - return(NOEXCEPTION); -} - -/* - * Single Fixed-point to Double Floating-point - */ -int -sgl_to_dbl_fcnvxf(srcptr, null, dstptr, status) - int *srcptr, *null; - dbl_floating_point *dstptr; - unsigned int *status; -{ - register int src, dst_exponent; - register unsigned int resultp1 = 0, resultp2 = 0; - - src = *srcptr; - /* - * set sign bit of result and get magnitude of source - */ - if (src < 0) { - Dbl_setone_sign(resultp1); - Int_negate(src); - } - else { - Dbl_setzero_sign(resultp1); - /* Check for zero */ - if (src == 0) { - Dbl_setzero(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - } - /* - * Generate exponent and normalized mantissa - */ - dst_exponent = 16; /* initialize for normalization */ - /* - * Check word for most significant bit set. Returns - * a value in dst_exponent indicating the bit position, - * between -1 and 30. - */ - Find_ms_one_bit(src,dst_exponent); - /* left justify source, with msb at bit position 1 */ - if (dst_exponent >= 0) src <<= dst_exponent; - else src = 1 << 30; - Dbl_set_mantissap1(resultp1, (src >> (DBL_EXP_LENGTH - 1))); - Dbl_set_mantissap2(resultp2, (src << (33-DBL_EXP_LENGTH))); - Dbl_set_exponent(resultp1, (30+DBL_BIAS) - dst_exponent); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); -} - -/* - * Double Fixed-point to Single Floating-point - */ -int -dbl_to_sgl_fcnvxf(srcptr, null, dstptr, status) - dbl_integer *srcptr, *null; - sgl_floating_point *dstptr; - unsigned int *status; -{ - int dst_exponent, srcp1; - unsigned int result = 0, srcp2; - - Dint_copyfromptr(srcptr,srcp1,srcp2); - /* - * set sign bit of result and get magnitude of source - */ - if (srcp1 < 0) { - Sgl_setone_sign(result); - Dint_negate(srcp1,srcp2); - } - else { - Sgl_setzero_sign(result); - /* Check for zero */ - if (srcp1 == 0 && srcp2 == 0) { - Sgl_setzero(result); - *dstptr = result; - return(NOEXCEPTION); - } - } - /* - * Generate exponent and normalized mantissa - */ - dst_exponent = 16; /* initialize for normalization */ - if (srcp1 == 0) { - /* - * Check word for most significant bit set. Returns - * a value in dst_exponent indicating the bit position, - * between -1 and 30. - */ - Find_ms_one_bit(srcp2,dst_exponent); - /* left justify source, with msb at bit position 1 */ - if (dst_exponent >= 0) { - srcp1 = srcp2 << dst_exponent; - srcp2 = 0; - } - else { - srcp1 = srcp2 >> 1; - srcp2 <<= 31; - } - /* - * since msb set is in second word, need to - * adjust bit position count - */ - dst_exponent += 32; - } - else { - /* - * Check word for most significant bit set. Returns - * a value in dst_exponent indicating the bit position, - * between -1 and 30. - * - */ - Find_ms_one_bit(srcp1,dst_exponent); - /* left justify source, with msb at bit position 1 */ - if (dst_exponent > 0) { - Variable_shift_double(srcp1,srcp2,(32-dst_exponent), - srcp1); - srcp2 <<= dst_exponent; - } - /* - * If dst_exponent = 0, we don't need to shift anything. - * If dst_exponent = -1, src = - 2**63 so we won't need to - * shift srcp2. - */ - else srcp1 >>= -(dst_exponent); - } - Sgl_set_mantissa(result, (srcp1 >> (SGL_EXP_LENGTH - 1))); - Sgl_set_exponent(result, (62+SGL_BIAS) - dst_exponent); - - /* check for inexact */ - if (Dint_isinexact_to_sgl(srcp1,srcp2)) { - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(result)) - Sgl_increment(result); - break; - case ROUNDMINUS: - if (Sgl_isone_sign(result)) - Sgl_increment(result); - break; - case ROUNDNEAREST: - Sgl_roundnearest_from_dint(srcp1,srcp2,result); - } - if (Is_inexacttrap_enabled()) { - *dstptr = result; - return(INEXACTEXCEPTION); - } - else Set_inexactflag(); - } - *dstptr = result; - return(NOEXCEPTION); -} - -/* - * Double Fixed-point to Double Floating-point - */ -int -dbl_to_dbl_fcnvxf(srcptr, null, dstptr, status) - dbl_integer *srcptr, *null; - dbl_floating_point *dstptr; - unsigned int *status; -{ - register int srcp1, dst_exponent; - register unsigned int srcp2, resultp1 = 0, resultp2 = 0; - - Dint_copyfromptr(srcptr,srcp1,srcp2); - /* - * set sign bit of result and get magnitude of source - */ - if (srcp1 < 0) { - Dbl_setone_sign(resultp1); - Dint_negate(srcp1,srcp2); - } - else { - Dbl_setzero_sign(resultp1); - /* Check for zero */ - if (srcp1 == 0 && srcp2 ==0) { - Dbl_setzero(resultp1,resultp2); - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); - } - } - /* - * Generate exponent and normalized mantissa - */ - dst_exponent = 16; /* initialize for normalization */ - if (srcp1 == 0) { - /* - * Check word for most significant bit set. Returns - * a value in dst_exponent indicating the bit position, - * between -1 and 30. - */ - Find_ms_one_bit(srcp2,dst_exponent); - /* left justify source, with msb at bit position 1 */ - if (dst_exponent >= 0) { - srcp1 = srcp2 << dst_exponent; - srcp2 = 0; - } - else { - srcp1 = srcp2 >> 1; - srcp2 <<= 31; - } - /* - * since msb set is in second word, need to - * adjust bit position count - */ - dst_exponent += 32; - } - else { - /* - * Check word for most significant bit set. Returns - * a value in dst_exponent indicating the bit position, - * between -1 and 30. - */ - Find_ms_one_bit(srcp1,dst_exponent); - /* left justify source, with msb at bit position 1 */ - if (dst_exponent > 0) { - Variable_shift_double(srcp1,srcp2,(32-dst_exponent), - srcp1); - srcp2 <<= dst_exponent; - } - /* - * If dst_exponent = 0, we don't need to shift anything. - * If dst_exponent = -1, src = - 2**63 so we won't need to - * shift srcp2. - */ - else srcp1 >>= -(dst_exponent); - } - Dbl_set_mantissap1(resultp1, srcp1 >> (DBL_EXP_LENGTH-1)); - Shiftdouble(srcp1,srcp2,DBL_EXP_LENGTH-1,resultp2); - Dbl_set_exponent(resultp1, (62+DBL_BIAS) - dst_exponent); - - /* check for inexact */ - if (Dint_isinexact_to_dbl(srcp2)) { - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(resultp1)) { - Dbl_increment(resultp1,resultp2); - } - break; - case ROUNDMINUS: - if (Dbl_isone_sign(resultp1)) { - Dbl_increment(resultp1,resultp2); - } - break; - case ROUNDNEAREST: - Dbl_roundnearest_from_dint(srcp2,resultp1, - resultp2); - } - if (Is_inexacttrap_enabled()) { - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(INEXACTEXCEPTION); - } - else Set_inexactflag(); - } - Dbl_copytoptr(resultp1,resultp2,dstptr); - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/float.h b/sys/arch/hppa/spmath/float.h deleted file mode 100644 index dbad0ed43..000000000 --- a/sys/arch/hppa/spmath/float.h +++ /dev/null @@ -1,474 +0,0 @@ -/* $OpenBSD: float.h,v 1.8 2012/06/25 16:55:13 deraadt Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)float.h: Revision: 2.14.88.2 Date: 93/12/08 13:27:42 */ - -#include "fpbits.h" -#include "hppa.h" - -/* - * Declare the basic structures for the 3 different - * floating-point precisions. - * - * Single number - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * |s| exp | mantissa | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - */ -#define Sall(object) (object) -#define Ssign(object) Bitfield_extract( 0, 1,object) -#define Ssignedsign(object) Bitfield_signed_extract( 0, 1,object) -#define Sexponent(object) Bitfield_extract( 1, 8,object) -#define Smantissa(object) Bitfield_mask( 9, 23,object) -#define Ssignaling(object) Bitfield_extract( 9, 1,object) -#define Ssignalingnan(object) Bitfield_extract( 1, 9,object) -#define Shigh2mantissa(object) Bitfield_extract( 9, 2,object) -#define Sexponentmantissa(object) Bitfield_mask( 1, 31,object) -#define Ssignexponent(object) Bitfield_extract( 0, 9,object) -#define Shidden(object) Bitfield_extract( 8, 1,object) -#define Shiddenoverflow(object) Bitfield_extract( 7, 1,object) -#define Shiddenhigh7mantissa(object) Bitfield_extract( 8, 8,object) -#define Shiddenhigh3mantissa(object) Bitfield_extract( 8, 4,object) -#define Slow(object) Bitfield_mask( 31, 1,object) -#define Slow4(object) Bitfield_mask( 28, 4,object) -#define Slow31(object) Bitfield_mask( 1, 31,object) -#define Shigh31(object) Bitfield_extract( 0, 31,object) -#define Ssignedhigh31(object) Bitfield_signed_extract( 0, 31,object) -#define Shigh4(object) Bitfield_extract( 0, 4,object) -#define Sbit24(object) Bitfield_extract( 24, 1,object) -#define Sbit28(object) Bitfield_extract( 28, 1,object) -#define Sbit29(object) Bitfield_extract( 29, 1,object) -#define Sbit30(object) Bitfield_extract( 30, 1,object) -#define Sbit31(object) Bitfield_mask( 31, 1,object) - -#define Deposit_ssign(object,value) Bitfield_deposit(value,0,1,object) -#define Deposit_sexponent(object,value) Bitfield_deposit(value,1,8,object) -#define Deposit_smantissa(object,value) Bitfield_deposit(value,9,23,object) -#define Deposit_shigh2mantissa(object,value) Bitfield_deposit(value,9,2,object) -#define Deposit_sexponentmantissa(object,value) \ - Bitfield_deposit(value,1,31,object) -#define Deposit_ssignexponent(object,value) Bitfield_deposit(value,0,9,object) -#define Deposit_slow(object,value) Bitfield_deposit(value,31,1,object) -#define Deposit_shigh4(object,value) Bitfield_deposit(value,0,4,object) - -#define Is_ssign(object) Bitfield_mask( 0, 1,object) -#define Is_ssignaling(object) Bitfield_mask( 9, 1,object) -#define Is_shidden(object) Bitfield_mask( 8, 1,object) -#define Is_shiddenoverflow(object) Bitfield_mask( 7, 1,object) -#define Is_slow(object) Bitfield_mask( 31, 1,object) -#define Is_sbit24(object) Bitfield_mask( 24, 1,object) -#define Is_sbit28(object) Bitfield_mask( 28, 1,object) -#define Is_sbit29(object) Bitfield_mask( 29, 1,object) -#define Is_sbit30(object) Bitfield_mask( 30, 1,object) -#define Is_sbit31(object) Bitfield_mask( 31, 1,object) - -/* - * Double number. - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * |s| exponent | mantissa part 1 | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * | mantissa part 2 | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - */ -#define Dallp1(object) (object) -#define Dsign(object) Bitfield_extract( 0, 1,object) -#define Dsignedsign(object) Bitfield_signed_extract( 0, 1,object) -#define Dexponent(object) Bitfield_extract( 1, 11,object) -#define Dmantissap1(object) Bitfield_mask( 12, 20,object) -#define Dsignaling(object) Bitfield_extract( 12, 1,object) -#define Dsignalingnan(object) Bitfield_extract( 1, 12,object) -#define Dhigh2mantissa(object) Bitfield_extract( 12, 2,object) -#define Dexponentmantissap1(object) Bitfield_mask( 1, 31,object) -#define Dsignexponent(object) Bitfield_extract( 0, 12,object) -#define Dhidden(object) Bitfield_extract( 11, 1,object) -#define Dhiddenoverflow(object) Bitfield_extract( 10, 1,object) -#define Dhiddenhigh7mantissa(object) Bitfield_extract( 11, 8,object) -#define Dhiddenhigh3mantissa(object) Bitfield_extract( 11, 4,object) -#define Dlowp1(object) Bitfield_mask( 31, 1,object) -#define Dlow31p1(object) Bitfield_mask( 1, 31,object) -#define Dhighp1(object) Bitfield_extract( 0, 1,object) -#define Dhigh4p1(object) Bitfield_extract( 0, 4,object) -#define Dhigh31p1(object) Bitfield_extract( 0, 31,object) -#define Dsignedhigh31p1(object) Bitfield_signed_extract( 0, 31,object) -#define Dbit3p1(object) Bitfield_extract( 3, 1,object) - -#define Deposit_dsign(object,value) Bitfield_deposit(value,0,1,object) -#define Deposit_dexponent(object,value) Bitfield_deposit(value,1,11,object) -#define Deposit_dmantissap1(object,value) Bitfield_deposit(value,12,20,object) -#define Deposit_dhigh2mantissa(object,value) Bitfield_deposit(value,12,2,object) -#define Deposit_dexponentmantissap1(object,value) \ - Bitfield_deposit(value,1,31,object) -#define Deposit_dsignexponent(object,value) Bitfield_deposit(value,0,12,object) -#define Deposit_dlowp1(object,value) Bitfield_deposit(value,31,1,object) -#define Deposit_dhigh4p1(object,value) Bitfield_deposit(value,0,4,object) - -#define Is_dsign(object) Bitfield_mask( 0, 1,object) -#define Is_dsignaling(object) Bitfield_mask( 12, 1,object) -#define Is_dhidden(object) Bitfield_mask( 11, 1,object) -#define Is_dhiddenoverflow(object) Bitfield_mask( 10, 1,object) -#define Is_dlowp1(object) Bitfield_mask( 31, 1,object) -#define Is_dhighp1(object) Bitfield_mask( 0, 1,object) -#define Is_dbit3p1(object) Bitfield_mask( 3, 1,object) - -#define Dallp2(object) (object) -#define Dmantissap2(object) (object) -#define Dlowp2(object) Bitfield_mask( 31, 1,object) -#define Dlow4p2(object) Bitfield_mask( 28, 4,object) -#define Dlow31p2(object) Bitfield_mask( 1, 31,object) -#define Dhighp2(object) Bitfield_extract( 0, 1,object) -#define Dhigh31p2(object) Bitfield_extract( 0, 31,object) -#define Dbit2p2(object) Bitfield_extract( 2, 1,object) -#define Dbit3p2(object) Bitfield_extract( 3, 1,object) -#define Dbit21p2(object) Bitfield_extract( 21, 1,object) -#define Dbit28p2(object) Bitfield_extract( 28, 1,object) -#define Dbit29p2(object) Bitfield_extract( 29, 1,object) -#define Dbit30p2(object) Bitfield_extract( 30, 1,object) -#define Dbit31p2(object) Bitfield_mask( 31, 1,object) - -#define Deposit_dlowp2(object,value) Bitfield_deposit(value,31,1,object) - -#define Is_dlowp2(object) Bitfield_mask( 31, 1,object) -#define Is_dhighp2(object) Bitfield_mask( 0, 1,object) -#define Is_dbit2p2(object) Bitfield_mask( 2, 1,object) -#define Is_dbit3p2(object) Bitfield_mask( 3, 1,object) -#define Is_dbit21p2(object) Bitfield_mask( 21, 1,object) -#define Is_dbit28p2(object) Bitfield_mask( 28, 1,object) -#define Is_dbit29p2(object) Bitfield_mask( 29, 1,object) -#define Is_dbit30p2(object) Bitfield_mask( 30, 1,object) -#define Is_dbit31p2(object) Bitfield_mask( 31, 1,object) - -/* - * Quad number. - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * |s| exponent | mantissa part 1 | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * | mantissa part 2 | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * | mantissa part 3 | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * | mantissa part 4 | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - */ -typedef struct - { - union - { - struct { unsigned qallp1; } u_qallp1; -/* Not needed for now... - Bitfield_extract( 0, 1,u_qsign,qsign) - Bitfield_signed_extract( 0, 1,u_qsignedsign,qsignedsign) - Bitfield_extract( 1, 15,u_qexponent,qexponent) - Bitfield_extract(16, 16,u_qmantissap1,qmantissap1) - Bitfield_extract(16, 1,u_qsignaling,qsignaling) - Bitfield_extract(1, 16,u_qsignalingnan,qsignalingnan) - Bitfield_extract(16, 2,u_qhigh2mantissa,qhigh2mantissa) - Bitfield_extract( 1, 31,u_qexponentmantissap1,qexponentmantissap1) - Bitfield_extract( 0, 16,u_qsignexponent,qsignexponent) - Bitfield_extract(15, 1,u_qhidden,qhidden) - Bitfield_extract(14, 1,u_qhiddenoverflow,qhiddenoverflow) - Bitfield_extract(15, 8,u_qhiddenhigh7mantissa,qhiddenhigh7mantissa) - Bitfield_extract(15, 4,u_qhiddenhigh3mantissa,qhiddenhigh3mantissa) - Bitfield_extract(31, 1,u_qlowp1,qlowp1) - Bitfield_extract( 1, 31,u_qlow31p1,qlow31p1) - Bitfield_extract( 0, 1,u_qhighp1,qhighp1) - Bitfield_extract( 0, 4,u_qhigh4p1,qhigh4p1) - Bitfield_extract( 0, 31,u_qhigh31p1,qhigh31p1) - */ - } quad_u1; - union - { - struct { unsigned qallp2; } u_qallp2; - /* Not needed for now... - Bitfield_extract(31, 1,u_qlowp2,qlowp2) - Bitfield_extract( 1, 31,u_qlow31p2,qlow31p2) - Bitfield_extract( 0, 1,u_qhighp2,qhighp2) - Bitfield_extract( 0, 31,u_qhigh31p2,qhigh31p2) - */ - } quad_u2; - union - { - struct { unsigned qallp3; } u_qallp3; - /* Not needed for now... - Bitfield_extract(31, 1,u_qlowp3,qlowp3) - Bitfield_extract( 1, 31,u_qlow31p3,qlow31p3) - Bitfield_extract( 0, 1,u_qhighp3,qhighp3) - Bitfield_extract( 0, 31,u_qhigh31p3,qhigh31p3) - */ - } quad_u3; - union - { - struct { unsigned qallp4; } u_qallp4; - /* Not need for now... - Bitfield_extract(31, 1,u_qlowp4,qlowp4) - Bitfield_extract( 1, 31,u_qlow31p4,qlow31p4) - Bitfield_extract( 0, 1,u_qhighp4,qhighp4) - Bitfield_extract( 0, 31,u_qhigh31p4,qhigh31p4) - */ - } quad_u4; - } quad_floating_point; - -/* Extension - An additional structure to hold the guard, round and - * sticky bits during computations. - */ -#define Extall(object) (object) -#define Extsign(object) Bitfield_extract( 0, 1,object) -#define Exthigh31(object) Bitfield_extract( 0, 31,object) -#define Extlow31(object) Bitfield_extract( 1, 31,object) -#define Extlow(object) Bitfield_extract( 31, 1,object) - -/* - * Declare the basic structures for the 3 different - * fixed-point precisions. - * - * Single number - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * |s| integer | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - */ -typedef int sgl_integer; - -/* - * Double number. - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * |s| high integer | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * | low integer | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - */ -struct dint { - int wd0; - unsigned int wd1; -}; - -struct dblwd { - unsigned int wd0; - unsigned int wd1; -}; - -/* - * Quad number. - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * |s| integer part1 | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * | integer part 2 | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * | integer part 3 | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * | integer part 4 | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - */ - -struct quadwd { - int wd0; - unsigned int wd1; - unsigned int wd2; - unsigned int wd3; -}; - -typedef struct quadwd quad_integer; - - -/* useful typedefs */ -typedef int sgl_floating_point; -typedef struct dblwd dbl_floating_point; -typedef struct dint dbl_integer; - -/* - * Define the different precisions' parameters. - */ -#define SGL_BITLENGTH 32 -#define SGL_EMAX 127 -#define SGL_BIAS 127 -#define SGL_WRAP 192 -#define SGL_INFINITY_EXPONENT (SGL_EMAX+SGL_BIAS+1) -#define SGL_THRESHOLD 32 -#define SGL_EXP_LENGTH 8 -#define SGL_P 24 - -#define DBL_BITLENGTH 64 -#define DBL_EMAX 1023 -#define DBL_BIAS 1023 -#define DBL_WRAP 1536 -#define DBL_INFINITY_EXPONENT (DBL_EMAX+DBL_BIAS+1) -#define DBL_THRESHOLD 64 -#define DBL_EXP_LENGTH 11 -#define DBL_P 53 - -#define QUAD_BITLENGTH 128 -#define QUAD_EMAX 16383 -#define QUAD_BIAS 16383 -#define QUAD_WRAP 24576 -#define QUAD_INFINITY_EXPONENT (QUAD_EMAX+QUAD_BIAS+1) -#define QUAD_P 113 - -/* Boolean Values etc. */ -#define FALSE 0 -#define TRUE (!FALSE) -#define NOT ! -#define XOR ^ - -/* Declare status register equivalent to FPUs architecture. - * - * 0 1 2 3 4 5 6 7 8 910 1 2 3 4 5 6 7 8 920 1 2 3 4 5 6 7 8 930 1 - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * |V|Z|O|U|I|C| rsv | model | version |RM |rsv|T|r|V|Z|O|U|I| - * +-------+-------+-------+-------+-------+-------+-------+-------+ - */ -#define Cbit(object) Bitfield_extract( 5, 1,object) -#define Tbit(object) Bitfield_extract( 25, 1,object) -#define Roundingmode(object) Bitfield_extract( 21, 2,object) -#define Invalidtrap(object) Bitfield_extract( 27, 1,object) -#define Divisionbyzerotrap(object) Bitfield_extract( 28, 1,object) -#define Overflowtrap(object) Bitfield_extract( 29, 1,object) -#define Underflowtrap(object) Bitfield_extract( 30, 1,object) -#define Inexacttrap(object) Bitfield_extract( 31, 1,object) -#define Invalidflag(object) Bitfield_extract( 0, 1,object) -#define Divisionbyzeroflag(object) Bitfield_extract( 1, 1,object) -#define Overflowflag(object) Bitfield_extract( 2, 1,object) -#define Underflowflag(object) Bitfield_extract( 3, 1,object) -#define Inexactflag(object) Bitfield_extract( 4, 1,object) -#define Allflags(object) Bitfield_extract( 0, 5,object) - -/* Definitions relevant to the status register */ - -/* Rounding Modes */ -#define ROUNDNEAREST 0 -#define ROUNDZERO 1 -#define ROUNDPLUS 2 -#define ROUNDMINUS 3 - -/* Exceptions */ -#define NOEXCEPTION 0x0 -#define INVALIDEXCEPTION 0x20 -#define DIVISIONBYZEROEXCEPTION 0x10 -#define OVERFLOWEXCEPTION 0x08 -#define UNDERFLOWEXCEPTION 0x04 -#define INEXACTEXCEPTION 0x02 -#define UNIMPLEMENTEDEXCEPTION 0x01 - -/* Declare exception registers equivalent to FPUs architecture - * - * 0 1 2 3 4 5 6 7 8 910 1 2 3 4 5 6 7 8 920 1 2 3 4 5 6 7 8 930 1 - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * |excepttype | r1 | r2/ext | operation |parm |n| t/cond | - * +-------+-------+-------+-------+-------+-------+-------+-------+ - */ -#define Allexception(object) (object) -#define Exceptiontype(object) Bitfield_extract( 0, 6,object) -#define Instructionfield(object) Bitfield_mask( 6,26,object) -#define Parmfield(object) Bitfield_extract( 23, 3,object) -#define Rabit(object) Bitfield_extract( 24, 1,object) -#define Ibit(object) Bitfield_extract( 25, 1,object) - -#define Set_exceptiontype(object,value) Bitfield_deposit(value, 0, 6,object) -#define Set_parmfield(object,value) Bitfield_deposit(value, 23, 3,object) -#define Set_exceptiontype_and_instr_field(exception,instruction,object) \ - object = ((exception) << 26) | (instruction) - -/* Declare the condition field - * - * 0 1 2 3 4 5 6 7 8 910 1 2 3 4 5 6 7 8 920 1 2 3 4 5 6 7 8 930 1 - * +-------+-------+-------+-------+-------+-------+-------+-------+ - * | |G|L|E|U|X| - * +-------+-------+-------+-------+-------+-------+-------+-------+ - */ -#define Allexception(object) (object) -#define Greaterthanbit(object) Bitfield_extract( 27, 1,object) -#define Lessthanbit(object) Bitfield_extract( 28, 1,object) -#define Equalbit(object) Bitfield_extract( 29, 1,object) -#define Unorderedbit(object) Bitfield_extract( 30, 1,object) -#define Exceptionbit(object) Bitfield_extract( 31, 1,object) - -/* An alias name for the status register */ -#define Fpustatus_register (*status) - -/************************************************** - * Status register referencing and manipulation. * - **************************************************/ - -/* Rounding mode */ -#define Rounding_mode() Roundingmode(Fpustatus_register) -#define Is_rounding_mode(rmode) \ - (Roundingmode(Fpustatus_register) == rmode) -#define Set_rounding_mode(value) \ - Bitfield_deposit(value,21,2,Fpustatus_register) - -/* Boolean testing of the trap enable bits */ -#define Is_invalidtrap_enabled() Invalidtrap(Fpustatus_register) -#define Is_divisionbyzerotrap_enabled() Divisionbyzerotrap(Fpustatus_register) -#define Is_overflowtrap_enabled() Overflowtrap(Fpustatus_register) -#define Is_underflowtrap_enabled() Underflowtrap(Fpustatus_register) -#define Is_inexacttrap_enabled() Inexacttrap(Fpustatus_register) - -/* Set the indicated flags in the status register */ -#define Set_invalidflag() Bitfield_deposit(1,0,1,Fpustatus_register) -#define Set_divisionbyzeroflag() Bitfield_deposit(1,1,1,Fpustatus_register) -#define Set_overflowflag() Bitfield_deposit(1,2,1,Fpustatus_register) -#define Set_underflowflag() Bitfield_deposit(1,3,1,Fpustatus_register) -#define Set_inexactflag() Bitfield_deposit(1,4,1,Fpustatus_register) - -#define Clear_all_flags() Bitfield_deposit(0,0,5,Fpustatus_register) - -/* Manipulate the trap and condition code bits (tbit and cbit) */ -#define Set_tbit() Bitfield_deposit(1,25,1,Fpustatus_register) -#define Clear_tbit() Bitfield_deposit(0,25,1,Fpustatus_register) -#define Is_tbit_set() Tbit(Fpustatus_register) -#define Is_cbit_set() Cbit(Fpustatus_register) - -#ifdef TIMEX -#define Set_status_cbit(value) \ - Bitfield_deposit(Bitfield_extract(10,10,Fpustatus_register),11,10,Fpustatus_register); \ - Bitfield_deposit(Bitfield_extract(5,1,Fpustatus_register),10,1,Fpustatus_register); \ - Bitfield_deposit(value,5,1,Fpustatus_register) -#else -#define Set_status_cbit(value) Bitfield_deposit(value,5,1,Fpustatus_register) -#endif - -/******************************* - * Condition field referencing * - *******************************/ -#define Unordered(cond) Unorderedbit(cond) -#define Equal(cond) Equalbit(cond) -#define Lessthan(cond) Lessthanbit(cond) -#define Greaterthan(cond) Greaterthanbit(cond) -#define Exception(cond) Exceptionbit(cond) - - -/* Defines for the extension */ -#define Ext_isone_sign(extent) (Extsign(extent)) -#define Ext_isnotzero(extent) \ - (Extall(extent)) -#define Ext_isnotzero_lower(extent) \ - (Extlow31(extent)) -#define Ext_leftshiftby1(extent) \ - Extall(extent) <<= 1 -#define Ext_negate(extent) \ - (int )Extall(extent) = 0 - (int )Extall(extent) -#define Ext_setone_low(extent) Bitfield_deposit(1,31,1,extent) diff --git a/sys/arch/hppa/spmath/fpbits.h b/sys/arch/hppa/spmath/fpbits.h deleted file mode 100644 index 4c17dbcb7..000000000 --- a/sys/arch/hppa/spmath/fpbits.h +++ /dev/null @@ -1,55 +0,0 @@ -/* $OpenBSD: fpbits.h,v 1.6 2002/09/20 19:26:59 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)fpbits.h: Revision: 1.6.88.1 Date: 93/12/07 15:06:21 */ - -/* - * These macros are designed to be portable to all machines that have - * a wordsize greater than or equal to 32 bits that support the portable - * C compiler and the standard C preprocessor. Wordsize (default 32) - * and bitfield assignment (default left-to-right, unlike VAX, PDP-11) - * should be predefined using the constants HOSTWDSZ and BITFRL and - * the C compiler "-D" flag (e.g., -DHOSTWDSZ=36 -DBITFLR for the DEC-20). - * Note that the macro arguments assume that the integer being referenced - * is a 32-bit integer (right-justified on the 20) and that bit 0 is the - * most significant bit. - */ - -#ifndef HOSTWDSZ -#define HOSTWDSZ 32 -#endif - - -/*########################### Macros ######################################*/ - -/*------------------------------------------------------------------------- - * NewDeclareBitField_Reference - Declare a structure similar to the simulator - * function "DeclBitfR" except its use is restricted to occur within a larger - * enclosing structure or union definition. This declaration is an unnamed - * structure with the argument, name, as the member name and the argument, - * uname, as the element name. - *----------------------------------------------------------------------- */ -#define Bitfield_extract(start, length, object) \ - ((object) >> (HOSTWDSZ - (start) - (length)) & \ - ((unsigned)-1 >> (HOSTWDSZ - (length)))) - -#define Bitfield_signed_extract(start, length, object) \ - ((int)((object) << start) >> (HOSTWDSZ - (length))) - -#define Bitfield_mask(start, len, object) \ - ((object) & (((unsigned)-1 >> (HOSTWDSZ-len)) << (HOSTWDSZ-start-len))) - -#define Bitfield_deposit(value,start,len,object) object = \ - ((object) & ~(((unsigned)-1 >> (HOSTWDSZ-(len))) << (HOSTWDSZ-(start)-(len)))) | \ - (((value) & ((unsigned)-1 >> (HOSTWDSZ-(len)))) << (HOSTWDSZ-(start)-(len))) diff --git a/sys/arch/hppa/spmath/frnd.c b/sys/arch/hppa/spmath/frnd.c deleted file mode 100644 index c27575e97..000000000 --- a/sys/arch/hppa/spmath/frnd.c +++ /dev/null @@ -1,236 +0,0 @@ -/* $OpenBSD: frnd.c,v 1.9 2023/03/08 04:43:07 guenther Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)frnd.c: Revision: 2.7.88.1 Date: 93/12/07 15:06:24 */ - -#include "float.h" -#include "sgl_float.h" -#include "dbl_float.h" -#include "quad_float.h" -#include "cnv_float.h" - -/* - * Single Floating-point Round to Integer - */ - -int -sgl_frnd(srcptr, null, dstptr, status) - sgl_floating_point *srcptr, *null, *dstptr; - unsigned int *status; -{ - register unsigned int src, result; - register int src_exponent; - register int inexact = FALSE; - - src = *srcptr; - /* - * check source operand for NaN or infinity - */ - if ((src_exponent = Sgl_exponent(src)) == SGL_INFINITY_EXPONENT) { - /* - * is signaling NaN? - */ - if (Sgl_isone_signaling(src)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(src); - } - /* - * return quiet NaN or infinity - */ - *dstptr = src; - return(NOEXCEPTION); - } - /* - * Need to round? - */ - if ((src_exponent -= SGL_BIAS) >= SGL_P - 1) { - *dstptr = src; - return(NOEXCEPTION); - } - /* - * Generate result - */ - if (src_exponent >= 0) { - Sgl_clear_exponent_set_hidden(src); - result = src; - Sgl_rightshift(result,(SGL_P-1) - (src_exponent)); - /* check for inexact */ - if (Sgl_isinexact_to_fix(src,src_exponent)) { - inexact = TRUE; - /* round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(src)) Sgl_increment(result); - break; - case ROUNDMINUS: - if (Sgl_isone_sign(src)) Sgl_increment(result); - break; - case ROUNDNEAREST: - if (Sgl_isone_roundbit(src,src_exponent)) - if (Sgl_isone_stickybit(src,src_exponent) - || (Sgl_isone_lowmantissa(result))) - Sgl_increment(result); - } - } - Sgl_leftshift(result,(SGL_P-1) - (src_exponent)); - if (Sgl_isone_hiddenoverflow(result)) - Sgl_set_exponent(result,src_exponent + (SGL_BIAS+1)); - else Sgl_set_exponent(result,src_exponent + SGL_BIAS); - } - else { - result = src; /* set sign */ - Sgl_setzero_exponentmantissa(result); - /* check for inexact */ - if (Sgl_isnotzero_exponentmantissa(src)) { - inexact = TRUE; - /* round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(src)) - Sgl_set_exponent(result,SGL_BIAS); - break; - case ROUNDMINUS: - if (Sgl_isone_sign(src)) - Sgl_set_exponent(result,SGL_BIAS); - break; - case ROUNDNEAREST: - if (src_exponent == -1) - if (Sgl_isnotzero_mantissa(src)) - Sgl_set_exponent(result,SGL_BIAS); - } - } - } - *dstptr = result; - if (inexact) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(NOEXCEPTION); -} - -/* - * Double Floating-point Round to Integer - */ - -int -dbl_frnd(srcptr, null, dstptr, status) - dbl_floating_point *srcptr, *null, *dstptr; - unsigned int *status; -{ - register unsigned int srcp1, srcp2, resultp1, resultp2; - register int src_exponent; - register int inexact = FALSE; - - Dbl_copyfromptr(srcptr,srcp1,srcp2); - /* - * check source operand for NaN or infinity - */ - if ((src_exponent = Dbl_exponent(srcp1)) == DBL_INFINITY_EXPONENT) { - /* - * is signaling NaN? - */ - if (Dbl_isone_signaling(srcp1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Dbl_set_quiet(srcp1); - } - /* - * return quiet NaN or infinity - */ - Dbl_copytoptr(srcp1,srcp2,dstptr); - return(NOEXCEPTION); - } - /* - * Need to round? - */ - if ((src_exponent -= DBL_BIAS) >= DBL_P - 1) { - Dbl_copytoptr(srcp1,srcp2,dstptr); - return(NOEXCEPTION); - } - /* - * Generate result - */ - if (src_exponent >= 0) { - Dbl_clear_exponent_set_hidden(srcp1); - resultp1 = srcp1; - resultp2 = srcp2; - Dbl_rightshift(resultp1,resultp2,(DBL_P-1) - (src_exponent)); - /* check for inexact */ - if (Dbl_isinexact_to_fix(srcp1,srcp2,src_exponent)) { - inexact = TRUE; - /* round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(srcp1)) - Dbl_increment(resultp1,resultp2); - break; - case ROUNDMINUS: - if (Dbl_isone_sign(srcp1)) - Dbl_increment(resultp1,resultp2); - break; - case ROUNDNEAREST: - if (Dbl_isone_roundbit(srcp1,srcp2,src_exponent)) - if (Dbl_isone_stickybit(srcp1,srcp2,src_exponent) - || (Dbl_isone_lowmantissap2(resultp2))) - Dbl_increment(resultp1,resultp2); - } - } - Dbl_leftshift(resultp1,resultp2,(DBL_P-1) - (src_exponent)); - if (Dbl_isone_hiddenoverflow(resultp1)) - Dbl_set_exponent(resultp1,src_exponent + (DBL_BIAS+1)); - else Dbl_set_exponent(resultp1,src_exponent + DBL_BIAS); - } - else { - resultp1 = srcp1; /* set sign */ - Dbl_setzero_exponentmantissa(resultp1,resultp2); - /* check for inexact */ - if (Dbl_isnotzero_exponentmantissa(srcp1,srcp2)) { - inexact = TRUE; - /* round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Dbl_iszero_sign(srcp1)) - Dbl_set_exponent(resultp1,DBL_BIAS); - break; - case ROUNDMINUS: - if (Dbl_isone_sign(srcp1)) - Dbl_set_exponent(resultp1,DBL_BIAS); - break; - case ROUNDNEAREST: - if (src_exponent == -1) - if (Dbl_isnotzero_mantissa(srcp1,srcp2)) - Dbl_set_exponent(resultp1,DBL_BIAS); - } - } - } - Dbl_copytoptr(resultp1,resultp2,dstptr); - if (inexact) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(NOEXCEPTION); -} - -int -quad_frnd(srcptr, null, dstptr, status) - quad_floating_point *srcptr, *null, *dstptr; - unsigned int *status; -{ - return(UNIMPLEMENTEDEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/hppa.h b/sys/arch/hppa/spmath/hppa.h deleted file mode 100644 index 216f50575..000000000 --- a/sys/arch/hppa/spmath/hppa.h +++ /dev/null @@ -1,32 +0,0 @@ -/* $OpenBSD: hppa.h,v 1.5 2002/05/07 22:19:30 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)hppa.h: Revision: 2.7.88.1 Date: 93/12/07 15:06:26 */ - -/* amount is assumed to be a constant between 0 and 32 (non-inclusive) */ -#define Shiftdouble(left,right,amount,dest) \ - /* int left, right, amount, dest; */ \ - dest = ((left) << (32-(amount))) | ((unsigned int)(right) >> (amount)) - -/* amount must be less than 32 */ -#define Variableshiftdouble(left,right,amount,dest) \ - /* unsigned int left, right; int amount, dest; */ \ - if (amount == 0) dest = right; \ - else dest = ((((unsigned) left)&0x7fffffff) << (32-(amount))) | \ - ((unsigned) right >> (amount)) - -/* amount must be between 0 and 32 (non-inclusive) */ -#define Variable_shift_double(left,right,amount,dest) \ - /* unsigned int left, right; int amount, dest; */ \ - dest = (left << (32-(amount))) | ((unsigned) right >> (amount)) diff --git a/sys/arch/hppa/spmath/impys.S b/sys/arch/hppa/spmath/impys.S deleted file mode 100644 index 99b3b4864..000000000 --- a/sys/arch/hppa/spmath/impys.S +++ /dev/null @@ -1,291 +0,0 @@ -/* $OpenBSD: impys.S,v 1.12 2011/04/16 20:52:12 deraadt Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)impys.s: Revision: 1.11.88.1 Date: 93/12/07 15:06:28 */ - -#include -#include - -;**************************************************************************** -; -;Implement an integer multiply routine for 32-bit operands and 64-bit product -;with operand values of zero (multiplicand only) and -2**31 treated specially. -;The algorithm uses the absolute value of the multiplier, four bits at a time, -;from right to left, to generate partial product. Execution speed is more -;important than program size in this implementation. -; -;**************************************************************************** -; -; Definitions - General registers -; -gr0 .reg %r0 ; General register zero -pu .reg %r3 ; upper part of product -pl .reg %r4 ; lower part of product -op2 .reg %r4 ; multiplier -op1 .reg %r5 ; multiplicand -cnt .reg %r6 ; count in multiply -brindex .reg %r7 ; index into the br. table -sign .reg %r8 ; sign of product -pc .reg %r9 ; carry bit of product, = 00...01 -pm .reg %r10 ; value of -1 used in shifting - -;***************************************************************************** - .text - -LEAF_ENTRY(s_xmpy) - stws,ma pu,4(sp) ; save registers on stack - stws,ma pl,4(sp) ; save registers on stack - stws,ma op1,4(sp) ; save registers on stack - stws,ma cnt,4(sp) ; save registers on stack - stws,ma brindex,4(sp) ; save registers on stack - stws,ma sign,4(sp) ; save registers on stack - stws,ma pc,4(sp) ; save registers on stack - stws,ma pm,4(sp) ; save registers on stack -; -; Start multiply process -; - ldws 0(arg1),op2 ; get multiplier - ldws 0(arg0),op1 ; get multiplicand - addi -1,gr0,pm ; initialize pm to 111...1 - comb,< op2,gr0,mpyb ; br. if multiplier < 0 - xor op2,op1,sign ; sign(0) = sign of product -mpy1 comb,< op1,gr0,mpya ; br. if multiplicand < 0 - addi 0,gr0,pu ; clear product - addib,= 0,op1,fini0 ; op1 = 0, product = 0 -mpy2 addi 1,gr0,pc ; initialize pc to 00...01 - movib,tr 8,cnt,mloop ; set count for mpy loop - extru op2,31,4,brindex ; 4 bits as index into table -; - .align 8 -; - b sh4c ; br. if sign overflow -sh4n shd pu,pl,4,pl ; shift product right 4 bits - addib,<= -1,cnt,mulend ; reduce count by 1, exit if - extru pu,27,28,pu ; <= zero -; -mloop blr brindex,gr0 ; br. into table - ; entries of 2 words - extru op2,27,4,brindex ; next 4 bits into index -; -; -; branch table for the multiplication process with four multiplier bits -; -mtable ; two words per entry -; -; ---- bits = 0000 ---- shift product 4 bits ------------------------------- -; - b sh4n+4 ; just shift partial - shd pu,pl,4,pl ; product right 4 bits -; -; ---- bits = 0001 ---- add op1, then shift 4 bits -; - addb,tr op1,pu,sh4n+4 ; add op1 to product, to shift - shd pu,pl,4,pl ; product right 4 bits -; -; ---- bits = 0010 ---- add op1, add op1, then shift 4 bits -; - addb,tr op1,pu,sh4n ; add 2*op1, to shift - addb,uv op1,pu,sh4c ; product right 4 bits -; -; ---- bits = 0011 ---- add op1, add 2*op1, shift 4 bits -; - addb,tr op1,pu,sh4n-4 ; add op1 & 2*op1, shift - sh1add,nsv op1,pu,pu ; product right 4 bits -; -; ---- bits = 0100 ---- shift 2, add op1, shift 2 -; - b sh2sa - shd pu,pl,2,pl ; shift product 2 bits -; -; ---- bits = 0101 ---- add op1, shift 2, add op1, and shift 2 again -; - addb,tr op1,pu,sh2us ; add op1 to product - shd pu,pl,2,pl ; shift 2 bits -; -; ---- bits = 0110 ---- add op1, add op1, shift 2, add op1, and shift 2 again -; - addb,tr op1,pu,sh2c ; add 2*op1, to shift 2 bits - addb,nuv op1,pu,sh2us ; br. if not overflow -; -; ---- bits = 0111 ---- subtract op1, shift 3, add op1, and shift 1 -; - b sh3s - sub pu,op1,pu ; subtract op1, br. to sh3s - -; -; ---- bits = 1000 ---- shift 3, add op1, shift 1 -; - b sh3sa - shd pu,pl,3,pl ; shift product right 3 bits -; -; ---- bits = 1001 ---- add op1, shift 3, add op1, shift 1 -; - addb,tr op1,pu,sh3us ; add op1, to shift 3, add op1, - shd pu,pl,3,pl ; and shift 1 -; -; ---- bits = 1010 ---- add op1, add op1, shift 3, add op1, shift 1 -; - addb,tr op1,pu,sh3c ; add 2*op1, to shift 3 bits - addb,nuv op1,pu,sh3us ; br. if no overflow -; -; ---- bits = 1011 ---- add -op1, shift 2, add -op1, shift 2, inc. next index -; - addib,tr 1,brindex,sh2s ; add 1 to index, subtract op1, - sub pu,op1,pu ; shift 2 with minus sign -; -; ---- bits = 1100 ---- shift 2, subtract op1, shift 2, increment next index -; - addib,tr 1,brindex,sh2sb ; add 1 to index, to shift - shd pu,pl,2,pl ; shift right 2 bits signed -; -; ---- bits = 1101 ---- add op1, shift 2, add -op1, shift 2 -; - addb,tr op1,pu,sh2ns ; add op1, to shift 2 - shd pu,pl,2,pl ; right 2 unsigned, etc. -; -; ---- bits = 1110 ---- shift 1 signed, add -op1, shift 3 signed -; - addib,tr 1,brindex,sh1sa ; add 1 to index, to shift - shd pu,pl,1,pl ; shift 1 bit -; -; ---- bits = 1111 ---- add -op1, shift 4 signed -; - addib,tr 1,brindex,sh4s ; add 1 to index, subtract op1, - sub pu,op1,pu ; to shift 4 signed - -; -; ---- bits = 10000 ---- shift 4 signed -; - addib,tr 1,brindex,sh4s+4 ; add 1 to index - shd pu,pl,4,pl ; shift 4 signed -; -; ---- end of table --------------------------------------------------------- -; -sh4s shd pu,pl,4,pl - addib,tr -1,cnt,mloop ; loop (count > 0 always here) - shd pm,pu,4,pu ; shift 4, minus signed -; -sh4c addib,> -1,cnt,mloop ; decrement count, loop if > 0 - shd pc,pu,4,pu ; shift 4 with overflow - b signs ; end of multiply - bb,>=,n sign,0,fini ; test sign of procduct -; -mpyb add,= op2,op2,gr0 ; if <> 0, back to main sect. - b mpy1 - sub 0,op2,op2 ; op2 = |multiplier| - add,>= op1,gr0,gr0 ; if op1 < 0, invert sign, - xor pm,sign,sign ; for correct result -; -; special case for multiplier = -2**31, op1 = signed multiplicand -; or multiplicand = -2**31, op1 = signed multiplier -; - shd op1,0,1,pl ; shift op1 left 31 bits -mmax extrs op1,30,31,pu - b signs ; negate product (if needed) - bb,>=,n sign,0,fini ; test sign of product -; -mpya add,= op1,op1,gr0 ; op1 = -2**31, special case - b mpy2 - sub 0,op1,op1 ; op1 = |multiplicand| - add,>= op2,gr0,gr0 ; if op2 < 0, invert sign, - xor pm,sign,sign ; for correct result - movb,tr op2,op1,mmax ; use op2 as multiplicand - shd op1,0,1,pl ; shift it left 31 bits -; -sh3c shd pu,pl,3,pl ; shift product 3 bits - shd pc,pu,3,pu ; shift 3 signed - addb,tr op1,pu,sh1 ; add op1, to shift 1 bit - shd pu,pl,1,pl -; -sh3us extru pu,28,29,pu ; shift 3 unsigned - addb,tr op1,pu,sh1 ; add op1, to shift 1 bit - shd pu,pl,1,pl -; -sh3sa extrs pu,28,29,pu ; shift 3 signed - addb,tr op1,pu,sh1 ; add op1, to shift 1 bit - shd pu,pl,1,pl -; -sh3s shd pu,pl,3,pl ; shift 3 minus signed - shd pm,pu,3,pu - addb,tr op1,pu,sh1 ; add op1, to shift 1 bit - shd pu,pl,1,pl -; -sh1 addib,> -1,cnt,mloop ; loop if count > 0 - extru pu,30,31,pu - b signs ; end of multiply - bb,>=,n sign,0,fini ; test sign of product -; -sh2ns addib,tr 1,brindex,sh2sb+4 ; increment index - extru pu,29,30,pu ; shift unsigned -; -sh2s shd pu,pl,2,pl ; shift with minus sign - shd pm,pu,2,pu ; - sub pu,op1,pu ; subtract op1 - shd pu,pl,2,pl ; shift with minus sign - addib,tr -1,cnt,mloop ; decrement count, loop - shd pm,pu,2,pu ; shift with minus sign - ; count never reaches 0 here -; -sh2sb extrs pu,29,30,pu ; shift 2 signed - sub pu,op1,pu ; subtract op1 from product - shd pu,pl,2,pl ; shift with minus sign - addib,tr -1,cnt,mloop ; decrement count, loop - shd pm,pu,2,pu ; shift with minus sign - ; count never reaches 0 here -; -sh1sa extrs pu,30,31,pu ; signed - sub pu,op1,pu ; subtract op1 from product - shd pu,pl,3,pl ; shift 3 with minus sign - addib,tr -1,cnt,mloop ; dec. count, to loop - shd pm,pu,3,pu ; count never reaches 0 here -; -fini0 movib,tr,n 0,pl,fini ; product = 0 as op1 = 0 -; -sh2us extru pu,29,30,pu ; shift 2 unsigned - addb,tr op1,pu,sh2a ; add op1 - shd pu,pl,2,pl ; shift 2 bits -; -sh2c shd pu,pl,2,pl - shd pc,pu,2,pu ; shift with carry - addb,tr op1,pu,sh2a ; add op1 to product - shd pu,pl,2,pl ; br. to sh2 to shift pu -; -sh2sa extrs pu,29,30,pu ; shift with sign - addb,tr op1,pu,sh2a ; add op1 to product - shd pu,pl,2,pl ; br. to sh2 to shift pu -; -sh2a addib,> -1,cnt,mloop ; loop if count > 0 - extru pu,29,30,pu -; -mulend bb,>=,n sign,0,fini ; test sign of product -signs sub 0,pl,pl ; negate product if sign - subb 0,pu,pu ; is negative -; -; finish -; -fini stws pu,0(arg2) ; save high part of result - stws pl,4(arg2) ; save low part of result - - ldws,mb -4(sp),pm ; restore registers - ldws,mb -4(sp),pc ; restore registers - ldws,mb -4(sp),sign ; restore registers - ldws,mb -4(sp),brindex ; restore registers - ldws,mb -4(sp),cnt ; restore registers - ldws,mb -4(sp),op1 ; restore registers - ldws,mb -4(sp),pl ; restore registers - bv 0(rp) ; return - ldws,mb -4(sp),pu ; restore registers -EXIT(s_xmpy) - - .end diff --git a/sys/arch/hppa/spmath/impyu.S b/sys/arch/hppa/spmath/impyu.S deleted file mode 100644 index e6884da9e..000000000 --- a/sys/arch/hppa/spmath/impyu.S +++ /dev/null @@ -1,289 +0,0 @@ -/* $OpenBSD: impyu.S,v 1.12 2011/04/16 20:52:12 deraadt Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)impyu.s: Revision: 1.11.88.1 Date: 93/12/07 15:06:31 */ - -#include -#include - -;**************************************************************************** -; -;Implement an integer multiply routine for 32-bit operands and 64-bit product -; with operand values of zero (multiplicand only) and 2**32reated specially. -; The algorithm uses the multiplier, four bits at a time, from right to left, -; to generate partial product. Execution speed is more important than program -; size in this implementation. -; -;****************************************************************************** -; -; Definitions - General registers -; -gr0 .reg %r0 ; General register zero -pu .reg %r3 ; upper part of product -pl .reg %r4 ; lower part of product -op2 .reg %r4 ; multiplier -op1 .reg %r5 ; multiplicand -cnt .reg %r6 ; count in multiply -brindex .reg %r7 ; index into the br. table -saveop2 .reg %r8 ; save op2 if high bit of multiplicand - ; is set -pc .reg %r9 ; carry bit of product, = 00...01 -pm .reg %r10 ; value of -1 used in shifting -temp .reg %r6 - -;**************************************************************************** - .text -LEAF_ENTRY(u_xmpy) - stws,ma pu,4(sp) ; save registers on stack - stws,ma pl,4(sp) ; save registers on stack - stws,ma op1,4(sp) ; save registers on stack - stws,ma cnt,4(sp) ; save registers on stack - stws,ma brindex,4(sp) ; save registers on stack - stws,ma saveop2,4(sp) ; save registers on stack - stws,ma pc,4(sp) ; save registers on stack - stws,ma pm,4(sp) ; save registers on stack -; -; Start multiply process -; - ldws 0(arg0),op1 ; get multiplicand - ldws 0(arg1),op2 ; get multiplier - addib,= 0,op1,fini0 ; op1 = 0, product = 0 - addi 0,gr0,pu ; clear product - bb,>= op1,0,mpy1 ; test msb of multiplicand - addi 0,gr0,saveop2 ; clear saveop2 -; -; msb of multiplicand is set so will save multiplier for a final -; addition into the result -; - extru,= op1,31,31,op1 ; clear msb of multiplicand - b mpy1 ; if op1 < 2**32, start multiply - add op2,gr0,saveop2 ; save op2 in saveop2 - shd gr0,op2,1,pu ; shift op2 left 31 for result - b fini ; go to finish - shd op2,gr0,1,pl -; -mpy1 addi -1,gr0,pm ; initialize pm to 111...1 - addi 1,gr0,pc ; initialize pc to 00...01 - movib,tr 8,cnt,mloop ; set count for mpy loop - extru op2,31,4,brindex ; 4 bits as index into table -; - .align 8 -; - b sh4c ; br. if sign overflow -sh4n shd pu,pl,4,pl ; shift product right 4 bits - addib,<= -1,cnt,mulend ; reduce count by 1, exit if - extru pu,27,28,pu ; <= zero -; -mloop blr brindex,gr0 ; br. into table - ; entries of 2 words - extru op2,27,4,brindex ; next 4 bits into index -; -; -; branch table for the multiplication process with four multiplier bits -; -mtable ; two words per entry -; -; ---- bits = 0000 ---- shift product 4 bits ------------------------------- -; - b sh4n+4 ; just shift partial - shd pu,pl,4,pl ; product right 4 bits -; -; ---- bits = 0001 ---- add op1, then shift 4 bits -; - addb,tr op1,pu,sh4n+4 ; add op1 to product, to shift - shd pu,pl,4,pl ; product right 4 bits -; -; ---- bits = 0010 ---- add op1, add op1, then shift 4 bits -; - addb,tr op1,pu,sh4n ; add 2*op1, to shift - addb,uv op1,pu,sh4c ; product right 4 bits -; -; ---- bits = 0011 ---- add op1, add 2*op1, shift 4 bits -; - addb,tr op1,pu,sh4n-4 ; add op1 & 2*op1, shift - sh1add,nuv op1,pu,pu ; product right 4 bits -; -; ---- bits = 0100 ---- shift 2, add op1, shift 2 -; - b sh2sa - shd pu,pl,2,pl ; shift product 2 bits -; -; ---- bits = 0101 ---- add op1, shift 2, add op1, and shift 2 again -; - addb,tr op1,pu,sh2us ; add op1 to product - shd pu,pl,2,pl ; shift 2 bits -; -; ---- bits = 0110 ---- add op1, add op1, shift 2, add op1, and shift 2 again -; - addb,tr op1,pu,sh2c ; add 2*op1, to shift 2 bits - addb,nuv op1,pu,sh2us ; br. if not overflow -; -; ---- bits = 0111 ---- subtract op1, shift 3, add op1, and shift 1 -; - b sh3s - sub pu,op1,pu ; subtract op1, br. to sh3s - -; -; ---- bits = 1000 ---- shift 3, add op1, shift 1 -; - b sh3sa - shd pu,pl,3,pl ; shift product right 3 bits -; -; ---- bits = 1001 ---- add op1, shift 3, add op1, shift 1 -; - addb,tr op1,pu,sh3us ; add op1, to shift 3, add op1, - shd pu,pl,3,pl ; and shift 1 -; -; ---- bits = 1010 ---- add op1, add op1, shift 3, add op1, shift 1 -; - addb,tr op1,pu,sh3c ; add 2*op1, to shift 3 bits - addb,nuv op1,pu,sh3us ; br. if no overflow -; -; ---- bits = 1011 ---- add -op1, shift 2, add -op1, shift 2, inc. next index -; - addib,tr 1,brindex,sh2s ; add 1 to index, subtract op1, - sub pu,op1,pu ; shift 2 with minus sign -; -; ---- bits = 1100 ---- shift 2, subtract op1, shift 2, increment next index -; - addib,tr 1,brindex,sh2sb ; add 1 to index, to shift - shd pu,pl,2,pl ; shift right 2 bits signed -; -; ---- bits = 1101 ---- add op1, shift 2, add -op1, shift 2 -; - addb,tr op1,pu,sh2ns ; add op1, to shift 2 - shd pu,pl,2,pl ; right 2 unsigned, etc. -; -; ---- bits = 1110 ---- shift 1 signed, add -op1, shift 3 signed -; - addib,tr 1,brindex,sh1sa ; add 1 to index, to shift - shd pu,pl,1,pl ; shift 1 bit -; -; ---- bits = 1111 ---- add -op1, shift 4 signed -; - addib,tr 1,brindex,sh4s ; add 1 to index, subtract op1, - sub pu,op1,pu ; to shift 4 signed - -; -; ---- bits = 10000 ---- shift 4 signed -; - addib,tr 1,brindex,sh4s+4 ; add 1 to index - shd pu,pl,4,pl ; shift 4 signed -; -; ---- end of table --------------------------------------------------------- -; -sh4s shd pu,pl,4,pl - addib,> -1,cnt,mloop ; decrement count, loop if > 0 - shd pm,pu,4,pu ; shift 4, minus signed - addb,tr op1,pu,lastadd ; do one more add, then finish - addb,=,n saveop2,gr0,fini ; check saveop2 -; -sh4c addib,> -1,cnt,mloop ; decrement count, loop if > 0 - shd pc,pu,4,pu ; shift 4 with overflow - b lastadd ; end of multiply - addb,=,n saveop2,gr0,fini ; check saveop2 -; -sh3c shd pu,pl,3,pl ; shift product 3 bits - shd pc,pu,3,pu ; shift 3 signed - addb,tr op1,pu,sh1 ; add op1, to shift 1 bit - shd pu,pl,1,pl -; -sh3us extru pu,28,29,pu ; shift 3 unsigned - addb,tr op1,pu,sh1 ; add op1, to shift 1 bit - shd pu,pl,1,pl -; -sh3sa extrs pu,28,29,pu ; shift 3 signed - addb,tr op1,pu,sh1 ; add op1, to shift 1 bit - shd pu,pl,1,pl -; -sh3s shd pu,pl,3,pl ; shift 3 minus signed - shd pm,pu,3,pu - addb,tr op1,pu,sh1 ; add op1, to shift 1 bit - shd pu,pl,1,pl -; -sh1 addib,> -1,cnt,mloop ; loop if count > 0 - extru pu,30,31,pu - b lastadd ; end of multiply - addb,=,n saveop2,gr0,fini ; check saveop2 -; -sh2ns addib,tr 1,brindex,sh2sb+4 ; increment index - extru pu,29,30,pu ; shift unsigned -; -sh2s shd pu,pl,2,pl ; shift with minus sign - shd pm,pu,2,pu ; - sub pu,op1,pu ; subtract op1 - shd pu,pl,2,pl ; shift with minus sign - addib,> -1,cnt,mloop ; decrement count, loop if > 0 - shd pm,pu,2,pu ; shift with minus sign - addb,tr op1,pu,lastadd ; do one more add, then finish - addb,=,n saveop2,gr0,fini ; check saveop2 -; -sh2sb extrs pu,29,30,pu ; shift 2 signed - sub pu,op1,pu ; subtract op1 from product - shd pu,pl,2,pl ; shift with minus sign - addib,> -1,cnt,mloop ; decrement count, loop if > 0 - shd pm,pu,2,pu ; shift with minus sign - addb,tr op1,pu,lastadd ; do one more add, then finish - addb,=,n saveop2,gr0,fini ; check saveop2 -; -sh1sa extrs pu,30,31,pu ; signed - sub pu,op1,pu ; subtract op1 from product - shd pu,pl,3,pl ; shift 3 with minus sign - addib,> -1,cnt,mloop ; decrement count, loop if >0 - shd pm,pu,3,pu - addb,tr op1,pu,lastadd ; do one more add, then finish - addb,=,n saveop2,gr0,fini ; check saveop2 -; -fini0 movib,tr 0,pl,fini ; product = 0 as op1 = 0 - stws pu,0(arg2) ; save high part of result -; -sh2us extru pu,29,30,pu ; shift 2 unsigned - addb,tr op1,pu,sh2a ; add op1 - shd pu,pl,2,pl ; shift 2 bits -; -sh2c shd pu,pl,2,pl - shd pc,pu,2,pu ; shift with carry - addb,tr op1,pu,sh2a ; add op1 to product - shd pu,pl,2,pl ; br. to sh2 to shift pu -; -sh2sa extrs pu,29,30,pu ; shift with sign - addb,tr op1,pu,sh2a ; add op1 to product - shd pu,pl,2,pl ; br. to sh2 to shift pu -; -sh2a addib,> -1,cnt,mloop ; loop if count > 0 - extru pu,29,30,pu -; -mulend addb,=,n saveop2,gr0,fini ; check saveop2 -lastadd shd saveop2,gr0,1,temp ; if saveop2 <> 0, shift it - shd gr0,saveop2,1,saveop2 ; left 31 and add to result - add pl,temp,pl - addc pu,saveop2,pu -; -; finish -; -fini stws pu,0(arg2) ; save high part of result - stws pl,4(arg2) ; save low part of result - - ldws,mb -4(sp),pm ; restore registers - ldws,mb -4(sp),pc ; restore registers - ldws,mb -4(sp),saveop2 ; restore registers - ldws,mb -4(sp),brindex ; restore registers - ldws,mb -4(sp),cnt ; restore registers - ldws,mb -4(sp),op1 ; restore registers - ldws,mb -4(sp),pl ; restore registers - bv 0(rp) ; return - ldws,mb -4(sp),pu ; restore registers -EXIT(u_xmpy) - - .end diff --git a/sys/arch/hppa/spmath/md.h b/sys/arch/hppa/spmath/md.h deleted file mode 100644 index ac007eada..000000000 --- a/sys/arch/hppa/spmath/md.h +++ /dev/null @@ -1,81 +0,0 @@ -/* $OpenBSD: md.h,v 1.7 2003/04/10 17:27:58 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)md.h: Revision: 1.8.88.1 Date: 93/12/07 15:06:33 */ - -#include - -/***************************************************************** - * Muliply/Divide SFU Internal State * - *****************************************************************/ -struct mdsfu_register { - int rslt_hi, - rslt_lo, - ovflow; - }; - -#define result_hi result->rslt_hi -#define result_lo result->rslt_lo -#define overflow result->ovflow - -/* - * Constants - */ - -#undef FALSE -#define FALSE 0 - -#undef TRUE -#define TRUE (!FALSE) - -#undef NIL -#define NIL 0 - -#define WORD_LEN 32 -#define BIT0 1<<31 -#define BIT28 0x8 -#define BIT29 0x4 -#define BIT30 0x2 -#define BIT31 0x1 - - /* Simply copy the arguments to the emulated copies of the registers */ -#define mdrr(reg1,reg2,result) {result_hi = reg1;result_lo = reg2;} - -/* - * Structures - */ - -struct md_state { - int resulthi, /* high word of result */ - resultlo; /* low word of result */ -}; - -void divsfm(int, int, struct mdsfu_register *); -void divsfr(int, int, struct mdsfu_register *); -void divsim(int, int, struct mdsfu_register *); -void divsir(int, int, struct mdsfu_register *); - -void divu(int, int, int, struct mdsfu_register *); -void divufr(unsigned int, unsigned int, struct mdsfu_register *); -void divuir(unsigned int, unsigned int, struct mdsfu_register *); - -void mpyaccs(int, int, struct mdsfu_register *); -void mpyaccu(unsigned int, unsigned int, struct mdsfu_register *); -void mpys(int, int, struct mdsfu_register *); -void mpyscv(int, int, struct mdsfu_register *); -void mpyu(unsigned int, unsigned int, struct mdsfu_register *); -void mpyucv(unsigned int, unsigned int, struct mdsfu_register *); - -int s_xmpy(int *, int *, struct mdsfu_register *); -int u_xmpy(int *, int *, struct mdsfu_register *); diff --git a/sys/arch/hppa/spmath/mpyaccs.c b/sys/arch/hppa/spmath/mpyaccs.c deleted file mode 100644 index 65c7e9ed1..000000000 --- a/sys/arch/hppa/spmath/mpyaccs.c +++ /dev/null @@ -1,40 +0,0 @@ -/* $OpenBSD: mpyaccs.c,v 1.6 2003/04/10 17:27:58 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)mpyaccs.c: Revision: 1.6.88.1 Date: 93/12/07 15:06:39 */ - -#include "md.h" - -void -mpyaccs(opnd1,opnd2,result) - int opnd1, opnd2; - struct mdsfu_register *result; -{ - struct mdsfu_register temp; - int carry, sign; - - s_xmpy(&opnd1,&opnd2,&temp); - - /* get result of low word add, and check for carry out */ - if ((result_lo += (unsigned)temp.rslt_lo) < (unsigned)temp.rslt_lo) - carry = 1; - else - carry = 0; - - /* get result of high word add, and determine overflow status */ - sign = result_hi ^ temp.rslt_hi; - result_hi += temp.rslt_hi + carry; - if (sign >= 0 && (temp.rslt_hi ^ result_hi) < 0) - overflow = TRUE; -} diff --git a/sys/arch/hppa/spmath/mpyaccu.c b/sys/arch/hppa/spmath/mpyaccu.c deleted file mode 100644 index 7e5d3d4ac..000000000 --- a/sys/arch/hppa/spmath/mpyaccu.c +++ /dev/null @@ -1,39 +0,0 @@ -/* $OpenBSD: mpyaccu.c,v 1.7 2003/04/10 17:27:58 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)mpyaccu.c: Revision: 1.6.88.1 Date: 93/12/07 15:06:41 */ - -#include "md.h" - -void -mpyaccu(opnd1,opnd2,result) - unsigned int opnd1, opnd2; - struct mdsfu_register *result; -{ - struct mdsfu_register temp; - int carry; - - u_xmpy(&opnd1,&opnd2,&temp); - - /* get result of low word add, and check for carry out */ - if ((result_lo += (unsigned)temp.rslt_lo) < (unsigned)temp.rslt_lo) - carry = 1; - else - carry = 0; - - /* get result of high word add, and determine overflow status */ - if ((result_hi += (unsigned)temp.rslt_hi + carry) < - (unsigned)temp.rslt_hi) - overflow = TRUE; -} diff --git a/sys/arch/hppa/spmath/mpys.c b/sys/arch/hppa/spmath/mpys.c deleted file mode 100644 index d8c3f7e45..000000000 --- a/sys/arch/hppa/spmath/mpys.c +++ /dev/null @@ -1,32 +0,0 @@ -/* $OpenBSD: mpys.c,v 1.7 2003/04/10 17:27:58 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)mpys.c: Revision: 1.6.88.1 Date: 93/12/07 15:06:43 */ - -#include "md.h" - -void -mpys(opnd1,opnd2,result) - int opnd1, opnd2; - struct mdsfu_register *result; -{ - s_xmpy(&opnd1,&opnd2,result); - - /* determine overflow status */ - if ((result_hi == 0 && result_lo >= 0) || - (result_hi == -1 && result_lo < 0)) - overflow = FALSE; - else - overflow = TRUE; -} diff --git a/sys/arch/hppa/spmath/mpyscv.c b/sys/arch/hppa/spmath/mpyscv.c deleted file mode 100644 index 7f7ea4e6b..000000000 --- a/sys/arch/hppa/spmath/mpyscv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* $OpenBSD: mpyscv.c,v 1.7 2003/04/10 17:27:58 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)mpyscv.c: Revision: 1.6.88.1 Date: 93/12/07 15:06:45 */ - -#include "md.h" - -void -mpyscv(opnd1,opnd2,result) - int opnd1, opnd2; - struct mdsfu_register *result; -{ - s_xmpy(&opnd1,&opnd2,result); - overflow = FALSE; -} diff --git a/sys/arch/hppa/spmath/mpyu.c b/sys/arch/hppa/spmath/mpyu.c deleted file mode 100644 index 18945c248..000000000 --- a/sys/arch/hppa/spmath/mpyu.c +++ /dev/null @@ -1,32 +0,0 @@ -/* $OpenBSD: mpyu.c,v 1.6 2003/04/10 17:27:58 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)mpyu.c: Revision: 1.6.88.1 Date: 93/12/07 15:06:48 */ - -#include "md.h" - -void -mpyu(opnd1,opnd2,result) - unsigned int opnd1, opnd2; - struct mdsfu_register *result; -{ - u_xmpy(&opnd1,&opnd2,result); - - /* determine overflow status */ - if (result_hi) - overflow = TRUE; - else - overflow = FALSE; - return; -} diff --git a/sys/arch/hppa/spmath/mpyucv.c b/sys/arch/hppa/spmath/mpyucv.c deleted file mode 100644 index 905c2eb15..000000000 --- a/sys/arch/hppa/spmath/mpyucv.c +++ /dev/null @@ -1,26 +0,0 @@ -/* $OpenBSD: mpyucv.c,v 1.6 2003/04/10 17:27:58 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)mpyucv.c: Revision: 1.6.88.1 Date: 93/12/07 15:06:50 */ - -#include "md.h" - -void -mpyucv(opnd1,opnd2,result) - unsigned int opnd1, opnd2; - struct mdsfu_register *result; -{ - u_xmpy(&opnd1,&opnd2,result); - overflow = FALSE; -} diff --git a/sys/arch/hppa/spmath/quad_float.h b/sys/arch/hppa/spmath/quad_float.h deleted file mode 100644 index a0f84040c..000000000 --- a/sys/arch/hppa/spmath/quad_float.h +++ /dev/null @@ -1,77 +0,0 @@ -/* $OpenBSD: quad_float.h,v 1.9 2021/03/11 11:16:57 jsg Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)quad_float.h: Revision: 1.7.88.1 Date: 93/12/07 15:06:55 */ - -/****************************** - * Quad precision functions * - ******************************/ - -/* 32-bit word grabbing functions */ -#define Quad_firstword(value) Qallp1(value) -#define Quad_secondword(value) Qallp2(value) -#define Quad_thirdword(value) Qallp3(value) -#define Quad_fourthword(value) Qallp4(value) - - -/* This magnitude comparison uses the signless first words and - * the regular part2 words. The comparison is graphically: - * - * 1st greater? ----------->| - * | - * 1st less?-----------------+------->| - * | | - * 2nd greater?------------->| | - * | | - * 2nd less?-----------------+------->| - * | | - * 3rd greater?------------->| | - * | | - * 3rd less?-----------------+------->| - * | | - * 4th greater or equal?---->| | - * | | - * False True - */ -#define Quad_ismagnitudeless(leftp3,leftp4,rightp1,rightp2,rightp3,rightp4,signlessleft,signlessright) \ -/* Quad_floating_point left, right; * \ - * unsigned int signlessleft, signlessright; */ \ - ( signlessleft<=signlessright && \ - (signlessleft SGL_THRESHOLD) - { - diff_exponent = SGL_THRESHOLD; - } - - /* Align right operand by shifting to right */ - Sgl_right_align(/*operand*/right,/*shifted by*/diff_exponent, - /*and lower to*/extent); - - /* Treat sum and difference of the operands separately. */ - if( (/*signed*/int) save < 0 ) - { - /* - * Difference of the two operands. Their can be no overflow. A - * borrow can occur out of the hidden bit and force a post - * normalization phase. - */ - Sgl_subtract_withextension(left,/*minus*/right,/*with*/extent,/*into*/result); - if(Sgl_iszero_hidden(result)) - { - /* Handle normalization */ - /* A straight forward algorithm would now shift the result - * and extension left until the hidden bit becomes one. Not - * all of the extension bits need participate in the shift. - * Only the two most significant bits (round and guard) are - * needed. If only a single shift is needed then the guard - * bit becomes a significant low order bit and the extension - * must participate in the rounding. If more than a single - * shift is needed, then all bits to the right of the guard - * bit are zeros, and the guard bit may or may not be zero. */ - sign_save = Sgl_signextendedsign(result); - Sgl_leftshiftby1_withextent(result,extent,result); - - /* Need to check for a zero result. The sign and exponent - * fields have already been zeroed. The more efficient test - * of the full object can be used. - */ - if(Sgl_iszero(result)) - /* Must have been "x-x" or "x+(-x)". */ - { - if(Is_rounding_mode(ROUNDMINUS)) Sgl_setone_sign(result); - *dstptr = result; - return(NOEXCEPTION); - } - result_exponent--; - /* Look to see if normalization is finished. */ - if(Sgl_isone_hidden(result)) - { - if(result_exponent==0) - { - /* Denormalized, exponent should be zero. Left operand * - * was normalized, so extent (guard, round) was zero */ - goto underflow; - } - else - { - /* No further normalization is needed. */ - Sgl_set_sign(result,/*using*/sign_save); - Ext_leftshiftby1(extent); - goto round; - } - } - - /* Check for denormalized, exponent should be zero. Left * - * operand was normalized, so extent (guard, round) was zero */ - if(!(underflowtrap = Is_underflowtrap_enabled()) && - result_exponent==0) goto underflow; - - /* Shift extension to complete one bit of normalization and - * update exponent. */ - Ext_leftshiftby1(extent); - - /* Discover first one bit to determine shift amount. Use a - * modified binary search. We have already shifted the result - * one position right and still not found a one so the remainder - * of the extension must be zero and simplifies rounding. */ - /* Scan bytes */ - while(Sgl_iszero_hiddenhigh7mantissa(result)) - { - Sgl_leftshiftby8(result); - if((result_exponent -= 8) <= 0 && !underflowtrap) - goto underflow; - } - /* Now narrow it down to the nibble */ - if(Sgl_iszero_hiddenhigh3mantissa(result)) - { - /* The lower nibble contains the normalizing one */ - Sgl_leftshiftby4(result); - if((result_exponent -= 4) <= 0 && !underflowtrap) - goto underflow; - } - /* Select case were first bit is set (already normalized) - * otherwise select the proper shift. */ - if((jumpsize = Sgl_hiddenhigh3mantissa(result)) > 7) - { - /* Already normalized */ - if(result_exponent <= 0) goto underflow; - Sgl_set_sign(result,/*using*/sign_save); - Sgl_set_exponent(result,/*using*/result_exponent); - *dstptr = result; - return(NOEXCEPTION); - } - Sgl_sethigh4bits(result,/*using*/sign_save); - switch(jumpsize) - { - case 1: - { - Sgl_leftshiftby3(result); - result_exponent -= 3; - break; - } - case 2: - case 3: - { - Sgl_leftshiftby2(result); - result_exponent -= 2; - break; - } - case 4: - case 5: - case 6: - case 7: - { - Sgl_leftshiftby1(result); - result_exponent -= 1; - break; - } - } - if(result_exponent > 0) - { - Sgl_set_exponent(result,/*using*/result_exponent); - *dstptr = result; - return(NOEXCEPTION); /* Sign bit is already set */ - } - /* Fixup potential underflows */ - underflow: - if(Is_underflowtrap_enabled()) - { - Sgl_set_sign(result,sign_save); - Sgl_setwrapped_exponent(result,result_exponent,unfl); - *dstptr = result; - /* inexact = FALSE; */ - return(UNDERFLOWEXCEPTION); - } - /* - * Since we cannot get an inexact denormalized result, - * we can now return. - */ - Sgl_right_align(result,/*by*/(1-result_exponent),extent); - Sgl_clear_signexponent(result); - Sgl_set_sign(result,sign_save); - *dstptr = result; - return(NOEXCEPTION); - } /* end if(hidden...)... */ - /* Fall through and round */ - } /* end if(save < 0)... */ - else - { - /* Add magnitudes */ - Sgl_addition(left,right,/*to*/result); - if(Sgl_isone_hiddenoverflow(result)) - { - /* Prenormalization required. */ - Sgl_rightshiftby1_withextent(result,extent,extent); - Sgl_arithrightshiftby1(result); - result_exponent++; - } /* end if hiddenoverflow... */ - } /* end else ...add magnitudes... */ - - /* Round the result. If the extension is all zeros,then the result is - * exact. Otherwise round in the correct direction. No underflow is - * possible. If a postnormalization is necessary, then the mantissa is - * all zeros so no shift is needed. */ - round: - if(Ext_isnotzero(extent)) - { - inexact = TRUE; - switch(Rounding_mode()) - { - case ROUNDNEAREST: /* The default. */ - if(Ext_isone_sign(extent)) - { - /* at least 1/2 ulp */ - if(Ext_isnotzero_lower(extent) || - Sgl_isone_lowmantissa(result)) - { - /* either exactly half way and odd or more than 1/2ulp */ - Sgl_increment(result); - } - } - break; - - case ROUNDPLUS: - if(Sgl_iszero_sign(result)) - { - /* Round up positive results */ - Sgl_increment(result); - } - break; - - case ROUNDMINUS: - if(Sgl_isone_sign(result)) - { - /* Round down negative results */ - Sgl_increment(result); - } - - case ROUNDZERO:; - /* truncate is simple */ - } /* end switch... */ - if(Sgl_isone_hiddenoverflow(result)) result_exponent++; - } - if(result_exponent == SGL_INFINITY_EXPONENT) - { - /* Overflow */ - if(Is_overflowtrap_enabled()) - { - Sgl_setwrapped_exponent(result,result_exponent,ovfl); - *dstptr = result; - if (inexact) { - if (Is_inexacttrap_enabled()) - return(OVERFLOWEXCEPTION | INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(OVERFLOWEXCEPTION); - } - else - { - Set_overflowflag(); - inexact = TRUE; - Sgl_setoverflow(result); - } - } - else Sgl_set_exponent(result,result_exponent); - *dstptr = result; - if(inexact) { - if(Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/sfcmp.c b/sys/arch/hppa/spmath/sfcmp.c deleted file mode 100644 index e8583fe28..000000000 --- a/sys/arch/hppa/spmath/sfcmp.c +++ /dev/null @@ -1,128 +0,0 @@ -/* $OpenBSD: sfcmp.c,v 1.6 2002/09/20 19:26:59 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)sfcmp.c: Revision: 1.7.88.2 Date: 93/12/08 13:28:43 */ - -#include "float.h" -#include "sgl_float.h" - -/* - * sgl_cmp: compare two values - */ -int -sgl_fcmp(leftptr, rightptr, cond, status) - sgl_floating_point *leftptr, *rightptr; - unsigned int cond; /* The predicate to be tested */ - unsigned int *status; -{ - register unsigned int left, right; - register int xorresult; - - /* Create local copies of the numbers */ - left = *leftptr; - right = *rightptr; - /* - * Test for NaN - */ - if( (Sgl_exponent(left) == SGL_INFINITY_EXPONENT) - || (Sgl_exponent(right) == SGL_INFINITY_EXPONENT) ) - { - /* Check if a NaN is involved. Signal an invalid exception when - * comparing a signaling NaN or when comparing quiet NaNs and the - * low bit of the condition is set */ - if( ( (Sgl_exponent(left) == SGL_INFINITY_EXPONENT) - && Sgl_isnotzero_mantissa(left) - && (Exception(cond) || Sgl_isone_signaling(left))) - || - ( (Sgl_exponent(right) == SGL_INFINITY_EXPONENT) - && Sgl_isnotzero_mantissa(right) - && (Exception(cond) || Sgl_isone_signaling(right)) ) ) - { - if( Is_invalidtrap_enabled() ) { - Set_status_cbit(Unordered(cond)); - return(INVALIDEXCEPTION); - } - else Set_invalidflag(); - Set_status_cbit(Unordered(cond)); - return(NOEXCEPTION); - } - /* All the exceptional conditions are handled, now special case - NaN compares */ - else if( ((Sgl_exponent(left) == SGL_INFINITY_EXPONENT) - && Sgl_isnotzero_mantissa(left)) - || - ((Sgl_exponent(right) == SGL_INFINITY_EXPONENT) - && Sgl_isnotzero_mantissa(right)) ) - { - /* NaNs always compare unordered. */ - Set_status_cbit(Unordered(cond)); - return(NOEXCEPTION); - } - /* infinities will drop down to the normal compare mechanisms */ - } - /* First compare for unequal signs => less or greater or - * special equal case */ - Sgl_xortointp1(left,right,xorresult); - if( xorresult < 0 ) - { - /* left negative => less, left positive => greater. - * equal is possible if both operands are zeros. */ - if( Sgl_iszero_exponentmantissa(left) - && Sgl_iszero_exponentmantissa(right) ) - { - Set_status_cbit(Equal(cond)); - } - else if( Sgl_isone_sign(left) ) - { - Set_status_cbit(Lessthan(cond)); - } - else - { - Set_status_cbit(Greaterthan(cond)); - } - } - /* Signs are the same. Treat negative numbers separately - * from the positives because of the reversed sense. */ - else if( Sgl_all(left) == Sgl_all(right) ) - { - Set_status_cbit(Equal(cond)); - } - else if( Sgl_iszero_sign(left) ) - { - /* Positive compare */ - if( Sgl_all(left) < Sgl_all(right) ) - { - Set_status_cbit(Lessthan(cond)); - } - else - { - Set_status_cbit(Greaterthan(cond)); - } - } - else - { - /* Negative compare. Signed or unsigned compares - * both work the same. That distinction is only - * important when the sign bits differ. */ - if( Sgl_all(left) > Sgl_all(right) ) - { - Set_status_cbit(Lessthan(cond)); - } - else - { - Set_status_cbit(Greaterthan(cond)); - } - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/sfdiv.c b/sys/arch/hppa/spmath/sfdiv.c deleted file mode 100644 index 724d4681c..000000000 --- a/sys/arch/hppa/spmath/sfdiv.c +++ /dev/null @@ -1,368 +0,0 @@ -/* $OpenBSD: sfdiv.c,v 1.5 2002/05/07 22:19:30 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)sfdiv.c: Revision: 2.9.88.1 Date: 93/12/07 15:07:05 */ - -#include "float.h" -#include "sgl_float.h" - -/* - * Single Precision Floating-point Divide - */ -int -sgl_fdiv(srcptr1,srcptr2,dstptr,status) - sgl_floating_point *srcptr1, *srcptr2, *dstptr; - unsigned int *status; -{ - register unsigned int opnd1, opnd2, opnd3, result; - register int dest_exponent, count; - register int inexact = FALSE, guardbit = FALSE, stickybit = FALSE; - int is_tiny; - - opnd1 = *srcptr1; - opnd2 = *srcptr2; - /* - * set sign bit of result - */ - if (Sgl_sign(opnd1) ^ Sgl_sign(opnd2)) Sgl_setnegativezero(result); - else Sgl_setzero(result); - /* - * check first operand for NaN's or infinity - */ - if (Sgl_isinfinity_exponent(opnd1)) { - if (Sgl_iszero_mantissa(opnd1)) { - if (Sgl_isnotnan(opnd2)) { - if (Sgl_isinfinity(opnd2)) { - /* - * invalid since both operands - * are infinity - */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - Set_invalidflag(); - Sgl_makequietnan(result); - *dstptr = result; - return(NOEXCEPTION); - } - /* - * return infinity - */ - Sgl_setinfinity_exponentmantissa(result); - *dstptr = result; - return(NOEXCEPTION); - } - } - else { - /* - * is NaN; signaling or quiet? - */ - if (Sgl_isone_signaling(opnd1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(opnd1); - } - /* - * is second operand a signaling NaN? - */ - else if (Sgl_is_signalingnan(opnd2)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(opnd2); - *dstptr = opnd2; - return(NOEXCEPTION); - } - /* - * return quiet NaN - */ - *dstptr = opnd1; - return(NOEXCEPTION); - } - } - /* - * check second operand for NaN's or infinity - */ - if (Sgl_isinfinity_exponent(opnd2)) { - if (Sgl_iszero_mantissa(opnd2)) { - /* - * return zero - */ - Sgl_setzero_exponentmantissa(result); - *dstptr = result; - return(NOEXCEPTION); - } - /* - * is NaN; signaling or quiet? - */ - if (Sgl_isone_signaling(opnd2)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(opnd2); - } - /* - * return quiet NaN - */ - *dstptr = opnd2; - return(NOEXCEPTION); - } - /* - * check for division by zero - */ - if (Sgl_iszero_exponentmantissa(opnd2)) { - if (Sgl_iszero_exponentmantissa(opnd1)) { - /* invalid since both operands are zero */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - Set_invalidflag(); - Sgl_makequietnan(result); - *dstptr = result; - return(NOEXCEPTION); - } - if (Is_divisionbyzerotrap_enabled()) - return(DIVISIONBYZEROEXCEPTION); - Set_divisionbyzeroflag(); - Sgl_setinfinity_exponentmantissa(result); - *dstptr = result; - return(NOEXCEPTION); - } - /* - * Generate exponent - */ - dest_exponent = Sgl_exponent(opnd1) - Sgl_exponent(opnd2) + SGL_BIAS; - - /* - * Generate mantissa - */ - if (Sgl_isnotzero_exponent(opnd1)) { - /* set hidden bit */ - Sgl_clear_signexponent_set_hidden(opnd1); - } - else { - /* check for zero */ - if (Sgl_iszero_mantissa(opnd1)) { - Sgl_setzero_exponentmantissa(result); - *dstptr = result; - return(NOEXCEPTION); - } - /* is denormalized; want to normalize */ - Sgl_clear_signexponent(opnd1); - Sgl_leftshiftby1(opnd1); - Sgl_normalize(opnd1,dest_exponent); - } - /* opnd2 needs to have hidden bit set with msb in hidden bit */ - if (Sgl_isnotzero_exponent(opnd2)) { - Sgl_clear_signexponent_set_hidden(opnd2); - } - else { - /* is denormalized; want to normalize */ - Sgl_clear_signexponent(opnd2); - Sgl_leftshiftby1(opnd2); - while(Sgl_iszero_hiddenhigh7mantissa(opnd2)) { - Sgl_leftshiftby8(opnd2); - dest_exponent += 8; - } - if(Sgl_iszero_hiddenhigh3mantissa(opnd2)) { - Sgl_leftshiftby4(opnd2); - dest_exponent += 4; - } - while(Sgl_iszero_hidden(opnd2)) { - Sgl_leftshiftby1(opnd2); - dest_exponent += 1; - } - } - - /* Divide the source mantissas */ - - /* - * A non_restoring divide algorithm is used. - */ - Sgl_subtract(opnd1,opnd2,opnd1); - Sgl_setzero(opnd3); - for (count=1;count<=SGL_P && Sgl_all(opnd1);count++) { - Sgl_leftshiftby1(opnd1); - Sgl_leftshiftby1(opnd3); - if (Sgl_iszero_sign(opnd1)) { - Sgl_setone_lowmantissa(opnd3); - Sgl_subtract(opnd1,opnd2,opnd1); - } - else Sgl_addition(opnd1,opnd2,opnd1); - } - if (count <= SGL_P) { - Sgl_leftshiftby1(opnd3); - Sgl_setone_lowmantissa(opnd3); - Sgl_leftshift(opnd3,SGL_P-count); - if (Sgl_iszero_hidden(opnd3)) { - Sgl_leftshiftby1(opnd3); - dest_exponent--; - } - } - else { - if (Sgl_iszero_hidden(opnd3)) { - /* need to get one more bit of result */ - Sgl_leftshiftby1(opnd1); - Sgl_leftshiftby1(opnd3); - if (Sgl_iszero_sign(opnd1)) { - Sgl_setone_lowmantissa(opnd3); - Sgl_subtract(opnd1,opnd2,opnd1); - } - else Sgl_addition(opnd1,opnd2,opnd1); - dest_exponent--; - } - if (Sgl_iszero_sign(opnd1)) guardbit = TRUE; - stickybit = Sgl_all(opnd1); - } - inexact = guardbit | stickybit; - - /* - * round result - */ - if (inexact && (dest_exponent > 0 || Is_underflowtrap_enabled())) { - Sgl_clear_signexponent(opnd3); - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(result)) - Sgl_increment_mantissa(opnd3); - break; - case ROUNDMINUS: - if (Sgl_isone_sign(result)) - Sgl_increment_mantissa(opnd3); - break; - case ROUNDNEAREST: - if (guardbit && - (stickybit || Sgl_isone_lowmantissa(opnd3))) - Sgl_increment_mantissa(opnd3); - } - if (Sgl_isone_hidden(opnd3)) dest_exponent++; - } - Sgl_set_mantissa(result,opnd3); - - /* - * Test for overflow - */ - if (dest_exponent >= SGL_INFINITY_EXPONENT) { - /* trap if OVERFLOWTRAP enabled */ - if (Is_overflowtrap_enabled()) { - /* - * Adjust bias of result - */ - Sgl_setwrapped_exponent(result,dest_exponent,ovfl); - *dstptr = result; - if (inexact) { - if (Is_inexacttrap_enabled()) - return(OVERFLOWEXCEPTION | INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(OVERFLOWEXCEPTION); - } - Set_overflowflag(); - /* set result to infinity or largest number */ - Sgl_setoverflow(result); - inexact = TRUE; - } - /* - * Test for underflow - */ - else if (dest_exponent <= 0) { - /* trap if UNDERFLOWTRAP enabled */ - if (Is_underflowtrap_enabled()) { - /* - * Adjust bias of result - */ - Sgl_setwrapped_exponent(result,dest_exponent,unfl); - *dstptr = result; - if (inexact) { - if (Is_inexacttrap_enabled()) - return(UNDERFLOWEXCEPTION | INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(UNDERFLOWEXCEPTION); - } - - /* Determine if should set underflow flag */ - is_tiny = TRUE; - if (dest_exponent == 0 && inexact) { - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(result)) { - Sgl_increment(opnd3); - if (Sgl_isone_hiddenoverflow(opnd3)) - is_tiny = FALSE; - Sgl_decrement(opnd3); - } - break; - case ROUNDMINUS: - if (Sgl_isone_sign(result)) { - Sgl_increment(opnd3); - if (Sgl_isone_hiddenoverflow(opnd3)) - is_tiny = FALSE; - Sgl_decrement(opnd3); - } - break; - case ROUNDNEAREST: - if (guardbit && (stickybit || - Sgl_isone_lowmantissa(opnd3))) { - Sgl_increment(opnd3); - if (Sgl_isone_hiddenoverflow(opnd3)) - is_tiny = FALSE; - Sgl_decrement(opnd3); - } - break; - } - } - - /* - * denormalize result or set to signed zero - */ - stickybit = inexact; - Sgl_denormalize(opnd3,dest_exponent,guardbit,stickybit,inexact); - - /* return rounded number */ - if (inexact) { - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(result)) { - Sgl_increment(opnd3); - } - break; - case ROUNDMINUS: - if (Sgl_isone_sign(result)) { - Sgl_increment(opnd3); - } - break; - case ROUNDNEAREST: - if (guardbit && (stickybit || - Sgl_isone_lowmantissa(opnd3))) { - Sgl_increment(opnd3); - } - break; - } - if (is_tiny) Set_underflowflag(); - } - Sgl_set_exponentmantissa(result,opnd3); - } - else Sgl_set_exponent(result,dest_exponent); - *dstptr = result; - /* check for inexact */ - if (inexact) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/sfmpy.c b/sys/arch/hppa/spmath/sfmpy.c deleted file mode 100644 index 57809a3a3..000000000 --- a/sys/arch/hppa/spmath/sfmpy.c +++ /dev/null @@ -1,351 +0,0 @@ -/* $OpenBSD: sfmpy.c,v 1.5 2002/05/07 22:19:30 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)sfmpy.c: Revision: 2.9.88.1 Date: 93/12/07 15:07:07 */ - -#include "float.h" -#include "sgl_float.h" - -/* - * Single Precision Floating-point Multiply - */ -int -sgl_fmpy(srcptr1,srcptr2,dstptr,status) - sgl_floating_point *srcptr1, *srcptr2, *dstptr; - unsigned int *status; -{ - register unsigned int opnd1, opnd2, opnd3, result; - register int dest_exponent, count; - register int inexact = FALSE, guardbit = FALSE, stickybit = FALSE; - int is_tiny; - - opnd1 = *srcptr1; - opnd2 = *srcptr2; - /* - * set sign bit of result - */ - if (Sgl_sign(opnd1) ^ Sgl_sign(opnd2)) Sgl_setnegativezero(result); - else Sgl_setzero(result); - /* - * check first operand for NaN's or infinity - */ - if (Sgl_isinfinity_exponent(opnd1)) { - if (Sgl_iszero_mantissa(opnd1)) { - if (Sgl_isnotnan(opnd2)) { - if (Sgl_iszero_exponentmantissa(opnd2)) { - /* - * invalid since operands are infinity - * and zero - */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - Set_invalidflag(); - Sgl_makequietnan(result); - *dstptr = result; - return(NOEXCEPTION); - } - /* - * return infinity - */ - Sgl_setinfinity_exponentmantissa(result); - *dstptr = result; - return(NOEXCEPTION); - } - } - else { - /* - * is NaN; signaling or quiet? - */ - if (Sgl_isone_signaling(opnd1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(opnd1); - } - /* - * is second operand a signaling NaN? - */ - else if (Sgl_is_signalingnan(opnd2)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(opnd2); - *dstptr = opnd2; - return(NOEXCEPTION); - } - /* - * return quiet NaN - */ - *dstptr = opnd1; - return(NOEXCEPTION); - } - } - /* - * check second operand for NaN's or infinity - */ - if (Sgl_isinfinity_exponent(opnd2)) { - if (Sgl_iszero_mantissa(opnd2)) { - if (Sgl_iszero_exponentmantissa(opnd1)) { - /* invalid since operands are zero & infinity */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - Set_invalidflag(); - Sgl_makequietnan(opnd2); - *dstptr = opnd2; - return(NOEXCEPTION); - } - /* - * return infinity - */ - Sgl_setinfinity_exponentmantissa(result); - *dstptr = result; - return(NOEXCEPTION); - } - /* - * is NaN; signaling or quiet? - */ - if (Sgl_isone_signaling(opnd2)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(opnd2); - } - /* - * return quiet NaN - */ - *dstptr = opnd2; - return(NOEXCEPTION); - } - /* - * Generate exponent - */ - dest_exponent = Sgl_exponent(opnd1) + Sgl_exponent(opnd2) - SGL_BIAS; - - /* - * Generate mantissa - */ - if (Sgl_isnotzero_exponent(opnd1)) { - /* set hidden bit */ - Sgl_clear_signexponent_set_hidden(opnd1); - } - else { - /* check for zero */ - if (Sgl_iszero_mantissa(opnd1)) { - Sgl_setzero_exponentmantissa(result); - *dstptr = result; - return(NOEXCEPTION); - } - /* is denormalized, adjust exponent */ - Sgl_clear_signexponent(opnd1); - Sgl_leftshiftby1(opnd1); - Sgl_normalize(opnd1,dest_exponent); - } - /* opnd2 needs to have hidden bit set with msb in hidden bit */ - if (Sgl_isnotzero_exponent(opnd2)) { - Sgl_clear_signexponent_set_hidden(opnd2); - } - else { - /* check for zero */ - if (Sgl_iszero_mantissa(opnd2)) { - Sgl_setzero_exponentmantissa(result); - *dstptr = result; - return(NOEXCEPTION); - } - /* is denormalized; want to normalize */ - Sgl_clear_signexponent(opnd2); - Sgl_leftshiftby1(opnd2); - Sgl_normalize(opnd2,dest_exponent); - } - - /* Multiply two source mantissas together */ - - Sgl_leftshiftby4(opnd2); /* make room for guard bits */ - Sgl_setzero(opnd3); - /* - * Four bits at a time are inspected in each loop, and a - * simple shift and add multiply algorithm is used. - */ - for (count=1;count= 2. */ - dest_exponent++; - } - /* check for denormalized result */ - while (Sgl_iszero_sign(opnd3)) { - Sgl_leftshiftby1(opnd3); - dest_exponent--; - } - /* - * check for guard, sticky and inexact bits - */ - stickybit |= Sgl_all(opnd3) << (SGL_BITLENGTH - SGL_EXP_LENGTH + 1); - guardbit = Sbit24(opnd3); - inexact = guardbit | stickybit; - - /* re-align mantissa */ - Sgl_rightshiftby8(opnd3); - - /* - * round result - */ - if (inexact && (dest_exponent>0 || Is_underflowtrap_enabled())) { - Sgl_clear_signexponent(opnd3); - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(result)) - Sgl_increment(opnd3); - break; - case ROUNDMINUS: - if (Sgl_isone_sign(result)) - Sgl_increment(opnd3); - break; - case ROUNDNEAREST: - if (guardbit && - (stickybit || Sgl_isone_lowmantissa(opnd3))) - Sgl_increment(opnd3); - break; - } - if (Sgl_isone_hidden(opnd3)) dest_exponent++; - } - Sgl_set_mantissa(result,opnd3); - - /* - * Test for overflow - */ - if (dest_exponent >= SGL_INFINITY_EXPONENT) { - /* trap if OVERFLOWTRAP enabled */ - if (Is_overflowtrap_enabled()) { - /* - * Adjust bias of result - */ - Sgl_setwrapped_exponent(result,dest_exponent,ovfl); - *dstptr = result; - if (inexact) { - if (Is_inexacttrap_enabled()) - return(OVERFLOWEXCEPTION | INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(OVERFLOWEXCEPTION); - } - inexact = TRUE; - Set_overflowflag(); - /* set result to infinity or largest number */ - Sgl_setoverflow(result); - } - /* - * Test for underflow - */ - else if (dest_exponent <= 0) { - /* trap if UNDERFLOWTRAP enabled */ - if (Is_underflowtrap_enabled()) { - /* - * Adjust bias of result - */ - Sgl_setwrapped_exponent(result,dest_exponent,unfl); - *dstptr = result; - if (inexact) { - if (Is_inexacttrap_enabled()) - return(UNDERFLOWEXCEPTION | INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(UNDERFLOWEXCEPTION); - } - - /* Determine if should set underflow flag */ - is_tiny = TRUE; - if (dest_exponent == 0 && inexact) { - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(result)) { - Sgl_increment(opnd3); - if (Sgl_isone_hiddenoverflow(opnd3)) - is_tiny = FALSE; - Sgl_decrement(opnd3); - } - break; - case ROUNDMINUS: - if (Sgl_isone_sign(result)) { - Sgl_increment(opnd3); - if (Sgl_isone_hiddenoverflow(opnd3)) - is_tiny = FALSE; - Sgl_decrement(opnd3); - } - break; - case ROUNDNEAREST: - if (guardbit && (stickybit || - Sgl_isone_lowmantissa(opnd3))) { - Sgl_increment(opnd3); - if (Sgl_isone_hiddenoverflow(opnd3)) - is_tiny = FALSE; - Sgl_decrement(opnd3); - } - break; - } - } - - /* - * denormalize result or set to signed zero - */ - stickybit = inexact; - Sgl_denormalize(opnd3,dest_exponent,guardbit,stickybit,inexact); - - /* return zero or smallest number */ - if (inexact) { - switch (Rounding_mode()) { - case ROUNDPLUS: - if (Sgl_iszero_sign(result)) - Sgl_increment(opnd3); - break; - case ROUNDMINUS: - if (Sgl_isone_sign(result)) - Sgl_increment(opnd3); - break; - case ROUNDNEAREST: - if (guardbit && (stickybit || - Sgl_isone_lowmantissa(opnd3))) - Sgl_increment(opnd3); - break; - } - if (is_tiny) Set_underflowflag(); - } - Sgl_set_exponentmantissa(result,opnd3); - } - else Sgl_set_exponent(result,dest_exponent); - *dstptr = result; - - /* check for inexact */ - if (inexact) { - if (Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/sfrem.c b/sys/arch/hppa/spmath/sfrem.c deleted file mode 100644 index ec8460cb9..000000000 --- a/sys/arch/hppa/spmath/sfrem.c +++ /dev/null @@ -1,263 +0,0 @@ -/* $OpenBSD: sfrem.c,v 1.5 2002/05/07 22:19:30 mickey Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)sfrem.c: Revision: 1.7.88.1 Date: 93/12/07 15:07:10 */ - -#include "float.h" -#include "sgl_float.h" - -/* - * Single Precision Floating-point Remainder - */ -int -sgl_frem(srcptr1,srcptr2,dstptr,status) - sgl_floating_point *srcptr1, *srcptr2, *dstptr; - unsigned int *status; -{ - register unsigned int opnd1, opnd2, result; - register int opnd1_exponent, opnd2_exponent, dest_exponent, stepcount; - register int roundup = FALSE; - - opnd1 = *srcptr1; - opnd2 = *srcptr2; - /* - * check first operand for NaN's or infinity - */ - if ((opnd1_exponent = Sgl_exponent(opnd1)) == SGL_INFINITY_EXPONENT) { - if (Sgl_iszero_mantissa(opnd1)) { - if (Sgl_isnotnan(opnd2)) { - /* invalid since first operand is infinity */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - Set_invalidflag(); - Sgl_makequietnan(result); - *dstptr = result; - return(NOEXCEPTION); - } - } - else { - /* - * is NaN; signaling or quiet? - */ - if (Sgl_isone_signaling(opnd1)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(opnd1); - } - /* - * is second operand a signaling NaN? - */ - else if (Sgl_is_signalingnan(opnd2)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) - return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(opnd2); - *dstptr = opnd2; - return(NOEXCEPTION); - } - /* - * return quiet NaN - */ - *dstptr = opnd1; - return(NOEXCEPTION); - } - } - /* - * check second operand for NaN's or infinity - */ - if ((opnd2_exponent = Sgl_exponent(opnd2)) == SGL_INFINITY_EXPONENT) { - if (Sgl_iszero_mantissa(opnd2)) { - /* - * return first operand - */ - *dstptr = opnd1; - return(NOEXCEPTION); - } - /* - * is NaN; signaling or quiet? - */ - if (Sgl_isone_signaling(opnd2)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(opnd2); - } - /* - * return quiet NaN - */ - *dstptr = opnd2; - return(NOEXCEPTION); - } - /* - * check second operand for zero - */ - if (Sgl_iszero_exponentmantissa(opnd2)) { - /* invalid since second operand is zero */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - Set_invalidflag(); - Sgl_makequietnan(result); - *dstptr = result; - return(NOEXCEPTION); - } - - /* - * get sign of result - */ - result = opnd1; - - /* - * check for denormalized operands - */ - if (opnd1_exponent == 0) { - /* check for zero */ - if (Sgl_iszero_mantissa(opnd1)) { - *dstptr = opnd1; - return(NOEXCEPTION); - } - /* normalize, then continue */ - opnd1_exponent = 1; - Sgl_normalize(opnd1,opnd1_exponent); - } - else { - Sgl_clear_signexponent_set_hidden(opnd1); - } - if (opnd2_exponent == 0) { - /* normalize, then continue */ - opnd2_exponent = 1; - Sgl_normalize(opnd2,opnd2_exponent); - } - else { - Sgl_clear_signexponent_set_hidden(opnd2); - } - - /* find result exponent and divide step loop count */ - dest_exponent = opnd2_exponent - 1; - stepcount = opnd1_exponent - opnd2_exponent; - - /* - * check for opnd1/opnd2 < 1 - */ - if (stepcount < 0) { - /* - * check for opnd1/opnd2 > 1/2 - * - * In this case n will round to 1, so - * r = opnd1 - opnd2 - */ - if (stepcount == -1 && Sgl_isgreaterthan(opnd1,opnd2)) { - Sgl_all(result) = ~Sgl_all(result); /* set sign */ - /* align opnd2 with opnd1 */ - Sgl_leftshiftby1(opnd2); - Sgl_subtract(opnd2,opnd1,opnd2); - /* now normalize */ - while (Sgl_iszero_hidden(opnd2)) { - Sgl_leftshiftby1(opnd2); - dest_exponent--; - } - Sgl_set_exponentmantissa(result,opnd2); - goto testforunderflow; - } - /* - * opnd1/opnd2 <= 1/2 - * - * In this case n will round to zero, so - * r = opnd1 - */ - Sgl_set_exponentmantissa(result,opnd1); - dest_exponent = opnd1_exponent; - goto testforunderflow; - } - - /* - * Generate result - * - * Do iterative subtract until remainder is less than operand 2. - */ - while (stepcount-- > 0 && Sgl_all(opnd1)) { - if (Sgl_isnotlessthan(opnd1,opnd2)) - Sgl_subtract(opnd1,opnd2,opnd1); - Sgl_leftshiftby1(opnd1); - } - /* - * Do last subtract, then determine which way to round if remainder - * is exactly 1/2 of opnd2 - */ - if (Sgl_isnotlessthan(opnd1,opnd2)) { - Sgl_subtract(opnd1,opnd2,opnd1); - roundup = TRUE; - } - if (stepcount > 0 || Sgl_iszero(opnd1)) { - /* division is exact, remainder is zero */ - Sgl_setzero_exponentmantissa(result); - *dstptr = result; - return(NOEXCEPTION); - } - - /* - * Check for cases where opnd1/opnd2 < n - * - * In this case the result's sign will be opposite that of - * opnd1. The mantissa also needs some correction. - */ - Sgl_leftshiftby1(opnd1); - if (Sgl_isgreaterthan(opnd1,opnd2)) { - Sgl_invert_sign(result); - Sgl_subtract((opnd2<<1),opnd1,opnd1); - } - /* check for remainder being exactly 1/2 of opnd2 */ - else if (Sgl_isequal(opnd1,opnd2) && roundup) { - Sgl_invert_sign(result); - } - - /* normalize result's mantissa */ - while (Sgl_iszero_hidden(opnd1)) { - dest_exponent--; - Sgl_leftshiftby1(opnd1); - } - Sgl_set_exponentmantissa(result,opnd1); - - /* - * Test for underflow - */ - testforunderflow: - if (dest_exponent <= 0) { - /* trap if UNDERFLOWTRAP enabled */ - if (Is_underflowtrap_enabled()) { - /* - * Adjust bias of result - */ - Sgl_setwrapped_exponent(result,dest_exponent,unfl); - *dstptr = result; - /* frem is always exact */ - return(UNDERFLOWEXCEPTION); - } - /* - * denormalize result or set to signed zero - */ - if (dest_exponent >= (1 - SGL_P)) { - Sgl_rightshift_exponentmantissa(result,1-dest_exponent); - } else { - Sgl_setzero_exponentmantissa(result); - } - } - else Sgl_set_exponent(result,dest_exponent); - *dstptr = result; - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/sfsqrt.c b/sys/arch/hppa/spmath/sfsqrt.c deleted file mode 100644 index dafc0f53f..000000000 --- a/sys/arch/hppa/spmath/sfsqrt.c +++ /dev/null @@ -1,158 +0,0 @@ -/* $OpenBSD: sfsqrt.c,v 1.8 2023/03/08 04:43:07 guenther Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)sfsqrt.c: Revision: 1.9.88.1 Date: 93/12/07 15:07:13 */ - -#include "float.h" -#include "sgl_float.h" - -/* - * Single Floating-point Square Root - */ - -int -sgl_fsqrt(srcptr, null, dstptr, status) - sgl_floating_point *srcptr, *null, *dstptr; - unsigned int *status; -{ - register unsigned int src, result; - register int src_exponent, newbit, sum; - register int guardbit = FALSE, even_exponent; - - src = *srcptr; - /* - * check source operand for NaN or infinity - */ - if ((src_exponent = Sgl_exponent(src)) == SGL_INFINITY_EXPONENT) { - /* - * is signaling NaN? - */ - if (Sgl_isone_signaling(src)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(src); - } - /* - * Return quiet NaN or positive infinity. - * Fall thru to negative test if negative infinity. - */ - if (Sgl_iszero_sign(src) || Sgl_isnotzero_mantissa(src)) { - *dstptr = src; - return(NOEXCEPTION); - } - } - - /* - * check for zero source operand - */ - if (Sgl_iszero_exponentmantissa(src)) { - *dstptr = src; - return(NOEXCEPTION); - } - - /* - * check for negative source operand - */ - if (Sgl_isone_sign(src)) { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_makequietnan(src); - *dstptr = src; - return(NOEXCEPTION); - } - - /* - * Generate result - */ - if (src_exponent > 0) { - even_exponent = Sgl_hidden(src); - Sgl_clear_signexponent_set_hidden(src); - } - else { - /* normalize operand */ - Sgl_clear_signexponent(src); - src_exponent++; - Sgl_normalize(src,src_exponent); - even_exponent = src_exponent & 1; - } - if (even_exponent) { - /* exponent is even */ - /* Add comment here. Explain why odd exponent needs correction */ - Sgl_leftshiftby1(src); - } - /* - * Add comment here. Explain following algorithm. - * - * Trust me, it works. - * - */ - Sgl_setzero(result); - newbit = 1 << SGL_P; - while (newbit && Sgl_isnotzero(src)) { - Sgl_addition(result,newbit,sum); - if(sum <= Sgl_all(src)) { - /* update result */ - Sgl_addition(result,(newbit<<1),result); - Sgl_subtract(src,sum,src); - } - Sgl_rightshiftby1(newbit); - Sgl_leftshiftby1(src); - } - /* correct exponent for pre-shift */ - if (even_exponent) { - Sgl_rightshiftby1(result); - } - - /* check for inexact */ - if (Sgl_isnotzero(src)) { - if (!even_exponent & Sgl_islessthan(result,src)) - Sgl_increment(result); - guardbit = Sgl_lowmantissa(result); - Sgl_rightshiftby1(result); - - /* now round result */ - switch (Rounding_mode()) { - case ROUNDPLUS: - Sgl_increment(result); - break; - case ROUNDNEAREST: - /* stickybit is always true, so guardbit - * is enough to determine rounding */ - if (guardbit) { - Sgl_increment(result); - } - break; - } - /* increment result exponent by 1 if mantissa overflowed */ - if (Sgl_isone_hiddenoverflow(result)) src_exponent+=2; - - if (Is_inexacttrap_enabled()) { - Sgl_set_exponent(result, - ((src_exponent-SGL_BIAS)>>1)+SGL_BIAS); - *dstptr = result; - return(INEXACTEXCEPTION); - } - else Set_inexactflag(); - } - else { - Sgl_rightshiftby1(result); - } - Sgl_set_exponent(result,((src_exponent-SGL_BIAS)>>1)+SGL_BIAS); - *dstptr = result; - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/sfsub.c b/sys/arch/hppa/spmath/sfsub.c deleted file mode 100644 index 164950ee1..000000000 --- a/sys/arch/hppa/spmath/sfsub.c +++ /dev/null @@ -1,496 +0,0 @@ -/* $OpenBSD: sfsub.c,v 1.6 2002/11/29 09:27:34 deraadt Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)sfsub.c: Revision: 2.7.88.1 Date: 93/12/07 15:07:15 */ - -#include "float.h" -#include "sgl_float.h" - -/* - * Single_subtract: subtract two single precision values. - */ -int -sgl_fsub(leftptr, rightptr, dstptr, status) - sgl_floating_point *leftptr, *rightptr, *dstptr; - unsigned int *status; -{ - register unsigned int left, right, result, extent; - register unsigned int signless_upper_left, signless_upper_right, save; - - register int result_exponent, right_exponent, diff_exponent; - register int sign_save, jumpsize; - register int inexact = FALSE, underflowtrap; - - /* Create local copies of the numbers */ - left = *leftptr; - right = *rightptr; - - /* A zero "save" helps discover equal operands (for later), * - * and is used in swapping operands (if needed). */ - Sgl_xortointp1(left,right,/*to*/save); - - /* - * check first operand for NaN's or infinity - */ - if ((result_exponent = Sgl_exponent(left)) == SGL_INFINITY_EXPONENT) - { - if (Sgl_iszero_mantissa(left)) - { - if (Sgl_isnotnan(right)) - { - if (Sgl_isinfinity(right) && save==0) - { - /* - * invalid since operands are same signed infinity's - */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - Set_invalidflag(); - Sgl_makequietnan(result); - *dstptr = result; - return(NOEXCEPTION); - } - /* - * return infinity - */ - *dstptr = left; - return(NOEXCEPTION); - } - } - else - { - /* - * is NaN; signaling or quiet? - */ - if (Sgl_isone_signaling(left)) - { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(left); - } - /* - * is second operand a signaling NaN? - */ - else if (Sgl_is_signalingnan(right)) - { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(right); - *dstptr = right; - return(NOEXCEPTION); - } - /* - * return quiet NaN - */ - *dstptr = left; - return(NOEXCEPTION); - } - } /* End left NaN or Infinity processing */ - /* - * check second operand for NaN's or infinity - */ - if (Sgl_isinfinity_exponent(right)) - { - if (Sgl_iszero_mantissa(right)) - { - /* return infinity */ - Sgl_invert_sign(right); - *dstptr = right; - return(NOEXCEPTION); - } - /* - * is NaN; signaling or quiet? - */ - if (Sgl_isone_signaling(right)) - { - /* trap if INVALIDTRAP enabled */ - if (Is_invalidtrap_enabled()) return(INVALIDEXCEPTION); - /* make NaN quiet */ - Set_invalidflag(); - Sgl_set_quiet(right); - } - /* - * return quiet NaN - */ - *dstptr = right; - return(NOEXCEPTION); - } /* End right NaN or Infinity processing */ - - /* Invariant: Must be dealing with finite numbers */ - - /* Compare operands by removing the sign */ - Sgl_copytoint_exponentmantissa(left,signless_upper_left); - Sgl_copytoint_exponentmantissa(right,signless_upper_right); - - /* sign difference selects sub or add operation. */ - if(Sgl_ismagnitudeless(signless_upper_left,signless_upper_right)) - { - /* Set the left operand to the larger one by XOR swap * - * First finish the first word using "save" */ - Sgl_xorfromintp1(save,right,/*to*/right); - Sgl_xorfromintp1(save,left,/*to*/left); - result_exponent = Sgl_exponent(left); - Sgl_invert_sign(left); - } - /* Invariant: left is not smaller than right. */ - - if((right_exponent = Sgl_exponent(right)) == 0) - { - /* Denormalized operands. First look for zeroes */ - if(Sgl_iszero_mantissa(right)) - { - /* right is zero */ - if(Sgl_iszero_exponentmantissa(left)) - { - /* Both operands are zeros */ - Sgl_invert_sign(right); - if(Is_rounding_mode(ROUNDMINUS)) - { - Sgl_or_signs(left,/*with*/right); - } - else - { - Sgl_and_signs(left,/*with*/right); - } - } - else - { - /* Left is not a zero and must be the result. Trapped - * underflows are signaled if left is denormalized. Result - * is always exact. */ - if( (result_exponent == 0) && Is_underflowtrap_enabled() ) - { - /* need to normalize results mantissa */ - sign_save = Sgl_signextendedsign(left); - Sgl_leftshiftby1(left); - Sgl_normalize(left,result_exponent); - Sgl_set_sign(left,/*using*/sign_save); - Sgl_setwrapped_exponent(left,result_exponent,unfl); - *dstptr = left; - /* inexact = FALSE */ - return(UNDERFLOWEXCEPTION); - } - } - *dstptr = left; - return(NOEXCEPTION); - } - - /* Neither are zeroes */ - Sgl_clear_sign(right); /* Exponent is already cleared */ - if(result_exponent == 0 ) - { - /* Both operands are denormalized. The result must be exact - * and is simply calculated. A sum could become normalized and a - * difference could cancel to a true zero. */ - if( (/*signed*/int) save >= 0 ) - { - Sgl_subtract(left,/*minus*/right,/*into*/result); - if(Sgl_iszero_mantissa(result)) - { - if(Is_rounding_mode(ROUNDMINUS)) - { - Sgl_setone_sign(result); - } - else - { - Sgl_setzero_sign(result); - } - *dstptr = result; - return(NOEXCEPTION); - } - } - else - { - Sgl_addition(left,right,/*into*/result); - if(Sgl_isone_hidden(result)) - { - *dstptr = result; - return(NOEXCEPTION); - } - } - if(Is_underflowtrap_enabled()) - { - /* need to normalize result */ - sign_save = Sgl_signextendedsign(result); - Sgl_leftshiftby1(result); - Sgl_normalize(result,result_exponent); - Sgl_set_sign(result,/*using*/sign_save); - Sgl_setwrapped_exponent(result,result_exponent,unfl); - *dstptr = result; - /* inexact = FALSE */ - return(UNDERFLOWEXCEPTION); - } - *dstptr = result; - return(NOEXCEPTION); - } - right_exponent = 1; /* Set exponent to reflect different bias - * with denomalized numbers. */ - } - else - { - Sgl_clear_signexponent_set_hidden(right); - } - Sgl_clear_exponent_set_hidden(left); - diff_exponent = result_exponent - right_exponent; - - /* - * Special case alignment of operands that would force alignment - * beyond the extent of the extension. A further optimization - * could special case this but only reduces the path length for this - * infrequent case. - */ - if(diff_exponent > SGL_THRESHOLD) - { - diff_exponent = SGL_THRESHOLD; - } - - /* Align right operand by shifting to right */ - Sgl_right_align(/*operand*/right,/*shifted by*/diff_exponent, - /*and lower to*/extent); - - /* Treat sum and difference of the operands separately. */ - if( (/*signed*/int) save >= 0 ) - { - /* - * Difference of the two operands. Their can be no overflow. A - * borrow can occur out of the hidden bit and force a post - * normalization phase. - */ - Sgl_subtract_withextension(left,/*minus*/right,/*with*/extent,/*into*/result); - if(Sgl_iszero_hidden(result)) - { - /* Handle normalization */ - /* A straight forward algorithm would now shift the result - * and extension left until the hidden bit becomes one. Not - * all of the extension bits need participate in the shift. - * Only the two most significant bits (round and guard) are - * needed. If only a single shift is needed then the guard - * bit becomes a significant low order bit and the extension - * must participate in the rounding. If more than a single - * shift is needed, then all bits to the right of the guard - * bit are zeros, and the guard bit may or may not be zero. */ - sign_save = Sgl_signextendedsign(result); - Sgl_leftshiftby1_withextent(result,extent,result); - - /* Need to check for a zero result. The sign and exponent - * fields have already been zeroed. The more efficient test - * of the full object can be used. - */ - if(Sgl_iszero(result)) - /* Must have been "x-x" or "x+(-x)". */ - { - if(Is_rounding_mode(ROUNDMINUS)) Sgl_setone_sign(result); - *dstptr = result; - return(NOEXCEPTION); - } - result_exponent--; - /* Look to see if normalization is finished. */ - if(Sgl_isone_hidden(result)) - { - if(result_exponent==0) - { - /* Denormalized, exponent should be zero. Left operand * - * was normalized, so extent (guard, round) was zero */ - goto underflow; - } - else - { - /* No further normalization is needed. */ - Sgl_set_sign(result,/*using*/sign_save); - Ext_leftshiftby1(extent); - goto round; - } - } - - /* Check for denormalized, exponent should be zero. Left * - * operand was normalized, so extent (guard, round) was zero */ - if(!(underflowtrap = Is_underflowtrap_enabled()) && - result_exponent==0) goto underflow; - - /* Shift extension to complete one bit of normalization and - * update exponent. */ - Ext_leftshiftby1(extent); - - /* Discover first one bit to determine shift amount. Use a - * modified binary search. We have already shifted the result - * one position right and still not found a one so the remainder - * of the extension must be zero and simplifies rounding. */ - /* Scan bytes */ - while(Sgl_iszero_hiddenhigh7mantissa(result)) - { - Sgl_leftshiftby8(result); - if((result_exponent -= 8) <= 0 && !underflowtrap) - goto underflow; - } - /* Now narrow it down to the nibble */ - if(Sgl_iszero_hiddenhigh3mantissa(result)) - { - /* The lower nibble contains the normalizing one */ - Sgl_leftshiftby4(result); - if((result_exponent -= 4) <= 0 && !underflowtrap) - goto underflow; - } - /* Select case were first bit is set (already normalized) - * otherwise select the proper shift. */ - if((jumpsize = Sgl_hiddenhigh3mantissa(result)) > 7) - { - /* Already normalized */ - if(result_exponent <= 0) goto underflow; - Sgl_set_sign(result,/*using*/sign_save); - Sgl_set_exponent(result,/*using*/result_exponent); - *dstptr = result; - return(NOEXCEPTION); - } - Sgl_sethigh4bits(result,/*using*/sign_save); - switch(jumpsize) - { - case 1: - { - Sgl_leftshiftby3(result); - result_exponent -= 3; - break; - } - case 2: - case 3: - { - Sgl_leftshiftby2(result); - result_exponent -= 2; - break; - } - case 4: - case 5: - case 6: - case 7: - { - Sgl_leftshiftby1(result); - result_exponent -= 1; - break; - } - } - if(result_exponent > 0) - { - Sgl_set_exponent(result,/*using*/result_exponent); - *dstptr = result; /* Sign bit is already set */ - return(NOEXCEPTION); - } - /* Fixup potential underflows */ - underflow: - if(Is_underflowtrap_enabled()) - { - Sgl_set_sign(result,sign_save); - Sgl_setwrapped_exponent(result,result_exponent,unfl); - *dstptr = result; - /* inexact = FALSE */ - return(UNDERFLOWEXCEPTION); - } - /* - * Since we cannot get an inexact denormalized result, - * we can now return. - */ - Sgl_right_align(result,/*by*/(1-result_exponent),extent); - Sgl_clear_signexponent(result); - Sgl_set_sign(result,sign_save); - *dstptr = result; - return(NOEXCEPTION); - } /* end if(hidden...)... */ - /* Fall through and round */ - } /* end if(save >= 0)... */ - else - { - /* Add magnitudes */ - Sgl_addition(left,right,/*to*/result); - if(Sgl_isone_hiddenoverflow(result)) - { - /* Prenormalization required. */ - Sgl_rightshiftby1_withextent(result,extent,extent); - Sgl_arithrightshiftby1(result); - result_exponent++; - } /* end if hiddenoverflow... */ - } /* end else ...sub magnitudes... */ - - /* Round the result. If the extension is all zeros,then the result is - * exact. Otherwise round in the correct direction. No underflow is - * possible. If a postnormalization is necessary, then the mantissa is - * all zeros so no shift is needed. */ - round: - if(Ext_isnotzero(extent)) - { - inexact = TRUE; - switch(Rounding_mode()) - { - case ROUNDNEAREST: /* The default. */ - if(Ext_isone_sign(extent)) - { - /* at least 1/2 ulp */ - if(Ext_isnotzero_lower(extent) || - Sgl_isone_lowmantissa(result)) - { - /* either exactly half way and odd or more than 1/2ulp */ - Sgl_increment(result); - } - } - break; - - case ROUNDPLUS: - if(Sgl_iszero_sign(result)) - { - /* Round up positive results */ - Sgl_increment(result); - } - break; - - case ROUNDMINUS: - if(Sgl_isone_sign(result)) - { - /* Round down negative results */ - Sgl_increment(result); - } - - case ROUNDZERO:; - /* truncate is simple */ - } /* end switch... */ - if(Sgl_isone_hiddenoverflow(result)) result_exponent++; - } - if(result_exponent == SGL_INFINITY_EXPONENT) - { - /* Overflow */ - if(Is_overflowtrap_enabled()) - { - Sgl_setwrapped_exponent(result,result_exponent,ovfl); - *dstptr = result; - if (inexact) { - if (Is_inexacttrap_enabled()) - return(OVERFLOWEXCEPTION | INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(OVERFLOWEXCEPTION); - } - else - { - Set_overflowflag(); - inexact = TRUE; - Sgl_setoverflow(result); - } - } - else Sgl_set_exponent(result,result_exponent); - *dstptr = result; - if(inexact) { - if(Is_inexacttrap_enabled()) return(INEXACTEXCEPTION); - else Set_inexactflag(); - } - return(NOEXCEPTION); -} diff --git a/sys/arch/hppa/spmath/sgl_float.h b/sys/arch/hppa/spmath/sgl_float.h deleted file mode 100644 index d4d34405b..000000000 --- a/sys/arch/hppa/spmath/sgl_float.h +++ /dev/null @@ -1,319 +0,0 @@ -/* $OpenBSD: sgl_float.h,v 1.13 2021/03/11 11:16:57 jsg Exp $ */ -/* - (c) Copyright 1986 HEWLETT-PACKARD COMPANY - To anyone who acknowledges that this file is provided "AS IS" - without any express or implied warranty: - permission to use, copy, modify, and distribute this file - for any purpose is hereby granted without fee, provided that - the above copyright notice and this notice appears in all - copies, and that the name of Hewlett-Packard Company not be - used in advertising or publicity pertaining to distribution - of the software without specific, written prior permission. - Hewlett-Packard Company makes no representations about the - suitability of this software for any purpose. -*/ -/* @(#)sgl_float.h: Revision: 2.8.88.1 Date: 93/12/07 15:07:17 */ - -#include - -/****************************** - * Single precision functions * - ******************************/ - -/* 32-bit word grabbing functions */ -#define Sgl_firstword(value) Sall(value) -#define Sgl_secondword(value) dummy_location -#define Sgl_thirdword(value) dummy_location -#define Sgl_fourthword(value) dummy_location - -#define Sgl_sign(object) Ssign(object) -#define Sgl_exponent(object) Sexponent(object) -#define Sgl_signexponent(object) Ssignexponent(object) -#define Sgl_mantissa(object) Smantissa(object) -#define Sgl_exponentmantissa(object) Sexponentmantissa(object) -#define Sgl_all(object) Sall(object) - -/* sgl_and_signs ands the sign bits of each argument and puts the result - * into the first argument. sgl_or_signs ors those same sign bits */ -#define Sgl_and_signs( src1dst, src2) \ - Sall(src1dst) = (Sall(src2)|~(1<<31)) & Sall(src1dst) -#define Sgl_or_signs( src1dst, src2) \ - Sall(src1dst) = (Sall(src2)&(1<<31)) | Sall(src1dst) - -/* The hidden bit is always the low bit of the exponent */ -#define Sgl_clear_exponent_set_hidden(srcdst) Deposit_sexponent(srcdst,1) -#define Sgl_clear_signexponent_set_hidden(srcdst) \ - Deposit_ssignexponent(srcdst,1) -#define Sgl_clear_sign(srcdst) Sall(srcdst) &= ~(1<<31) -#define Sgl_clear_signexponent(srcdst) Sall(srcdst) &= 0x007fffff - -/* varamount must be less than 32 for the next three functions */ -#define Sgl_rightshift(srcdst, varamount) \ - Sall(srcdst) >>= varamount -#define Sgl_leftshift(srcdst, varamount) \ - Sall(srcdst) <<= varamount -#define Sgl_rightshift_exponentmantissa(srcdst, varamount) \ - Sall(srcdst) = \ - (Sexponentmantissa(srcdst) >> (varamount)) | (Sall(srcdst) & (1<<31)) - -#define Sgl_leftshiftby1_withextent(left,right,result) \ - Shiftdouble(Sall(left),Extall(right),31,Sall(result)) - -#define Sgl_rightshiftby1_withextent(left,right,dst) \ - Shiftdouble(Sall(left),Extall(right),1,Extall(right)) -#define Sgl_arithrightshiftby1(srcdst) \ - Sall(srcdst) = (int)Sall(srcdst) >> 1 - -/* Sign extend the sign bit with an integer destination */ -#define Sgl_signextendedsign(value) Ssignedsign(value) - -#define Sgl_isone_hidden(sgl_value) (Shidden(sgl_value)) -#define Sgl_increment(sgl_value) Sall(sgl_value) += 1 -#define Sgl_increment_mantissa(sgl_value) \ - Deposit_smantissa(sgl_value,sgl_value+1) -#define Sgl_decrement(sgl_value) Sall(sgl_value) -= 1 - -#define Sgl_isone_sign(sgl_value) (Is_ssign(sgl_value)!=0) -#define Sgl_isone_hiddenoverflow(sgl_value) \ - (Is_shiddenoverflow(sgl_value)!=0) -#define Sgl_isone_lowmantissa(sgl_value) (Is_slow(sgl_value)!=0) -#define Sgl_isone_signaling(sgl_value) (Is_ssignaling(sgl_value)!=0) -#define Sgl_is_signalingnan(sgl_value) (Ssignalingnan(sgl_value)==0x1ff) -#define Sgl_isnotzero(sgl_value) (Sall(sgl_value)!=0) -#define Sgl_isnotzero_hiddenhigh7mantissa(sgl_value) \ - (Shiddenhigh7mantissa(sgl_value)!=0) -#define Sgl_isnotzero_low4(sgl_value) (Slow4(sgl_value)!=0) -#define Sgl_isnotzero_exponent(sgl_value) (Sexponent(sgl_value)!=0) -#define Sgl_isnotzero_mantissa(sgl_value) (Smantissa(sgl_value)!=0) -#define Sgl_isnotzero_exponentmantissa(sgl_value) \ - (Sexponentmantissa(sgl_value)!=0) -#define Sgl_iszero(sgl_value) (Sall(sgl_value)==0) -#define Sgl_iszero_signaling(sgl_value) (Is_ssignaling(sgl_value)==0) -#define Sgl_iszero_hidden(sgl_value) (Is_shidden(sgl_value)==0) -#define Sgl_iszero_hiddenoverflow(sgl_value) \ - (Is_shiddenoverflow(sgl_value)==0) -#define Sgl_iszero_hiddenhigh3mantissa(sgl_value) \ - (Shiddenhigh3mantissa(sgl_value)==0) -#define Sgl_iszero_hiddenhigh7mantissa(sgl_value) \ - (Shiddenhigh7mantissa(sgl_value)==0) -#define Sgl_iszero_sign(sgl_value) (Is_ssign(sgl_value)==0) -#define Sgl_iszero_exponent(sgl_value) (Sexponent(sgl_value)==0) -#define Sgl_iszero_mantissa(sgl_value) (Smantissa(sgl_value)==0) -#define Sgl_iszero_exponentmantissa(sgl_value) \ - (Sexponentmantissa(sgl_value)==0) -#define Sgl_isinfinity_exponent(sgl_value) \ - (Sgl_exponent(sgl_value)==SGL_INFINITY_EXPONENT) -#define Sgl_isnotinfinity_exponent(sgl_value) \ - (Sgl_exponent(sgl_value)!=SGL_INFINITY_EXPONENT) -#define Sgl_isinfinity(sgl_value) \ - (Sgl_exponent(sgl_value)==SGL_INFINITY_EXPONENT && \ - Sgl_mantissa(sgl_value)==0) -#define Sgl_isnan(sgl_value) \ - (Sgl_exponent(sgl_value)==SGL_INFINITY_EXPONENT && \ - Sgl_mantissa(sgl_value)!=0) -#define Sgl_isnotnan(sgl_value) \ - (Sgl_exponent(sgl_value)!=SGL_INFINITY_EXPONENT || \ - Sgl_mantissa(sgl_value)==0) -#define Sgl_islessthan(sgl_op1,sgl_op2) \ - (Sall(sgl_op1) < Sall(sgl_op2)) -#define Sgl_isgreaterthan(sgl_op1,sgl_op2) \ - (Sall(sgl_op1) > Sall(sgl_op2)) -#define Sgl_isnotlessthan(sgl_op1,sgl_op2) \ - (Sall(sgl_op1) >= Sall(sgl_op2)) -#define Sgl_isequal(sgl_op1,sgl_op2) \ - (Sall(sgl_op1) == Sall(sgl_op2)) - -#define Sgl_leftshiftby8(sgl_value) \ - Sall(sgl_value) <<= 8 -#define Sgl_leftshiftby4(sgl_value) \ - Sall(sgl_value) <<= 4 -#define Sgl_leftshiftby3(sgl_value) \ - Sall(sgl_value) <<= 3 -#define Sgl_leftshiftby2(sgl_value) \ - Sall(sgl_value) <<= 2 -#define Sgl_leftshiftby1(sgl_value) \ - Sall(sgl_value) <<= 1 -#define Sgl_rightshiftby1(sgl_value) \ - Sall(sgl_value) >>= 1 -#define Sgl_rightshiftby4(sgl_value) \ - Sall(sgl_value) >>= 4 -#define Sgl_rightshiftby8(sgl_value) \ - Sall(sgl_value) >>= 8 - -#define Sgl_ismagnitudeless(signlessleft,signlessright) \ -/* unsigned int signlessleft, signlessright; */ \ - (signlessleft < signlessright) - - -#define Sgl_copytoint_exponentmantissa(source,dest) \ - dest = Sexponentmantissa(source) - -/* A quiet NaN has the high mantissa bit clear and at least on other (in this - * case the adjacent bit) bit set. */ -#define Sgl_set_quiet(sgl_value) Deposit_shigh2mantissa(sgl_value,1) -#define Sgl_set_exponent(sgl_value,exp) Deposit_sexponent(sgl_value,exp) - -#define Sgl_set_mantissa(dest,value) Deposit_smantissa(dest,value) -#define Sgl_set_exponentmantissa(dest,value) \ - Deposit_sexponentmantissa(dest,value) - -/* An infinity is represented with the max exponent and a zero mantissa */ -#define Sgl_setinfinity_exponent(sgl_value) \ - Deposit_sexponent(sgl_value,SGL_INFINITY_EXPONENT) -#define Sgl_setinfinity_exponentmantissa(sgl_value) \ - Deposit_sexponentmantissa(sgl_value, \ - (SGL_INFINITY_EXPONENT << (32-(1+SGL_EXP_LENGTH)))) -#define Sgl_setinfinitypositive(sgl_value) \ - Sall(sgl_value) = (SGL_INFINITY_EXPONENT << (32-(1+SGL_EXP_LENGTH))) -#define Sgl_setinfinitynegative(sgl_value) \ - Sall(sgl_value) = (SGL_INFINITY_EXPONENT << (32-(1+SGL_EXP_LENGTH))) \ - | (1<<31) -#define Sgl_setinfinity(sgl_value,sign) \ - Sall(sgl_value) = (SGL_INFINITY_EXPONENT << (32-(1+SGL_EXP_LENGTH))) | \ - (sign << 31) -#define Sgl_sethigh4bits(sgl_value, extsign) \ - Deposit_shigh4(sgl_value,extsign) -#define Sgl_set_sign(sgl_value,sign) Deposit_ssign(sgl_value,sign) -#define Sgl_invert_sign(sgl_value) \ - Deposit_ssign(sgl_value,~Ssign(sgl_value)) -#define Sgl_setone_sign(sgl_value) Deposit_ssign(sgl_value,1) -#define Sgl_setone_lowmantissa(sgl_value) Deposit_slow(sgl_value,1) -#define Sgl_setzero_sign(sgl_value) Sall(sgl_value) &= 0x7fffffff -#define Sgl_setzero_exponent(sgl_value) Sall(sgl_value) &= 0x807fffff -#define Sgl_setzero_mantissa(sgl_value) Sall(sgl_value) &= 0xff800000 -#define Sgl_setzero_exponentmantissa(sgl_value) Sall(sgl_value) &= 0x80000000 -#define Sgl_setzero(sgl_value) Sall(sgl_value) = 0 -#define Sgl_setnegativezero(sgl_value) Sall(sgl_value) = 1U << 31 - -/* Use following macro for both overflow & underflow conditions */ -#define ovfl - -#define unfl + -#define Sgl_setwrapped_exponent(sgl_value,exponent,op) \ - Deposit_sexponent(sgl_value,(exponent op SGL_WRAP)) - -#define Sgl_setlargestpositive(sgl_value) \ - Sall(sgl_value) = ((SGL_EMAX+SGL_BIAS) << (32-(1+SGL_EXP_LENGTH))) \ - | ((1<<(32-(1+SGL_EXP_LENGTH))) - 1) -#define Sgl_setlargestnegative(sgl_value) \ - Sall(sgl_value) = ((SGL_EMAX+SGL_BIAS) << (32-(1+SGL_EXP_LENGTH))) \ - | ((1<<(32-(1+SGL_EXP_LENGTH))) - 1 ) | (1<<31) - -#define Sgl_setnegativeinfinity(sgl_value) \ - Sall(sgl_value) = \ - ((1<>= shift; \ - } \ - else { \ - Extall(extent) = Sall(srcdst); \ - Sall(srcdst) = 0; \ - } -#define Sgl_hiddenhigh3mantissa(sgl_value) Shiddenhigh3mantissa(sgl_value) -#define Sgl_hidden(sgl_value) Shidden(sgl_value) -#define Sgl_lowmantissa(sgl_value) Slow(sgl_value) - -/* The left argument is never smaller than the right argument */ -#define Sgl_subtract(sgl_left,sgl_right,sgl_result) \ - Sall(sgl_result) = Sall(sgl_left) - Sall(sgl_right) - -/* Subtract right augmented with extension from left augmented with zeros and - * store into result and extension. */ -#define Sgl_subtract_withextension(left,right,extent,result) \ - /* sgl_floating_point left,right,result; extension extent */ \ - Sgl_subtract(left,right,result); \ - if((Extall(extent) = 0-Extall(extent))) \ - Sall(result) = Sall(result)-1 - -#define Sgl_addition(sgl_left,sgl_right,sgl_result) \ - Sall(sgl_result) = Sall(sgl_left) + Sall(sgl_right) - -#define Sgl_xortointp1(left,right,result) \ - result = Sall(left) XOR Sall(right); - -#define Sgl_xorfromintp1(left,right,result) \ - Sall(result) = left XOR Sall(right) - -/* Need to Initialize */ -#define Sgl_makequietnan(dest) \ - Sall(dest) = ((SGL_EMAX+SGL_BIAS)+1)<< (32-(1+SGL_EXP_LENGTH)) \ - | (1<<(32-(1+SGL_EXP_LENGTH+2))) -#define Sgl_makesignalingnan(dest) \ - Sall(dest) = ((SGL_EMAX+SGL_BIAS)+1)<< (32-(1+SGL_EXP_LENGTH)) \ - | (1<<(32-(1+SGL_EXP_LENGTH+1))) - -#define Sgl_normalize(sgl_opnd,exponent) \ - while(Sgl_iszero_hiddenhigh7mantissa(sgl_opnd)) { \ - Sgl_leftshiftby8(sgl_opnd); \ - exponent -= 8; \ - } \ - if(Sgl_iszero_hiddenhigh3mantissa(sgl_opnd)) { \ - Sgl_leftshiftby4(sgl_opnd); \ - exponent -= 4; \ - } \ - while(Sgl_iszero_hidden(sgl_opnd)) { \ - Sgl_leftshiftby1(sgl_opnd); \ - exponent -= 1; \ - } - -#define Sgl_setoverflow(sgl_opnd) \ - /* set result to infinity or largest number */ \ - switch (Rounding_mode()) { \ - case ROUNDPLUS: \ - if (Sgl_isone_sign(sgl_opnd)) { \ - Sgl_setlargestnegative(sgl_opnd); \ - } \ - else { \ - Sgl_setinfinitypositive(sgl_opnd); \ - } \ - break; \ - case ROUNDMINUS: \ - if (Sgl_iszero_sign(sgl_opnd)) { \ - Sgl_setlargestpositive(sgl_opnd); \ - } \ - else { \ - Sgl_setinfinitynegative(sgl_opnd); \ - } \ - break; \ - case ROUNDNEAREST: \ - Sgl_setinfinity_exponentmantissa(sgl_opnd); \ - break; \ - case ROUNDZERO: \ - Sgl_setlargest_exponentmantissa(sgl_opnd); \ - } - -#define Sgl_denormalize(opnd,exponent,guard,sticky,inexact) \ - Sgl_clear_signexponent_set_hidden(opnd); \ - if (exponent >= (1 - SGL_P)) { \ - guard = (Sall(opnd) >> (-(exponent))) & 1; \ - if (exponent < 0) sticky |= Sall(opnd) << (32+exponent); \ - inexact = (guard) | (sticky); \ - Sall(opnd) >>= (1-exponent); \ - } \ - else { \ - guard = 0; \ - sticky |= Sall(opnd); \ - inexact = sticky; \ - Sgl_setzero(opnd); \ - } - -int sgl_fadd(sgl_floating_point *, sgl_floating_point *, sgl_floating_point *, unsigned int *); -int sgl_fcmp(sgl_floating_point *, sgl_floating_point *, unsigned int, unsigned int *); -int sgl_fdiv(sgl_floating_point *, sgl_floating_point *, sgl_floating_point *, unsigned int *); -int sgl_fmpy(sgl_floating_point *, sgl_floating_point *, sgl_floating_point *, unsigned int *); -int sgl_frem(sgl_floating_point *, sgl_floating_point *, sgl_floating_point *, unsigned int *); -int sgl_fsqrt(sgl_floating_point *, sgl_floating_point *, sgl_floating_point *, unsigned int *); -int sgl_fsub(sgl_floating_point *, sgl_floating_point *, sgl_floating_point *, unsigned int *); -int sgl_frnd(sgl_floating_point *, sgl_floating_point *, sgl_floating_point *, unsigned int *); diff --git a/sys/arch/hppa/stand/Makefile b/sys/arch/hppa/stand/Makefile deleted file mode 100644 index 8bc37348a..000000000 --- a/sys/arch/hppa/stand/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -# $OpenBSD: Makefile,v 1.4 2007/11/25 20:37:24 maja Exp $ - -.if ${MACHINE} == "hppa" -SUBDIR= libsa libz -.endif -SUBDIR+= mkboot boot -.if ${MACHINE} == "hppa" -SUBDIR+= cdboot -.endif - -.include diff --git a/sys/arch/hppa/stand/Makefile.inc b/sys/arch/hppa/stand/Makefile.inc deleted file mode 100644 index 2f9798bfd..000000000 --- a/sys/arch/hppa/stand/Makefile.inc +++ /dev/null @@ -1,41 +0,0 @@ -# $OpenBSD: Makefile.inc,v 1.22 2017/07/25 13:32:14 robert Exp $ - -CFLAGS=${DEBUG} -Oz -Wall -Werror -CPPFLAGS+=-I${S} -I. -I${.CURDIR} -SACFLAGS=-nostdinc -fno-builtin -D_STANDALONE -I${STANDIR}/libsa -SACFLAGS+=-mdisable-fpregs -mfast-indirect-calls -mpa-risc-1-1 -SACFLAGS+=-fno-stack-protector -#DEBUGFLAGS=-DDEBUG -#DEBUGFLAGS+=-DPDCDEBUG -#DEBUGFLAGS+=-DLIFDEBUG -#DEBUGFLAGS+=-DEXEC_DEBUG -#DEBUGFLAGS+=-DALLOC_TRACE -LINKADDR=0xf80000 -LOADADDR=0xf80000 -HEAP_LIMIT=0xff8000 -CLEANFILES+= machine - -.if !make(clean) && !make(cleandir) && !make(includes) && !make(libdep) && \ - !make(sadep) && !make(salibdir) && !make(obj) && \ - (${MACHINE} == "hppa" && !(defined(PROG) && ${PROG} == "mkboot")) -.BEGIN: - @([ -h machine ] || ln -s $(S)/arch/hppa/include machine) -.endif - -.if exists(${STANDIR}/libsa/libsa.a) -LIBSA=${STANDIR}/libsa/libsa.a -.else -LIBSA=${STANDIR}/libsa/${__objdir}/libsa.a -.endif -.if exists(${STANDIR}/libz/libz.a) -LIBZ=${STANDIR}/libz/libz.a -.else -LIBZ=${STANDIR}/libz/${__objdir}/libz.a -.endif -.if exists(${STANDIR}/mkboot/mkboot) -MKBOOT=${STANDIR}/mkboot/mkboot -.else -MKBOOT=${STANDIR}/mkboot/${__objdir}/mkboot -.endif - -BINDIR= /usr/mdec diff --git a/sys/arch/hppa/stand/boot/Makefile b/sys/arch/hppa/stand/boot/Makefile deleted file mode 100644 index 20623093b..000000000 --- a/sys/arch/hppa/stand/boot/Makefile +++ /dev/null @@ -1,65 +0,0 @@ -# $OpenBSD: Makefile,v 1.30 2023/02/23 19:48:22 miod Exp $ - -MAN= boot.8 -MANSUBDIR=hppa -S =${.CURDIR}/../../../.. -CLEANFILES+= boot.gdb boot.map boot.lif - -.if ${MACHINE} == "hppa" -PROG= boot -SRCS= srt0.S exec.c conf.c - -.PATH: ${S}/stand/boot -SRCS+= bootarg.c boot.c vars.c cmd.c - -.PATH: ${S}/lib/libsa -SRCS+= hexdump.c strtoll.c - -.PATH: ${S}/lib/libkern/arch/hppa ${S}/lib/libkern -SRCS+= milli.S ashldi3.c ashrdi3.c memcmp.c memcpy.c memmove.c memset.c \ - moddi3.c muldi3.c qdivrem.c strcmp.c strlcpy.c strlen.c \ - strncmp.c strncpy.c divdi3.c - -LD?= ld -LDFLAGS+=-Bstatic -nostartfiles -nostdlib -N -Ttext $(LINKADDR) -nopie -znorelro -LDFLAGS+=-T ${.CURDIR}/ld.script -Map boot.map -SIZE?= size -STRIP?= strip -STANDIR=${.CURDIR}/.. -CRTBEGIN= -CRTEND= -LINKS= ${BINDIR}/boot.lif ${BINDIR}/sdboot \ - ${BINDIR}/boot.lif ${BINDIR}/stboot \ - ${BINDIR}/boot.lif ${BINDIR}/xxboot - -LDADD= ${LIBSA} ${LIBZ} -DPADD= ${LIBSA} ${LIBZ} - -all: boot.lif - -realinstall: - ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - boot ${DESTDIR}${BINDIR} - ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - boot.lif ${DESTDIR}${BINDIR} - -# probably we should check for 256k limit for ISL -boot.lif: ${PROG} ${ADDBOOT} - -@cp ${PROG} ${PROG}.gdb - ${STRIP} ${PROG} - ${MKBOOT} -v ${PROG} ${ADDBOOT} boot.lif - -${PROG}: $(OBJS) $(DPADD) - $(LD) $(LDFLAGS) -o $(PROG) $(OBJS) $(LDADD) - @${SIZE} $(PROG) -.else -NOPROG= -.endif - -.include - -CPPFLAGS+=${DEBUGFLAGS} -DRELOC=${LOADADDR} -DHEAP_LIMIT=${HEAP_LIMIT} \ - -DBOOT_STTY -CFLAGS+=$(SACFLAGS) -CFLAGS+=-fno-pie -AFLAGS+=-fno-pie diff --git a/sys/arch/hppa/stand/boot/boot.8 b/sys/arch/hppa/stand/boot/boot.8 deleted file mode 100644 index 117f7b6cc..000000000 --- a/sys/arch/hppa/stand/boot/boot.8 +++ /dev/null @@ -1,316 +0,0 @@ -.\" $OpenBSD: boot.8,v 1.27 2023/02/23 19:48:22 miod Exp $ -.\" -.\" Copyright (c) 2002 Miodrag Vallat -.\" Copyright (c) 1997-2002 Michael Shalayeff -.\" 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 OR HIS RELATIVES 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 MIND, 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. -.\" -.\" -.Dd $Mdocdate: February 23 2023 $ -.Dt BOOT 8 hppa -.Os -.Sh NAME -.Nm boot , -.Nm boot.conf -.Nd hppa-specific bootstrap -.Sh DESCRIPTION -The main purpose of this program is to load the system kernel while dealing -with the various features of the PA-RISC hardware. -.Pp -As described in -.Xr boot_hppa 8 , -this program is loaded by the PDC firmware -and provides a convenient way to load the kernel. -.Pp -Basic operations include: -.Pp -.Bl -bullet -compact -.It -Loading kernels from any device supported by your system. -.It -Loading kernels compressed by -.Xr gzip 1 . -.It -Providing an interactive command line. -.It -Detecting and switching between multiple consoles. -.El -.Pp -The sequence of its operation is as follows: initialization, -parsing the configuration file, then an interactive command line. -While at the command line you have 5 seconds to type any commands, if needed. -If time expires, the kernel will be loaded according to -the current variable settings (see the -.Nm set -command). -Each time a kernel load fails, the timeout is increased by one second. -The sequence of -.Nm -operations is as follows: -.Bl -enum -.It -If the file -.Pa /etc/boot.conf -exists on the filesystem or LIF image -.Nm -was loaded from, open and parse it. -Lines beginning with the -.Sq # -character, -as well as whitespace at the beginning of lines, -are ignored. -The file may contain any commands -.Nm -accepts at the interactive prompt. -Though default settings usually suffice, they can be changed here. -.It -The header line -.Pp -.Dl >> OpenBSD/hppa BOOT [x.xx] -.Pp -is displayed to the active console, where -.Ar x.xx -is the version number of the -.Nm -program, followed by the -.Pp -.Dl boot> -.Pp -prompt, which means you are in interactive mode and may enter commands. -If you do not, -.Nm -will proceed to load the kernel with the current parameters after the -timeout period has expired. -.El -.Pp -By default, -.Nm -attempts to load the kernel executable -.Pa /bsd . -If it fails to find the kernel and no alternative kernel image has -been specified, the system will be unable to boot. -.Sh COMMANDS -The following commands are accepted at the -.Nm -prompt: -.Bl -tag -width shorten -.It Ic boot Oo Oo Ar device : Oc Ns Ar image Oc Op Fl acds -Boots the specified kernel image -with any options given. -If -.Ar device -or -.Ar image -are omitted, values from -.Nm -variables will be used. -.Bl -tag -width _a_ -.It Fl a -Causes the kernel to ask for the -.Nm root -device to use. -.It Fl c -Causes the kernel to go into -.Xr boot_config 8 -before performing -.Xr autoconf 4 -procedures. -.It Fl d -Causes the kernel to drop into -.Xr ddb 4 -at the earliest convenient point. -.It Fl s -Causes the kernel to boot single-user. -.El -.It Ic echo Op Ar args -Displays -.Ar args -on the console device. -.It Ic help -Prints a list of available commands and machine dependent -commands, if any. -.It Ic hexdump Ar addr size -Show -.Ar size -bytes of memory at address -.Ar addr . -.It Ic machine Op Ar command -Issues machine-dependent commands. -These are defined for hppa architecture: -.Bl -tag -width keyboard -.It Ic console -Displays or sets the console path. -.Pp -When invoked with no argument, this command will display the configured -console path found in the stable storage area. -.Pp -Otherwise, the argument will be interpreted as a console path -definition string, and -.Nm -will attempt to switch the console configuration to the desired device. -The console definition attempts to follow the PDC syntax, -and would have a form of: -.Bd -filled -graphics -.Op _head -.Op .mode -.Ed -for graphics console, and -.Bd -filled -rs232 -.Op _2 -.Op .speed Op .bits Op .parity -.Ed -for serial console. -.Pp -The default head and mode for graphics console are 0, that is the default -videomode of the first graphics device. -The default serial settings are 9600 bps, 8 data bits, and no parity. -.It Ic keyboard -Displays or sets the keyboard path. -.Pp -When invoked with no argument, this command will display the configured -keyboard path found in the stable storage area. -.Pp -Otherwise, the argument will be interpreted as a keyboard path definition -string, and -.Nm -will attempt to switch the keyboard configuration to the desired port. -The keyboard definition attempts to follow the PDC syntax, -and would have a form of: -.Bd -filled -hil -.Ed -for hil keyboard, and -.Bd -filled -ps2 -.Ed -for PS/2 keyboard. -.El -.Pp -After changing any path settings, the machine usually has to be restarted for -the changes to have effect. -.It Ic ls Op Ar directory -Prints contents of the specified -.Ar directory -in long format including: attributes and file type, owner, group, -size, filename. -.It Ic reboot -Reboots the machine by initiating a warm boot procedure. -.It Ic set Op Ar varname Op Ar value -If invoked without arguments, prints a list of variables and their values. -If only -.Ar varname -is specified, displays contents of that variable. -If -.Ar varname -and -.Ar value -are both specified, sets that variable to the given value. -Variables include: -.Pp -.Bl -tag -compact -width db_console -.It Ic db_console -Boolean (0 or 1) to permit entry into the kernel debugger before the -.Em ddb.console -sysctl gets effective. -.It Ic debug -Debug flag if -.Nm -was compiled with DEBUG defined. -.It Ic device -Boot device name (i.e., -.Li lf0a , -.Li sd0a ) . -.It Ic howto -Options to pass to the loaded kernel. -.It Ic image -File name containing the kernel image. -.It Ic timeout -Number of seconds boot will wait for human intervention before -booting the default kernel image. -.It Ic time -Displays system time and date. -.El -.Sh FILES -.Bl -tag -width /etc/boot.conf -compact -.It Pa /boot -system bootstrap -.It Pa /etc/boot.conf -system bootstrap's startup file -.It Pa /bsd -kernel image -.It Pa /bsd.rd -kernel image for installation/recovery -.El -.Sh EXAMPLES -Boot the default kernel: -.Pp -.Dl boot> boot -.Pp -Remove the 5 second pause at boot-time permanently, causing -.Nm -to load the kernel immediately without prompting: -.Pp -.Dl # echo \&"boot\&" > /etc/boot.conf -.Pp -Use serial console on the first serial port, with the usual 9600 8N1 settings. -A null modem cable should connect the specified serial port to a terminal. -Useful for debugging. -.Pp -.Dl boot> machine console rs232.9600.8.none -.Pp -Boot the kernel named -.Pa /bsd -from the second SCSI disk in -.Dq User Kernel Configuration -mode (see -.Xr boot_config 8 ) . -This mechanism allows for the explicit enabling and disabling of devices -during the current boot sequence, as well as the modification -of device parameters. -Once booted, such changes can be made permanent by using -.Xr config 8 Ns 's -.Fl e -option. -.Pp -.Dl boot> boot sd1a:/bsd -c -.Sh SEE ALSO -.Xr gzip 1 , -.Xr autoconf 4 , -.Xr ddb 4 , -.Xr boot_config 8 , -.Xr boot_hppa 8 , -.\" .Xr installboot 8 , -.Xr reboot 8 -.Sh HISTORY -This program was written by Michael Shalayeff for -.Ox 2.1 . -The hppa specific parts were written by Michael Shalayeff and Miodrag Vallat -for -.Ox 3.1 . -.Sh CAVEATS -Making mistakes in console paths may cost you a toupee. -.Sh BUGS -Changing the display resolution (mode) on a graphics console does not work -correctly. diff --git a/sys/arch/hppa/stand/boot/conf.c b/sys/arch/hppa/stand/boot/conf.c deleted file mode 100644 index 21f5c8bd9..000000000 --- a/sys/arch/hppa/stand/boot/conf.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $OpenBSD: conf.c,v 1.37 2020/12/09 18:10:18 krw Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include -#include -#include - -const char version[] = "1.11"; -int debug = 0; - -struct fs_ops file_system[] = { - { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, - ufs_stat, ufs_readdir, ufs_fchmod }, - { ufs2_open, ufs2_close, ufs2_read, ufs2_write, ufs2_seek, - ufs2_stat, ufs2_readdir, ufs2_fchmod }, - { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, - cd9660_stat, cd9660_readdir }, - { lif_open, lif_close, lif_read, lif_write, lif_seek, - lif_stat, lif_readdir }, -}; -int nfsys = nitems(file_system); - -struct devsw devsw[] = { - { "dk", iodcstrategy, dkopen, dkclose, noioctl }, - { "ct", iodcstrategy, ctopen, ctclose, noioctl }, - { "lf", iodcstrategy, lfopen, lfclose, noioctl } -}; -int ndevs = nitems(devsw); - -struct consdev constab[] = { - { ite_probe, ite_init, ite_getc, ite_putc }, - { NULL } -}; -struct consdev *cn_tab; - diff --git a/sys/arch/hppa/stand/boot/exec.c b/sys/arch/hppa/stand/boot/exec.c deleted file mode 100644 index d8947d9be..000000000 --- a/sys/arch/hppa/stand/boot/exec.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $OpenBSD: exec.c,v 1.6 2019/04/10 04:17:34 deraadt Exp $ */ - -/* - * Copyright (c) 2002-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include "libsa.h" -#include -#include -#include "dev_hppa.h" - -typedef void (*startfuncp)(int, int, int, int, int, int, caddr_t) - __attribute__ ((noreturn)); - -void -run_loadfile(uint64_t *marks, int howto) -{ - fcacheall(); - - __asm("mtctl %r0, %cr17"); - __asm("mtctl %r0, %cr17"); - /* stack and the gung is ok at this point, so, no need for asm setup */ - (*(startfuncp)((u_long)marks[MARK_ENTRY]))((int)pdc, howto, bootdev, - (u_long)marks[MARK_END], BOOTARG_APIVER, BOOTARG_LEN, (caddr_t)BOOTARG_OFF); - - /* not reached */ -} diff --git a/sys/arch/hppa/stand/boot/ld.script b/sys/arch/hppa/stand/boot/ld.script deleted file mode 100644 index f738b833b..000000000 --- a/sys/arch/hppa/stand/boot/ld.script +++ /dev/null @@ -1,50 +0,0 @@ -/* $OpenBSD: ld.script,v 1.4 2010/05/09 13:27:30 kettenis Exp $ */ - -OUTPUT_FORMAT("elf32-hppa") -OUTPUT_ARCH(hppa) -ENTRY(begin) - -SECTIONS { - - /* Read-only sections, merged into text segment: */ - . = + SIZEOF_HEADERS; - .text : { - *(.text) - *(.text.*) - *(.rodata) - *(.rodata1) - *(.rodata.*) - *($CODE$) - etext = .; - } = 0x08000240 - - /* Read-write sections, merged into data segment: */ - .data : { - $global$ = .; - *(.data) - *(.data1) - *(.sdata) - *(.sdata2) - *(.dynamic) - CONSTRUCTORS - edata = ABSOLUTE(.); - } = 0 - - .bss : { - __bss_start = .; - *(.dynbss) - *(.bss) - *(.sbss) - *(.scommon) - *(COMMON) - end = ABSOLUTE(.); - __bss_end = .; - } - - /* don't need an unwind in the boot, unless we'll have a boot-ddb (; */ - /DISCARD/ : - { - *(.PARISC.unwind) - } -} - diff --git a/sys/arch/hppa/stand/boot/srt0.S b/sys/arch/hppa/stand/boot/srt0.S deleted file mode 100644 index 67ddf4372..000000000 --- a/sys/arch/hppa/stand/boot/srt0.S +++ /dev/null @@ -1,163 +0,0 @@ -/* $OpenBSD: srt0.S,v 1.11 2011/04/17 09:49:48 kettenis Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 1996 1995 by Open Software Foundation, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ -; -; Copyright (c) 1990 mt Xinu, Inc. All rights reserved. -; Copyright (c) 1990 University of Utah. All rights reserved. -; -; This file may be freely distributed in any form as long as -; this copyright notice is included. -; THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -; IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -; WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -; -; Utah $Hdr: srt0.c 1.3 94/12/13$ -; - -#define _LOCORE -#include -#include -#include - -/* - * This is the ending of the begin - */ -ENTRY(begin,0) - - blr %r0,%r5 ; Get address of 'boff' into 'r5', - ldo begin-boff(%r5),%r5 ; and subtract to get 'begin'. -boff - ldil L%RELOC,%r4 - ldo R%RELOC(%r4),%r4 - ldo start-begin(%r4),%rp - ldil L%edata,%r3 - ldo R%edata(%r3),%r3 ; Get address of edata. - ldil L%begin,%r1 - ldo R%begin(%r1),%r1 ; Get address of begin - sub %r3,%r1,%r3 ; Subtract to get # of bytes to copy -copyloop ; do - ldwm 4(%r5),%r1 ; *r4++ = *r5++; - addib,>= -4,%r3,copyloop ; while (--r3 >= 0); - stwm %r1,4(%r4) - - ; here we zero the .bss - ldil L%__bss_start, %r4 - ldo R%__bss_start(%r4), %r4 - ldil L%__bss_end, %r3 - ldo R%__bss_end(%r3), %r3 -zeroloop - combf,<,n %r3,%r4, zeroloop ; while (r4 < r3); - stwm %r0,4(%r4) ; *r4++ = 0; - - ldil L%$global$,%dp - ldo R%$global$(%dp),%dp - ldil L%start,%r1 - ldo R%start(%r1),%r1 - sub %dp,%r1,%dp ; Subtract to get difference - add %rp,%dp,%dp ; and relocate it. - -; -; We have relocated ourself to RELOC. If we are running on a machine -; with separate instruction and data caches, we must flush our data -; cache before trying to execute the code starting at rp. -; - ldil L%RELOC,%r22 ; Set %t1 to start of relocated code. - ldo R%RELOC(%r22),%r22 - ldil L%edata,%r21 ; Set r21 to address of edata - ldo R%edata(%r21),%r21 - ldil L%begin,%r1 ; set %r1 to address of begin - ldo R%begin(%r1),%r1 - sub %r21,%r1,%r21 ; Subtract to get length - mtsp %r0,%sr0 ; Set sr0 to kernel space. - ldo -1(%r21),%r21 - fdc %r21(0,%r22) -loop addib,>,n -16,%r21,loop ; Decrement by cache line size (16). - fdc %r21(%sr0,%r22) - fdc 0(%sr0,%r22) ; Flush first word at addr to handle - sync ; arbitrary cache line boundary. - nop ; Prevent prefetching. - nop - nop - nop - nop - nop - nop - bv 0(rp) - nop -EXIT(begin) /* jump to relocated code */ - -start - ldil L%HEAP_LIMIT, %sp - ldo R%HEAP_LIMIT(%sp), %sp - - comb,= %r0, %r26, call_boot - nop - .import boottimeout, data - ldil L%boottimeout, %r22 - stw %r0, R%boottimeout(%r22) - -call_boot - b boot ; Call boot(), - copy %r0, arg0 ; use default boot device - nop - -/* - * rtt - restart the box - */ -LEAF_ENTRY(_rtt) - ldil L%HPPA_LBCAST, %r25 - ldi CMD_RESET, %r26 - stw %r26,R%iomod_command(%r25) -forever ; Loop until bus reset takes effect. - b,n forever - - bv 0(rp) - ldo -48(sp),sp -EXIT(_rtt) - - .end diff --git a/sys/arch/hppa/stand/cdboot/Makefile b/sys/arch/hppa/stand/cdboot/Makefile deleted file mode 100644 index ed9c79c1f..000000000 --- a/sys/arch/hppa/stand/cdboot/Makefile +++ /dev/null @@ -1,66 +0,0 @@ -# $OpenBSD: Makefile,v 1.11 2019/10/29 02:55:51 deraadt Exp $ - -NOMAN= no man -S =${.CURDIR}/../../../.. -CLEANFILES+= cdboot.gdb cdboot.map - -.if ${MACHINE} == "hppa" - -PROG= cdboot - -.PATH: ${.CURDIR}/../boot -SRCS+= srt0.S - -SRCS= srt0.S cdboot.c - -.PATH: ${.CURDIR}/../../../../lib/libsa -.PATH: ${.CURDIR}/../libsa -SRCS+= pdc.c itecons.c dev_hppa.c dk.c elf32.c elf64.c arc4.c -CPPFLAGS+=-DCONSPEED=9600 - -.PATH: ${S}/lib/libkern/arch/hppa ${S}/lib/libkern -SRCS+= milli.S strlen.c strlcpy.c - -LD?= ld -LDFLAGS+=-Bstatic -nostartfiles -nostdlib -N -Ttext $(LINKADDR) -nopie -znorelro -LDFLAGS+=-T ${.CURDIR}/ld.script -Map cdboot.map -SIZE?= size -STRIP?= strip -STANDIR=${.CURDIR}/.. -CRTBEGIN= -CRTEND= - -SAREL= -USE_LOADFILE=yes -.include "${S}/lib/libsa/Makefile.inc" -DPADD+= $(SALIB) -LDADD+= $(SALIB) - -all: ${PROG} - -clean:: - rm -f a.out [Ee]rrs mklog *.core \ - ${PROG} ${OBJS} ${LOBJS} ${CLEANFILES} - -realinstall: - ${INSTALL} ${INSTALL_COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \ - ${PROG} ${DESTDIR}${BINDIR} - -# TODO check for <=32k -${PROG}: $(OBJS) $(DPADD) - $(LD) $(LDFLAGS) -o $(PROG) $(OBJS) $(LDADD) - @cp ${PROG} ${PROG}.gdb - ${STRIP} ${PROG} - @${SIZE} $(PROG) - @${MKBOOT} -v ${PROG} ${PROG}.lif - @mv ${PROG}.lif ${PROG} -.else -NOPROG= -.endif - -.include - -CPPFLAGS+=-DRELOC=${LOADADDR} -DHEAP_LIMIT=${HEAP_LIMIT} -CFLAGS+=$(SACFLAGS) -I../.. -I${.CURDIR}/../libsa -I${S}/stand/boot -CFLAGS+=-fno-pie -AFLAGS+=-fno-pie diff --git a/sys/arch/hppa/stand/cdboot/cdboot.c b/sys/arch/hppa/stand/cdboot/cdboot.c deleted file mode 100644 index 8c394cbb8..000000000 --- a/sys/arch/hppa/stand/cdboot/cdboot.c +++ /dev/null @@ -1,99 +0,0 @@ -/* $OpenBSD: cdboot.c,v 1.16 2023/02/23 19:48:22 miod Exp $ */ - -/* - * Copyright (c) 2003 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "dev_hppa.h" -#include "cmd.h" - -dev_t bootdev; -int debug = 1; -int boottimeout = 5; - -struct fs_ops file_system[] = { - { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek, - cd9660_stat, cd9660_readdir }, -}; -int nfsys = nitems(file_system); - -struct devsw devsw[] = { - { "dk", iodcstrategy, dkopen, dkclose, noioctl }, -}; -int ndevs = nitems(devsw); - -struct consdev constab[] = { - { ite_probe, ite_init, ite_getc, ite_putc }, - { NULL } -}; -struct consdev *cn_tab; - -typedef void (*startfuncp)(int, int, int, int, int, int, caddr_t) - __attribute__ ((noreturn)); - -char rnddata[BOOTRANDOM_MAX]; /* XXX dummy */ -struct rc4_ctx randomctx; - -void -boot(dev_t dev) -{ - uint64_t marks[MARK_MAX]; - char path[128]; - - pdc_init(); - cninit(); - devboot(dev, path); - strncpy(path + strlen(path), ":/bsd.rd", 9); - printf(">> OpenBSD/" MACHINE " CDBOOT 0.2\n" - "booting %s: ", path); - - /* XXX note that rnddata is not initialized */ - rc4_keysetup(&randomctx, rnddata, sizeof rnddata); - rc4_skip(&randomctx, 1536); - - marks[MARK_START] = 0; - if (!loadfile(path, marks, LOAD_KERNEL)) { - marks[MARK_END] = ALIGN(marks[MARK_END]); - fcacheall(); - - __asm("mtctl %r0, %cr17"); - __asm("mtctl %r0, %cr17"); - (*(startfuncp)((u_long)marks[MARK_ENTRY]))((int)pdc, 0, bootdev, - (u_long)marks[MARK_END], BOOTARG_APIVER, BOOTARG_LEN, - (caddr_t)BOOTARG_OFF); - /* not reached */ - } -} diff --git a/sys/arch/hppa/stand/cdboot/elf64.c b/sys/arch/hppa/stand/cdboot/elf64.c deleted file mode 100644 index 2f261d8b8..000000000 --- a/sys/arch/hppa/stand/cdboot/elf64.c +++ /dev/null @@ -1,36 +0,0 @@ -/* $OpenBSD: elf64.c,v 1.2 2019/04/10 04:17:34 deraadt Exp $ */ - -/* - * Copyright (c) 2010 Mark Kettenis - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#include -#include - -#include "../../../../lib/libsa/loadfile.h" - -#undef ELFSIZE -#define ELFSIZE 64 - -#include - -int -ELFNAME(exec)(int fd, Elf_Ehdr *elf, uint64_t *marks, int flags) -{ - return 1; -} diff --git a/sys/arch/hppa/stand/cdboot/ld.script b/sys/arch/hppa/stand/cdboot/ld.script deleted file mode 100644 index 8bc7ceb3e..000000000 --- a/sys/arch/hppa/stand/cdboot/ld.script +++ /dev/null @@ -1,50 +0,0 @@ -/* $OpenBSD: ld.script,v 1.2 2010/05/09 13:27:30 kettenis Exp $ */ - -OUTPUT_FORMAT("elf32-hppa") -OUTPUT_ARCH(hppa) -ENTRY(begin) - -SECTIONS { - - /* Read-only sections, merged into text segment: */ - . = + SIZEOF_HEADERS; - .text : { - *(.text) - *(.text.*) - *(.rodata) - *(.rodata1) - *(.rodata.*) - *($CODE$) - etext = .; - } = 0x08000240 - - /* Read-write sections, merged into data segment: */ - .data : { - $global$ = .; - *(.data) - *(.data1) - *(.sdata) - *(.sdata2) - *(.dynamic) - CONSTRUCTORS - edata = ABSOLUTE(.); - } = 0 - - .bss : { - __bss_start = .; - *(.dynbss) - *(.bss) - *(.sbss) - *(.scommon) - *(COMMON) - end = ABSOLUTE(.); - __bss_end = .; - } - - /* don't need an unwind in the boot, unless we'll have a boot-ddb (; */ - /DISCARD/ : - { - *(.PARISC.unwind) - } -} - diff --git a/sys/arch/hppa/stand/libsa/Makefile b/sys/arch/hppa/stand/libsa/Makefile deleted file mode 100644 index 5aa85eb19..000000000 --- a/sys/arch/hppa/stand/libsa/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# $OpenBSD: Makefile,v 1.23 2020/03/12 19:19:37 otto Exp $ - -.include "${.CURDIR}/../Makefile.inc" - -LIB= sa - -S=${.CURDIR}/../../../.. -SADIR=${.CURDIR}/.. -DIR_SA= $S/lib/libsa - -NOPROFILE=noprofile -NOPIC=nopic - -#AS=cat ; -#AS+= -R -#AS+= -a - -# hppa stuff -SRCS= machdep.c pdc.c itecons.c dev_hppa.c time.c \ - ct.c dk.c lf.c lif.c cmd_hppa.c loadfile.c arc4.c elf32.c elf64.c - -# stand routines -SRCS+= alloc.c exit.c getfile.c getln.c getchar.c globals.c \ - printf.c putchar.c strerror.c strtol.c strchr.c ctime.c snprintf.c - -# io routines -SRCS+= close.c closeall.c dev.c disklabel.c dkcksum.c fchmod.c fstat.c \ - ioctl.c lseek.c open.c read.c stat.c write.c cread.c readdir.c cons.c - -# boot filesystems -SRCS+= ufs.c ufs2.c cd9660.c - -.PATH: ${DIR_SA} - -all: ${SALIB} - -install: - -.include - -CPPFLAGS+=-DHEAP_LIMIT=${HEAP_LIMIT} ${DEBUGFLAGS} -DNO_NET -CPPFLAGS+=-I${S}/stand/boot -CFLAGS+=${SACFLAGS} -D__INTERNAL_LIBSA_CREAD -DCOMPAT_UFS -fno-pie -CFLAGS+=-DCONSPEED=9600 diff --git a/sys/arch/hppa/stand/libsa/cmd_hppa.c b/sys/arch/hppa/stand/libsa/cmd_hppa.c deleted file mode 100644 index 8e81e22e6..000000000 --- a/sys/arch/hppa/stand/libsa/cmd_hppa.c +++ /dev/null @@ -1,1017 +0,0 @@ -/* $OpenBSD: cmd_hppa.c,v 1.12 2010/12/06 22:51:45 jasper Exp $ */ - -/* - * Copyright (c) 2002, 2009 Miodrag Vallat - * 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 OR HIS RELATIVES 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 MIND, 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 -/* would come from if -D_KERNEL */ -#define offsetof(s, e) ((size_t)&((s *)0)->e) - -#include -#include - -#include -#include - -#include -#include - -#include -#include "cmd.h" -#include "dev_hppa.h" /* pdc */ - -extern struct stable_storage sstor; -extern int sstorsiz; - -/* storage sizes we're interested in */ -#define CONSOLEOFFSET \ - offsetof(struct stable_storage, ss_console) -#define CONSOLESIZE \ - (offsetof(struct stable_storage, ss_console) + \ - sizeof(struct device_path)) - -#define KEYBOARDOFFSET \ - offsetof(struct stable_storage, ss_keyboard) -#define KEYBOARDSIZE \ - (offsetof(struct stable_storage, ss_keyboard) + \ - sizeof(struct device_path)) - -/* - * Table for the possible console devices found during the device walk. - */ -struct consoledev { - struct device_path dp; - int type; - int iodc_type; - int iodc_model; -}; - -#define PS2 1 -#define HIL 2 -#define USB 3 -#define SERIAL 4 -#define GRAPHICS 5 - -#define MAX_SERIALS 4 -#define MAX_KEYBOARDS 4 -#define MAX_GRAPHICS 4 - -struct consoledev serials[MAX_SERIALS]; -struct consoledev keyboards[MAX_KEYBOARDS]; -struct consoledev graphics[MAX_GRAPHICS]; - -int walked; - -void bus_walk(struct device_path *, int); -uint32_t dino_conf_read(u_int, int, int, u_int); -uint32_t elroy_conf_read(u_int, int, int, u_int); -int path_match(struct device_path *, struct device_path *); -void path_shift(struct device_path *, int); -void pci_bus_walk(struct device_path *, struct iodc_data *, - struct pdc_memmap *); -void register_device(struct consoledev *, int, struct device_path *, - struct iodc_data *, int, int); - -int Xconsole(void); -void print_console(void); -int set_graphics(struct device_path *, int, char *); -int set_serial(struct device_path *, int, char *); -int set_console(struct device_path *); - -int Xkeyboard(void); -void print_keyboard(void); -int set_keyboard(struct device_path *); - -struct cmd_table cmd_machine[] = { - { "console", CMDT_CMD, Xconsole }, - { "keyboard", CMDT_CMD, Xkeyboard }, - { NULL, }, -}; - -/* value to console speed table */ -const int i_speeds[] = { - 50, - 75, - 110, - 150, - 300, - 600, - 1200, - 2400, - 4800, - 7200, - 9600, - 19200, - 38400, - 57600, - 115200, - 230400, -}; - -const char *c_speeds[] = { - "50", - "75", - "110", - "150", - "300", - "600", - "1200", - "2400", - "4800", - "7200", - "9600", - "19200", - "38400", - "57600", - "115200", - "230400", -}; - -/* values to console parity table */ -const char *parities[] = { - "none", - "odd", - "", - "even", -}; - -/* - * C O N S O L E S E T T I N G S - */ - -void -print_console() -{ - int port, mode, speed, parity, bits; - int i; - -#ifdef DEBUG - printf("console flags %x mod %x bc %d/%d/%d/%d/%d/%d\n", - sstor.ss_console.dp_flags, - sstor.ss_console.dp_mod, - sstor.ss_console.dp_bc[0], - sstor.ss_console.dp_bc[1], - sstor.ss_console.dp_bc[2], - sstor.ss_console.dp_bc[3], - sstor.ss_console.dp_bc[4], - sstor.ss_console.dp_bc[5]); - - printf("console path %x/%x/%x/%x/%x/%x\n", - sstor.ss_console.dp_layers[0], - sstor.ss_console.dp_layers[1], - sstor.ss_console.dp_layers[2], - sstor.ss_console.dp_layers[3], - sstor.ss_console.dp_layers[4], - sstor.ss_console.dp_layers[5]); -#endif - - printf("Console path: "); - - /* look for a serial console */ - for (port = i = 0; i < MAX_SERIALS; i++) - if (path_match(&serials[i].dp, &sstor.ss_console)) { - port = i + 1; - break; - } - - if (port == 0) { - /* - * Graphics console - */ - - for (port = i = 0; i < MAX_GRAPHICS; i++) - if (path_match(&graphics[i].dp, &sstor.ss_console)) { - port = i; - break; - } - - /* - * If the console could still not be identified, consider - * it is a simplified encoding for the default graphics - * console. Hence port == 0, no need to check. - */ - if (port == 0) - printf("graphics"); - else - printf("graphics_%d", port); - - mode = sstor.ss_console.dp_layers[0]; - if (mode != 0) - printf(".%d", mode); - } else { - /* - * Serial console - */ - - if (port == 1) - printf("rs232"); - else - printf("rs232_%d", port); - - speed = PZL_SPEED(sstor.ss_console.dp_layers[0]); - printf(".%d", i_speeds[speed]); - - bits = PZL_BITS(sstor.ss_console.dp_layers[0]); - printf(".%d", bits); - - parity = PZL_PARITY(sstor.ss_console.dp_layers[0]); - printf(".%s", parities[parity]); - } - - printf("\n"); -} - -int -set_graphics(console, port, arg) - struct device_path *console; - int port; - char *arg; -{ - int maxmode, mode = 0; - char *digit; - - /* head */ - if (graphics[port].type == 0) { - printf("no such device found\n"); - return 0; - } - - /* mode */ - if (arg != NULL) { - for (digit = arg; *digit != '\0'; digit++) { - if (*digit >= '0' && *digit <= '9') - mode = 10 * mode + (*digit - '0'); - else { - printf("invalid mode specification, %s\n", arg); - return 0; - } - } - - if (mode <= 0) { - printf("invalid mode specification, %s\n", arg); - return 0; - } - } - - /* - * If we are just changing the mode of the same graphics - * console, check that our mode is in the valid range. - */ - if (path_match(&graphics[port].dp, &sstor.ss_console)) { - maxmode = sstor.ss_console.dp_layers[1]; - - /* pick back same mode if unspecified */ - if (mode == 0) - mode = sstor.ss_console.dp_layers[0]; - - if (mode > maxmode) { - printf("invalid mode value, available range is 1-%d\n", - maxmode); - return 0; - } - } else { - if (mode == 0) - mode = 1; - maxmode = mode; - } - - *console = graphics[port].dp; - console->dp_layers[0] = mode; - console->dp_layers[1] = maxmode; - console->dp_layers[2] = console->dp_layers[3] = - console->dp_layers[4] = console->dp_layers[5] = 0; - - return 1; -} - -int -set_serial(console, port, arg) - struct device_path *console; - int port; - char *arg; -{ - char *dot; - int i; - int speed, parity, bits; - - /* port */ - port--; - if (serials[port].type == 0) { - printf("no such device found\n"); - return 0; - } - - /* speed */ - dot = strchr(arg, '.'); - if (dot != NULL) - *dot++ = '\0'; - - speed = 0; - if (arg == NULL || *arg == '\0') { - for (i = 0; i < nitems(i_speeds); i++) - if (i_speeds[i] == 9600) { - speed = i; - break; - } - } else { - for (i = 0; i < nitems(c_speeds); i++) - if (strcmp(arg, c_speeds[i]) == 0) { - speed = i; - break; - } - if (speed == 0) { - printf("invalid speed specification, %s\n", arg); - return 0; - } - } - - /* data bits */ - arg = dot; - dot = strchr(arg, '.'); - - if (arg == NULL || *arg == '\0') - bits = 8; - else { - if (dot == arg + 1) - bits = *arg - '0'; - else - bits = 0; - - if (bits < 5 || bits > 8) { - printf("invalid bits specification, %s\n", arg); - return 0; - } - } - if (dot != NULL) - *dot++ = '\0'; - - /* parity */ - arg = dot; - if (arg == NULL || *arg == '\0') - parity = 0; /* none */ - else { - parity = -1; - for (i = 0; i <= 3; i++) - if (strcmp(arg, parities[i]) == 0) { - parity = i; - break; - } - if (parity == 2) - parity = -1; /* unknown parity */ - } - if (parity < 0) { - printf("invalid parity specification, %s\n", arg); - return 0; - } - - *console = serials[port].dp; - console->dp_layers[0] = PZL_ENCODE(bits, parity, speed); - - return 1; -} - -int -set_console(console) - struct device_path *console; -{ - char *arg = cmd.argv[1], *dot; - int port; - - /* extract first word */ - dot = strchr(arg, '.'); - if (dot != NULL) - *dot++ = '\0'; - - /* - * Graphics console - */ - if (strcmp(arg, "graphics") == 0) - return set_graphics(console, 0, dot); - if (strncmp(arg, "graphics_", 9) == 0) { - port = arg[9] - '0'; - if (port > 0 && port < MAX_GRAPHICS) - return set_graphics(console, port, dot); - } - - /* - * Serial console - */ - if (strcmp(arg, "rs232") == 0) - return set_serial(console, 1, dot); - if (strncmp(arg, "rs232_", 6) == 0) { - port = arg[6] - '0'; - if (port > 0 && port <= MAX_SERIALS) - return set_serial(console, port, dot); - } - - printf("invalid device specification, %s\n", arg); - return 0; -} - -int -Xconsole() -{ - struct device_path console; - int rc; - - /* walk the device list if not already done */ - if (walked == 0) { - bus_walk(NULL, MAXMODBUS); - walked++; - } - - if (sstorsiz < CONSOLESIZE) { - printf("no console information in stable storage\n"); - return 0; - } - - if (cmd.argc == 1) { - print_console(); - } else { - console = sstor.ss_console; - if (set_console(&console)) { - if (memcmp(&sstor.ss_console, &console, - sizeof console) != 0) { - sstor.ss_console = console; - - /* alea jacta est */ - rc = (*pdc)(PDC_STABLE, PDC_STABLE_WRITE, - CONSOLEOFFSET, &sstor.ss_console, - sizeof(sstor.ss_console)); - if (rc != 0) { - printf("failed to save console" - " settings, error %d\n", rc); - /* read sstor again for safety */ - (*pdc)(PDC_STABLE, PDC_STABLE_READ, - CONSOLEOFFSET, &sstor.ss_console, - sizeof(sstor.ss_console)); - } else - printf("you will need to power-cycle " - "your machine for the changes " - "to take effect.\n"); - } - print_console(); - } - } - - return 0; -} - -/* - * K E Y B O A R D S E T T I N G S - */ - -void -print_keyboard() -{ - int type; - int i; - -#ifdef DEBUG - printf("keyboard flags %x mod %x bc %d/%d/%d/%d/%d/%d\n", - sstor.ss_keyboard.dp_flags, - sstor.ss_keyboard.dp_mod, - sstor.ss_keyboard.dp_bc[0], - sstor.ss_keyboard.dp_bc[1], - sstor.ss_keyboard.dp_bc[2], - sstor.ss_keyboard.dp_bc[3], - sstor.ss_keyboard.dp_bc[4], - sstor.ss_keyboard.dp_bc[5]); - - printf("keyboard path %x/%x/%x/%x/%x/%x\n", - sstor.ss_keyboard.dp_layers[0], - sstor.ss_keyboard.dp_layers[1], - sstor.ss_keyboard.dp_layers[2], - sstor.ss_keyboard.dp_layers[3], - sstor.ss_keyboard.dp_layers[4], - sstor.ss_keyboard.dp_layers[5]); -#endif - - printf("Keyboard path: "); - - for (type = i = 0; i < MAX_KEYBOARDS; i++) - if (path_match(&keyboards[i].dp, &sstor.ss_keyboard)) { - type = keyboards[i].type; - break; - } - - switch (type) { - case USB: - printf("usb"); - break; - case HIL: - printf("hil"); - break; - case PS2: - printf("ps2"); - break; - default: - printf("unknown"); - break; - } - - printf("\n"); -} - -int -set_keyboard(keyboard) - struct device_path *keyboard; -{ - int i; - char *arg = cmd.argv[1]; - int type; - - if (strcmp(arg, "hil") == 0) - type = HIL; - else if (strcmp(arg, "ps2") == 0) - type = PS2; - else if (strcmp(arg, "usb") == 0) - type = USB; - else { - /* XXX should probably handle multiple USB controllers */ - printf("invalid device specification, %s\n", arg); - return 0; - } - - for (i = 0; i < MAX_KEYBOARDS; i++) - if (keyboards[i].type == type) { - *keyboard = keyboards[i].dp; - return 1; - } - - printf("no such device found\n"); - return 0; -} - -int -Xkeyboard() -{ - struct device_path keyboard; - int rc; - - /* walk the device list if not already done */ - if (walked == 0) { - bus_walk(NULL, MAXMODBUS); - walked++; - } - - if (sstorsiz < KEYBOARDSIZE) { - printf("no keyboard information in stable storage\n"); - return 0; - } - - if (cmd.argc == 1) { - print_keyboard(); - } else { - keyboard = sstor.ss_keyboard; - if (set_keyboard(&keyboard)) { - if (memcmp(&sstor.ss_keyboard, &keyboard, - sizeof keyboard) != 0) { - sstor.ss_keyboard = keyboard; - - /* alea jacta est */ - rc = (*pdc)(PDC_STABLE, PDC_STABLE_WRITE, - KEYBOARDOFFSET, &sstor.ss_keyboard, - sizeof(sstor.ss_keyboard)); - if (rc != 0) { - printf("failed to save keyboard" - " settings, error %d\n", rc); - /* read sstor again for safety */ - (*pdc)(PDC_STABLE, PDC_STABLE_READ, - KEYBOARDOFFSET, &sstor.ss_keyboard, - sizeof(sstor.ss_keyboard)); - } else - printf("you will need to power-cycle " - "your machine for the changes " - "to take effect.\n"); - } - print_keyboard(); - } - } - - return 0; -} - -/* - * U T I L I T I E S - */ - -/* - * Bus walker. - * This routine will walk all the modules on a given bus, registering - * serial ports, keyboard and graphics devices as they are found. - */ -void -bus_walk(struct device_path *idp, int maxmod) -{ - struct device_path dp; - struct pdc_memmap memmap; - struct iodc_data mptr; - int err, i, kluge_ps2 = 0; /* kluge, see below */ - - for (i = 0; i < maxmod; i++) { - if (idp) { - dp = *idp; - path_shift(&dp, i); - } else { - dp.dp_flags = 0; - dp.dp_bc[0] = dp.dp_bc[1] = dp.dp_bc[2] = - dp.dp_bc[3] = dp.dp_bc[4] = dp.dp_bc[5] = -1; - dp.dp_mod = i; - bzero(&dp.dp_layers, sizeof dp.dp_layers); - } - - if ((pdc)(PDC_MEMMAP, PDC_MEMMAP_HPA, &memmap, &dp) < 0 && - (pdc)(PDC_SYSMAP, PDC_SYSMAP_HPA, &memmap, &dp) < 0) - continue; - - if ((err = (pdc)(PDC_IODC, PDC_IODC_READ, &pdcbuf, memmap.hpa, - IODC_DATA, &mptr, sizeof(mptr))) < 0) - continue; - -#ifdef DEBUG - printf("device %d/%d/%d/%d/%d/%d " - "flags %d mod %x type %x model %x\n", - dp.dp_bc[0], dp.dp_bc[1], dp.dp_bc[2], dp.dp_bc[3], - dp.dp_bc[4], dp.dp_bc[5], dp.dp_flags, dp.dp_mod, - mptr.iodc_type, mptr.iodc_sv_model); -#endif - - /* - * If the device can be considered as a valid rs232, - * graphics console or keyboard, register it. - * - * Unfortunately, devices which should be considered as - * ``main'' aren't necessarily seen first. - * The rules we try to enforce here are as follows: - * - GIO PS/2 ports wins over any other PS/2 port. - * - the first GIO serial found wins over any other - * serial port. - * The second rule is a bit tricky to achieve, since on - * some machines (for example, 715/100XC), the two serial - * ports are not seen as attached to the same busses... - */ - switch (mptr.iodc_type) { - case HPPA_TYPE_BCPORT: - bus_walk(&dp, MAXMODBUS); - break; - case HPPA_TYPE_BRIDGE: - if (mptr.iodc_sv_model == HPPA_BRIDGE_DINO) { - pci_bus_walk(&dp, &mptr, &memmap); - break; - } - /* FALLTHROUGH */ - case HPPA_TYPE_BHA: - /* if there was no phantomas(4) here */ - if (dp.dp_bc[5] == -1) - path_shift(&dp, 0); - bus_walk(&dp, MAXMODBUS); - break; - case HPPA_TYPE_ADIRECT: - switch (mptr.iodc_sv_model) { - case HPPA_ADIRECT_RS232: - register_device(serials, MAX_SERIALS, - &dp, &mptr, SERIAL, 0); - break; - case HPPA_ADIRECT_HIL: - register_device(keyboards, MAX_KEYBOARDS, - &dp, &mptr, HIL, 0); - break; - case HPPA_ADIRECT_PEACOCK: - case HPPA_ADIRECT_LEONARDO: - register_device(graphics, MAX_GRAPHICS, - &dp, &mptr, GRAPHICS, 0); - break; - } - break; - case HPPA_TYPE_FIO: - switch (mptr.iodc_sv_model) { - case HPPA_FIO_HIL: - register_device(keyboards, MAX_KEYBOARDS, - &dp, &mptr, HIL, 0); - break; - case HPPA_FIO_RS232: /* com@gsc */ - register_device(serials, MAX_SERIALS, - &dp, &mptr, SERIAL, 0); - break; - case HPPA_FIO_DINOPCK: - register_device(keyboards, MAX_KEYBOARDS, - &dp, &mptr, PS2, 0); - break; - case HPPA_FIO_GPCIO: - /* - * KLUGE! At this point, there is no way to - * know if this port is the keyboard port or - * the mouse port. - * Let's assume the first port found is the - * keyboard, and ignore the others. - */ - if (kluge_ps2 != 0) - break; - register_device(keyboards, MAX_KEYBOARDS, - &dp, &mptr, PS2, 1); - kluge_ps2++; - break; - case HPPA_FIO_GRS232: /* com@dino, com@gsc */ - { - int j, first; - - /* - * If a GIO serial port is already registered, - * register as extra port... - */ - first = 1; - for (j = 0; j < MAX_SERIALS; j++) - if (serials[j].type == SERIAL && - serials[j].iodc_type == - HPPA_TYPE_FIO && - serials[j].iodc_model == - HPPA_FIO_GRS232) { - first = 0; - break; - } - - register_device(serials, MAX_SERIALS, - &dp, &mptr, SERIAL, first); - } - break; - case HPPA_FIO_SGC: - register_device(graphics, MAX_GRAPHICS, - &dp, &mptr, GRAPHICS, 0); - break; - case HPPA_FIO_GSGC: - register_device(graphics, MAX_GRAPHICS, - &dp, &mptr, GRAPHICS, 1); - break; -#if 0 /* can these really be used as console? */ - case HPPA_FIO_GRJ16: /* com@gsc */ - register_device(serials, MAX_SERIALS, - &dp, &mptr, SERIAL, 0); - break; -#endif - } - break; - case HPPA_TYPE_IOA: - switch (mptr.iodc_sv_model) { - case HPPA_IOA_UTURN: - bus_walk(&dp, MAXMODBUS - 1); - break; - } - break; - } - } -} - -/* - * PCI bus walker. - * The PDC device enumeration stops at the PCI bridge level, however - * in order to properly handle console path on systems with PCI graphics - * and USB controllers, it is necessary to dig further. - * - * Note that there are apparently PDC routines to access bridge configuration - * space, but I have yet to find documentation about them. - * - * We ignore multi-function devices and subordinate PCI busses here, since - * PDC PCI device paths stop at the PCI device number, and subordinate - * busses are unlikely to be configured by the PDC. - */ - -#define ELROY_MODEL 0x78 -#define DINO_PAMR 0x804 -#define DINO_CFG_ADDR 0x64 -#define DINO_CFG_DATA 0x68 - -void -pci_bus_walk(struct device_path *idp, struct iodc_data *mptr, - struct pdc_memmap *memmap) -{ - struct device_path dp; - int dev, fn, nfuncs; - uint32_t id, bhlcr, class; - uint32_t (*conf_read)(u_int, int, int, u_int); - - if (mptr->iodc_model == ELROY_MODEL) - conf_read = elroy_conf_read; - else - conf_read = dino_conf_read; - - for (dev = 0; dev < 32; dev++) { - id = (*conf_read)(memmap->hpa, dev, 0, PCI_ID_REG); - - if (PCI_VENDOR(id) == PCI_VENDOR_INVALID || PCI_VENDOR(id) == 0) - continue; - - bhlcr = (*conf_read)(memmap->hpa, dev, 0, PCI_BHLC_REG); - nfuncs = PCI_HDRTYPE_MULTIFN(bhlcr) ? 8 : 1; - - for (fn = 0; fn < nfuncs; fn++) { - dp = *idp; - path_shift(&dp, dev); - path_shift(&dp, fn); - - if (fn != 0) - id = (*conf_read)(memmap->hpa, dev, fn, - PCI_ID_REG); - class = (*conf_read)(memmap->hpa, dev, fn, - PCI_CLASS_REG); - - /* - * We are only interested in two kinds of devices - * here: sti graphics, and USB controllers. - */ - if (PCI_CLASS(class) == PCI_CLASS_SERIALBUS && - PCI_SUBCLASS(class) == PCI_SUBCLASS_SERIALBUS_USB) { - /* - * Note about the last parameter of the - * register_device() call below being zero: - * machines with USB keyboards have neither - * PS/2 nor HIL controllers, so it doesn't - * matter what order the USB controllers are - * in. - * However machines with PS/2 keyboards - * might have an USB PCI card plugged in, - * which better appear after the PS/2 - * keyboard. - */ - register_device(keyboards, MAX_KEYBOARDS, - &dp, mptr, USB, 0); - continue; - } - - switch (PCI_VENDOR(id)) { - case PCI_VENDOR_HP: - switch (PCI_PRODUCT(id)) { - case PCI_PRODUCT_HP_VISUALIZE_EG: - case PCI_PRODUCT_HP_VISUALIZE_FX2: - case PCI_PRODUCT_HP_VISUALIZE_FX4: - case PCI_PRODUCT_HP_VISUALIZE_FX6: - case PCI_PRODUCT_HP_VISUALIZE_FXE: - register_device(graphics, MAX_GRAPHICS, - &dp, mptr, GRAPHICS, 0); - break; - } - break; - case PCI_VENDOR_NS: - if (PCI_PRODUCT(id) == PCI_PRODUCT_NS_PC87560) { - /* serial_2 */ - path_shift(&dp, 2); - register_device(serials, MAX_SERIALS, - &dp, mptr, SERIAL, 1); - /* serial_1 */ - dp.dp_mod = 1; - register_device(serials, MAX_SERIALS, - &dp, mptr, SERIAL, 1); - } - break; - } - } - } -} - -uint32_t -dino_conf_read(u_int hpa, int dev, int fn, u_int reg) -{ - volatile uint32_t *dino = (volatile uint32_t *)hpa; - uint32_t pamr; - uint32_t addr, id; - - addr = (dev << 11) | (fn << 8) | reg; - - pamr = dino[DINO_PAMR / 4]; - dino[DINO_PAMR / 4] = 0; - dino[DINO_CFG_ADDR / 4] = addr; - id = dino[DINO_CFG_DATA / 4]; - dino[DINO_PAMR / 4] = pamr; - - return letoh32(id); -} - -uint32_t -elroy_conf_read(u_int hpa, int dev, int fn, u_int reg) -{ - volatile struct elroy_regs *elroy = (volatile struct elroy_regs *)hpa; - uint32_t arb_mask, err_cfg, control; - uint32_t addr, id; - - addr = (dev << 11) | (fn << 8) | reg; - - arb_mask = *(volatile uint32_t *)&elroy->arb_mask; - err_cfg = *(volatile uint32_t *)&elroy->err_cfg; - control = *(volatile uint32_t *)&elroy->control; - - if (arb_mask == 0) - *(volatile uint32_t *)&elroy->arb_mask = - htole32(ELROY_ARB_ENABLE); - *(volatile uint32_t *)&elroy->err_cfg = err_cfg | - htole32(ELROY_ERRCFG_SMART | ELROY_ERRCFG_CM); - *(volatile uint32_t *)&elroy->control = - (control | htole32(ELROY_CONTROL_CE)) & ~htole32(ELROY_CONTROL_HF); - - *(volatile uint32_t *)&elroy->pci_conf_addr = htole32(addr); - addr = *(volatile uint32_t *)&elroy->pci_conf_addr; - id = *(volatile uint32_t *)&elroy->pci_conf_data; - - *(volatile uint32_t *)&elroy->control = - control | htole32(ELROY_CONTROL_CE | ELROY_CONTROL_CL); - *(volatile uint32_t *)&elroy->control = control; - *(volatile uint32_t *)&elroy->err_cfg = err_cfg; - if (arb_mask == 0) - *(volatile uint32_t *)&elroy->arb_mask = arb_mask; - - return letoh32(id); -} - -/* - * Relaxed device comparison - */ -int -path_match(struct device_path *dev1, struct device_path *dev2) -{ - return dev1->dp_mod == dev2->dp_mod && - dev1->dp_bc[0] == dev2->dp_bc[0] && - dev1->dp_bc[1] == dev2->dp_bc[1] && - dev1->dp_bc[2] == dev2->dp_bc[2] && - dev1->dp_bc[3] == dev2->dp_bc[3] && - dev1->dp_bc[4] == dev2->dp_bc[4] && - dev1->dp_bc[5] == dev2->dp_bc[5]; -} - -/* - * Shift a device path, inserting a new value as dp_mod. - */ -void -path_shift(struct device_path *dp, int nmod) -{ - dp->dp_bc[0] = dp->dp_bc[1]; - dp->dp_bc[1] = dp->dp_bc[2]; - dp->dp_bc[2] = dp->dp_bc[3]; - dp->dp_bc[3] = dp->dp_bc[4]; - dp->dp_bc[4] = dp->dp_bc[5]; - dp->dp_bc[5] = dp->dp_mod; - dp->dp_mod = nmod; -} - -void -register_device(devlist, cnt, dp, mptr, type, first) - struct consoledev *devlist; - int cnt; - struct device_path *dp; - struct iodc_data *mptr; - int type; - int first; -{ - int i; - struct consoledev *dev; - - for (i = 0, dev = devlist; i < cnt; i++, dev++) - if (dev->type == 0) - break; - - if (i == cnt) { -#ifdef DEBUG - printf("can't register device, need more room!\n"); -#endif - return; - } - - /* - * If this is supposedly the main device, insert on top - */ - if (first != 0) { - memcpy(devlist + 1, devlist, - (cnt - 1) * sizeof(struct consoledev)); - dev = devlist; - } - - dev->dp = *dp; - dev->type = type; - dev->iodc_type = mptr->iodc_type; - dev->iodc_model = mptr->iodc_sv_model; - -#ifdef DEBUG - printf("(registered as type %d)\n", type); -#endif -} diff --git a/sys/arch/hppa/stand/libsa/ct.c b/sys/arch/hppa/stand/libsa/ct.c deleted file mode 100644 index 443291161..000000000 --- a/sys/arch/hppa/stand/libsa/ct.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $OpenBSD: ct.c,v 1.10 2023/03/08 04:43:07 guenther Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 1996 1995 by Open Software Foundation, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include "libsa.h" - -#include -#include -#include - -#include -#include - -#include "dev_hppa.h" - -int -ctopen(struct open_file *f, ...) -{ - struct hppa_dev *dp = f->f_devdata; - - if (!(dp->pz_dev = pdc_findev(-1, PCL_SEQU))) - return (ENXIO); - - return (0); -} - -int -ctclose(f) - struct open_file *f; -{ - free (f->f_devdata, sizeof(struct hppa_dev)); - f->f_devdata = NULL; - return 0; -} diff --git a/sys/arch/hppa/stand/libsa/dev_hppa.c b/sys/arch/hppa/stand/libsa/dev_hppa.c deleted file mode 100644 index 8ed4b5212..000000000 --- a/sys/arch/hppa/stand/libsa/dev_hppa.c +++ /dev/null @@ -1,197 +0,0 @@ -/* $OpenBSD: dev_hppa.c,v 1.17 2014/07/13 09:26:08 jasper Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 "libsa.h" -#include -#include -#include -#include - -#include - -#include "dev_hppa.h" - -extern int debug; - -const char cdevs[][4] = { - "ite", "", "", "", "", "", "", "", - "", "", "", "", "" -}; -const int ncdevs = nitems(cdevs); - -const struct pdc_devs { - char name[3]; - int dev_type; -} pdc_devs[] = { - { "dk", 0 }, - { "ct", 1 }, - { "lf", 2 }, - { "", -1 }, - { "rd", -1 }, - { "sw", -1 }, - { "fl", -1 }, -}; - -/* pass dev_t to the open routines */ -int -devopen(f, fname, file) - struct open_file *f; - const char *fname; - char **file; -{ - struct hppa_dev *hpd; - const struct pdc_devs *dp = pdc_devs; - int rc = 1; - - if (!(*file = strchr(fname, ':'))) - return ENODEV; - else - (*file)++; - -#ifdef DEBUG - if (debug) - printf("devopen: "); -#endif - - for (dp = pdc_devs; dp < &pdc_devs[nitems(pdc_devs)]; dp++) - if (!strncmp(fname, dp->name, sizeof(dp->name)-1)) - break; - - if (dp >= &pdc_devs[nitems(pdc_devs)] || dp->dev_type < 0) - return ENODEV; -#ifdef DEBUG - if (debug) - printf("%s\n", dp->name); -#endif - - if (!(hpd = alloc(sizeof *hpd))) { -#ifdef DEBUG - printf ("devopen: no mem\n"); -#endif - } else { - bzero(hpd, sizeof *hpd); - hpd->bootdev = bootdev; - hpd->buf = (char *)(((u_int)hpd->ua_buf + IODC_MINIOSIZ-1) & - ~(IODC_MINIOSIZ-1)); - f->f_devdata = hpd; - if ((rc = (*devsw[dp->dev_type].dv_open)(f, file)) == 0) { - f->f_dev = &devsw[dp->dev_type]; - return 0; - } - free (hpd, 0); - f->f_devdata = NULL; - } - - if (!(f->f_flags & F_NODEV)) - f->f_dev = &devsw[dp->dev_type]; - - if (!f->f_devdata) - *file = NULL; - - return rc; -} - -void -devboot(dev, p) - dev_t dev; - char *p; -{ - const char *q; - int unit; - - if (!dev) { - int type; - - switch (PAGE0->mem_boot.pz_class) { - case PCL_RANDOM: - type = 0; - unit = PAGE0->mem_boot.pz_layers[0]; - break; - case PCL_SEQU: - type = 1; - unit = PAGE0->mem_boot.pz_layers[0]; - break; - case PCL_NET_MASK|PCL_SEQU: - type = 2; - unit = 0; - break; - default: - type = 0; - unit = 0; - break; - } - dev = bootdev = MAKEBOOTDEV(type, 0, 0, unit, B_PARTITION(dev)); - } -#ifdef _TEST - *p++ = '/'; - *p++ = 'd'; - *p++ = 'e'; - *p++ = 'v'; - *p++ = '/'; - *p++ = 'r'; -#endif - /* quick copy device name */ - for (q = pdc_devs[B_TYPE(dev)].name; (*p++ = *q++);); - unit = B_UNIT(dev); - if (unit >= 10) { - p[-1] = '0' + unit / 10; - *p++ = '0' + (unit % 10); - } else - p[-1] = '0' + unit; - *p++ = 'a' + B_PARTITION(dev); - *p = '\0'; -} - -char ttyname_buf[8]; - -char * -ttyname(fd) - int fd; -{ - snprintf(ttyname_buf, sizeof ttyname_buf, "%s%d", - cdevs[major(cn_tab->cn_dev)], - minor(cn_tab->cn_dev)); - return (ttyname_buf); -} - -dev_t -ttydev(name) - char *name; -{ - int i, unit = -1; - char *no = name + strlen(name) - 1; - - while (no >= name && *no >= '0' && *no <= '9') - unit = (unit < 0 ? 0 : (unit * 10)) + *no-- - '0'; - if (no < name || unit < 0) - return (NODEV); - for (i = 0; i < ncdevs; i++) - if (strncmp(name, cdevs[i], no - name + 1) == 0) - return (makedev(i, unit)); - return (NODEV); -} diff --git a/sys/arch/hppa/stand/libsa/dev_hppa.h b/sys/arch/hppa/stand/libsa/dev_hppa.h deleted file mode 100644 index 5e9bcf161..000000000 --- a/sys/arch/hppa/stand/libsa/dev_hppa.h +++ /dev/null @@ -1,43 +0,0 @@ -/* $OpenBSD: dev_hppa.h,v 1.9 2011/03/13 00:13:52 deraadt Exp $ */ - - -#define IOPGSHIFT 11 -#define IONBPG (1 << IOPGSHIFT) -#define IOPGOFSET (IONBPG - 1) - -struct disklabel; -struct hppa_dev { - dev_t bootdev; - struct pz_device *pz_dev; /* device descriptor */ - daddr32_t fsoff; /* offset to the file system */ - daddr32_t last_blk; /* byte offset for last read blk */ - size_t last_read; /* amount read last time */ - struct disklabel *label; - /* buffer to cache data (aligned properly) */ - char *buf; - char ua_buf[IODC_IOSIZ + IODC_MINIOSIZ]; -}; - -#ifdef PDCDEBUG -#define DEVPATH_PRINT(dp) \ - printf("%x, %d.%d.%d.%d.%d.%d, 0x%x, %x.%x.%x.%x.%x.%x\n", \ - (dp)->dp_flags, (dp)->dp_bc[0], (dp)->dp_bc[1], (dp)->dp_bc[2], \ - (dp)->dp_bc[3], (dp)->dp_bc[4], (dp)->dp_bc[5], (dp)->dp_mod, \ - (dp)->dp_layers[0], (dp)->dp_layers[1], (dp)->dp_layers[2], \ - (dp)->dp_layers[3], (dp)->dp_layers[4], (dp)->dp_layers[5]); -#define PZDEV_PRINT(dp) \ - printf("devpath={%x, %d.%d.%d.%d.%d.%d, 0x%x, %x.%x.%x.%x.%x.%x}," \ - "\n\thpa=%p, spa=%p, io=%p, class=%u\n", \ - (dp)->pz_flags, (dp)->pz_bc[0], (dp)->pz_bc[1], (dp)->pz_bc[2], \ - (dp)->pz_bc[3], (dp)->pz_bc[4], (dp)->pz_bc[5], (dp)->pz_mod, \ - (dp)->pz_layers[0], (dp)->pz_layers[1], (dp)->pz_layers[2], \ - (dp)->pz_layers[3], (dp)->pz_layers[4], (dp)->pz_layers[5], \ - (dp)->pz_hpa, (dp)->pz_spa, (dp)->pz_iodc_io, (dp)->pz_class); -#endif - -extern pdcio_t pdc; -extern int pdcbuf[]; /* PDC returns, pdc.c */ - -int iodc_rw(char *, u_int, u_int, int func, struct pz_device *); -const char *dk_disklabel(struct hppa_dev *dp, struct disklabel *label); - diff --git a/sys/arch/hppa/stand/libsa/dk.c b/sys/arch/hppa/stand/libsa/dk.c deleted file mode 100644 index 4a73ccd8a..000000000 --- a/sys/arch/hppa/stand/libsa/dk.c +++ /dev/null @@ -1,101 +0,0 @@ -/* $OpenBSD: dk.c,v 1.15 2015/10/01 16:08:20 krw Exp $ */ - -/* - * Copyright 1996 1995 by Open Software Foundation, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include "libsa.h" - -#include -#include -#include -#include -#include - -#include "dev_hppa.h" - -const char * -dk_disklabel(struct hppa_dev *dp, struct disklabel *label) -{ - char buf[DEV_BSIZE]; - size_t ret; - - if (iodcstrategy(dp, F_READ, LABELSECTOR, DEV_BSIZE, buf, &ret)) - if (ret != DEV_BSIZE) - return "cannot read disklabel"; - - return (getdisklabel(buf, label)); -} - -int -dkopen(struct open_file *f, ...) -{ - struct disklabel *lp; - struct hppa_dev *dp = f->f_devdata; - const char *st; - -#ifdef DEBUG - if (debug) - printf("dkopen(%p)\n", f); -#endif - - if (!(dp->pz_dev = pdc_findev(-1, PCL_RANDOM))) - return ENXIO; - - lp = dp->label; - st = NULL; - -#ifdef DEBUG - if (debug) - printf ("disklabel\n"); -#endif - - if ((st = dk_disklabel(dp, lp)) != NULL) { -#ifdef DEBUG - if (debug) - printf ("dkopen: %s\n", st); -#endif - /* we do not know if it's a disk or net, but do not fail */ - } else { - u_int i; - - i = B_PARTITION(dp->bootdev); - if (i >= lp->d_npartitions || !lp->d_partitions[i].p_size) - return (EPART); - - dp->fsoff = lp->d_partitions[i].p_offset; - } - -#ifdef DEBUG - if (debug) - printf ("dkopen() ret\n"); -#endif - return (0); -} - -int -dkclose(f) - struct open_file *f; -{ - free (f->f_devdata, sizeof(struct hppa_dev)); - f->f_devdata = NULL; - return 0; -} diff --git a/sys/arch/hppa/stand/libsa/elf32.c b/sys/arch/hppa/stand/libsa/elf32.c deleted file mode 100644 index 4bf83948e..000000000 --- a/sys/arch/hppa/stand/libsa/elf32.c +++ /dev/null @@ -1,32 +0,0 @@ -/* $OpenBSD: elf32.c,v 1.1 2007/12/26 18:52:59 kettenis Exp $ */ - -/* - * Copyright (c) 2007 Tom Cosgrove - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#include -#include - -#include "../../../../lib/libsa/loadfile.h" - -#undef ELFSIZE -#define ELFSIZE 32 - -#include - -#include "../../../../lib/libsa/loadfile_elf.c" diff --git a/sys/arch/hppa/stand/libsa/elf64.c b/sys/arch/hppa/stand/libsa/elf64.c deleted file mode 100644 index fab232f3c..000000000 --- a/sys/arch/hppa/stand/libsa/elf64.c +++ /dev/null @@ -1,32 +0,0 @@ -/* $OpenBSD: elf64.c,v 1.1 2007/12/26 18:52:59 kettenis Exp $ */ - -/* - * Copyright (c) 2007 Tom Cosgrove - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#include - -#include -#include - -#include "../../../../lib/libsa/loadfile.h" - -#undef ELFSIZE -#define ELFSIZE 64 - -#include - -#include "../../../../lib/libsa/loadfile_elf.c" diff --git a/sys/arch/hppa/stand/libsa/itecons.c b/sys/arch/hppa/stand/libsa/itecons.c deleted file mode 100644 index ffcd37cfc..000000000 --- a/sys/arch/hppa/stand/libsa/itecons.c +++ /dev/null @@ -1,219 +0,0 @@ -/* $OpenBSD: itecons.c,v 1.12 2014/07/17 12:37:46 miod Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 1996 1995 by Open Software Foundation, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ - -#include "libsa.h" - -#include -#include -#include -#include -#include - -#include "dev_hppa.h" - -iodcio_t cniodc; /* console IODC entry point */ -iodcio_t kyiodc; /* keyboard IODC entry point */ -pz_device_t *cons_pzdev, *kbd_pzdev; - -/* - * Console. - */ - -char cnbuf[IODC_MINIOSIZ] __attribute__ ((aligned (IODC_MINIOSIZ))); -int kycode[IODC_MAXSIZE/sizeof(int)]; - -int -cnspeed(dev_t dev, int sp) -{ - return CONSPEED; -} - -void -ite_probe(cn) - struct consdev *cn; -{ - cniodc = (iodcio_t)PAGE0->mem_free; - cons_pzdev = &PAGE0->mem_cons; - kbd_pzdev = &PAGE0->mem_kbd; - - if ((*pdc) (PDC_IODC, PDC_IODC_READ, pdcbuf, cons_pzdev->pz_hpa, - IODC_INIT, cniodc, IODC_MAXSIZE) < 0 || - (*cniodc)(cons_pzdev->pz_hpa, - (cons_pzdev->pz_hpa==PAGE0->mem_boot.pz_hpa)? - IODC_INIT_DEV: IODC_INIT_ALL, cons_pzdev->pz_spa, - cons_pzdev->pz_layers, pdcbuf, 0,0,0,0) < 0 || - (*pdc) (PDC_IODC, PDC_IODC_READ, pdcbuf, cons_pzdev->pz_hpa, - IODC_IO, cniodc, IODC_MAXSIZE) < 0) { - /* morse code with the LED's?!! */ - cons_pzdev->pz_iodc_io = kbd_pzdev->pz_iodc_io = NULL; - } else { - cn->cn_pri = CN_MIDPRI; - cn->cn_dev = makedev(0, 0); - } -} - -void -ite_init(cn) - struct consdev *cn; -{ - /* - * If the keyboard is separate from the console output device, - * we load the keyboard code at `kycode'. - * - * N.B. In this case, since the keyboard code is part of the - * boot code, it will be overwritten when we load a kernel. - */ - if (cons_pzdev->pz_class != PCL_DUPLEX || - kbd_pzdev->pz_class == PCL_KEYBD) { - - kyiodc = (iodcio_t)kycode; - - if ((*pdc) (PDC_IODC, PDC_IODC_READ, pdcbuf, kbd_pzdev->pz_hpa, - IODC_INIT, kyiodc, IODC_MAXSIZE) < 0 || - (*kyiodc)(kbd_pzdev->pz_hpa, - (kbd_pzdev->pz_hpa == PAGE0->mem_boot.pz_hpa || - kbd_pzdev->pz_hpa == cons_pzdev->pz_hpa)? - IODC_INIT_DEV: IODC_INIT_ALL, kbd_pzdev->pz_spa, - kbd_pzdev->pz_layers, pdcbuf, 0, 0, 0, 0) < 0 || - (*pdc) (PDC_IODC, PDC_IODC_READ, pdcbuf, kbd_pzdev->pz_hpa, - IODC_IO, kyiodc, IODC_MAXSIZE)) - kyiodc = NULL; - } else { - kyiodc = cniodc; - - bcopy((char *)&PAGE0->mem_cons, (char *)&PAGE0->mem_kbd, - sizeof(struct pz_device)); - } - - cons_pzdev->pz_iodc_io = (u_int)cniodc; - kbd_pzdev->pz_iodc_io = (u_int)kyiodc; -#ifdef DEBUG - if (!kyiodc) - printf("ite_init: no kbd\n"); -#endif -} - -void -ite_putc(dev, c) - dev_t dev; - int c; -{ - if (cniodc == NULL) - return; - - *cnbuf = c; - - (*cniodc)(cons_pzdev->pz_hpa, IODC_IO_CONSOUT, cons_pzdev->pz_spa, - cons_pzdev->pz_layers, pdcbuf, 0, cnbuf, 1, 0); -} - -/* - * since i don't know how to 'just check the char available' - * i store the key into the stash removing on read op later; - */ -int -ite_getc(dev) - dev_t dev; -{ - static int stash = 0; - int err, c, l, i; - - if (kyiodc == NULL) - return(0x100); - - if (stash) { - c = stash; - if (!(dev & 0x80)) - stash = 0; - return c; - } - - i = 16; - do { - err = (*kyiodc)(kbd_pzdev->pz_hpa, IODC_IO_CONSIN, - kbd_pzdev->pz_spa, kbd_pzdev->pz_layers, - pdcbuf, 0, cnbuf, 1, 0); - l = pdcbuf[0]; - c = cnbuf[0]; -#ifdef DEBUG - if (debug && err < 0) - printf("KBD input error: %d", err); -#endif - - /* if we are doing ischar() report immediately */ - if (!i-- && (dev & 0x80) && l == 0) { -#ifdef DEBUG - if (debug > 2) - printf("ite_getc(0x%x): no char %d(%x)\n", - dev, l, c); -#endif - return (0); - } - } while(!l); - -#if DEBUG - if (debug && l > 1) - printf("KBD input got too much (%d)\n", l); - - if (debug > 3) - printf("kbd: \'%c\' (0x%x)\n", c, c); -#endif - if (dev & 0x80) - stash = c; - - return (c); -} - -void -ite_pollc(dev, on) - dev_t dev; - int on; -{ - -} diff --git a/sys/arch/hppa/stand/libsa/lf.c b/sys/arch/hppa/stand/libsa/lf.c deleted file mode 100644 index e23d9886c..000000000 --- a/sys/arch/hppa/stand/libsa/lf.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $OpenBSD: lf.c,v 1.10 2014/07/12 21:03:38 tedu Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include "libsa.h" -#include -#include - -#include "dev_hppa.h" - -int -lfopen(struct open_file *f, ...) -{ - struct hppa_dev *dp = f->f_devdata; - - if (!(dp->pz_dev = pdc_findev(-1, PCL_NET_MASK|PCL_SEQU))) - return ENXIO; - - return 0; -} - -int -lfclose(struct open_file *f) -{ - free(f->f_devdata, sizeof(struct hppa_dev)); - f->f_devdata = NULL; - return 0; -} diff --git a/sys/arch/hppa/stand/libsa/libsa.h b/sys/arch/hppa/stand/libsa/libsa.h deleted file mode 100644 index 4e2b9697e..000000000 --- a/sys/arch/hppa/stand/libsa/libsa.h +++ /dev/null @@ -1,79 +0,0 @@ -/* $OpenBSD: libsa.h,v 1.17 2023/02/23 19:48:22 miod Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 - -#define EXEC_ELF -#define EXEC_SOM - -extern dev_t bootdev; - -void pdc_init(void); -struct pz_device; -struct pz_device *pdc_findev(int, int); - -int iodcstrategy(void *, int, daddr_t, size_t, void *, size_t *); - -int ctopen(struct open_file *, ...); -int ctclose(struct open_file *); - -int dkopen(struct open_file *, ...); -int dkclose(struct open_file *); - -int lfopen(struct open_file *, ...); -int lfstrategy(void *, int, daddr_t, size_t, void *, size_t *); -int lfclose(struct open_file *); - -void ite_probe(struct consdev *); -void ite_init(struct consdev *); -int ite_getc(dev_t); -void ite_putc(dev_t, int); -void ite_pollc(dev_t, int); - -void machdep(void); -void devboot(dev_t, char *); -void fcacheall(void); -void run_loadfile(uint64_t *marks, int howto); - -int lif_open(char *path, struct open_file *f); -int lif_close(struct open_file *f); -int lif_read(struct open_file *f, void *buf, size_t size, size_t *resid); -int lif_write(struct open_file *f, void *buf, size_t size, size_t *resid); -off_t lif_seek(struct open_file *f, off_t offset, int where); -int lif_stat(struct open_file *f, struct stat *sb); -int lif_readdir(struct open_file *f, char *name); - -union x_header; -struct x_param; -int som_probe(int, union x_header *); -int som_load(int, struct x_param *); -int som_ldsym(int, struct x_param *); - -extern int debug; - -#define MACHINE_CMD cmd_machine /* we have hppa specific commands */ diff --git a/sys/arch/hppa/stand/libsa/lif.c b/sys/arch/hppa/stand/libsa/lif.c deleted file mode 100644 index 99e43f255..000000000 --- a/sys/arch/hppa/stand/libsa/lif.c +++ /dev/null @@ -1,270 +0,0 @@ -/* $OpenBSD: lif.c,v 1.10 2004/11/22 18:41:41 mickey Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include "libsa.h" - -extern int debug; - -struct file { - char f_buf[LIF_FILESTART];/* buffer for lif volume header and dir */ - struct lifvol *f_lp; /* lif volume header pointer */ - struct lifdir *f_ld; /* lif dir pointer */ - int f_nfiles; /* gross number for lif dir entries */ - - off_t f_seek; /* seek pointer for file read */ - struct lifdir *f_rd; /* lif dir pointer for readdir */ - - int f_isdir; /* special hacky flag for '.' dir */ - int f_count; /* this file length */ - int f_off; /* this file offset */ -}; - -int -lif_open (path, f) - char *path; - struct open_file *f; -{ - struct file *fp; - struct lifdir *dp; - char *p, *q; - struct lif_load load; - size_t buf_size; - int err, l; - -#ifdef LIFDEBUG - if (debug) - printf("lif_open(%s, %p)\n", path, f); -#endif - - fp = alloc(sizeof(*fp)); - /* XXX we're assuming here that sizeof(fp->f_buf) >= LIF_FILESTART */ - if ((err = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, 0, - sizeof(fp->f_buf), &fp->f_buf, &buf_size)) || - buf_size != sizeof(fp->f_buf)) { -#ifdef LIFDEBUG - if (debug) - printf("lif_open: unable to read LIF header (%d)\n", err); -#endif - } else if ((fp->f_lp = (struct lifvol *)fp->f_buf)->vol_id == LIF_VOL_ID) { - f->f_fsdata = fp; - fp->f_ld = (struct lifdir *)(fp->f_buf + LIF_DIRSTART); - fp->f_seek = 0; - fp->f_rd = fp->f_ld; - fp->f_nfiles = lifstob(fp->f_lp->vol_dirsize) / - sizeof(struct lifdir); - - /* no dirs on the lif */ - for (p = path + (l = strlen(path)); p >= path; p--) - if (*p == '/') { - p++; - break; - } - if (p > path) - path = p; - } else - err = EINVAL; - - if (!err && *path != '.') { - fp->f_isdir = 0; - err = ENOENT; - for (dp = fp->f_ld; dp < &fp->f_ld[fp->f_nfiles]; dp++) { -#ifdef LIFDEBUG - if (debug) - printf("lif_open: " - "%s <--> '%c%c%c%c%c%c%c%c%c%c'\n", - path, dp->dir_name[0], dp->dir_name[1], - dp->dir_name[2], dp->dir_name[3], - dp->dir_name[4], dp->dir_name[5], - dp->dir_name[6], dp->dir_name[7], - dp->dir_name[8], dp->dir_name[9]); -#endif - for (p = path, q = dp->dir_name; - *q && *q != ' '; q++, p++) - if (tolower(*q) != tolower(*p)) - break; - if ((!*q || *q == ' ') && !*p) { - err = 0; - break; - } - } - if (!err) { - fp->f_off = lifstodb(dp->dir_addr); - if (!(err =(f->f_dev->dv_strategy)(f->f_devdata, F_READ, - fp->f_off, sizeof(load), &load, &buf_size)) && - buf_size == sizeof(load)) { - /* no checksum */ - fp->f_count = load.count - sizeof(int); - fp->f_off = dbtob(fp->f_off) + sizeof(load); -#ifdef LIFDEBUG - if (debug) - printf("lif_open: %u @ %u [%x]\n", - fp->f_count, fp->f_off, - load.address); -#endif - } else if (!err) - err = EIO; - } - } else - fp->f_isdir = 1; - - if (err) { - free (fp, sizeof(*fp)); - f->f_fsdata = NULL; - } -#ifdef LIFDEBUG - if (debug) - printf("ret(%d)\n", err); -#endif - return err; -} - -int -lif_close(f) - struct open_file *f; -{ - free (f->f_fsdata, sizeof(struct file)); - f->f_fsdata = NULL; - return 0; -} - -int -lif_read(f, buf, size, resid) - struct open_file *f; - void *buf; - size_t size; - size_t *resid; -{ - struct file *fp = (struct file *)f->f_fsdata; - char *p; - char bbuf[DEV_BSIZE]; - size_t bsize, count = sizeof(bbuf); - int err = 0; - int foff; - -#ifdef LIFDEBUG - if (debug) - printf("lif_read(%p, %p, %u, %p)\n", f, buf, size, resid); -#endif - - for (p = bbuf; size; fp->f_seek += bsize, p += bsize) { - twiddle(); - foff = fp->f_off + fp->f_seek; - if (fp->f_seek >= fp->f_count || - (err = (f->f_dev->dv_strategy)(f->f_devdata, F_READ, - btodb(foff), count, p, &bsize))) - break; - if (p == bbuf) { - bsize = sizeof(bbuf) - (foff & (sizeof(bbuf) - 1)); - bsize = min(bsize, size); - bcopy(bbuf + (foff & (sizeof(bbuf) - 1)), buf, bsize); - p = buf; - } - count = size -= bsize; - } - if (resid) - *resid = size; - - return err; -} - -int -lif_write(f, buf, size, resid) - struct open_file *f; - void *buf; - size_t size; - size_t *resid; -{ - return EOPNOTSUPP; -} - -off_t -lif_seek(f, offset, where) - struct open_file *f; - off_t offset; - int where; -{ - struct file *fp = (struct file *)f->f_fsdata; - - switch (where) { - case SEEK_SET: - fp->f_seek = offset; - break; - case SEEK_CUR: - fp->f_seek += offset; - break; - case SEEK_END: - fp->f_seek = fp->f_count - offset; - break; - default: - return (-1); - } - return (fp->f_seek); -} - -int -lif_stat(f, sb) - struct open_file *f; - struct stat *sb; -{ - struct file *fp = (struct file *)f->f_fsdata; - - sb->st_mode = 0755 | (fp->f_isdir? S_IFDIR: 0); /* XXX */ - sb->st_uid = 0; - sb->st_gid = 0; - sb->st_size = fp->f_count; - return 0; -} - -int -lif_readdir(f, name) - struct open_file *f; - char *name; -{ - struct file *fp = (struct file *)f->f_fsdata; - char *p; - - if (name) { - while ((fp->f_rd->dir_name[0] == ' ' || - !fp->f_rd->dir_name[0]) && - (fp->f_rd - fp->f_ld) < fp->f_nfiles) - fp->f_rd++; - if ((fp->f_rd - fp->f_ld) >= fp->f_nfiles) { - *name = '\0'; - return -1; - } - strncpy(name, fp->f_rd->dir_name, sizeof(fp->f_rd->dir_name)); - if ((p = strchr(name, ' '))) - *p = '\0'; - fp->f_rd++; - } else - fp->f_rd = fp->f_ld; - - return 0; -} diff --git a/sys/arch/hppa/stand/libsa/machdep.c b/sys/arch/hppa/stand/libsa/machdep.c deleted file mode 100644 index 850d5ad0a..000000000 --- a/sys/arch/hppa/stand/libsa/machdep.c +++ /dev/null @@ -1,84 +0,0 @@ -/* $OpenBSD: machdep.c,v 1.9 2004/04/07 18:24:20 mickey Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include "libsa.h" -#include -#include - -#include "dev_hppa.h" - -extern struct stable_storage sstor; /* contents of Stable Storage */ -int howto; -dev_t bootdev; - -void -machdep() -{ - pdc_init(); -#ifdef notyet - debug_init(); -#endif - cninit(); - -#ifdef PDCDEBUG - if (debug) { - int i; - - printf("SSTOR:\n"); - printf("pri_boot="); DEVPATH_PRINT(&sstor.ss_pri_boot); - printf("alt_boot="); DEVPATH_PRINT(&sstor.ss_alt_boot); - printf("console ="); DEVPATH_PRINT(&sstor.ss_console); - printf("keyboard="); DEVPATH_PRINT(&sstor.ss_keyboard); - printf("mem=%d, fn=%s, osver=%d\nos={", - sstor.ss_fast_size, sstor.ss_filenames, - sstor.ss_os_version); - for (i = 0; i < sizeof(sstor.ss_os); i++) - printf ("%x%c", sstor.ss_os[i], (i%8)? ',' : '\n'); - - printf("}\nPAGE0:\n"); - printf("ivec=%x, pf=%p[%u], toc=%p[%u], rndz=%p, clk/10ms=%u\n", - PAGE0->ivec_special, PAGE0->ivec_mempf, - PAGE0->ivec_mempflen, PAGE0->ivec_toc, - PAGE0->ivec_toclen, PAGE0->ivec_rendz, - PAGE0->mem_10msec); - printf ("mem: cont=%u, phys=%u, pdc_spa=%u, resv=%u, free=%x\n" - "cpu_hpa=%x, pdc=%p, imm_hpa=%p[%u,%u], soft=%u\n", - PAGE0->memc_cont, PAGE0->memc_phsize, PAGE0->memc_adsize, - PAGE0->memc_resv, PAGE0->mem_free, PAGE0->mem_hpa, - PAGE0->mem_pdc, PAGE0->imm_hpa, PAGE0->imm_spa_size, - PAGE0->imm_max_mem, PAGE0->imm_soft_boot); - - printf("console: "); PZDEV_PRINT(&PAGE0->mem_cons); - printf("boot: "); PZDEV_PRINT(&PAGE0->mem_boot); - printf("keyboard: "); PZDEV_PRINT(&PAGE0->mem_kbd); - } -#endif -} diff --git a/sys/arch/hppa/stand/libsa/pdc.c b/sys/arch/hppa/stand/libsa/pdc.c deleted file mode 100644 index f92c07506..000000000 --- a/sys/arch/hppa/stand/libsa/pdc.c +++ /dev/null @@ -1,461 +0,0 @@ -/* $OpenBSD: pdc.c,v 1.24 2023/01/06 19:05:46 miod Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 1996 1995 by Open Software Foundation, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - */ -/* - * Copyright (c) 1990 mt Xinu, Inc. All rights reserved. - * Copyright (c) 1990 University of Utah. All rights reserved. - * - * This file may be freely distributed in any form as long as - * this copyright notice is included. - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED - * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. - * - * Utah $Hdr: pdc.c 1.8 92/03/14$ - */ - -#include -#include -#include "libsa.h" -#include -#include - -#include -#include -#include -#include - -#include "dev_hppa.h" - -/* - * Interface routines to initialize and access the PDC. - */ - -pdcio_t pdc; -int pdcbuf[64] PDC_ALIGNMENT;/* PDC return buffer */ -struct stable_storage sstor; /* contents of Stable Storage */ -int sstorsiz; /* size of Stable Storage */ - -/* - * Initialize PDC and related variables. - */ -void -pdc_init() -{ - int err; - - /* - * Initialize important global variables (defined above). - */ - pdc = (pdcio_t)PAGE0->mem_pdc; - - err = (*pdc)(PDC_STABLE, PDC_STABLE_SIZE, pdcbuf, 0, 0); - if (err >= 0) { - sstorsiz = min(pdcbuf[0],sizeof(sstor)); - err = (*pdc)(PDC_STABLE, PDC_STABLE_READ, 0, &sstor, sstorsiz); - } - - /* - * Now that we (may) have an output device, if we encountered - * an error reading Stable Storage (above), let them know. - */ -#ifdef DEBUG - if (debug && err) - printf("Stable storage PDC_STABLE Read Ret'd %d\n", err); -#endif - - /* - * Clear the FAULT light (so we know when we get a real one) - */ - (*pdc)(PDC_CHASSIS, PDC_CHASSIS_DISP, - PDC_OSTAT(PDC_OSTAT_BOOT) | 0xCEC0); -} - -/* - * Generic READ/WRITE through IODC. Takes pointer to PDC device - * information, returns (positive) number of bytes actually read or - * the (negative) error condition, or zero if at "EOF". - */ -int -iodcstrategy(devdata, rw, blk, size, buf, rsize) - void *devdata; - int rw; - daddr_t blk; - size_t size; - void *buf; - size_t *rsize; -{ - struct hppa_dev *dp = devdata; - struct pz_device *pzdev = dp->pz_dev; - int offset, xfer, ret; - -#ifdef PDCDEBUG - if (debug) - printf("iodcstrategy(%p, %s, %u, %u, %p, %p)\n", devdata, - rw==F_READ? "READ" : "WRITE", blk, size, buf, rsize); - - if (debug > 1) - PZDEV_PRINT(pzdev); -#endif - - blk += dp->fsoff; - blk *= DEV_BSIZE; - if ((pzdev->pz_class & PCL_CLASS_MASK) == PCL_SEQU) { - /* rewind and re-read to seek */ - if (blk < dp->last_blk) { -#ifdef PDCDEBUG - if (debug) - printf("iodc: rewind "); -#endif - if ((ret = ((iodcio_t)pzdev->pz_iodc_io)(pzdev->pz_hpa, - IODC_IO_READ, pzdev->pz_spa, pzdev->pz_layers, - pdcbuf, 0, dp->buf, 0, 0)) < 0) { -#ifdef DEBUG - if (debug) - printf("IODC_IO: %d\n", ret); -#endif - return (EIO); - } else { - dp->last_blk = 0; - dp->last_read = 0; - } - } - -#ifdef PDCDEBUG - if (debug) - printf("seek %d ", dp->last_blk); -#endif - for (; (dp->last_blk + dp->last_read) <= blk; - dp->last_read = ret) { - twiddle(); - dp->last_blk += dp->last_read; - if ((ret = ((iodcio_t)pzdev->pz_iodc_io)(pzdev->pz_hpa, - IODC_IO_READ, pzdev->pz_spa, pzdev->pz_layers, - pdcbuf, dp->last_blk, dp->buf, IODC_IOSIZ, - IODC_IOSIZ)) < 0) { -#ifdef DEBUG - if (debug) - printf("IODC_IO: %d\n", ret); -#endif - return (EIO); - } - if ((ret = pdcbuf[0]) == 0) - break; -#ifdef PDCDEBUG - if (debug) - printf("-"); -#endif - } -#ifdef PDCDEBUG - if (debug) - printf("> %d[%d]\n", dp->last_blk, dp->last_read); -#endif - } - - xfer = 0; - /* On read, see if we can scratch anything from buffer */ - if (rw == F_READ && - dp->last_blk <= blk && (dp->last_blk + dp->last_read) > blk) { - twiddle(); - offset = blk - dp->last_blk; - xfer = min(dp->last_read - offset, size); - size -= xfer; - blk += xfer; -#ifdef PDCDEBUG - if (debug) - printf("off=%d,xfer=%d,size=%d,blk=%d\n", - offset, xfer, size, blk); -#endif - bcopy(dp->buf + offset, buf, xfer); - buf += xfer; - } - - /* - * double buffer it all the time, to cache - */ - for (; size; size -= ret, buf += ret, blk += ret, xfer += ret) { - offset = blk & IOPGOFSET; - if (rw != F_READ) { - /* put block into cache, but invalidate cache */ - bcopy(buf, dp->buf, size); - dp->last_blk = 0; - dp->last_read = 0; - } - if ((ret = ((iodcio_t)pzdev->pz_iodc_io)(pzdev->pz_hpa, - (rw == F_READ? IODC_IO_READ: IODC_IO_WRITE), - pzdev->pz_spa, pzdev->pz_layers, pdcbuf, - (u_int)blk - offset, dp->buf, IODC_IOSIZ, IODC_IOSIZ)) < 0) { -#ifdef DEBUG - if (debug) - printf("iodc_read(%d,%d): %d\n", - blk - offset, IODC_IOSIZ, ret); -#endif - if (xfer) - break; - else - return (EIO); - } - if ((ret = pdcbuf[0]) <= 0) - break; - if (rw == F_READ) { - dp->last_blk = blk - offset; - dp->last_read = ret; - if ((ret -= offset) > size) - ret = size; - bcopy(dp->buf + offset, buf, ret); - } -#ifdef PDCDEBUG - if (debug) - printf("read %d(%d,%d)@%x ", ret, - dp->last_blk, dp->last_read, (u_int)buf); -#endif - } - -#ifdef PDCDEBUG - if (debug) - printf("\n"); -#endif - - if (rsize) - *rsize = xfer; - return (0); -} - -/* - * Find a device with specified unit number - * (any if unit == -1), and of specified class (PCL_*). - */ -struct pz_device * -pdc_findev(unit, class) - int unit, class; -{ - static struct pz_device pz; - int layers[sizeof(pz.pz_layers)/sizeof(pz.pz_layers[0])]; - struct iomod *io; - iodcio_t iodc; - int err = 0; - -#ifdef PDCDEBUG - if (debug) - printf("pdc_finddev(%d, %x)\n", unit, class); -#endif - iodc = (iodcio_t)(PAGE0->mem_free + IODC_MAXSIZE); - io = (struct iomod *)PAGE0->mem_boot.pz_hpa; - - /* quick hack for boot device */ - if (PAGE0->mem_boot.pz_class == class && - (unit == -1 || PAGE0->mem_boot.pz_layers[0] == unit)) { - - bcopy (&PAGE0->mem_boot.pz_dp, &pz.pz_dp, sizeof(pz.pz_dp)); - bcopy (pz.pz_layers, layers, sizeof(layers)); - if ((err = (pdc)(PDC_IODC, PDC_IODC_READ, pdcbuf, io, - IODC_INIT, iodc, IODC_MAXSIZE)) < 0) { -#ifdef DEBUG - if (debug) - printf("IODC_READ: %d\n", err); -#endif - return NULL; - } - } else { - struct pdc_memmap memmap; - struct iodc_data mptr; - int i, stp; - - for (i = 0; i < 0xf; i++) { - pz.pz_bc[0] = pz.pz_bc[1] = - pz.pz_bc[2] = pz.pz_bc[3] = -1; - pz.pz_bc[4] = 2; - pz.pz_bc[5] = 0; /* core bus */ - pz.pz_mod = i; - if ((pdc)(PDC_MEMMAP, PDC_MEMMAP_HPA, &memmap, - &pz.pz_dp) < 0) - continue; -#ifdef PDCDEBUG - if (debug) - printf("memap: %d.%d.%d, hpa=%x, mpgs=%x\n", - pz.pz_bc[4], pz.pz_bc[5], pz.pz_mod, - memmap.hpa, memmap.morepages); -#endif - io = (struct iomod *) memmap.hpa; - - if ((err = (pdc)(PDC_IODC, PDC_IODC_READ, &pdcbuf, io, - IODC_DATA, &mptr, sizeof(mptr))) < 0) { -#ifdef DEBUG - if (debug) - printf("IODC_DATA: %d\n", err); -#endif - continue; - } - - if ((err = (pdc)(PDC_IODC, PDC_IODC_READ, pdcbuf, io, - IODC_INIT, iodc, IODC_MAXSIZE)) < 0) { -#ifdef DEBUG - if (debug) - printf("IODC_READ: %d\n", err); -#endif - continue; - } - - stp = IODC_INIT_FIRST; - do { - if ((err = (iodc)((u_int)io, stp, io->io_spa, - layers, pdcbuf, 0, 0, 0, 0)) < 0) { -#ifdef DEBUG - if (debug && err != PDC_ERR_EOD) - printf("IODC_INIT_%s: %d\n", - stp==IODC_INIT_FIRST? - "FIRST":"NEXT", err); -#endif - break; - } -#ifdef PDCDEBUG - if (debug) - printf("[%x,%x,%x,%x,%x,%x], " - "[%x,%x,%x,%x,%x,%x]\n", - pdcbuf[0], pdcbuf[1], pdcbuf[2], - pdcbuf[3], pdcbuf[4], pdcbuf[5], - layers[0], layers[1], layers[2], - layers[3], layers[4], layers[5]); -#endif - stp = IODC_INIT_NEXT; - - } while (pdcbuf[1] != class && - unit != -1 && unit != layers[0]); - - if (err >= 0) - break; - } - } - - if (err >= 0) { - /* init device */ - if (0 && (err = (iodc)((u_int)io, IODC_INIT_DEV, io->io_spa, - layers, pdcbuf, 0, 0, 0, 0)) < 0) { -#ifdef DEBUG - if (debug) - printf("INIT_DEV: %d\n", err); -#endif - return NULL; - } - - /* read i/o entry code */ - if ((err = (pdc)(PDC_IODC, PDC_IODC_READ, pdcbuf, io, - IODC_IO, iodc, IODC_MAXSIZE)) < 0) { -#ifdef DEBUG - if (debug) - printf("IODC_READ: %d\n", err); -#endif - return NULL; - } - - pz.pz_flags = 0; - bcopy(layers, pz.pz_layers, sizeof(pz.pz_layers)); - pz.pz_hpa = (u_int)io; -/* XXX pz.pz_spa = io->io_spa; */ - pz.pz_iodc_io = (u_int)iodc; - pz.pz_class = class; - - return &pz; - } - - return NULL; -} - -static __inline void -fall(int c_base, int c_count, int c_loop, int c_stride, int data) -{ - int loop; /* Internal vars */ - - for (; c_count--; c_base += c_stride) - for (loop = c_loop; loop--; ) - if (data) - fdce(0, c_base); - else - fice(0, c_base); -} - -/* - * fcacheall - Flush all caches. - * - * This routine is just a wrapper around the real cache flush routine. - */ -struct pdc_cache pdc_cacheinfo PDC_ALIGNMENT; - -void -fcacheall() -{ - int err; - - if ((err = (*pdc)(PDC_CACHE, PDC_CACHE_DFLT, &pdc_cacheinfo)) < 0) { -#ifdef DEBUG - if (debug) - printf("fcacheall: PDC_CACHE failed (%d).\n", err); -#endif - return; - } -#if PDCDEBUG - if (debug) - printf("pdc_cache:\nic={%u,%x,%x,%u,%u,%u}\n" - "dc={%u,%x,%x,%u,%u,%u}\n", - pdc_cacheinfo.ic_size, *(u_int *)&pdc_cacheinfo.ic_conf, - pdc_cacheinfo.ic_base, pdc_cacheinfo.ic_stride, - pdc_cacheinfo.ic_count, pdc_cacheinfo.ic_loop, - pdc_cacheinfo.dc_size, *(u_int *)&pdc_cacheinfo.ic_conf, - pdc_cacheinfo.dc_base, pdc_cacheinfo.dc_stride, - pdc_cacheinfo.dc_count, pdc_cacheinfo.dc_loop); -#endif - /* - * Flush the instruction, then data cache. - */ - fall(pdc_cacheinfo.ic_base, pdc_cacheinfo.ic_count, - pdc_cacheinfo.ic_loop, pdc_cacheinfo.ic_stride, 0); - sync_caches(); - fall(pdc_cacheinfo.dc_base, pdc_cacheinfo.dc_count, - pdc_cacheinfo.dc_loop, pdc_cacheinfo.dc_stride, 1); - sync_caches(); -} diff --git a/sys/arch/hppa/stand/libsa/time.c b/sys/arch/hppa/stand/libsa/time.c deleted file mode 100644 index 9dac8f3ab..000000000 --- a/sys/arch/hppa/stand/libsa/time.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $OpenBSD: time.c,v 1.5 2004/04/07 18:24:20 mickey Exp $ */ - -/* - * Copyright (c) 1998-2004 Michael Shalayeff - * 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 OR HIS RELATIVES 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 MIND, 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 -#include -#include -#include "libsa.h" -#include "dev_hppa.h" - -time_t -getsecs() -{ - time_t tt; - int err; - - if ((err = (*pdc)(PDC_TOD, PDC_TOD_READ, &pdcbuf)) < 0) { - tt = 0; -#ifdef DEBUG - if (debug) - printf("getsecs: TOD read failed (%d)\n", err); -#endif - } else { - tt = ((struct pdc_tod *)pdcbuf)->sec; -#ifdef DEBUG - if (debug && tt < 800000000) - printf("getsecs: got %u seconds\n", tt); -#endif - } - - return tt; -} diff --git a/sys/arch/hppa/stand/libz/Makefile b/sys/arch/hppa/stand/libz/Makefile deleted file mode 100644 index d57a8d578..000000000 --- a/sys/arch/hppa/stand/libz/Makefile +++ /dev/null @@ -1,10 +0,0 @@ -# $OpenBSD: Makefile,v 1.4 2012/08/31 16:13:20 pascal Exp $ - -S=${.CURDIR}/../../../.. -ZDST=${.OBJDIR} -SADIR=${.CURDIR}/.. - -.PATH: ${S}/lib/libz - -.include "${S}/lib/libz/Makefile" -CFLAGS+=${SACFLAGS} -I${S}/lib/libsa -fno-pie diff --git a/sys/arch/hppa/stand/mkboot/Makefile b/sys/arch/hppa/stand/mkboot/Makefile deleted file mode 100644 index 81f7dc51a..000000000 --- a/sys/arch/hppa/stand/mkboot/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -# $OpenBSD: Makefile,v 1.6 2003/07/19 00:03:52 david Exp $ - -MAN= mkboot.8 -MANSUBDIR=hppa - -.if ${MACHINE} == "hppa" -PROG= mkboot -CC= ${HOSTCC} -LDSTATIC= -static -.else -NOPROG= -.endif - -.include diff --git a/sys/arch/hppa/stand/mkboot/mkboot.8 b/sys/arch/hppa/stand/mkboot/mkboot.8 deleted file mode 100644 index f1261c82b..000000000 --- a/sys/arch/hppa/stand/mkboot/mkboot.8 +++ /dev/null @@ -1,55 +0,0 @@ -.\" $OpenBSD: mkboot.8,v 1.10 2015/01/15 19:06:32 schwarze Exp $ -.\" -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. 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. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. -.\" -.Dd $Mdocdate: January 15 2015 $ -.Dt MKBOOT 8 hppa -.Os -.Sh NAME -.Nm mkboot -.Nd create LIF files -.Sh SYNOPSIS -.Nm mkboot -.Op Fl v -.Op Fl l Ar loadpoint -.Ar program ... outfile -.Sh DESCRIPTION -Creates the LIF file containing the bootstrap -.Ar program -and possibly other programs to be used -by the HP 9000/700 and HP 9000/800 systems. -.Pp -An argument to the -.Fl l -option specifies the load point for the boot program, -with the default value of zero. -.Sh HISTORY -An -.Nm -utility first appeared in -.Ox 2.4 . diff --git a/sys/arch/hppa/stand/mkboot/mkboot.c b/sys/arch/hppa/stand/mkboot/mkboot.c deleted file mode 100644 index 88d71da06..000000000 --- a/sys/arch/hppa/stand/mkboot/mkboot.c +++ /dev/null @@ -1,370 +0,0 @@ -/* $OpenBSD: mkboot.c,v 1.21 2017/12/30 23:08:29 guenther Exp $ */ - -/* - * Copyright (c) 1990, 1993 - * The Regents of the University of California. 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. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. - * - * @(#)mkboot.c 8.1 (Berkeley) 7/15/93 - */ - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef hppa -/* hack for cross compile XXX */ -#include "../../include/disklabel.h" -#else -#include -#endif - -int putfile(char *, int); -void __dead usage(void); -void bcddate(char *, char *); -char *lifname(char *); -int cksum(int, int *, int); - -char *to_file; -int loadpoint, verbose; -u_long entry; - -/* - * Old Format: - * sector 0: LIF volume header (40 bytes) - * sector 1: - * sector 2: LIF directory (8 x 32 == 256 bytes) - * sector 3-: LIF file 0, LIF file 1, etc. - * where sectors are 256 bytes. - * - * New Format: - * sector 0: LIF volume header (40 bytes) - * sector 1: - * sector 2: LIF directory (8 x 32 == 256 bytes) - * sector 3: - * sector 4-31: disklabel (~300 bytes right now) - * sector 32-: LIF file 0, LIF file 1, etc. - */ -int -main(int argc, char **argv) -{ - int to; - register int n, pos, c; - char buf[LIF_FILESTART]; - struct lifvol *lifv = (struct lifvol *)buf; - struct lifdir *lifd = (struct lifdir *)(buf + LIF_DIRSTART); - - while ((c = getopt(argc, argv, "vl:")) != -1) { - switch (c) { - case 'v': - verbose++; - break; - case 'l': - sscanf(optarg, "0x%x", &loadpoint); - break; - default: - usage(); - } - } - if (argc - optind < 2) - usage(); - else if (argc - optind > 8) - errx(1, "too many boot programs (max 8 supported)"); - - to_file = argv[--argc]; - if ((to = open(to_file, O_RDWR | O_TRUNC | O_CREAT, 0644)) < 0) - err(1, "%s: open", to_file); - - bzero(buf, sizeof(buf)); - /* clear possibly unused directory entries */ - memset(lifd[1].dir_name, ' ', sizeof lifd[1].dir_name); - lifd[1].dir_type = -1; - lifd[1].dir_addr = 0; - lifd[1].dir_length = 0; - lifd[1].dir_flag = 0xFF; - lifd[1].dir_implement = 0; - lifd[7] = lifd[6] = lifd[5] = lifd[4] = lifd[3] = lifd[2] = lifd[1]; - - /* record volume info */ - lifv->vol_id = htobe16(LIF_VOL_ID); - strncpy(lifv->vol_label, "BOOT44", 6); - lifv->vol_addr = htobe32(btolifs(LIF_DIRSTART)); - lifv->vol_oct = htobe16(LIF_VOL_OCT); - lifv->vol_dirsize = htobe32(btolifs(LIF_DIRSIZE)); - lifv->vol_version = htobe16(1); - lifv->vol_lastvol = lifv->vol_number = htobe16(1); - lifv->vol_length = LIF_FILESTART; - bcddate(to_file, lifv->vol_toc); - lifv->ipl_addr = htobe32(LIF_FILESTART); - lifv->ipl_size = 0; - lifv->ipl_entry = 0; - - argv += optind; - argc -= optind; - optind = 0; - for (pos = LIF_FILESTART; optind < argc; optind++) { - - /* output bootfile */ - lseek(to, pos, 0); - lifd[optind].dir_addr = htobe32(btolifs(pos)); - n = btolifs(putfile(argv[optind], to)); - if (lifv->ipl_entry == 0) { - lifv->ipl_entry = htobe32(loadpoint + entry); - lifv->ipl_size = htobe32(lifstob(n)); - lifd[optind].dir_type = htobe16(LIF_DIR_ISL); - lifd[optind].dir_implement = 0; - } else { - lifd[optind].dir_type = htobe16(LIF_DIR_TYPE); - lifd[1].dir_implement = htobe32(loadpoint + entry); - } - - strlcpy(lifd[optind].dir_name, lifname(argv[optind]), - sizeof lifd[optind].dir_name); - lifd[optind].dir_length = htobe32(n); - bcddate(argv[optind], lifd[optind].dir_toc); - lifd[optind].dir_flag = htobe16(LIF_DIR_FLAG); - - lifv->vol_length += n; - pos += lifstob(n); - } - - lifv->vol_length = htobe32(lifv->vol_length); - - /* output volume/directory header info */ - lseek(to, LIF_VOLSTART, 0); - if (write(to, buf, sizeof(buf)) != sizeof(buf)) - err(1, "%s: write LIF volume", to_file); - lseek(to, 0, SEEK_END); - - if (close(to) < 0) - err(1, "%s", to_file); - - return (0); -} - -int -putfile(char *from_file, int to) -{ - struct exec ex; - register int n, total; - char buf[2048]; - int from, check_sum = 0; - struct lif_load load; - - if ((from = open(from_file, O_RDONLY)) < 0) - err(1, "%s", from_file); - - n = read(from, &ex, sizeof(ex)); - if (n != sizeof(ex)) - err(1, "%s: reading file header", from_file); - - entry = ex.a_entry; - if (N_GETMAGIC(ex) == OMAGIC || N_GETMAGIC(ex) == NMAGIC) - entry += sizeof(ex); - else if (IS_ELF(*(Elf32_Ehdr *)&ex)) { - Elf32_Ehdr elf_header; - Elf32_Phdr *elf_segments; - int i, header_count, memory_needed, elf_load_image_segment; - - (void) lseek(from, 0, SEEK_SET); - n = read(from, &elf_header, sizeof(elf_header)); - if (n != sizeof (elf_header)) - err(1, "%s: reading ELF header", from_file); - header_count = ntohs(elf_header.e_phnum); - elf_segments = reallocarray(NULL, header_count, - sizeof(*elf_segments)); - if (elf_segments == NULL) - err(1, "malloc"); - memory_needed = header_count * sizeof(*elf_segments); - (void) lseek(from, ntohl(elf_header.e_phoff), SEEK_SET); - n = read(from, elf_segments, memory_needed); - if (n != memory_needed) - err(1, "%s: reading ELF segments", from_file); - elf_load_image_segment = -1; - for (i = 0; i < header_count; i++) { - if (elf_segments[i].p_filesz && - ntohl(elf_segments[i].p_flags) & PF_X) { - if (elf_load_image_segment != -1) - errx(1, "%s: more than one ELF program segment", from_file); - elf_load_image_segment = i; - } - } - if (elf_load_image_segment == -1) - errx(1, "%s: no suitable ELF program segment", from_file); - entry = ntohl(elf_header.e_entry) + - ntohl(elf_segments[elf_load_image_segment].p_offset) - - ntohl(elf_segments[elf_load_image_segment].p_vaddr); - free(elf_segments); - } else if (*(u_char *)&ex == 0x1f && ((u_char *)&ex)[1] == 0x8b) { - entry = 0; - } else - errx(1, "%s: bad magic number", from_file); - - entry += sizeof(load); - lseek(to, sizeof(load), SEEK_CUR); - total = 0; - n = sizeof(buf) - sizeof(load); - /* copy the whole file */ - for (lseek(from, 0, 0); ; n = sizeof(buf)) { - bzero(buf, sizeof(buf)); - if ((n = read(from, buf, n)) < 0) - err(1, "%s", from_file); - else if (n == 0) - break; - - if (write(to, buf, n) != n) - err(1, "%s", to_file); - - total += n; - check_sum = cksum(check_sum, (int *)buf, n); - } - - /* load header */ - load.address = htobe32(loadpoint + sizeof(load)); - load.count = htobe32(4 + total); - check_sum = cksum(check_sum, (int *)&load, sizeof(load)); - - if (verbose) - warnx("wrote %d bytes of file \'%s\'", total, from_file); - - total += sizeof(load); - /* insert the header */ - lseek(to, -total, SEEK_CUR); - if (write(to, &load, sizeof(load)) != sizeof(load)) - err(1, "%s", to_file); - lseek(to, total - sizeof(load), SEEK_CUR); - - bzero(buf, sizeof(buf)); - /* pad to int */ - n = sizeof(int) - total % sizeof(int); - if (total % sizeof(int)) { - if (write(to, buf, n) != n) - err(1, "%s", to_file); - else - total += n; - } - - /* pad to the blocksize */ - n = sizeof(buf) - total % sizeof(buf); - - if (n < sizeof(int)) { - n += sizeof(buf); - total += sizeof(buf); - } else - total += n; - - /* TODO should pad here to the 65k boundary for tape boot */ - - if (verbose) - warnx("checksum is 0x%08x", -check_sum); - - check_sum = htobe32(-check_sum); - if (write(to, &check_sum, sizeof(int)) != sizeof(int)) - err(1, "%s", to_file); - - n -= sizeof(int); - - if (write(to, buf, n) != n) - err(1, "%s", to_file); - - if (close(from) < 0 ) - err(1, "%s", from_file); - - return total; -} - -int -cksum(int ck, int *p, int size) -{ - /* we assume size is int-aligned */ - for (size = (size + sizeof(int) - 1) / sizeof(int); size--; p++ ) - ck += betoh32(*p); - - return ck; -} - -void __dead -usage(void) -{ - extern char *__progname; - fprintf(stderr, - "usage: %s [-v] [-l loadpoint] prog1 {progN} outfile\n", - __progname); - exit(1); -} - -char * -lifname(char *str) -{ - static char lname[10] = "XXXXXXXXXX"; - register int i; - - for (i = 0; i < 9; i++) { - if (islower(*str)) - lname[i] = toupper(*str); - else if (isalnum(*str) || *str == '_') - lname[i] = *str; - else - break; - str++; - } - for ( ; i < 10; i++) - lname[i] = ' '; - return(lname); -} - - -void -bcddate(char *file, char *toc) -{ - struct stat statb; - struct tm *tm; - - stat(file, &statb); - tm = localtime(&statb.st_ctime); - *toc = (tm->tm_year / 10) << 4; - *toc++ |= tm->tm_year % 10; - *toc = ((tm->tm_mon+1) / 10) << 4; - *toc++ |= (tm->tm_mon+1) % 10; - *toc = (tm->tm_mday / 10) << 4; - *toc++ |= tm->tm_mday % 10; - *toc = (tm->tm_hour / 10) << 4; - *toc++ |= tm->tm_hour % 10; - *toc = (tm->tm_min / 10) << 4; - *toc++ |= tm->tm_min % 10; - *toc = (tm->tm_sec / 10) << 4; - *toc |= tm->tm_sec % 10; -} diff --git a/sys/dev/fdt/files.fdt b/sys/dev/fdt/files.fdt index ff1084285..5089bcc92 100644 --- a/sys/dev/fdt/files.fdt +++ b/sys/dev/fdt/files.fdt @@ -1,4 +1,4 @@ -# $OpenBSD: files.fdt,v 1.192 2023/05/23 14:10:27 patrick Exp $ +# $OpenBSD: files.fdt,v 1.193 2023/06/10 18:31:38 patrick Exp $ # # Config file and device description for machine-independent FDT code. # Included by ports that need it. @@ -691,6 +691,11 @@ device qcmtx attach qcmtx at fdt file dev/fdt/qcmtx.c qcmtx +# Qualcomm Peripheral Authentication Service +device qcpas +attach qcpas at fdt +file dev/fdt/qcpas.c qcpas + # Qualcomm SCM device qcscm attach qcscm at fdt diff --git a/sys/dev/fdt/qcpas.c b/sys/dev/fdt/qcpas.c new file mode 100644 index 000000000..1a5774274 --- /dev/null +++ b/sys/dev/fdt/qcpas.c @@ -0,0 +1,1286 @@ +/* $OpenBSD: qcpas.c,v 1.1 2023/06/10 18:31:38 patrick Exp $ */ +/* + * Copyright (c) 2023 Patrick Wildt + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "apm.h" + +#define MDT_TYPE_MASK (7 << 24) +#define MDT_TYPE_HASH (2 << 24) +#define MDT_RELOCATABLE (1 << 27) + +#define HREAD4(sc, reg) \ + (bus_space_read_4((sc)->sc_iot, (sc)->sc_ioh, (reg))) +#define HWRITE4(sc, reg, val) \ + bus_space_write_4((sc)->sc_iot, (sc)->sc_ioh, (reg), (val)) + +struct qcpas_dmamem { + bus_dmamap_t tdm_map; + bus_dma_segment_t tdm_seg; + size_t tdm_size; + caddr_t tdm_kva; +}; +#define QCPAS_DMA_MAP(_tdm) ((_tdm)->tdm_map) +#define QCPAS_DMA_LEN(_tdm) ((_tdm)->tdm_size) +#define QCPAS_DMA_DVA(_tdm) ((_tdm)->tdm_map->dm_segs[0].ds_addr) +#define QCPAS_DMA_KVA(_tdm) ((void *)(_tdm)->tdm_kva) + +struct qcpas_softc { + struct device sc_dev; + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + bus_dma_tag_t sc_dmat; + int sc_node; + + void *sc_ih[6]; + + paddr_t sc_mem_phys; + size_t sc_mem_size; + void *sc_mem_region; + vaddr_t sc_mem_reloc; + + uint32_t sc_pas_id; + char *sc_load_state; + + struct qcpas_dmamem *sc_metadata; + + /* GLINK */ + volatile uint32_t *sc_tx_tail; + volatile uint32_t *sc_tx_head; + volatile uint32_t *sc_rx_tail; + volatile uint32_t *sc_rx_head; + + uint32_t sc_tx_off; + uint32_t sc_rx_off; + + uint8_t *sc_tx_fifo; + int sc_tx_fifolen; + uint8_t *sc_rx_fifo; + int sc_rx_fifolen; + void *sc_glink_ih; + + struct mbox_channel *sc_mc; + + struct task sc_glink_rx; + uint32_t sc_glink_max_channel; + TAILQ_HEAD(,qcpas_glink_channel) sc_glink_channels; +}; + +int qcpas_match(struct device *, void *, void *); +void qcpas_attach(struct device *, struct device *, void *); + +const struct cfattach qcpas_ca = { + sizeof (struct qcpas_softc), qcpas_match, qcpas_attach +}; + +struct cfdriver qcpas_cd = { + NULL, "qcpas", DV_DULL +}; + +void qcpas_mountroot(struct device *); +int qcpas_map_memory(struct qcpas_softc *); +int qcpas_mdt_init(struct qcpas_softc *, u_char *, size_t); +void qcpas_glink_attach(struct qcpas_softc *, int); + +struct qcpas_dmamem * + qcpas_dmamem_alloc(struct qcpas_softc *, bus_size_t, bus_size_t); +void qcpas_dmamem_free(struct qcpas_softc *, struct qcpas_dmamem *); + +void qcpas_intr_establish(struct qcpas_softc *, int, char *, void *); +int qcpas_intr_wdog(void *); +int qcpas_intr_fatal(void *); +int qcpas_intr_ready(void *); +int qcpas_intr_handover(void *); +int qcpas_intr_stop_ack(void *); +int qcpas_intr_shutdown_ack(void *); + +int +qcpas_match(struct device *parent, void *match, void *aux) +{ + struct fdt_attach_args *faa = aux; + + return OF_is_compatible(faa->fa_node, "qcom,sc8280xp-adsp-pas"); +} + +void +qcpas_attach(struct device *parent, struct device *self, void *aux) +{ + struct qcpas_softc *sc = (struct qcpas_softc *)self; + struct fdt_attach_args *faa = aux; + + if (faa->fa_nreg < 1) { + printf(": no registers\n"); + return; + } + + sc->sc_iot = faa->fa_iot; + if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, + faa->fa_reg[0].size, 0, &sc->sc_ioh)) { + printf(": can't map registers\n"); + return; + } + sc->sc_dmat = faa->fa_dmat; + sc->sc_node = faa->fa_node; + + if (OF_is_compatible(faa->fa_node, "qcom,sc8280xp-adsp-pas")) { + sc->sc_pas_id = 1; + sc->sc_load_state = "adsp"; + } + if (OF_is_compatible(faa->fa_node, "qcom,sc8280xp-nsp0-pas")) { + sc->sc_pas_id = 18; + } + if (OF_is_compatible(faa->fa_node, "qcom,sc8280xp-nsp1-pas")) { + sc->sc_pas_id = 30; + } + + qcpas_intr_establish(sc, 0, "wdog", qcpas_intr_wdog); + qcpas_intr_establish(sc, 1, "fatal", qcpas_intr_fatal); + qcpas_intr_establish(sc, 2, "ready", qcpas_intr_ready); + qcpas_intr_establish(sc, 3, "handover", qcpas_intr_handover); + qcpas_intr_establish(sc, 4, "stop-ack", qcpas_intr_stop_ack); + qcpas_intr_establish(sc, 5, "shutdown-ack", qcpas_intr_shutdown_ack); + + printf("\n"); + + config_mountroot(self, qcpas_mountroot); +} + +extern int qcaoss_send(char *, size_t); + +void +qcpas_mountroot(struct device *self) +{ + struct qcpas_softc *sc = (struct qcpas_softc *)self; + char fwname[64]; + size_t fwlen; + u_char *fw; + int node, ret; + + if (qcpas_map_memory(sc) != 0) + return; + + if (OF_getproplen(sc->sc_node, "firmware-name") <= 0) + return; + OF_getprop(sc->sc_node, "firmware-name", fwname, sizeof(fwname)); + fwname[sizeof(fwname) - 1] = '\0'; + + if (loadfirmware(fwname, &fw, &fwlen) != 0) { + printf("%s: failed to load %s\n", + sc->sc_dev.dv_xname, fwname); + return; + } + + if (sc->sc_load_state) { + char buf[64]; + snprintf(buf, sizeof(buf), + "{class: image, res: load_state, name: %s, val: on}", + sc->sc_load_state); + ret = qcaoss_send(buf, sizeof(buf)); + if (ret != 0) { + printf("%s: failed to toggle load state\n", + sc->sc_dev.dv_xname); + return; + } + } + + power_domain_enable_all(sc->sc_node); + clock_enable(sc->sc_node, "xo"); + + ret = qcpas_mdt_init(sc, fw, fwlen); + free(fw, M_DEVBUF, fwlen); + if (ret != 0) { + printf("%s: failed to boot coprocessor\n", + sc->sc_dev.dv_xname); + return; + } + + node = OF_getnodebyname(sc->sc_node, "glink-edge"); + if (node) + qcpas_glink_attach(sc, node); +} + +int +qcpas_map_memory(struct qcpas_softc *sc) +{ + uint32_t phandle, reg[4]; + size_t off; + int node; + + phandle = OF_getpropint(sc->sc_node, "memory-region", 0); + if (phandle == 0) + return EINVAL; + node = OF_getnodebyphandle(phandle); + if (node == 0) + return EINVAL; + if (OF_getpropintarray(node, "reg", reg, sizeof(reg)) != sizeof(reg)) + return EINVAL; + + sc->sc_mem_phys = (uint64_t)reg[0] << 32 | reg[1]; + KASSERT((sc->sc_mem_phys & PAGE_MASK) == 0); + sc->sc_mem_size = (uint64_t)reg[2] << 32 | reg[3]; + KASSERT((sc->sc_mem_size & PAGE_MASK) == 0); + + sc->sc_mem_region = km_alloc(sc->sc_mem_size, &kv_any, &kp_none, + &kd_nowait); + if (!sc->sc_mem_region) + return ENOMEM; + + for (off = 0; off < sc->sc_mem_size; off += PAGE_SIZE) { + pmap_kenter_cache((vaddr_t)sc->sc_mem_region + off, + sc->sc_mem_phys + off, PROT_READ | PROT_WRITE, + PMAP_CACHE_DEV_NGNRNE); + } + + return 0; +} + +extern int qcscm_pas_init_image(uint32_t, paddr_t); +extern int qcscm_pas_mem_setup(uint32_t, paddr_t, size_t); +extern int qcscm_pas_auth_and_reset(uint32_t); + +int +qcpas_mdt_init(struct qcpas_softc *sc, u_char *fw, size_t fwlen) +{ + Elf32_Ehdr *ehdr; + Elf32_Phdr *phdr; + paddr_t minpa = -1, maxpa = 0; + int i, hashseg = 0, relocate = 0; + int error; + ssize_t off; + + ehdr = (Elf32_Ehdr *)fw; + phdr = (Elf32_Phdr *)&ehdr[1]; + + if (ehdr->e_phnum < 2 || phdr[0].p_type == PT_LOAD) + return EINVAL; + + for (i = 0; i < ehdr->e_phnum; i++) { + if ((phdr[i].p_flags & MDT_TYPE_MASK) == MDT_TYPE_HASH) { + if (i > 0 && !hashseg) + hashseg = i; + continue; + } + if (phdr[i].p_type != PT_LOAD || phdr[i].p_memsz == 0) + continue; + if (phdr[i].p_flags & MDT_RELOCATABLE) + relocate = 1; + if (phdr[i].p_paddr < minpa) + minpa = phdr[i].p_paddr; + if (phdr[i].p_paddr + phdr[i].p_memsz > maxpa) + maxpa = + roundup(phdr[i].p_paddr + phdr[i].p_memsz, + PAGE_SIZE); + } + + if (!hashseg) + return EINVAL; + + sc->sc_metadata = qcpas_dmamem_alloc(sc, phdr[0].p_filesz + + phdr[hashseg].p_filesz, PAGE_SIZE); + if (sc->sc_metadata == NULL) + return EINVAL; + + memcpy(QCPAS_DMA_KVA(sc->sc_metadata), fw, phdr[0].p_filesz); + if (phdr[0].p_filesz + phdr[hashseg].p_filesz == fwlen) { + memcpy(QCPAS_DMA_KVA(sc->sc_metadata) + phdr[0].p_filesz, + fw + phdr[0].p_filesz, phdr[hashseg].p_filesz); + } else if (phdr[hashseg].p_offset + phdr[hashseg].p_filesz <= fwlen) { + memcpy(QCPAS_DMA_KVA(sc->sc_metadata) + phdr[0].p_filesz, + fw + phdr[hashseg].p_offset, phdr[hashseg].p_filesz); + } else { + printf("%s: metadata split segment not supported\n", + sc->sc_dev.dv_xname); + return EINVAL; + } + + membar_producer(); + + if (qcscm_pas_init_image(sc->sc_pas_id, + QCPAS_DMA_DVA(sc->sc_metadata)) != 0) { + printf("%s: init image failed\n", sc->sc_dev.dv_xname); + qcpas_dmamem_free(sc, sc->sc_metadata); + return EINVAL; + } + + if (qcscm_pas_mem_setup(sc->sc_pas_id, + sc->sc_mem_phys, maxpa - minpa) != 0) { + printf("%s: mem setup failed\n", sc->sc_dev.dv_xname); + qcpas_dmamem_free(sc, sc->sc_metadata); + return EINVAL; + } + + sc->sc_mem_reloc = relocate ? minpa : sc->sc_mem_phys; + + for (i = 0; i < ehdr->e_phnum; i++) { + if ((phdr[i].p_flags & MDT_TYPE_MASK) == MDT_TYPE_HASH || + phdr[i].p_type != PT_LOAD || phdr[i].p_memsz == 0) + continue; + off = phdr[i].p_paddr - sc->sc_mem_reloc; + if (off < 0 || off + phdr[i].p_memsz > sc->sc_mem_size) + return EINVAL; + if (phdr[i].p_filesz > phdr[i].p_memsz) + return EINVAL; + + if (phdr[i].p_filesz && phdr[i].p_offset < fwlen && + phdr[i].p_offset + phdr[i].p_filesz <= fwlen) { + memcpy(sc->sc_mem_region + off, fw + phdr[i].p_offset, + phdr[i].p_filesz); + } else if (phdr[i].p_filesz) { + printf("%s: firmware split segment not supported\n", + sc->sc_dev.dv_xname); + return EINVAL; + } + + if (phdr[i].p_memsz > phdr[i].p_filesz) + memset(sc->sc_mem_region + off + phdr[i].p_filesz, 0, + phdr[i].p_memsz - phdr[i].p_filesz); + } + + membar_producer(); + + if (qcscm_pas_auth_and_reset(sc->sc_pas_id) != 0) { + printf("%s: auth and reset failed\n", sc->sc_dev.dv_xname); + qcpas_dmamem_free(sc, sc->sc_metadata); + return EINVAL; + } + + error = tsleep_nsec(sc, PWAIT, "qcpas", SEC_TO_NSEC(5)); + if (error) { + printf("%s: failed to receive ready signal\n", + sc->sc_dev.dv_xname); + return error; + } + + /* XXX: free metadata ? */ + + return 0; +} + +struct qcpas_dmamem * +qcpas_dmamem_alloc(struct qcpas_softc *sc, bus_size_t size, bus_size_t align) +{ + struct qcpas_dmamem *tdm; + int nsegs; + + tdm = malloc(sizeof(*tdm), M_DEVBUF, M_WAITOK | M_ZERO); + tdm->tdm_size = size; + + if (bus_dmamap_create(sc->sc_dmat, size, 1, size, 0, + BUS_DMA_WAITOK | BUS_DMA_ALLOCNOW, &tdm->tdm_map) != 0) + goto tdmfree; + + if (bus_dmamem_alloc_range(sc->sc_dmat, size, align, 0, + &tdm->tdm_seg, 1, &nsegs, BUS_DMA_WAITOK, 0, 0xffffffff) != 0) + goto destroy; + + if (bus_dmamem_map(sc->sc_dmat, &tdm->tdm_seg, nsegs, size, + &tdm->tdm_kva, BUS_DMA_WAITOK | BUS_DMA_COHERENT) != 0) + goto free; + + if (bus_dmamap_load(sc->sc_dmat, tdm->tdm_map, tdm->tdm_kva, size, + NULL, BUS_DMA_WAITOK) != 0) + goto unmap; + + bzero(tdm->tdm_kva, size); + + return (tdm); + +unmap: + bus_dmamem_unmap(sc->sc_dmat, tdm->tdm_kva, size); +free: + bus_dmamem_free(sc->sc_dmat, &tdm->tdm_seg, 1); +destroy: + bus_dmamap_destroy(sc->sc_dmat, tdm->tdm_map); +tdmfree: + free(tdm, M_DEVBUF, 0); + + return (NULL); +} + +void +qcpas_dmamem_free(struct qcpas_softc *sc, struct qcpas_dmamem *tdm) +{ + bus_dmamem_unmap(sc->sc_dmat, tdm->tdm_kva, tdm->tdm_size); + bus_dmamem_free(sc->sc_dmat, &tdm->tdm_seg, 1); + bus_dmamap_destroy(sc->sc_dmat, tdm->tdm_map); + free(tdm, M_DEVBUF, 0); +} + +void +qcpas_intr_establish(struct qcpas_softc *sc, int i, char *name, void *handler) +{ + int idx; + + idx = OF_getindex(sc->sc_node, name, "interrupt-names"); + if (idx >= 0) + sc->sc_ih[i] = + fdt_intr_establish_idx(sc->sc_node, idx, IPL_BIO, + handler, sc, sc->sc_dev.dv_xname); +} + +int +qcpas_intr_wdog(void *cookie) +{ + return 0; +} + +int +qcpas_intr_fatal(void *cookie) +{ + return 0; +} + +int +qcpas_intr_ready(void *cookie) +{ + struct qcpas_softc *sc = cookie; + + wakeup(sc); + return 0; +} + +int +qcpas_intr_handover(void *cookie) +{ + return 0; +} + +int +qcpas_intr_stop_ack(void *cookie) +{ + return 0; +} + +int +qcpas_intr_shutdown_ack(void *cookie) +{ + return 0; +} + +/* GLINK */ + +#define SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR 478 +#define SMEM_GLINK_NATIVE_XPRT_FIFO_0 479 +#define SMEM_GLINK_NATIVE_XPRT_FIFO_1 480 + +struct glink_msg { + uint16_t cmd; + uint16_t param1; + uint32_t param2; + uint8_t data[]; +} __packed; + +struct qcpas_glink_intent_pair { + uint32_t size; + uint32_t iid; +} __packed; + +struct qcpas_glink_intent { + TAILQ_ENTRY(qcpas_glink_intent) it_q; + uint32_t it_id; + uint32_t it_size; + int it_inuse; +}; + +struct qcpas_glink_channel { + TAILQ_ENTRY(qcpas_glink_channel) ch_q; + struct qcpas_softc *ch_sc; + struct qcpas_glink_protocol *ch_proto; + uint32_t ch_rcid; + uint32_t ch_lcid; + uint32_t ch_max_intent; + TAILQ_HEAD(,qcpas_glink_intent) ch_l_intents; + TAILQ_HEAD(,qcpas_glink_intent) ch_r_intents; +}; + +#define GLINK_CMD_VERSION 0 +#define GLINK_CMD_VERSION_ACK 1 +#define GLINK_VERSION 1 +#define GLINK_FEATURE_INTENT_REUSE (1 << 0) +#define GLINK_CMD_OPEN 2 +#define GLINK_CMD_CLOSE 3 +#define GLINK_CMD_OPEN_ACK 4 +#define GLINK_CMD_INTENT 5 +#define GLINK_CMD_RX_DONE 6 +#define GLINK_CMD_RX_INTENT_REQ 7 +#define GLINK_CMD_RX_INTENT_REQ_ACK 8 +#define GLINK_CMD_TX_DATA 9 +#define GLINK_CMD_CLOSE_ACK 11 +#define GLINK_CMD_TX_DATA_CONT 12 +#define GLINK_CMD_READ_NOTIF 13 +#define GLINK_CMD_RX_DONE_W_REUSE 14 + +void qcpas_glink_recv(void *); +int qcpas_glink_intr(void *); + +void qcpas_glink_tx(struct qcpas_softc *, uint8_t *, int); +void qcpas_glink_tx_commit(struct qcpas_softc *); +void qcpas_glink_rx(struct qcpas_softc *, uint8_t *, int); +void qcpas_glink_rx_commit(struct qcpas_softc *); + +void qcpas_glink_send(void *, void *, int); + +extern int qcsmem_alloc(int, int, int); +extern void *qcsmem_get(int, int, int *); + +int qcpas_pmic_rtr_init(void *); +int qcpas_pmic_rtr_recv(void *, uint8_t *, int); +int qcpas_pmic_rtr_apminfo(struct apm_power_info *); + +struct qcpas_glink_protocol { + char *name; + int (*init)(void *cookie); + int (*recv)(void *cookie, uint8_t *buf, int len); +} qcpas_glink_protocols[] = { + { "PMIC_RTR_ADSP_APPS", qcpas_pmic_rtr_init , qcpas_pmic_rtr_recv }, +}; + +void +qcpas_glink_attach(struct qcpas_softc *sc, int node) +{ + uint32_t remote; + uint32_t *descs; + int size; + + remote = OF_getpropint(node, "qcom,remote-pid", -1); + if (remote == -1) + return; + + if (qcsmem_alloc(remote, SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR, 32) != 0 || + qcsmem_alloc(remote, SMEM_GLINK_NATIVE_XPRT_FIFO_0, 16384) != 0) + return; + + descs = qcsmem_get(remote, SMEM_GLINK_NATIVE_XPRT_DESCRIPTOR, &size); + if (descs == NULL || size != 32) + return; + + sc->sc_tx_tail = &descs[0]; + sc->sc_tx_head = &descs[1]; + sc->sc_rx_tail = &descs[2]; + sc->sc_rx_head = &descs[3]; + + sc->sc_tx_fifo = qcsmem_get(remote, SMEM_GLINK_NATIVE_XPRT_FIFO_0, + &sc->sc_tx_fifolen); + if (sc->sc_tx_fifo == NULL) + return; + sc->sc_rx_fifo = qcsmem_get(remote, SMEM_GLINK_NATIVE_XPRT_FIFO_1, + &sc->sc_rx_fifolen); + if (sc->sc_rx_fifo == NULL) + return; + + sc->sc_mc = mbox_channel_idx(node, 0, NULL); + if (sc->sc_mc == NULL) + return; + + TAILQ_INIT(&sc->sc_glink_channels); + task_set(&sc->sc_glink_rx, qcpas_glink_recv, sc); + + sc->sc_glink_ih = fdt_intr_establish(node, IPL_BIO, + qcpas_glink_intr, sc, sc->sc_dev.dv_xname); + if (sc->sc_glink_ih == NULL) + return; + + /* Expect peer to send initial message */ +} + +void +qcpas_glink_rx(struct qcpas_softc *sc, uint8_t *buf, int len) +{ + uint32_t head, tail; + int avail; + + head = *sc->sc_rx_head; + tail = *sc->sc_rx_tail + sc->sc_rx_off; + if (tail >= sc->sc_rx_fifolen) + tail -= sc->sc_rx_fifolen; + + /* Checked by caller */ + KASSERT(head != tail); + + if (head >= tail) + avail = head - tail; + else + avail = (sc->sc_rx_fifolen - tail) + head; + + /* Dumb, but should do. */ + KASSERT(avail >= len); + + while (len > 0) { + *buf = sc->sc_rx_fifo[tail]; + tail++; + if (tail >= sc->sc_rx_fifolen) + tail -= sc->sc_rx_fifolen; + buf++; + sc->sc_rx_off++; + len--; + } +} + +void +qcpas_glink_rx_commit(struct qcpas_softc *sc) +{ + uint32_t tail; + + tail = *sc->sc_rx_tail + roundup(sc->sc_rx_off, 8); + if (tail >= sc->sc_rx_fifolen) + tail -= sc->sc_rx_fifolen; + + membar_producer(); + *sc->sc_rx_tail = tail; + sc->sc_rx_off = 0; +} + +void +qcpas_glink_tx(struct qcpas_softc *sc, uint8_t *buf, int len) +{ + uint32_t head, tail; + int avail; + + head = *sc->sc_tx_head + sc->sc_tx_off; + if (head >= sc->sc_tx_fifolen) + head -= sc->sc_tx_fifolen; + tail = *sc->sc_tx_tail; + + if (head < tail) + avail = tail - head; + else + avail = (sc->sc_rx_fifolen - head) + tail; + + /* Dumb, but should do. */ + KASSERT(avail >= len); + + while (len > 0) { + sc->sc_tx_fifo[head] = *buf; + head++; + if (head >= sc->sc_tx_fifolen) + head -= sc->sc_tx_fifolen; + buf++; + sc->sc_tx_off++; + len--; + } +} + +void +qcpas_glink_tx_commit(struct qcpas_softc *sc) +{ + uint32_t head; + + head = *sc->sc_tx_head + roundup(sc->sc_tx_off, 8); + if (head >= sc->sc_tx_fifolen) + head -= sc->sc_tx_fifolen; + + membar_producer(); + *sc->sc_tx_head = head; + sc->sc_tx_off = 0; + mbox_send(sc->sc_mc, NULL, 0); +} + +void +qcpas_glink_send(void *cookie, void *buf, int len) +{ + struct qcpas_glink_channel *ch = cookie; + struct qcpas_softc *sc = ch->ch_sc; + struct qcpas_glink_intent *it; + struct glink_msg msg; + uint32_t chunk_size, left_size; + + TAILQ_FOREACH(it, &ch->ch_r_intents, it_q) { + if (!it->it_inuse) + break; + if (it->it_size < len) + continue; + } + if (it == NULL) { + printf("%s: all intents in use\n", + sc->sc_dev.dv_xname); + return; + } + it->it_inuse = 1; + + msg.cmd = GLINK_CMD_TX_DATA; + msg.param1 = ch->ch_lcid; + msg.param2 = it->it_id; + + chunk_size = len; + left_size = 0; + + qcpas_glink_tx(sc, (char *)&msg, sizeof(msg)); + qcpas_glink_tx(sc, (char *)&chunk_size, sizeof(chunk_size)); + qcpas_glink_tx(sc, (char *)&left_size, sizeof(left_size)); + qcpas_glink_tx(sc, buf, len); + qcpas_glink_tx_commit(sc); +} + +void +qcpas_glink_recv_version(struct qcpas_softc *sc, uint32_t version, + uint32_t features) +{ + struct glink_msg msg; + + if (version != GLINK_VERSION) { + printf("%s: unsupported glink version %u\n", + sc->sc_dev.dv_xname, version); + return; + } + + msg.cmd = GLINK_CMD_VERSION_ACK; + msg.param1 = GLINK_VERSION; + msg.param2 = features & GLINK_FEATURE_INTENT_REUSE; + + qcpas_glink_tx(sc, (char *)&msg, sizeof(msg)); + qcpas_glink_tx_commit(sc); +} + +void +qcpas_glink_recv_open(struct qcpas_softc *sc, uint32_t rcid, uint32_t namelen) +{ + struct qcpas_glink_protocol *proto = NULL; + struct qcpas_glink_channel *ch; + struct glink_msg msg; + char *name; + int i, err; + + name = malloc(namelen, M_TEMP, M_WAITOK); + qcpas_glink_rx(sc, name, namelen); + qcpas_glink_rx_commit(sc); + + TAILQ_FOREACH(ch, &sc->sc_glink_channels, ch_q) { + if (ch->ch_rcid == rcid) { + printf("%s: duplicate open for %s\n", + sc->sc_dev.dv_xname, name); + free(name, M_TEMP, namelen); + return; + } + } + + for (i = 0; i < nitems(qcpas_glink_protocols); i++) { + if (strcmp(qcpas_glink_protocols[i].name, name) != 0) + continue; + proto = &qcpas_glink_protocols[i]; + break; + } + if (proto == NULL) { + free(name, M_TEMP, namelen); + return; + } + + /* Assume we can leave HW dangling if proto init fails */ + err = proto->init(NULL); + if (err) { + free(name, M_TEMP, namelen); + return; + } + + ch = malloc(sizeof(*ch), M_DEVBUF, M_WAITOK | M_ZERO); + ch->ch_sc = sc; + ch->ch_proto = proto; + ch->ch_rcid = rcid; + ch->ch_lcid = ++sc->sc_glink_max_channel; + TAILQ_INIT(&ch->ch_l_intents); + TAILQ_INIT(&ch->ch_r_intents); + TAILQ_INSERT_TAIL(&sc->sc_glink_channels, ch, ch_q); + + msg.cmd = GLINK_CMD_OPEN_ACK; + msg.param1 = ch->ch_rcid; + msg.param2 = 0; + + qcpas_glink_tx(sc, (char *)&msg, sizeof(msg)); + qcpas_glink_tx_commit(sc); + + msg.cmd = GLINK_CMD_OPEN; + msg.param1 = ch->ch_lcid; + msg.param2 = strlen(name) + 1; + + qcpas_glink_tx(sc, (char *)&msg, sizeof(msg)); + qcpas_glink_tx(sc, name, strlen(name) + 1); + qcpas_glink_tx_commit(sc); + + free(name, M_TEMP, namelen); +} + +void +qcpas_glink_recv_open_ack(struct qcpas_softc *sc, uint32_t lcid) +{ + struct qcpas_glink_channel *ch; + struct glink_msg msg; + struct qcpas_glink_intent_pair intent; + int i; + + TAILQ_FOREACH(ch, &sc->sc_glink_channels, ch_q) { + if (ch->ch_lcid == lcid) + break; + } + if (ch == NULL) { + printf("%s: unknown channel %u for OPEN_ACK\n", + sc->sc_dev.dv_xname, lcid); + return; + } + + /* Respond with default intent now that channel is open */ + for (i = 0; i < 5; i++) { + struct qcpas_glink_intent *it; + + it = malloc(sizeof(*it), M_DEVBUF, M_WAITOK | M_ZERO); + it->it_id = ++ch->ch_max_intent; + it->it_size = 1024; + TAILQ_INSERT_TAIL(&ch->ch_l_intents, it, it_q); + + msg.cmd = GLINK_CMD_INTENT; + msg.param1 = ch->ch_lcid; + msg.param2 = 1; + intent.size = it->it_size; + intent.iid = it->it_id; + } + + qcpas_glink_tx(sc, (char *)&msg, sizeof(msg)); + qcpas_glink_tx(sc, (char *)&intent, sizeof(intent)); + qcpas_glink_tx_commit(sc); +} + +void +qcpas_glink_recv_intent(struct qcpas_softc *sc, uint32_t rcid, uint32_t count) +{ + struct qcpas_glink_intent_pair *intents; + struct qcpas_glink_channel *ch; + struct qcpas_glink_intent *it; + int i; + + intents = malloc(sizeof(*intents) * count, M_TEMP, M_WAITOK); + qcpas_glink_rx(sc, (char *)intents, sizeof(*intents) * count); + qcpas_glink_rx_commit(sc); + + TAILQ_FOREACH(ch, &sc->sc_glink_channels, ch_q) { + if (ch->ch_rcid == rcid) + break; + } + if (ch == NULL) { + printf("%s: unknown channel %u for INTENT\n", + sc->sc_dev.dv_xname, rcid); + free(intents, M_TEMP, sizeof(*intents) * count); + return; + } + + for (i = 0; i < count; i++) { + it = malloc(sizeof(*it), M_DEVBUF, M_WAITOK | M_ZERO); + it->it_id = intents[i].iid; + it->it_size = intents[i].size; + TAILQ_INSERT_TAIL(&ch->ch_r_intents, it, it_q); + } + + free(intents, M_TEMP, sizeof(*intents) * count); +} + +void +qcpas_glink_recv_tx_data(struct qcpas_softc *sc, uint32_t rcid, uint32_t liid) +{ + struct qcpas_glink_channel *ch; + struct qcpas_glink_intent *it; + struct glink_msg msg; + uint32_t chunk_size, left_size; + char *buf; + + qcpas_glink_rx(sc, (char *)&chunk_size, sizeof(chunk_size)); + qcpas_glink_rx(sc, (char *)&left_size, sizeof(left_size)); + qcpas_glink_rx_commit(sc); + + buf = malloc(chunk_size, M_TEMP, M_WAITOK); + qcpas_glink_rx(sc, buf, chunk_size); + qcpas_glink_rx_commit(sc); + + TAILQ_FOREACH(ch, &sc->sc_glink_channels, ch_q) { + if (ch->ch_rcid == rcid) + break; + } + if (ch == NULL) { + printf("%s: unknown channel %u for TX_DATA\n", + sc->sc_dev.dv_xname, rcid); + free(buf, M_TEMP, chunk_size); + return; + } + + TAILQ_FOREACH(it, &ch->ch_l_intents, it_q) { + if (it->it_id == liid) + break; + } + if (it == NULL) { + printf("%s: unknown intent %u for TX_DATA\n", + sc->sc_dev.dv_xname, liid); + free(buf, M_TEMP, chunk_size); + return; + } + + /* FIXME: handle message chunking */ + KASSERT(left_size == 0); + + ch->ch_proto->recv(ch, buf, chunk_size); + free(buf, M_TEMP, chunk_size); + + if (!left_size) { + msg.cmd = GLINK_CMD_RX_DONE_W_REUSE; + msg.param1 = ch->ch_lcid; + msg.param2 = it->it_id; + + qcpas_glink_tx(sc, (char *)&msg, sizeof(msg)); + qcpas_glink_tx_commit(sc); + } +} + +void +qcpas_glink_recv_rx_done(struct qcpas_softc *sc, uint32_t rcid, uint32_t riid, + int reuse) +{ + struct qcpas_glink_channel *ch; + struct qcpas_glink_intent *it; + + TAILQ_FOREACH(ch, &sc->sc_glink_channels, ch_q) { + if (ch->ch_rcid == rcid) + break; + } + if (ch == NULL) { + printf("%s: unknown channel %u for RX_DONE\n", + sc->sc_dev.dv_xname, rcid); + return; + } + + TAILQ_FOREACH(it, &ch->ch_r_intents, it_q) { + if (it->it_id == riid) + break; + } + if (it == NULL) { + printf("%s: unknown intent %u for RX_DONE\n", + sc->sc_dev.dv_xname, riid); + return; + } + + /* FIXME: handle non-reuse */ + KASSERT(reuse); + + KASSERT(it->it_inuse); + it->it_inuse = 0; +} + +void +qcpas_glink_recv(void *cookie) +{ + struct qcpas_softc *sc = cookie; + struct glink_msg msg; + + while (*sc->sc_rx_tail != *sc->sc_rx_head) { + membar_consumer(); + qcpas_glink_rx(sc, (uint8_t *)&msg, sizeof(msg)); + qcpas_glink_rx_commit(sc); + + switch (msg.cmd) { + case GLINK_CMD_VERSION: + qcpas_glink_recv_version(sc, msg.param1, msg.param2); + break; + case GLINK_CMD_OPEN: + qcpas_glink_recv_open(sc, msg.param1, msg.param2); + break; + case GLINK_CMD_OPEN_ACK: + qcpas_glink_recv_open_ack(sc, msg.param1); + break; + case GLINK_CMD_INTENT: + qcpas_glink_recv_intent(sc, msg.param1, msg.param2); + break; + case GLINK_CMD_RX_INTENT_REQ: + /* Nothing to do so far */ + break; + case GLINK_CMD_TX_DATA: + qcpas_glink_recv_tx_data(sc, msg.param1, msg.param2); + break; + case GLINK_CMD_RX_DONE: + qcpas_glink_recv_rx_done(sc, msg.param1, msg.param2, 0); + break; + case GLINK_CMD_RX_DONE_W_REUSE: + qcpas_glink_recv_rx_done(sc, msg.param1, msg.param2, 1); + break; + default: + printf("%s: unknown cmd %u\n", __func__, msg.cmd); + return; + } + } +} + +int +qcpas_glink_intr(void *cookie) +{ + struct qcpas_softc *sc = cookie; + + task_add(systq, &sc->sc_glink_rx); + return 1; +} + +/* GLINK PMIC Router */ + +struct pmic_glink_hdr { + uint32_t owner; +#define PMIC_GLINK_OWNER_BATTMGR 32778 +#define PMIC_GLINK_OWNER_USBC 32779 +#define PMIC_GLINK_OWNER_USBC_PAN 32780 + uint32_t type; +#define PMIC_GLINK_TYPE_REQ_RESP 1 +#define PMIC_GLINK_TYPE_NOTIFY 2 + uint32_t opcode; +}; + +#define BATTMGR_OPCODE_BAT_STATUS 0x1 +#define BATTMGR_OPCODR_REQUEST_NOTIFICATION 0x4 +#define BATTMGR_OPCODE_NOTIF 0x7 +#define BATTMGR_OPCODE_BAT_INFO 0x9 +#define BATTMGR_OPCODE_BAT_DISCHARGE_TIME 0xc +#define BATTMGR_OPCODE_BAT_CHARGE_TIME 0xd + +#define BATTMGR_NOTIF_BAT_PROPERTY 0x30 +#define BATTMGR_NOTIF_USB_PROPERTY 0x32 +#define BATTMGR_NOTIF_WLS_PROPERTY 0x34 +#define BATTMGR_NOTIF_BAT_STATUS 0x80 +#define BATTMGR_NOTIF_BAT_INFO 0x81 + +#define BATTMGR_CHEMISTRY_LEN 4 +#define BATTMGR_STRING_LEN 128 + +struct battmgr_bat_info { + uint32_t power_unit; + uint32_t design_capacity; + uint32_t last_full_capacity; + uint32_t battery_tech; + uint32_t design_voltage; + uint32_t capacity_low; + uint32_t capacity_warning; + uint32_t cycle_count; + uint32_t accuracy; + uint32_t max_sample_time_ms; + uint32_t min_sample_time_ms; + uint32_t max_average_interval_ms; + uint32_t min_averae_interval_ms; + uint32_t capacity_granularity1; + uint32_t capacity_granularity2; + uint32_t swappable; + uint32_t capabilities; + char model_number[BATTMGR_STRING_LEN]; + char serial_number[BATTMGR_STRING_LEN]; + char battery_type[BATTMGR_STRING_LEN]; + char oem_info[BATTMGR_STRING_LEN]; + char battery_chemistry[BATTMGR_CHEMISTRY_LEN]; + char uid[BATTMGR_STRING_LEN]; + uint32_t critical_bias; + uint8_t day; + uint8_t month; + uint16_t year; + uint32_t battery_id; +}; + +struct battmgr_bat_status { + uint32_t battery_state; +#define BATTMGR_BAT_STATE_DISCHARGE (1 << 0) +#define BATTMGR_BAT_STATE_CHARGING (1 << 1) +#define BATTMGR_BAT_STATE_CRITICAL_LOW (1 << 2) + uint32_t capacity; + uint32_t rate; + uint32_t battery_voltage; + uint32_t power_state; + uint32_t charging_source; +#define BATTMGR_CHARGING_SOURCE_AC 1 +#define BATTMGR_CHARGING_SOURCE_USB 2 +#define BATTMGR_CHARGING_SOURCE_WIRELESS 3 + uint32_t temperature; +}; + +void +qcpas_pmic_rtr_battmgr_req_info(void *cookie) +{ + struct { + struct pmic_glink_hdr hdr; + uint32_t battery_id; + } msg; + + msg.hdr.owner = PMIC_GLINK_OWNER_BATTMGR; + msg.hdr.type = PMIC_GLINK_TYPE_REQ_RESP; + msg.hdr.opcode = BATTMGR_OPCODE_BAT_INFO; + msg.battery_id = 0; + qcpas_glink_send(cookie, &msg, sizeof(msg)); +} + +void +qcpas_pmic_rtr_battmgr_req_status(void *cookie) +{ + struct { + struct pmic_glink_hdr hdr; + uint32_t battery_id; + } msg; + + msg.hdr.owner = PMIC_GLINK_OWNER_BATTMGR; + msg.hdr.type = PMIC_GLINK_TYPE_REQ_RESP; + msg.hdr.opcode = BATTMGR_OPCODE_BAT_STATUS; + msg.battery_id = 0; + qcpas_glink_send(cookie, &msg, sizeof(msg)); +} + +#if NAPM > 0 +struct apm_power_info qcpas_pmic_rtr_apm_power_info; +uint32_t qcpas_pmic_rtr_last_full_capacity; +#endif + +int +qcpas_pmic_rtr_init(void *cookie) +{ +#if NAPM > 0 + struct apm_power_info *info; + + info = &qcpas_pmic_rtr_apm_power_info; + info->battery_state = APM_BATT_UNKNOWN; + info->ac_state = APM_AC_UNKNOWN; + info->battery_life = 0; + info->minutes_left = -1; + + apm_setinfohook(qcpas_pmic_rtr_apminfo); +#endif + return 0; +} + +int +qcpas_pmic_rtr_recv(void *cookie, uint8_t *buf, int len) +{ + struct pmic_glink_hdr hdr; + uint32_t notification; + + if (len < sizeof(hdr)) { + printf("%s: pmic glink message too small\n", + __func__); + return 0; + } + + memcpy(&hdr, buf, sizeof(hdr)); + + switch (hdr.owner) { + case PMIC_GLINK_OWNER_BATTMGR: + switch (hdr.opcode) { + case BATTMGR_OPCODE_NOTIF: + if (len - sizeof(hdr) != sizeof(uint32_t)) { + printf("%s: invalid battgmr notification\n", + __func__); + return 0; + } + memcpy(¬ification, buf + sizeof(hdr), + sizeof(uint32_t)); + switch (notification) { + case BATTMGR_NOTIF_BAT_INFO: + qcpas_pmic_rtr_battmgr_req_info(cookie); + /* FALLTHROUGH */ + case BATTMGR_NOTIF_BAT_STATUS: + case BATTMGR_NOTIF_BAT_PROPERTY: + qcpas_pmic_rtr_battmgr_req_status(cookie); + break; + default: + printf("%s: unknown battmgr notification" + " 0x%02x\n", __func__, notification); + break; + } + break; + case BATTMGR_OPCODE_BAT_INFO: { + struct battmgr_bat_info *bat; + if (len - sizeof(hdr) != sizeof(*bat)) { + printf("%s: invalid battgmr bat info\n", + __func__); + return 0; + } + bat = malloc(sizeof(*bat), M_TEMP, M_WAITOK); + memcpy((void *)bat, buf + sizeof(hdr), sizeof(*bat)); +#if NAPM > 0 + qcpas_pmic_rtr_last_full_capacity = + bat->last_full_capacity; +#endif + free(bat, M_TEMP, sizeof(*bat)); + break; + } + case BATTMGR_OPCODE_BAT_STATUS: { + struct battmgr_bat_status *bat; +#if NAPM > 0 + struct apm_power_info *info; +#endif + if (len - sizeof(hdr) != sizeof(*bat)) { + printf("%s: invalid battgmr bat status\n", + __func__); + return 0; + } +#if NAPM > 0 + /* Needs BAT_INFO fist */ + if (!qcpas_pmic_rtr_last_full_capacity) + return 0; +#endif + bat = malloc(sizeof(*bat), M_TEMP, M_WAITOK); + memcpy((void *)bat, buf + sizeof(hdr), sizeof(*bat)); +#if NAPM > 0 + info = &qcpas_pmic_rtr_apm_power_info; + info->battery_life = ((bat->capacity * 100) / + qcpas_pmic_rtr_last_full_capacity); + if (info->battery_life > 50) + info->battery_state = APM_BATT_HIGH; + else if (info->battery_life > 25) + info->battery_state = APM_BATT_LOW; + else + info->battery_state = APM_BATT_CRITICAL; + if (bat->battery_state & BATTMGR_BAT_STATE_CHARGING) + info->battery_state = APM_BATT_CHARGING; + else if (bat->battery_state & BATTMGR_BAT_STATE_CRITICAL_LOW) + info->battery_state = APM_BATT_CRITICAL; +#endif + free(bat, M_TEMP, sizeof(*bat)); + break; + } + default: + printf("%s: unknown battmgr opcode 0x%02x\n", + __func__, hdr.opcode); + break; + } + break; + default: + printf("%s: unknown pmic glink owner 0x%04x\n", + __func__, hdr.owner); + break; + } + + return 0; +} + +#if NAPM > 0 +int +qcpas_pmic_rtr_apminfo(struct apm_power_info *info) +{ + memcpy(info, &qcpas_pmic_rtr_apm_power_info, sizeof(*info)); + + return 0; +} +#endif diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_devlist.h b/sys/dev/pci/drm/amd/amdgpu/amdgpu_devlist.h index a1ee77ae9..821f25cc6 100644 --- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_devlist.h +++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_devlist.h @@ -202,15 +202,17 @@ static const struct pci_matchid amdgpu_devices[] = { /* GC 10.3.7, DCN 3.1.6, APU, Ryzen 7020 "Mendocino" */ {0x1002, 0x1506 }, - /* GC 11.0.0, DCN 3.2.0, dGPU, Radeon RX 7900 XT/XTX "Navi 31" */ - {0x1002, 0x744c }, + /* GC 11.0.0, DCN 3.2.0, dGPU, "Navi 31" */ + {0x1002, 0x744c }, /* Radeon RX 7900 XT/XTX */ + {0x1002, 0x7448 }, /* Radeon Pro W7900 */ + {0x1002, 0x745e }, /* Radeon Pro W7800 */ /* GC 11.0.1, DCN 3.1.4, APU, Ryzen 7040 "Phoenix" */ {0x1002, 0x15bf }, /* GC 11.0.2, DCN 3.2.1, dGPU, "Navi 33" */ - {0x1002, 0x7480 }, - {0x1002, 0x7483 }, + {0x1002, 0x7480 }, /* Radeon RX 7600S, 7700S, 7600M XT, 7600 */ + {0x1002, 0x7483 }, /* Radeon RX 7600M */ /* GC 11.0.3, DCN 3.2.0, dGPU */ /* GC 11.0.4, DCN 3.1.4, APU */ diff --git a/sys/dev/pci/pcidevs b/sys/dev/pci/pcidevs index 8f4860748..87726e0fc 100644 --- a/sys/dev/pci/pcidevs +++ b/sys/dev/pci/pcidevs @@ -1,4 +1,4 @@ -$OpenBSD: pcidevs,v 1.2037 2023/05/22 13:23:56 denis Exp $ +$OpenBSD: pcidevs,v 1.2038 2023/06/12 01:12:33 jsg Exp $ /* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */ /* @@ -2097,7 +2097,9 @@ product ATI BEIGE_GOBY_3 0x7422 Navi 24 product ATI BEIGE_GOBY_4 0x7423 Navi 24 product ATI BEIGE_GOBY_5 0x7424 Navi 24 product ATI BEIGE_GOBY_6 0x743f Navi 24 +product ATI NAVI31_2 0x7448 Navi 31 product ATI NAVI31_1 0x744c Navi 31 +product ATI NAVI31_3 0x745e Navi 31 product ATI NAVI33_1 0x7480 Navi 33 product ATI NAVI33_2 0x7483 Navi 33 product ATI RADEON_9000IGP 0x7834 Radeon 9000/9100 IGP diff --git a/sys/dev/pci/pcidevs.h b/sys/dev/pci/pcidevs.h index e214e4aab..34461cb01 100644 --- a/sys/dev/pci/pcidevs.h +++ b/sys/dev/pci/pcidevs.h @@ -2,7 +2,7 @@ * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * OpenBSD: pcidevs,v 1.2037 2023/05/22 13:23:56 denis Exp + * OpenBSD: pcidevs,v 1.2038 2023/06/12 01:12:33 jsg Exp */ /* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */ @@ -2102,7 +2102,9 @@ #define PCI_PRODUCT_ATI_BEIGE_GOBY_4 0x7423 /* Navi 24 */ #define PCI_PRODUCT_ATI_BEIGE_GOBY_5 0x7424 /* Navi 24 */ #define PCI_PRODUCT_ATI_BEIGE_GOBY_6 0x743f /* Navi 24 */ +#define PCI_PRODUCT_ATI_NAVI31_2 0x7448 /* Navi 31 */ #define PCI_PRODUCT_ATI_NAVI31_1 0x744c /* Navi 31 */ +#define PCI_PRODUCT_ATI_NAVI31_3 0x745e /* Navi 31 */ #define PCI_PRODUCT_ATI_NAVI33_1 0x7480 /* Navi 33 */ #define PCI_PRODUCT_ATI_NAVI33_2 0x7483 /* Navi 33 */ #define PCI_PRODUCT_ATI_RADEON_9000IGP 0x7834 /* Radeon 9000/9100 IGP */ diff --git a/sys/dev/pci/pcidevs_data.h b/sys/dev/pci/pcidevs_data.h index cc9788b76..f6826dcf1 100644 --- a/sys/dev/pci/pcidevs_data.h +++ b/sys/dev/pci/pcidevs_data.h @@ -2,7 +2,7 @@ * THIS FILE AUTOMATICALLY GENERATED. DO NOT EDIT. * * generated from: - * OpenBSD: pcidevs,v 1.2037 2023/05/22 13:23:56 denis Exp + * OpenBSD: pcidevs,v 1.2038 2023/06/12 01:12:33 jsg Exp */ /* $NetBSD: pcidevs,v 1.30 1997/06/24 06:20:24 thorpej Exp $ */ @@ -6535,10 +6535,18 @@ static const struct pci_known_product pci_known_products[] = { PCI_VENDOR_ATI, PCI_PRODUCT_ATI_BEIGE_GOBY_6, "Navi 24", }, + { + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_NAVI31_2, + "Navi 31", + }, { PCI_VENDOR_ATI, PCI_PRODUCT_ATI_NAVI31_1, "Navi 31", }, + { + PCI_VENDOR_ATI, PCI_PRODUCT_ATI_NAVI31_3, + "Navi 31", + }, { PCI_VENDOR_ATI, PCI_PRODUCT_ATI_NAVI33_1, "Navi 33", diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c index a68c6d55b..1f61901bb 100644 --- a/sys/kern/exec_elf.c +++ b/sys/kern/exec_elf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.c,v 1.181 2023/04/19 15:37:36 kettenis Exp $ */ +/* $OpenBSD: exec_elf.c,v 1.182 2023/06/10 19:30:48 kettenis Exp $ */ /* * Copyright (c) 1996 Per Fogelstrom @@ -1383,6 +1383,9 @@ coredump_note_elf(struct proc *p, void *iocookie, size_t *sizep) #ifdef PT_GETFPREGS struct fpreg freg; #endif +#ifdef PT_PACMASK + register_t pacmask[2]; +#endif size = 0; @@ -1427,6 +1430,24 @@ coredump_note_elf(struct proc *p, void *iocookie, size_t *sizep) size += notesize; #endif +#ifdef PT_PACMASK + notesize = sizeof(nhdr) + elfround(namesize) + + elfround(sizeof(pacmask)); + if (iocookie) { + pacmask[0] = pacmask[1] = process_get_pacmask(p); + + nhdr.namesz = namesize; + nhdr.descsz = sizeof(pacmask); + nhdr.type = NT_OPENBSD_PACMASK; + + error = coredump_writenote_elf(p, iocookie, &nhdr, + name, &pacmask); + if (error) + return (error); + } + size += notesize; +#endif + *sizep = size; /* XXX Add hook for machdep per-LWP notes. */ return (0); diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 6e0fbd1f8..8e7566092 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_process.c,v 1.93 2023/01/24 00:12:03 deraadt Exp $ */ +/* $OpenBSD: sys_process.c,v 1.94 2023/06/10 19:30:48 kettenis Exp $ */ /* $NetBSD: sys_process.c,v 1.55 1996/05/15 06:17:47 tls Exp $ */ /*- @@ -104,6 +104,7 @@ sys_ptrace(struct proc *p, void *v, register_t *retval) struct ptrace_event u_pe; struct ptrace_state u_ps; register_t u_wcookie; + register_t u_pacmask[2]; } u; int size = 0; enum { NONE, IN, IN_ALLOC, OUT, OUT_ALLOC, IN_OUT } mode; @@ -199,6 +200,12 @@ sys_ptrace(struct proc *p, void *v, register_t *retval) size = sizeof u.u_wcookie; data = size; /* suppress the data == size check */ break; +#endif +#ifdef PT_PACMASK + case PT_PACMASK: + mode = OUT; + size = sizeof u.u_pacmask; + break; #endif default: return EINVAL; @@ -731,6 +738,12 @@ ptrace_ustate(struct proc *p, int req, pid_t pid, void *addr, int data, case PT_WCOOKIE: *(register_t *)addr = process_get_wcookie(t); return 0; +#endif +#ifdef PT_PACMASK + case PT_PACMASK: + ((register_t *)addr)[0] = process_get_pacmask(t); + ((register_t *)addr)[1] = process_get_pacmask(t); + return 0; #endif default: KASSERTMSG(0, "%s: unhandled request %d", __func__, req); diff --git a/sys/sys/exec_elf.h b/sys/sys/exec_elf.h index 1bbacff54..8e0f22501 100644 --- a/sys/sys/exec_elf.h +++ b/sys/sys/exec_elf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_elf.h,v 1.100 2023/04/19 15:37:36 kettenis Exp $ */ +/* $OpenBSD: exec_elf.h,v 1.101 2023/06/10 19:30:48 kettenis Exp $ */ /* * Copyright (c) 1995, 1996 Erik Theisen. All rights reserved. * @@ -667,6 +667,7 @@ typedef struct { #define NT_OPENBSD_FPREGS 21 #define NT_OPENBSD_XFPREGS 22 #define NT_OPENBSD_WCOOKIE 23 +#define NT_OPENBSD_PACMASK 24 struct elfcore_procinfo { /* Version 1 fields start here. */ diff --git a/sys/ufs/ext2fs/ext2fs_vfsops.c b/sys/ufs/ext2fs/ext2fs_vfsops.c index 3baea804c..b7c3da687 100644 --- a/sys/ufs/ext2fs/ext2fs_vfsops.c +++ b/sys/ufs/ext2fs/ext2fs_vfsops.c @@ -719,7 +719,7 @@ ext2fs_sync_vnode(struct vnode *vp, void *args) return (0); ip = VTOI(vp); - + if (ip->i_e2fs_nlink == 0) nlink0 = 1; @@ -812,7 +812,7 @@ ext2fs_sync(struct mount *mp, int waitfor, int stall, mp->mnt_stat.f_mntonname, esa.nlink0, esa.inflight); #endif } - } + } if (fs->e2fs_fmod != 0) { fs->e2fs_fmod = 0; fs->e2fs.e2fs_wtime = gettime(); diff --git a/sys/ufs/ffs/ffs_balloc.c b/sys/ufs/ffs/ffs_balloc.c index ce94cffc7..823342a65 100644 --- a/sys/ufs/ffs/ffs_balloc.c +++ b/sys/ufs/ffs/ffs_balloc.c @@ -439,7 +439,7 @@ ffs2_balloc(struct inode *ip, off_t off, int size, struct ucred *cred, struct fs *fs; struct vnode *vp; struct proc *p; - + vp = ITOV(ip); fs = ip->i_fs; p = curproc; diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 4ef913f44..bb6910595 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -173,7 +173,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) return (EFBIG); uvm_vnp_setsize(ovp, length); - oip->i_ci.ci_lasta = oip->i_ci.ci_clen + oip->i_ci.ci_lasta = oip->i_ci.ci_clen = oip->i_ci.ci_cstart = oip->i_ci.ci_lastw = 0; if (DOINGSOFTDEP(ovp)) { @@ -210,7 +210,7 @@ ffs_truncate(struct inode *oip, off_t length, int flags, struct ucred *cred) aflags = B_CLRBUF; if (flags & IO_SYNC) aflags |= B_SYNC; - error = UFS_BUF_ALLOC(oip, length - 1, 1, + error = UFS_BUF_ALLOC(oip, length - 1, 1, cred, aflags, &bp); if (error) return (error); @@ -566,7 +566,7 @@ ffs_indirtrunc(struct inode *ip, daddr_t lbn, daddr_t dbn, bp->b_flags |= B_INVAL; brelse(bp); } - + *countp = blocksreleased; return (allerror); } diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index 15017537b..00750081e 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -531,7 +531,7 @@ STATIC int max_softdeps; /* maximum number of structs before slowdown */ STATIC int tickdelay = 2; /* number of ticks to pause during slowdown */ STATIC int proc_waiting; /* tracks whether we have a timeout posted */ STATIC int *stat_countp; /* statistic to count in proc_waiting timeout */ -STATIC struct timeout proc_waiting_timeout; +STATIC struct timeout proc_waiting_timeout; STATIC struct proc *filesys_syncer; /* proc of filesystem syncer process */ STATIC int req_clear_inodedeps; /* syncer process flush some inodedeps */ #define FLUSH_INODES 1 @@ -587,7 +587,7 @@ add_to_worklist(struct worklist *wk) * ordering ensures that no new triples will be generated * until all the old ones have been purged from the dependency lists. */ -int +int softdep_process_worklist(struct mount *matchmnt) { struct proc *p = CURPROC; @@ -922,7 +922,7 @@ softdep_flushfiles(struct mount *oldmnt, int flags, struct proc *p) /* * Structure hashing. - * + * * There are three types of structures that can be looked up: * 1) pagedep structures identified by mount point, inode number, * and logical block. @@ -1153,7 +1153,7 @@ top: * Executed during filesystem system initialization before * mounting any file systems. */ -void +void softdep_initialize(void) { @@ -1256,7 +1256,7 @@ softdep_mount(struct vnode *devvp, struct mount *mp, struct fs *fs, /* * Protecting the freemaps (or bitmaps). - * + * * To eliminate the need to execute fsck before mounting a file system * after a power failure, one must (conservatively) guarantee that the * on-disk copy of the bitmaps never indicate that a live inode or block is @@ -1271,7 +1271,7 @@ softdep_mount(struct vnode *devvp, struct mount *mp, struct fs *fs, * Each "inodedep" is also inserted into the hash indexing structure so * that any additional link additions can be made dependent on the inode * allocation. - * + * * The ufs file system maintains a number of free block counts (e.g., per * cylinder group, per cylinder and per pair) * in addition to the bitmaps. These counts are used to improve efficiency @@ -1380,7 +1380,7 @@ bmsafemap_lookup(struct buf *bp) /* * Direct block allocation dependencies. - * + * * When a new block is allocated, the corresponding disk locations must be * initialized (with zeros or new data) before the on-disk inode points to * them. Also, the freemap from which the block was allocated must be @@ -1394,7 +1394,7 @@ bmsafemap_lookup(struct buf *bp) * (i.e., the file is deleted, the block is de-allocated, or the block is a * fragment that gets upgraded). All of these cases are handled in * procedures described later. - * + * * When a file extension causes a fragment to be upgraded, either to a larger * fragment or to a full block, the on-disk location may change (if the * previous fragment could not simply be extended). In this case, the old @@ -1406,7 +1406,7 @@ bmsafemap_lookup(struct buf *bp) * (for the same block pointer) remains. This case is handled in the main * allocation dependency setup procedure by immediately freeing the * unreferenced fragments. - */ + */ /* inode to which block is being added */ /* block pointer within inode */ /* disk block number being added */ @@ -1414,7 +1414,7 @@ bmsafemap_lookup(struct buf *bp) /* size of new block */ /* size of new block */ /* bp for allocated block */ -void +void softdep_setup_allocdirect(struct inode *ip, daddr_t lbn, daddr_t newblkno, daddr_t oldblkno, long newsize, long oldsize, struct buf *bp) { @@ -1586,7 +1586,7 @@ allocdirect_merge(struct allocdirectlst *adphead, struct allocdirect *newadp, } free_allocdirect(adphead, oldadp, 0); } - + /* * Allocate a new freefrag structure if needed. */ @@ -1616,7 +1616,7 @@ newfreefrag(struct inode *ip, daddr_t blkno, long size) * This workitem de-allocates fragments that were replaced during * file block allocation. */ -STATIC void +STATIC void handle_workitem_freefrag(struct freefrag *freefrag) { struct inode tip; @@ -1635,7 +1635,7 @@ handle_workitem_freefrag(struct freefrag *freefrag) /* * Indirect block allocation dependencies. - * + * * The same dependencies that exist for a direct block also exist when * a new block is allocated and pointed to by an entry in a block of * indirect pointers. The undo/redo states described above are also @@ -1749,7 +1749,7 @@ softdep_setup_allocindir_meta(struct buf *nbp, struct inode *ip, /* in-memory copy of the indirect block */ /* inode for file being extended */ /* allocindir allocated by the above routines */ -STATIC void +STATIC void setup_allocindir_phase2(struct buf *bp, struct inode *ip, struct allocindir *aip) { @@ -1858,7 +1858,7 @@ setup_allocindir_phase2(struct buf *bp, struct inode *ip, /* * Block de-allocation dependencies. - * + * * When blocks are de-allocated, the on-disk pointers must be nullified before * the blocks are made available for use by other files. (The true * requirement is that old pointers must be nullified before new on-disk @@ -2090,7 +2090,7 @@ deallocate_dependencies(struct buf *bp, struct inodedep *inodedep) /* * Copy any directory remove dependencies to the list * to be processed after the zero'ed inode is written. - * If the inode has already been written, then they + * If the inode has already been written, then they * can be dumped directly onto the work list. */ while ((dirrem = LIST_FIRST(&pagedep->pd_dirremhd))) { @@ -2532,14 +2532,14 @@ free_allocindir(struct allocindir *aip, struct inodedep *inodedep) /* * Directory entry addition dependencies. - * + * * When adding a new directory entry, the inode (with its incremented link * count) must be written to disk before the directory entry's pointer to it. * Also, if the inode is newly allocated, the corresponding freemap must be * updated (on disk) before the directory entry's pointer. These requirements * are met via undo/redo on the directory entry's pointer, which consists * simply of the inode number. - * + * * As directory entries are added and deleted, the free space within a * directory block can become fragmented. The ufs file system will compact * a fragmented directory block to make space for a new entry. When this @@ -2559,7 +2559,7 @@ free_allocindir(struct allocindir *aip, struct inodedep *inodedep) /* inode referenced by new directory entry */ /* non-NULL => contents of new mkdir */ /* entry is in a newly allocated block */ -int +int softdep_setup_directory_add(struct buf *bp, struct inode *dp, off_t diroffset, long newinum, struct buf *newdirbp, int isnewblk) { @@ -2572,7 +2572,7 @@ softdep_setup_directory_add(struct buf *bp, struct inode *dp, off_t diroffset, struct inodedep *inodedep; struct newdirblk *newdirblk = NULL; struct mkdir *mkdir1, *mkdir2; - + fs = dp->i_fs; lbn = lblkno(fs, diroffset); @@ -2669,7 +2669,7 @@ softdep_setup_directory_add(struct buf *bp, struct inode *dp, off_t diroffset, FREE_LOCK(&lk); return (0); } - + if ((pagedep->pd_state & NEWBLOCK) != 0) { WORKITEM_FREE(newdirblk, D_NEWDIRBLK); FREE_LOCK(&lk); @@ -2705,7 +2705,7 @@ softdep_setup_directory_add(struct buf *bp, struct inode *dp, off_t diroffset, /* address of old directory location */ /* address of new directory location */ /* size of directory entry */ -void +void softdep_change_directoryentry_offset(struct inode *dp, caddr_t base, caddr_t oldloc, caddr_t newloc, int entrysize) { @@ -2798,7 +2798,7 @@ free_diradd(struct diradd *dap) /* * Directory entry removal dependencies. - * + * * When removing a directory entry, the entry's inode pointer must be * zero'ed on disk before the corresponding inode's link count is decremented * (possibly freeing the inode for re-use). This dependency is handled by @@ -2817,7 +2817,7 @@ free_diradd(struct diradd *dap) /* inode for the directory being modified */ /* inode for directory entry being removed */ /* indicates if doing RMDIR */ -void +void softdep_setup_remove(struct buf *bp, struct inode *dp, struct inode *ip, int isrmdir) { @@ -2950,7 +2950,7 @@ newdirrem(struct buf *bp, struct inode *dp, struct inode *ip, int isrmdir, /* * Directory entry change dependencies. - * + * * Changing an existing directory entry requires that an add operation * be completed first followed by a deletion. The semantics for the addition * are identical to the description of adding a new entry above except @@ -2970,7 +2970,7 @@ newdirrem(struct buf *bp, struct inode *dp, struct inode *ip, int isrmdir, /* inode for directory entry being removed */ /* new inode number for changed entry */ /* indicates if doing RMDIR */ -void +void softdep_setup_directory_change(struct buf *bp, struct inode *dp, struct inode *ip, long newinum, int isrmdir) { @@ -3001,7 +3001,7 @@ softdep_setup_directory_change(struct buf *bp, struct inode *dp, * creating a new directory entry, so the link count on the new * directory should not change. Thus we do not need the followup * dirrem which is usually done in handle_workitem_remove. We set - * the DIRCHG flag to tell handle_workitem_remove to skip the + * the DIRCHG flag to tell handle_workitem_remove to skip the * followup dirrem. */ if (isrmdir > 1) @@ -3088,7 +3088,7 @@ softdep_change_linkcnt(struct inode *ip, int nodelay) * This workitem decrements the inode's link count. * If the link count reaches zero, the file is removed. */ -STATIC void +STATIC void handle_workitem_remove(struct dirrem *dirrem) { struct proc *p = CURPROC; /* XXX */ @@ -3104,7 +3104,7 @@ handle_workitem_remove(struct dirrem *dirrem) } ip = VTOI(vp); ACQUIRE_LOCK(&lk); - if ((inodedep_lookup(ip->i_fs, dirrem->dm_oldinum, 0, &inodedep)) + if ((inodedep_lookup(ip->i_fs, dirrem->dm_oldinum, 0, &inodedep)) == 0) { FREE_LOCK(&lk); panic("handle_workitem_remove: lost inodedep"); @@ -3178,7 +3178,7 @@ handle_workitem_remove(struct dirrem *dirrem) /* * Inode de-allocation dependencies. - * + * * When an inode's link count is reduced to zero, it can be de-allocated. We * found it convenient to postpone de-allocation until after the inode is * written to disk with its new link count (zero). At this point, all of the @@ -3190,7 +3190,7 @@ handle_workitem_remove(struct dirrem *dirrem) * procedure above (softdep_setup_freeblocks) and completed by the * following procedure. */ -STATIC void +STATIC void handle_workitem_freefile(struct freefile *freefile) { struct fs *fs; @@ -3215,7 +3215,7 @@ handle_workitem_freefile(struct freefile *freefile) tip.i_vnode = &vp; vp.v_data = &tip; - if ((error = ffs_freefile(&tip, freefile->fx_oldinum, + if ((error = ffs_freefile(&tip, freefile->fx_oldinum, freefile->fx_mode)) != 0) { softdep_error("handle_workitem_freefile", error); } @@ -3224,7 +3224,7 @@ handle_workitem_freefile(struct freefile *freefile) /* * Disk writes. - * + * * The dependency structures constructed above are most actively used when file * system blocks are written to disk. No constraints are placed on when a * block can be written, but unsatisfied update dependencies are made safe by @@ -3233,7 +3233,7 @@ handle_workitem_freefile(struct freefile *freefile) * up-to-date. * * In-core inode structure reclamation. - * + * * Because there are a finite number of "in-core" inode structures, they are * reused regularly. By transferring all inode-related dependencies to the * in-memory inode block and indexing them separately (via "inodedep"s), we @@ -3245,7 +3245,7 @@ handle_workitem_freefile(struct freefile *freefile) * while we are manipulating its associated dependencies. */ /* structure describing disk write to occur */ -void +void softdep_disk_io_initiation(struct buf *bp) { struct worklist *wk, *nextwk; @@ -3385,7 +3385,7 @@ initiate_write_filepage(struct pagedep *pagedep, struct buf *bp) * are manipulating its associated dependencies. */ /* The inode block */ -STATIC void +STATIC void initiate_write_inodeblock_ufs1(struct inodedep *inodedep, struct buf *bp) { struct allocdirect *adp, *lastadp; @@ -3755,7 +3755,7 @@ initiate_write_inodeblock_ufs2(struct inodedep *inodedep, struct buf *bp) * processes or other routines are called. */ /* describes the completed disk write */ -void +void softdep_disk_write_complete(struct buf *bp) { struct worklist *wk; @@ -3886,7 +3886,7 @@ softdep_disk_write_complete(struct buf *bp) * splbio interrupts blocked. */ /* the completed allocdirect */ -STATIC void +STATIC void handle_allocdirect_partdone(struct allocdirect *adp) { struct allocdirect *listadp; @@ -3997,7 +3997,7 @@ handle_allocindir_partdone(struct allocindir *aip) * splbio interrupts blocked. */ /* buffer containing the inode block */ -STATIC int +STATIC int handle_written_inodeblock(struct inodedep *inodedep, struct buf *bp) { struct worklist *wk, *filefree; @@ -4043,7 +4043,7 @@ handle_written_inodeblock(struct inodedep *inodedep, struct buf *bp) } inodedep->id_state |= COMPLETE; /* - * Roll forward anything that had to be rolled back before + * Roll forward anything that had to be rolled back before * the inode could be updated. */ hadchanges = 0; @@ -4104,7 +4104,7 @@ handle_written_inodeblock(struct inodedep *inodedep, struct buf *bp) */ if (inodedep->id_savedsize == -1) panic("handle_written_inodeblock: bad size"); - + if (fstype == UM_UFS1) { if (dp1->di_size != inodedep->id_savedsize) { dp1->di_size = inodedep->id_savedsize; @@ -4257,7 +4257,7 @@ handle_written_mkdir(struct mkdir *mkdir, int type) * with further splbio interrupts blocked. */ /* buffer containing the written page */ -STATIC int +STATIC int handle_written_filepage(struct pagedep *pagedep, struct buf *bp) { struct dirrem *dirrem; @@ -4339,7 +4339,7 @@ handle_written_filepage(struct pagedep *pagedep, struct buf *bp) /* * Writing back in-core inode structures. - * + * * The file system only accesses an inode's contents when it occupies an * "in-core" inode structure. These "in-core" structures are separate from * the page frames used to cache inode blocks. Only the latter are @@ -4355,7 +4355,7 @@ handle_written_filepage(struct pagedep *pagedep, struct buf *bp) * need to ensure that the correct effective link count is put back. */ /* the "in_core" copy of the inode */ -void +void softdep_load_inodeblock(struct inode *ip) { struct inodedep *inodedep; @@ -4380,13 +4380,13 @@ softdep_load_inodeblock(struct inode *ip) * the force flag is set, then the dependencies will be * cleared so that the update can always be made. Note that * the buffer is locked when this routine is called, so we - * will never be in the middle of writing the inode block + * will never be in the middle of writing the inode block * to disk. */ /* the "in_core" copy of the inode */ /* the buffer containing the inode block */ /* nonzero => update must be allowed */ -void +void softdep_update_inodeblock(struct inode *ip, struct buf *bp, int waitfor) { struct inodedep *inodedep; @@ -4419,7 +4419,7 @@ softdep_update_inodeblock(struct inode *ip, struct buf *bp, int waitfor) if ((inodedep->id_state & ONWORKLIST) == 0) WORKLIST_INSERT(&bp->b_dep, &inodedep->id_list); /* - * Any new dependencies associated with the incore inode must + * Any new dependencies associated with the incore inode must * now be moved to the list associated with the buffer holding * the in-memory copy of the inode. Once merged process any * allocdirects that are completed by the merger. @@ -4584,7 +4584,7 @@ softdep_fsync(struct vnode *vp) return (error); /* * All MKDIR_PARENT dependencies and all the NEWBLOCK pagedeps - * that are contained in direct blocks will be resolved by + * that are contained in direct blocks will be resolved by * doing a UFS_UPDATE. Pagedeps contained in indirect blocks * may require a complete sync'ing of the directory. So, we * try the cheap and fast UFS_UPDATE first, and if that fails, @@ -4640,7 +4640,7 @@ softdep_fsync_mountdev(struct vnode *vp, int waitfor) panic("softdep_fsync_mountdev: vnode not a disk"); ACQUIRE_LOCK(&lk); LIST_FOREACH_SAFE(bp, &vp->v_dirtyblkhd, b_vnbufs, nbp) { - /* + /* * If it is already scheduled, skip to the next buffer. */ splassert(IPL_BIO); @@ -4665,7 +4665,7 @@ softdep_fsync_mountdev(struct vnode *vp, int waitfor) (void) bawrite(bp); ACQUIRE_LOCK(&lk); /* - * Since we may have slept during the I/O, we need + * Since we may have slept during the I/O, we need * to start from a known point. */ nbp = LIST_FIRST(&vp->v_dirtyblkhd); @@ -5276,7 +5276,7 @@ request_cleanup(int resource, int islocked) * flushing some dirty inodes. Otherwise, we are constrained * by file deletions, so try accelerating flushes of directories * with removal dependencies. We would like to do the cleanup - * here, but we probably hold an inode locked at this point and + * here, but we probably hold an inode locked at this point and * that might deadlock against one that we try to clean. So, * the best that we can do is request the syncer daemon to do * the cleanup for us. @@ -5402,7 +5402,7 @@ clear_inodedeps(struct proc *p) ACQUIRE_LOCK(&lk); /* * Pick a random inode dependency to be cleared. - * We will then gather up all the inodes in its block + * We will then gather up all the inodes in its block * that have dependencies and flush them out. */ for (cnt = 0; cnt <= inodedep_hash; cnt++) { @@ -5612,7 +5612,7 @@ drain_output(struct vnode *vp, int islocked) * Called whenever a buffer that is being invalidated or reallocated * contains dependencies. This should only happen if an I/O error has * occurred. The routine is called with the buffer locked. - */ + */ void softdep_deallocate_dependencies(struct buf *bp) { @@ -5743,7 +5743,7 @@ worklist_print(struct worklist *wk, int full, break; case D_DIRADD: dap = WK_DIRADD(wk); - (*pr)("off %d ino %u da_un %p\n", dap->da_offset, + (*pr)("off %d ino %u da_un %p\n", dap->da_offset, dap->da_newinum, dap->da_un.dau_previous); break; case D_MKDIR: @@ -5752,7 +5752,7 @@ worklist_print(struct worklist *wk, int full, break; case D_DIRREM: dirrem = WK_DIRREM(wk); - (*pr)("mp %p ino %u dm_un %p\n", dirrem->dm_mnt, + (*pr)("mp %p ino %u dm_un %p\n", dirrem->dm_mnt, dirrem->dm_oldinum, dirrem->dm_un.dmu_pagedep); break; case D_NEWDIRBLK: diff --git a/sys/ufs/ffs/ffs_softdep_stub.c b/sys/ufs/ffs/ffs_softdep_stub.c index 26ec89c73..6d7a5e3f4 100644 --- a/sys/ufs/ffs/ffs_softdep_stub.c +++ b/sys/ufs/ffs/ffs_softdep_stub.c @@ -59,7 +59,7 @@ softdep_mount(struct vnode *devvp, struct mount *mp, struct fs *fs, return (0); } -void +void softdep_initialize(void) { return; @@ -79,7 +79,7 @@ softdep_setup_blkmapdep(struct buf *bp, struct fs *fs, daddr_t newblkno) panic("softdep_setup_blkmapdep called"); } -void +void softdep_setup_allocdirect(struct inode *ip, daddr_t lbn, daddr_t newblkno, daddr_t oldblkno, long newsize, long oldsize, struct buf *bp) { @@ -120,21 +120,21 @@ softdep_setup_directory_add(struct buf *bp, struct inode *dp, off_t diroffset, return (0); } -void +void softdep_change_directoryentry_offset(struct inode *dp, caddr_t base, caddr_t oldloc, caddr_t newloc, int entrysize) { panic("softdep_change_directoryentry_offset called"); } -void +void softdep_setup_remove(struct buf *bp, struct inode *dp, struct inode *ip, int isrmdir) { panic("softdep_setup_remove called"); } -void +void softdep_setup_directory_change(struct buf *bp, struct inode *dp, struct inode *ip, long newinum, int isrmdir) { @@ -147,13 +147,13 @@ softdep_change_linkcnt(struct inode *ip, int nodelay) panic("softdep_change_linkcnt called"); } -void +void softdep_load_inodeblock(struct inode *ip) { panic("softdep_load_inodeblock called"); } -void +void softdep_update_inodeblock(struct inode *ip, struct buf *bp, int waitfor) { panic("softdep_update_inodeblock called"); diff --git a/sys/ufs/ffs/ffs_vfsops.c b/sys/ufs/ffs/ffs_vfsops.c index ffe78ef14..372c97679 100644 --- a/sys/ufs/ffs/ffs_vfsops.c +++ b/sys/ufs/ffs/ffs_vfsops.c @@ -354,7 +354,7 @@ ffs_mount(struct mount *mp, const char *path, void *data, /* * Process export requests. */ - error = vfs_export(mp, &ump->um_export, + error = vfs_export(mp, &ump->um_export, &args->export_info); if (error) goto error_1; @@ -495,7 +495,7 @@ struct ffs_reload_args { }; int -ffs_reload_vnode(struct vnode *vp, void *args) +ffs_reload_vnode(struct vnode *vp, void *args) { struct ffs_reload_args *fra = args; struct inode *ip; @@ -524,7 +524,7 @@ ffs_reload_vnode(struct vnode *vp, void *args) */ ip = VTOI(vp); - error = bread(fra->devvp, + error = bread(fra->devvp, fsbtodb(fra->fs, ino_to_fsba(fra->fs, ip->i_number)), (int)fra->fs->fs_bsize, &bp); if (error) { @@ -1255,7 +1255,7 @@ ffs_sync(struct mount *mp, int waitfor, int stall, struct ucred *cred, struct pr if ((error = softdep_flushworklist(ump->um_mountp, &count, p))) allerror = error; /* Flushed work items may create new vnodes to clean */ - if (count) + if (count) goto loop; } if (waitfor != MNT_LAZY) { @@ -1351,7 +1351,7 @@ retry: * disk portion of this inode to be read. */ error = ufs_ihashins(ip); - + if (error) { /* * VOP_INACTIVE will treat this as a stale file diff --git a/sys/ufs/ffs/ffs_vnops.c b/sys/ufs/ffs/ffs_vnops.c index 668586b9f..19cfce62f 100644 --- a/sys/ufs/ffs/ffs_vnops.c +++ b/sys/ufs/ffs/ffs_vnops.c @@ -439,7 +439,7 @@ loop: bp->b_flags &= ~B_SCANNED; } LIST_FOREACH_SAFE(bp, &vp->v_dirtyblkhd, b_vnbufs, nbp) { - /* + /* * Reasons to skip this buffer: it has already been considered * on this pass, this pass is the first time through on a * synchronous flush request and the buffer being considered diff --git a/sys/ufs/ffs/fs.h b/sys/ufs/ffs/fs.h index 10e89cfd9..78846259c 100644 --- a/sys/ufs/ffs/fs.h +++ b/sys/ufs/ffs/fs.h @@ -71,7 +71,7 @@ /* * Addresses stored in inodes are capable of addressing fragments - * of `blocks'. File system blocks of at most size MAXBSIZE can + * of `blocks'. File system blocks of at most size MAXBSIZE can * be optionally broken into 2, 4, or 8 pieces, each of which is * addressable; these pieces may be DEV_BSIZE, or some multiple of * a DEV_BSIZE unit. @@ -286,7 +286,7 @@ struct fs { int32_t fs_sparecon[26]; /* reserved for future constants */ u_int32_t fs_flags; /* see FS_ flags below */ int32_t fs_fscktime; /* last time fsck(8)ed */ - int32_t fs_contigsumsize; /* size of cluster summary array */ + int32_t fs_contigsumsize; /* size of cluster summary array */ int32_t fs_maxsymlinklen; /* max length of an internal symlink */ int32_t fs_inodefmt; /* format of on-disk inodes */ u_int64_t fs_maxfilesize; /* maximum representable file size */ @@ -324,7 +324,7 @@ struct fs { #define FS_OPTTIME 0 /* minimize allocation time */ #define FS_OPTSPACE 1 /* minimize disk fragmentation */ -/* +/* * Filesystem flags. */ #define FS_UNCLEAN 0x01 /* filesystem not clean at mount */ diff --git a/sys/ufs/ffs/softdep.h b/sys/ufs/ffs/softdep.h index 8279399a8..4a18d9350 100644 --- a/sys/ufs/ffs/softdep.h +++ b/sys/ufs/ffs/softdep.h @@ -47,7 +47,7 @@ * Allocation dependencies are handled with undo/redo on the in-memory * copy of the data. A particular data dependency is eliminated when * it is ALLCOMPLETE: that is ATTACHED, DEPCOMPLETE, and COMPLETE. - * + * * ATTACHED means that the data is not currently being written to * disk. UNDONE means that the data has been rolled back to a safe * state for writing to the disk. When the I/O completes, the data is @@ -90,7 +90,7 @@ * just been allocated, so must be claimed by the inode before all * dependencies are complete. The ONWORKLIST flag shows whether the * structure is currently linked onto a worklist. - * + * */ #define ATTACHED 0x0001 #define UNDONE 0x0002 @@ -115,7 +115,7 @@ /* * The workitem queue. - * + * * It is sometimes useful and/or necessary to clean up certain dependencies * in the background rather than during execution of an application process * or interrupt service routine. To realize this, we append dependency @@ -202,7 +202,7 @@ struct pagedep { * The "inodedep" structure tracks the set of dependencies associated * with an inode. One task that it must manage is delayed operations * (i.e., work requests that must be held until the inodedep's associated - * inode has been written to disk). Getting an inode from its incore + * inode has been written to disk). Getting an inode from its incore * state to the disk requires two steps to be taken by the filesystem * in this order: first the inode must be copied to its disk buffer by * the VOP_UPDATE operation; second the inode's buffer must be written @@ -277,7 +277,7 @@ struct inodedep { * an associated allocdirect or allocindir allocation which will attach * themselves to the bmsafemap structure if the newblk's DEPCOMPLETE flag * is not set (i.e., its cylinder group map has not been written). - */ + */ struct newblk { LIST_ENTRY(newblk) nb_hash; /* hashed lookup */ struct fs *nb_fs; /* associated filesystem */ @@ -385,7 +385,7 @@ struct indirdep { * to disk, ai_state has the DEPCOMPLETE flag set. When the block itself * is written, the COMPLETE flag is set. Once both the cylinder group map * and the data itself have been written, it is safe to write the entry in - * the indirect block that claims the block; the "allocindir" dependency + * the indirect block that claims the block; the "allocindir" dependency * can then be freed as it is no longer applicable. */ struct allocindir { @@ -580,7 +580,7 @@ struct dirrem { * deleted from their pagedep->id_pendinghd and inodedep->id_pendinghd * lists. Note that we could track directory blocks allocated to indirect * blocks using a similar scheme with the allocindir structures. Rather - * than adding this level of complexity, we simply write those newly + * than adding this level of complexity, we simply write those newly * allocated indirect blocks synchronously as such allocations are rare. */ struct newdirblk { diff --git a/usr.bin/file/magdir/OpenBSD b/usr.bin/file/magdir/OpenBSD index ded9443ef..c3d83bb39 100644 --- a/usr.bin/file/magdir/OpenBSD +++ b/usr.bin/file/magdir/OpenBSD @@ -12,7 +12,7 @@ >16 belong >0 not stripped 0 belong&0377777777 041400413 OpenBSD/i386 demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -33,7 +33,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 041600413 OpenBSD/m68k demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <8192 shared library >>20 belong =8192 dynamically linked executable >>20 belong >8192 dynamically linked executable @@ -54,7 +54,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 046200413 OpenBSD/m88k demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <8192 shared library >>20 belong =8192 dynamically linked executable >>20 belong >8192 dynamically linked executable @@ -75,7 +75,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 042000413 OpenBSD/m68k4k demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <4096 shared library >>20 belong =4096 dynamically linked executable >>20 belong >4096 dynamically linked executable @@ -96,7 +96,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 042200413 OpenBSD/ns32532 demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -117,7 +117,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 042400413 OpenBSD/sparc demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <8192 shared library >>20 belong =8192 dynamically linked executable >>20 belong >8192 dynamically linked executable @@ -138,7 +138,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 042600413 OpenBSD/pmax demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -159,7 +159,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 043000413 OpenBSD/vax1k demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -180,7 +180,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 045400413 OpenBSD/vax demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -201,7 +201,7 @@ >12 string >\0 from '%s' # OpenBSD/alpha does not support (and has never supported) a.out objects, -# so no rules are provided for them. OpenBSD/alpha ELF objects are +# so no rules are provided for them. OpenBSD/alpha ELF objects are # dealt with in "elf". 0 leshort 0x00070185 ECOFF OpenBSD/alpha binary >10 leshort 0x0001 not stripped @@ -223,7 +223,7 @@ # OpenBSD/mips64 0 belong&0377777777 047400413 OpenBSD/mips64 demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <8192 shared library >>20 belong =8192 dynamically linked executable >>20 belong >8192 dynamically linked executable diff --git a/usr.bin/file/magdir/SecBSD b/usr.bin/file/magdir/SecBSD index 07c617a33..16e5ab261 100644 --- a/usr.bin/file/magdir/SecBSD +++ b/usr.bin/file/magdir/SecBSD @@ -12,7 +12,7 @@ >16 belong >0 not stripped 0 belong&0377777777 041400413 SecBSD/i386 demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -33,7 +33,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 041600413 SecBSD/m68k demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <8192 shared library >>20 belong =8192 dynamically linked executable >>20 belong >8192 dynamically linked executable @@ -54,7 +54,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 046200413 SecBSD/m88k demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <8192 shared library >>20 belong =8192 dynamically linked executable >>20 belong >8192 dynamically linked executable @@ -75,7 +75,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 042000413 SecBSD/m68k4k demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <4096 shared library >>20 belong =4096 dynamically linked executable >>20 belong >4096 dynamically linked executable @@ -96,7 +96,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 042200413 SecBSD/ns32532 demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -117,7 +117,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 042400413 SecBSD/sparc demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <8192 shared library >>20 belong =8192 dynamically linked executable >>20 belong >8192 dynamically linked executable @@ -138,7 +138,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 042600413 SecBSD/pmax demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -159,7 +159,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 043000413 SecBSD/vax1k demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -180,7 +180,7 @@ >12 string >\0 from '%s' 0 belong&0377777777 045400413 SecBSD/vax demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 lelong <4096 shared library >>20 lelong =4096 dynamically linked executable >>20 lelong >4096 dynamically linked executable @@ -201,7 +201,7 @@ >12 string >\0 from '%s' # SecBSD/alpha does not support (and has never supported) a.out objects, -# so no rules are provided for them. SecBSD/alpha ELF objects are +# so no rules are provided for them. SecBSD/alpha ELF objects are # dealt with in "elf". 0 leshort 0x00070185 ECOFF SecBSD/alpha binary >10 leshort 0x0001 not stripped @@ -223,7 +223,7 @@ # SecBSD/mips64 0 belong&0377777777 047400413 SecBSD/mips64 demand paged ->0 byte &0x80 +>0 byte &0x80 >>20 belong <8192 shared library >>20 belong =8192 dynamically linked executable >>20 belong >8192 dynamically linked executable diff --git a/usr.bin/openssl/apps.c b/usr.bin/openssl/apps.c index f5f1248c0..44b304a98 100644 --- a/usr.bin/openssl/apps.c +++ b/usr.bin/openssl/apps.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.c,v 1.64 2023/04/22 20:50:26 tb Exp $ */ +/* $OpenBSD: apps.c,v 1.65 2023/06/11 12:35:00 jsg Exp $ */ /* * Copyright (c) 2014 Joel Sing * @@ -199,75 +199,6 @@ program_name(char *in, char *out, int size) strlcpy(out, p, size); } -int -chopup_args(ARGS *arg, char *buf, int *argc, char **argv[]) -{ - int num, i; - char *p; - - *argc = 0; - *argv = NULL; - - if (arg->count == 0) { - arg->count = 20; - arg->data = reallocarray(NULL, arg->count, sizeof(char *)); - if (arg->data == NULL) - return 0; - } - for (i = 0; i < arg->count; i++) - arg->data[i] = NULL; - - num = 0; - p = buf; - for (;;) { - /* first scan over white space */ - if (!*p) - break; - while (*p && ((*p == ' ') || (*p == '\t') || (*p == '\n'))) - p++; - if (!*p) - break; - - /* The start of something good :-) */ - if (num >= arg->count) { - char **tmp_p; - int tlen = arg->count + 20; - tmp_p = reallocarray(arg->data, tlen, sizeof(char *)); - if (tmp_p == NULL) - return 0; - arg->data = tmp_p; - arg->count = tlen; - /* initialize newly allocated data */ - for (i = num; i < arg->count; i++) - arg->data[i] = NULL; - } - arg->data[num++] = p; - - /* now look for the end of this */ - if ((*p == '\'') || (*p == '\"')) { /* scan for closing - * quote */ - i = *(p++); - arg->data[num - 1]++; /* jump over quote */ - while (*p && (*p != i)) - p++; - *p = '\0'; - } else { - while (*p && ((*p != ' ') && - (*p != '\t') && (*p != '\n'))) - p++; - - if (*p == '\0') - p--; - else - *p = '\0'; - } - p++; - } - *argc = num; - *argv = arg->data; - return (1); -} - int dump_cert_text(BIO *out, X509 *x) { diff --git a/usr.bin/openssl/apps.h b/usr.bin/openssl/apps.h index 82e0662c8..8556dc14b 100644 --- a/usr.bin/openssl/apps.h +++ b/usr.bin/openssl/apps.h @@ -1,4 +1,4 @@ -/* $OpenBSD: apps.h,v 1.32 2023/04/14 15:27:13 tb Exp $ */ +/* $OpenBSD: apps.h,v 1.34 2023/06/11 13:02:10 jsg Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -133,11 +133,6 @@ extern CONF *config; extern char *default_config_file; extern BIO *bio_err; -typedef struct args_st { - char **data; - int count; -} ARGS; - #define PW_MIN_LENGTH 4 typedef struct pw_cb_data { const void *password; @@ -159,7 +154,6 @@ int should_retry(int i); int args_from_file(char *file, int *argc, char **argv[]); int str2fmt(char *s); void program_name(char *in, char *out, int size); -int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[]); #ifdef HEADER_X509_H int dump_cert_text(BIO *out, X509 *x); void print_name(BIO *out, const char *title, X509_NAME *nm, diff --git a/usr.bin/openssl/enc.c b/usr.bin/openssl/enc.c index b80a177cd..00ae0e1b7 100644 --- a/usr.bin/openssl/enc.c +++ b/usr.bin/openssl/enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enc.c,v 1.27 2023/03/06 14:32:06 tb Exp $ */ +/* $OpenBSD: enc.c,v 1.30 2023/06/11 12:06:08 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -80,9 +80,6 @@ static struct { char *bufsize; const EVP_CIPHER *cipher; int debug; -#ifdef ZLIB - int do_zlib; -#endif int enc; char *hiv; char *hkey; @@ -287,14 +284,6 @@ static const struct option enc_options[] = { .type = OPTION_FLAG, .opt.flag = &cfg.verbose, }, -#ifdef ZLIB - { - .name = "z", - .desc = "Perform zlib compression/decompression", - .type = OPTION_FLAG, - .opt.flag = &cfg.do_zlib, - }, -#endif { .name = NULL, .type = OPTION_ARGV_FUNC, @@ -349,9 +338,6 @@ enc_main(int argc, char **argv) int ret = 1, inl; unsigned char key[EVP_MAX_KEY_LENGTH], iv[EVP_MAX_IV_LENGTH]; unsigned char salt[PKCS5_SALT_LEN]; -#ifdef ZLIB - BIO *bzl = NULL; -#endif EVP_CIPHER_CTX *ctx = NULL; const EVP_MD *dgst = NULL; BIO *in = NULL, *out = NULL, *b64 = NULL, *benc = NULL; @@ -374,21 +360,9 @@ enc_main(int argc, char **argv) if (strcmp(pname, "base64") == 0) cfg.base64 = 1; -#ifdef ZLIB - if (strcmp(pname, "zlib") == 0) - cfg.do_zlib = 1; -#endif - cfg.cipher = EVP_get_cipherbyname(pname); -#ifdef ZLIB - if (!cfg.do_zlib && !cfg.base64 && - cfg.cipher == NULL && strcmp(pname, "enc") != 0) -#else - if (!cfg.base64 && cfg.cipher == NULL && - strcmp(pname, "enc") != 0) -#endif - { + if (!cfg.base64 && cfg.cipher == NULL && strcmp(pname, "enc") != 0) { BIO_printf(bio_err, "%s is an unknown cipher\n", pname); goto end; } @@ -417,9 +391,9 @@ enc_main(int argc, char **argv) } fclose(infile); i = strlen(buf); - if ((i > 0) && ((buf[i - 1] == '\n') || (buf[i - 1] == '\r'))) + if (i > 0 && (buf[i - 1] == '\n' || buf[i - 1] == '\r')) buf[--i] = '\0'; - if ((i > 0) && ((buf[i - 1] == '\n') || (buf[i - 1] == '\r'))) + if (i > 0 && (buf[i - 1] == '\n' || buf[i - 1] == '\r')) buf[--i] = '\0'; if (i < 1) { BIO_printf(bio_err, "zero length password\n"); @@ -447,9 +421,8 @@ enc_main(int argc, char **argv) cfg.md); goto end; } - if (dgst == NULL) { + if (dgst == NULL) dgst = EVP_sha256(); - } if (cfg.bufsize != NULL) { char *p = cfg.bufsize; @@ -480,13 +453,13 @@ enc_main(int argc, char **argv) } strbuf = malloc(SIZE); buff = malloc(EVP_ENCODE_LENGTH(bsize)); - if ((buff == NULL) || (strbuf == NULL)) { + if (buff == NULL || strbuf == NULL) { BIO_printf(bio_err, "malloc failure %ld\n", (long) EVP_ENCODE_LENGTH(bsize)); goto end; } in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); - if ((in == NULL) || (out == NULL)) { + if (in == NULL || out == NULL) { ERR_print_errors(bio_err); goto end; } @@ -508,15 +481,13 @@ enc_main(int argc, char **argv) } if (!cfg.keystr && cfg.passarg) { - if (!app_passwd(bio_err, cfg.passarg, NULL, - &pass, NULL)) { + if (!app_passwd(bio_err, cfg.passarg, NULL, &pass, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; } cfg.keystr = pass; } - if (cfg.keystr == NULL && cfg.cipher != NULL && - cfg.hkey == NULL) { + if (cfg.keystr == NULL && cfg.cipher != NULL && cfg.hkey == NULL) { for (;;) { char buf[200]; int retval; @@ -561,17 +532,6 @@ enc_main(int argc, char **argv) rbio = in; wbio = out; -#ifdef ZLIB - if (do_zlib) { - if ((bzl = BIO_new(BIO_f_zlib())) == NULL) - goto end; - if (enc) - wbio = BIO_push(bzl, wbio); - else - rbio = BIO_push(bzl, rbio); - } -#endif - if (cfg.base64) { if ((b64 = BIO_new(BIO_f_base64())) == NULL) goto end; @@ -677,8 +637,7 @@ enc_main(int argc, char **argv) explicit_bzero(cfg.keystr, strlen(cfg.keystr)); } - if (cfg.hiv != NULL && - !set_hex(cfg.hiv, iv, sizeof iv)) { + if (cfg.hiv != NULL && !set_hex(cfg.hiv, iv, sizeof iv)) { BIO_printf(bio_err, "invalid hex iv value\n"); goto end; } @@ -692,8 +651,7 @@ enc_main(int argc, char **argv) BIO_printf(bio_err, "iv undefined\n"); goto end; } - if (cfg.hkey != NULL && - !set_hex(cfg.hkey, key, sizeof key)) { + if (cfg.hkey != NULL && !set_hex(cfg.hkey, key, sizeof key)) { BIO_printf(bio_err, "invalid hex key value\n"); goto end; } @@ -717,8 +675,7 @@ enc_main(int argc, char **argv) if (cfg.nopad) EVP_CIPHER_CTX_set_padding(ctx, 0); - if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, - cfg.enc)) { + if (!EVP_CipherInit_ex(ctx, NULL, NULL, key, iv, cfg.enc)) { BIO_printf(bio_err, "Error setting cipher %s\n", EVP_CIPHER_name(cfg.cipher)); ERR_print_errors(bio_err); @@ -787,9 +744,6 @@ enc_main(int argc, char **argv) BIO_free_all(out); BIO_free(benc); BIO_free(b64); -#ifdef ZLIB - BIO_free(bzl); -#endif free(pass); return (ret); @@ -812,11 +766,11 @@ set_hex(char *in, unsigned char *out, int size) *(in++) = '\0'; if (j == 0) break; - if ((j >= '0') && (j <= '9')) + if (j >= '0' && j <= '9') j -= '0'; - else if ((j >= 'A') && (j <= 'F')) + else if (j >= 'A' && j <= 'F') j = j - 'A' + 10; - else if ((j >= 'a') && (j <= 'f')) + else if (j >= 'a' && j <= 'f') j = j - 'a' + 10; else { BIO_printf(bio_err, "non-hex digit\n"); diff --git a/usr.bin/openssl/openssl.1 b/usr.bin/openssl/openssl.1 index 3005cdd2d..45ae95fa5 100644 --- a/usr.bin/openssl/openssl.1 +++ b/usr.bin/openssl/openssl.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: openssl.1,v 1.147 2023/06/07 10:53:30 schwarze Exp $ +.\" $OpenBSD: openssl.1,v 1.148 2023/06/08 09:40:17 schwarze Exp $ .\" ==================================================================== .\" Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. .\" @@ -110,7 +110,7 @@ .\" copied and put under another distribution licence .\" [including the GNU Public Licence.] .\" -.Dd $Mdocdate: June 7 2023 $ +.Dd $Mdocdate: June 8 2023 $ .Dt OPENSSL 1 .Os .Sh NAME @@ -6058,137 +6058,16 @@ error 24 at 1 depth lookup:invalid CA certificate .Pp The first line contains the name of the certificate being verified, followed by the subject name of the certificate. -The second line contains the error number and the depth. +The second line contains the error number as defined by the +.Dv X509_V_ERR_* +constants in +.In openssl/x509_vfy.h , +the associated error message documented in +.Xr X509_STORE_CTX_get_error 3 , +and the depth. The depth is the number of the certificate being verified when a problem was detected starting with zero for the certificate being verified itself, then 1 for the CA that signed the certificate and so on. -Finally a text version of the error number is presented. -.Pp -An exhaustive list of the error codes and messages is shown below; this also -includes the name of the error code as defined in the header file -.In openssl/x509_vfy.h . -Some of the error codes are defined but never returned: these are described as -.Qq unused . -.Bl -tag -width "XXXX" -.It 0 X509_V_OK -The operation was successful. -.It 2 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT -The issuer certificate of an untrusted certificate could not be found. -.It 3 X509_V_ERR_UNABLE_TO_GET_CRL -The CRL of a certificate could not be found. -.It 4 X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE -The certificate signature could not be decrypted. -This means that the actual signature value could not be determined -rather than it not matching the expected value. -This is only meaningful for RSA keys. -.It 5 X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE -The CRL signature could not be decrypted. -This means that the actual signature value could not be determined -rather than it not matching the expected value. -Unused. -.It 6 X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY -The public key in the certificate -.Cm SubjectPublicKeyInfo -could not be read. -.It 7 X509_V_ERR_CERT_SIGNATURE_FAILURE -The signature of the certificate is invalid. -.It 8 X509_V_ERR_CRL_SIGNATURE_FAILURE -The signature of the certificate is invalid. -.It 9 X509_V_ERR_CERT_NOT_YET_VALID -The certificate is not yet valid: the -.Cm notBefore -date is after the current time. -.It 10 X509_V_ERR_CERT_HAS_EXPIRED -The certificate has expired; that is, the -.Cm notAfter -date is before the current time. -.It 11 X509_V_ERR_CRL_NOT_YET_VALID -The CRL is not yet valid. -.It 12 X509_V_ERR_CRL_HAS_EXPIRED -The CRL has expired. -.It 13 X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD -The certificate -.Cm notBefore -field contains an invalid time. -.It 14 X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD -The certificate -.Cm notAfter -field contains an invalid time. -.It 15 X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD -The CRL -.Cm thisUpdate -field contains an invalid time. -The error code is misnamed and the error message confusingly talks about -.Dq lastUpdate -instead of -.Dq thisUpdate -for historical reasons. -.It 16 X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD -The CRL -.Cm nextUpdate -field contains an invalid time. -.It 17 X509_V_ERR_OUT_OF_MEM -An error occurred trying to allocate memory. -This should never happen. -.It 18 X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT -The passed certificate is self-signed and the same certificate cannot be -found in the list of trusted certificates. -.It 19 X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN -The certificate chain could be built up using the untrusted certificates but -the root could not be found locally. -.It 20 X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY -The issuer certificate of a locally looked up certificate could not be found. -This normally means the list of trusted certificates is not complete. -.It 21 X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE -No signatures could be verified because the chain contains only one -certificate and it is not self-signed. -.It 22 X509_V_ERR_CERT_CHAIN_TOO_LONG -The certificate chain length is greater than the supplied maximum depth. -Unused. -.It 23 X509_V_ERR_CERT_REVOKED -The certificate has been revoked. -.It 24 X509_V_ERR_INVALID_CA -A CA certificate is invalid. -Either it is not a CA or its extensions are not consistent -with the supplied purpose. -.It 25 X509_V_ERR_PATH_LENGTH_EXCEEDED -The -.Cm basicConstraints -pathlength parameter has been exceeded. -.It 26 X509_V_ERR_INVALID_PURPOSE -The supplied certificate cannot be used for the specified purpose. -.It 27 X509_V_ERR_CERT_UNTRUSTED -The root CA is not marked as trusted for the specified purpose. -.It 28 X509_V_ERR_CERT_REJECTED -The root CA is marked to reject the specified purpose. -.It 29 X509_V_ERR_SUBJECT_ISSUER_MISMATCH -The current candidate issuer certificate was rejected because its subject name -did not match the issuer name of the current certificate. -Only displayed when the -.Fl issuer_checks -option is set. -.It 30 X509_V_ERR_AKID_SKID_MISMATCH -The current candidate issuer certificate was rejected because its subject key -identifier was present and did not match the authority key identifier current -certificate. -Only displayed when the -.Fl issuer_checks -option is set. -.It 31 X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH -The current candidate issuer certificate was rejected because its issuer name -and serial number were present and did not match the authority key identifier -of the current certificate. -Only displayed when the -.Fl issuer_checks -option is set. -.It 32 X509_V_ERR_KEYUSAGE_NO_CERTSIGN -The current candidate issuer certificate was rejected because its -.Cm keyUsage -extension does not permit certificate signing. -.It 50 X509_V_ERR_APPLICATION_VERIFICATION -An application specific error. -Unused. -.El .Tg version .Sh VERSION .Nm openssl version diff --git a/usr.bin/openssl/openssl.c b/usr.bin/openssl/openssl.c index 51940fdf6..e5ff31a2c 100644 --- a/usr.bin/openssl/openssl.c +++ b/usr.bin/openssl/openssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openssl.c,v 1.33 2023/04/25 16:11:02 tb Exp $ */ +/* $OpenBSD: openssl.c,v 1.35 2023/06/11 13:02:10 jsg Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -329,10 +329,6 @@ FUNCTION functions[] = { { FUNC_TYPE_CIPHER, "sm4-ofb", enc_main }, { FUNC_TYPE_CIPHER, "sm4-cfb", enc_main }, #endif -#ifdef ZLIB - { FUNC_TYPE_CIPHER, "zlib", enc_main }, -#endif - { 0, NULL, NULL } }; @@ -382,16 +378,12 @@ openssl_shutdown(void) int main(int argc, char **argv) { - ARGS arg; char *to_free = NULL; int i, ret = 0; char *p; LHASH_OF(FUNCTION) * prog = NULL; long errline; - arg.data = NULL; - arg.count = 0; - if (pledge("stdio cpath wpath rpath inet dns proc flock tty", NULL) == -1) { fprintf(stderr, "openssl: pledge: %s\n", strerror(errno)); exit(1); @@ -471,7 +463,6 @@ main(int argc, char **argv) } if (prog != NULL) lh_FUNCTION_free(prog); - free(arg.data); openssl_shutdown(); diff --git a/usr.bin/pkg-config/OpenBSD/PkgConfig.pm b/usr.bin/pkg-config/OpenBSD/PkgConfig.pm index 757d1c8b4..bdbbed873 100644 --- a/usr.bin/pkg-config/OpenBSD/PkgConfig.pm +++ b/usr.bin/pkg-config/OpenBSD/PkgConfig.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: PkgConfig.pm,v 1.9 2023/01/25 19:06:50 millert Exp $ +# $OpenBSD: PkgConfig.pm,v 1.10 2023/06/08 08:55:27 espie Exp $ # # Copyright (c) 2006 Marc Espie # @@ -14,17 +14,16 @@ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -use strict; -use warnings; +use v5.36; -# this is a 'special' package, interface to the *.pc file format of pkg-config. +# interface to the *.pc file format of pkg-config. package OpenBSD::PkgConfig; # specific properties may have specific needs. my $parse = { - Requires => sub { - my @l = split(/[,\s]+/, shift); + Requires => sub($req) { + my @l = split(/[,\s]+/, $req); my @r = (); while (@l > 0) { my $n = shift @l; @@ -46,16 +45,14 @@ my $parse = { my $write = { - Libs => sub { " ".__PACKAGE__->compress(shift) } + Libs => sub($arg) { " ".__PACKAGE__->compress($arg) } }; $parse->{'Requires.private'} = $parse->{Requires}; $write->{'Libs.private'} = $write->{Libs}; -sub new +sub new($class) { - my $class = shift; - return bless { variables => {}, vlist => [], @@ -64,9 +61,8 @@ sub new }, $class; } -sub add_variable +sub add_variable($self, $name, $value) { - my ($self, $name, $value) = @_; if (defined $self->{variables}{$name}) { die "Duplicate variable $name"; } @@ -74,9 +70,8 @@ sub add_variable $self->{variables}{$name} = ($value =~ s/^\"|\"$//rg); } -sub parse_value +sub parse_value($self, $name, $value) { - my ($self, $name, $value) = @_; if (defined $parse->{$name}) { return $parse->{$name}($value); } else { @@ -84,9 +79,8 @@ sub parse_value } } -sub add_property +sub add_property($self, $name, $value) { - my ($self, $name, $value) = @_; if (defined $self->{properties}{$name}) { die "Duplicate property $name"; } @@ -100,12 +94,10 @@ sub add_property $self->{properties}{$name} = $v; } -sub read_fh +sub read_fh($class, $fh, $name = '') { - my ($class, $fh, $name) = @_; my $cfg = $class->new; - $name //= ''; while (<$fh>) { chomp; # continuation lines @@ -135,20 +127,16 @@ sub read_fh return $cfg; } -sub read_file +sub read_file($class, $filename) { - my ($class, $filename) = @_; - open my $fh, '<:crlf', $filename or die "Can't open $filename: $!"; return $class->read_fh($fh, $filename); } -sub write_fh +sub write_fh($self, $fh) { - my ($self, $fh) = @_; - foreach my $variable (@{$self->{vlist}}) { - print $fh "$variable=", $self->{variables}{$variable}, "\n"; + say $fh "$variable=", $self->{variables}{$variable}; } print $fh "\n\n"; foreach my $property (@{$self->{proplist}}) { @@ -163,16 +151,14 @@ sub write_fh } } -sub write_file +sub write_file($cfg, $filename) { - my ($cfg, $filename) = @_; open my $fh, '>', $filename or die "Can't open $filename: $!"; $cfg->write_fh($fh); } -sub compress_list +sub compress_list($class, $l, $keep = undef) { - my ($class, $l, $keep) = @_; my $h = {}; my $r = []; foreach my $i (@$l) { @@ -184,60 +170,52 @@ sub compress_list return $r; } -sub compress +sub compress($class, $l, $keep = undef) { - my ($class, $l, $keep) = @_; return join(' ', @{$class->compress_list($l, $keep)}); } -sub rcompress +sub rcompress($class, $l, $keep = undef) { - my ($class, $l, $keep) = @_; my @l2 = reverse @$l; return join(' ', reverse @{$class->compress_list(\@l2, $keep)}); } -sub expanded +sub expanded($self, $v, $extra = {}) { - my ($self, $v, $extra) = @_; - - $extra = {} if !defined $extra; my $get_value = - sub { - my $var = shift; - if (defined $extra->{$var}) { - if ($extra->{$var} =~ m/\$\{.*\}/ ) { - return undef; - } else { - return $extra->{$var}; - } - } elsif (defined $self->{variables}{$var}) { - return $self->{variables}{$var}; + sub($var) { + if (defined $extra->{$var}) { + if ($extra->{$var} =~ m/\$\{.*\}/ ) { + return undef; } else { - return ''; + return $extra->{$var}; } - }; + } elsif (defined $self->{variables}{$var}) { + return $self->{variables}{$var}; + } else { + return ''; + } + }; # Expand all variables, unless the returned value is defined as an # as an unexpandable variable (such as with --defined-variable). while ($v =~ m/\$\{(.*?)\}/) { - # Limit the expanded variable size if 64K to prevent a - # malicious .pc file from consuming too much memory. - die "Variable expansion overflow" if length($v) > 64 * 1024; + # Limit the expanded variable size if 64K to prevent a + # malicious .pc file from consuming too much memory. + die "Variable expansion overflow" if length($v) > 64 * 1024; - unless (defined &$get_value($1)) { - $v =~ s/\$\{(.*?)\}/$extra->{$1}/g; - last; - } - $v =~ s/\$\{(.*?)\}/&$get_value($1)/ge; + unless (defined &$get_value($1)) { + $v =~ s/\$\{(.*?)\}/$extra->{$1}/g; + last; + } + $v =~ s/\$\{(.*?)\}/&$get_value($1)/ge; } return $v; } -sub get_property +sub get_property($self, $k, $extra = {}) { - my ($self, $k, $extra) = @_; - my $l = $self->{properties}{$k}; if (!defined $l) { return undef; @@ -256,10 +234,8 @@ sub get_property return $r; } -sub get_variable +sub get_variable($self, $k, $extra = {}) { - my ($self, $k, $extra) = @_; - my $v = $self->{variables}{$k}; if (defined $v) { return $self->expanded($v, $extra); @@ -271,10 +247,8 @@ sub get_variable # to be used to make sure a config does not depend on absolute path names, # e.g., $cfg->add_bases(X11R6 => '/usr/X11R6'); -sub add_bases +sub add_bases($self, $extra) { - my ($self, $extra) = @_; - while (my ($k, $v) = each %$extra) { for my $name (keys %{$self->{variables}}) { $self->{variables}{$name} =~ s/\Q$v\E\b/\$\{\Q$k\E\}/g; diff --git a/usr.bin/pkg-config/pkg-config b/usr.bin/pkg-config/pkg-config index 71a69b69b..29aaf47cb 100644 --- a/usr.bin/pkg-config/pkg-config +++ b/usr.bin/pkg-config/pkg-config @@ -1,5 +1,5 @@ #!/usr/bin/perl -# $OpenBSD: pkg-config,v 1.95 2020/09/15 07:18:45 jasper Exp $ +# $OpenBSD: pkg-config,v 1.96 2023/06/08 08:55:27 espie Exp $ # Copyright (c) 2006 Chris Kuethe # Copyright (c) 2011-2020 Jasper Lievisse Adriaanse @@ -16,14 +16,20 @@ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -use strict; -use warnings; +use v5.36; use Config; use Getopt::Long; use File::Basename; use File::stat; use OpenBSD::PkgConfig; +use constant { + ONLY_I => 1, + ONLY_l => 2, + ONLY_L => 4, + ONLY_OTHER => 8 +}; + my @PKGPATH = qw(/usr/lib/pkgconfig /usr/local/lib/pkgconfig /usr/local/share/pkgconfig @@ -70,7 +76,7 @@ defined $ENV{PKG_CONFIG_DEBUG_SPEW} ? $mode{debug} = 1 : $mode{debug} = 0; if ($logfile) { open my $L, ">>" , $logfile or die; - print $L beautify_list($0, @ARGV), "\n"; + say $L beautify_list($0, @ARGV); close $L; } @@ -87,7 +93,7 @@ GetOptions( 'debug' => \$mode{debug}, 'help' => \&help, #does not return 'usage' => \&help, #does not return 'list-all' => \$mode{list}, - 'version' => sub { print "$version\n" ; exit(0);} , + 'version' => sub { say $version ; exit(0);} , 'errors-to-stdout' => sub { $mode{estdout} = 1}, 'print-errors' => sub { $mode{printerr} = 1}, 'silence-errors' => sub { $mode{printerr} = 0}, @@ -97,13 +103,13 @@ GetOptions( 'debug' => \$mode{debug}, 'print-requires' => \$mode{printrequires}, 'print-requires-private' => \$mode{printrequiresprivate}, - 'cflags' => sub { $mode{cflags} = 3}, - 'cflags-only-I' => sub { $mode{cflags} |= 1}, - 'cflags-only-other' => sub { $mode{cflags} |= 2}, - 'libs' => sub { $mode{libs} = 7}, - 'libs-only-l' => sub { $mode{libs} |= 1}, - 'libs-only-L' => sub { $mode{libs} |= 2}, - 'libs-only-other' => sub { $mode{libs} |= 4}, + 'cflags' => sub { $mode{cflags} = ONLY_I|ONLY_OTHER}, + 'cflags-only-I' => sub { $mode{cflags} |= ONLY_I}, + 'cflags-only-other' => sub { $mode{cflags} |= ONLY_OTHER}, + 'libs' => sub { $mode{libs} = ONLY_L|ONLY_l|ONLY_OTHER}, + 'libs-only-l' => sub { $mode{libs} |= ONLY_l}, + 'libs-only-L' => sub { $mode{libs} |= ONLY_L}, + 'libs-only-other' => sub { $mode{libs} |= ONLY_OTHER}, 'exists' => sub { $mode{exists} = 1} , 'validate' => sub { $mode{validate} = 1}, 'static' => sub { $mode{static} = 1}, @@ -164,29 +170,29 @@ my $top_config = []; # When we got here we're supposed to have had at least one # package as argument. -if (!@ARGV){ +if (!@ARGV) { say_error("No package name(s) specified."); exit 1; } # Return the next module from @ARGV, if it turns out to be a comma separated # module list, take the first one and put the rest back to the front. -sub get_next_module +sub get_next_module() { my $module = shift @ARGV; my $m; if ($module =~ m/,/) { my @ms = split(/,/, $module); $m = shift @ms; - unshift(@ARGV, @ms) if (scalar(@ms) > 0); + unshift(@ARGV, @ms) if @ms != 0; } else { - return $module; + return $module; } return $m; } -while (@ARGV){ +while (@ARGV) { my $p = get_next_module(); my $op = undef; my $v = undef; @@ -267,16 +273,15 @@ if ($mode{static}){ if ($mode{cflags} || $mode{libs} || $mode{variable}) { push @vlist, do_cflags($dep_cfg_list) if $mode{cflags}; push @vlist, do_libs($dep_cfg_list) if $mode{libs}; - print join(' ', @vlist), "\n" if $rc == 0; + say join(' ', @vlist) if $rc == 0; } exit $rc; ########################################################################### -sub handle_config +sub handle_config($p, $op, $v, $list) { - my ($p, $op, $v, $list) = @_; my $cfg = cache_find_config($p); unshift @$list, $p if defined $cfg; @@ -294,8 +299,7 @@ sub handle_config } } - my $get_props = sub { - my $property = shift; + my $get_props = sub($property) { my $pkg; # See if there's anything in the environment that we need to @@ -316,7 +320,7 @@ sub handle_config my $deps = $cfg->get_property($property, $variables); return unless defined $deps; for my $dep (@$deps) { - if ($dep =~ m/^(.*?)\s*([<=>]+)\s*([\d\.]+|[\d\.]+[\w]*[\d]+)$/) { + if ($dep =~ m/^(.*?)\s*([<=>]+)\s*([\d\.]+|[\d\.]+\w*\d+)$/) { handle_config($1, $2, $3, $list); } else { handle_config($dep, undef, undef, $list); @@ -339,10 +343,8 @@ sub handle_config # look for the .pc file in each of the PKGPATH elements. Return the path or # undef if it's not there -sub pathresolve +sub pathresolve($p) { - my ($p) = @_; - if ($allow_uninstalled && $p !~ m/\-uninstalled$/) { for my $d (@PKGPATH) { my $f = "$d/$p-uninstalled.pc"; @@ -362,13 +364,11 @@ sub pathresolve return undef; } -sub get_config +sub get_config($f) { - my ($f) = @_; - my $cfg; eval { - $cfg = OpenBSD::PkgConfig->read_file($f); + $cfg = OpenBSD::PkgConfig->read_file($f); }; if (!$@) { return validate_config($f, $cfg); @@ -378,10 +378,8 @@ sub get_config return undef; } -sub cache_find_config +sub cache_find_config($name) { - my $name = shift; - say_debug("processing $name"); if (exists $configs{$name}) { @@ -392,9 +390,8 @@ sub cache_find_config } # Required elements for a valid .pc file: Name, Description, Version -sub validate_config +sub validate_config($f, $cfg) { - my ($f, $cfg) = @_; my @required_elems = ('Name', 'Description', 'Version'); # Check if we're dealing with an empty file, but don't error out just @@ -417,7 +414,7 @@ sub validate_config # pkg-config won't install a pkg-config.pc file itself, but it may be # listed as a dependency in other files. so prime the cache with self. -sub setup_self +sub setup_self() { my $pkg_pc = OpenBSD::PkgConfig->new; $pkg_pc->add_property('Version', $version); @@ -427,10 +424,8 @@ sub setup_self $configs{'pkg-config'} = $pkg_pc; } -sub find_config +sub find_config($p) { - my ($p) = @_; - # Differentiate between getting a full path and just the module name. my $f = ($p =~ m/\.pc$/ ? $p : pathresolve($p)); @@ -441,11 +436,8 @@ sub find_config return undef; } -sub stringize +sub stringize($list, $sep = ',') { - my $list = shift; - my $sep = shift || ','; - if (defined $list) { return join($sep, @$list) } else { @@ -454,10 +446,8 @@ sub stringize } #if the variable option is set, pull out the named variable -sub do_variable +sub do_variable($p, $v) { - my ($p, $v) = @_; - my $cfg = cache_find_config($p); if (defined $cfg) { @@ -472,20 +462,18 @@ sub do_variable #if the modversion or print-provides options are set, #pull out the compiler flags -sub do_modversion +sub do_modversion($p) { - my ($p) = @_; - my $cfg = cache_find_config($p); if (defined $cfg) { my $value = $cfg->get_property('Version', $variables); if (defined $value) { if (defined($mode{printprovides})){ - print "$p = " . stringize($value) . "\n"; + say "$p = " , stringize($value); return undef; } else { - print stringize($value), "\n"; + say stringize($value); return undef; } } @@ -494,32 +482,29 @@ sub do_modversion } #if the cflags option is set, pull out the compiler flags -sub do_cflags +sub do_cflags($list) { - my $list = shift; - my $cflags = []; for my $pkg (@$list) { my $l = $configs{$pkg}->get_property('Cflags', $variables); PATH: for my $path (@$l) { for my $sys_path (@sys_includes) { - next PATH if ($path =~ /${sys_path}\/*$/); + next PATH if $path =~ /\Q${sys_path}\E\/*$/; } push(@$cflags, $path); } } my $a = OpenBSD::PkgConfig->compress($cflags, - sub { - local $_ = shift; - if (($mode{cflags} & 1) && /^-I/ || - ($mode{cflags} & 2) && !/^-I/) { + sub($r) { + if (($mode{cflags} & ONLY_I) && $r =~ /^-I/ || + ($mode{cflags} & ONLY_OTHER) && $r !~ /^-I/) { return 1; } else { return 0; } }); - if (defined($a) && defined($variables->{pc_sysrootdir})){ + if (defined($variables->{pc_sysrootdir})){ $a =~ s/[\w]?-I/$&$variables->{pc_sysrootdir}/g; } @@ -527,10 +512,8 @@ sub do_cflags } #if the lib option is set, pull out the linker flags -sub do_libs +sub do_libs($list) { - my $list = shift; - my $libs = []; # In static mode, we have to make sure we discover the libs in dependency @@ -556,11 +539,10 @@ sub do_libs # Get the linker path directives (-L) and store it in $a. # $b will be the actual libraries. - my $a = OpenBSD::PkgConfig->compress($libs, - sub { - local $_ = shift; - if (($mode{libs} & 2) && /^-L/ || - ($mode{libs} & 4) && !/^-[lL]/) { + my $r = OpenBSD::PkgConfig->compress_list($libs, + sub($r) { + if (($mode{libs} & ONLY_L) && $r =~ /^-L/ || + ($mode{libs} & ONLY_OTHER) && $r !~ /^-[lL]/) { return 1; } else { return 0; @@ -568,22 +550,23 @@ sub do_libs }); if (defined($variables->{pc_sysrootdir})){ - $a =~ s/[\w]?-[lL]/$&$variables->{pc_sysrootdir}/g; + for my $i (@$r) { + $i =~ s/[\w]?-[lL]/$&$variables->{pc_sysrootdir}/; + } } - if ($mode{libs} & 1) { - my $b = OpenBSD::PkgConfig->rcompress($libs, - sub { shift =~ m/^-l/; }); - return ($a, $b); - } else { - return $a; + if ($mode{libs} & ONLY_l) { + push(@$r, OpenBSD::PkgConfig->rcompress($libs, + sub($l) { $l =~ m/^-l/; })); } + return @$r; } #list all packages -sub do_list +sub do_list() { my ($p, $x, $y, @files, $fname, $name); + my $error = 0; for my $p (@PKGPATH) { @@ -616,7 +599,7 @@ sub do_list return $error; } -sub help +sub help(@) { print < $y; return -1 if $x < $y; return 0 if (($x == $y) and ($eq == 1)); @@ -780,10 +759,8 @@ sub compare_numeric } # got a package meeting the requested specific version? -sub versionmatch +sub versionmatch($cfg, $op, $want) { - my ($cfg, $op, $want) = @_; - # can't possibly match if we can't find the file return 0 if !defined $cfg; @@ -802,9 +779,8 @@ sub versionmatch elsif ($op eq '<=') { return $value <= 0; } } -sub mismatch +sub mismatch($p, $cfg, $op, $v) { - my ($p, $cfg, $op, $v) = @_; my $name = stringize($cfg->get_property('Name'), ' '); my $version = stringize($cfg->get_property('Version')); my $url = stringize($cfg->get_property('URL')); @@ -813,9 +789,8 @@ sub mismatch say_warning("You may find new versions of $name at $url") if $url; } -sub simplify_and_reverse +sub simplify_and_reverse($reqlist) { - my $reqlist = shift; my $dejavu = {}; my $result = []; @@ -829,10 +804,8 @@ sub simplify_and_reverse } # retrieve and print Requires(.private) -sub print_requires +sub print_requires($p) { - my ($p) = @_; - my $cfg = cache_find_config($p); if (defined($cfg)) { @@ -848,7 +821,7 @@ sub print_requires } if (defined($value)) { - print "$_\n" for @$value; + say $_ for @$value; return undef; } } @@ -856,30 +829,28 @@ sub print_requires $rc = 1; } -sub beautify_list +sub beautify_list(@p) { - return join(' ', map {"[$_]"} @_); + return join(' ', map {"[$_]"} @p); } -sub say_debug +sub say_debug($msg) { - say_msg(shift) if $mode{debug}; + say_msg($msg) if $mode{debug}; } -sub say_error +sub say_error($msg) { - say_msg(shift) if $mode{printerr} + say_msg($msg) if $mode{printerr} } -sub say_warning +sub say_warning($msg) { - say_msg(shift); + say_msg($msg); } -sub say_msg +sub say_msg($str) { - my $str = shift; - # If --errors-to-stdout was given, close STDERR (to be safe), # then dup the output to STDOUT and delete the key from %mode so we # won't keep checking it. STDERR stays dup'ed. @@ -889,5 +860,5 @@ sub say_msg delete($mode{estdout}); } - print STDERR $str, "\n"; + say STDERR $str; } diff --git a/usr.bin/printf/printf.c b/usr.bin/printf/printf.c index ecbf4ba59..fc6a8b35c 100644 --- a/usr.bin/printf/printf.c +++ b/usr.bin/printf/printf.c @@ -47,10 +47,10 @@ static int getint(void); static long getlong(void); static unsigned long getulong(void); static char *getstr(void); -static char *mklong(const char *, int); +static char *mklong(const char *, int); static void check_conversion(const char *, const char *); static void __dead usage(void); - + static int rval; static char **gargv; @@ -100,9 +100,9 @@ main(int argc, char *argv[]) /* * Basic algorithm is to scan the format string for conversion * specifications -- once one is found, find out if the field - * width or precision is a '*'; if it is, gather up value. + * width or precision is a '*'; if it is, gather up value. * Note, format strings are reused as necessary to use up the - * provided arguments, arguments of zero/null string are + * provided arguments, arguments of zero/null string are * provided to use up the format string. */ @@ -228,7 +228,7 @@ main(int argc, char *argv[]) /* - * Print SysV echo(1) style escape string + * Print SysV echo(1) style escape string * Halts processing string and returns 1 if a \c escape is encountered. */ static int @@ -240,10 +240,10 @@ print_escape_str(const char *str) while (*str) { if (*str == '\\') { str++; - /* + /* * %b string octal constants are not like those in C. - * They start with a \0, and are followed by 0, 1, 2, - * or 3 octal digits. + * They start with a \0, and are followed by 0, 1, 2, + * or 3 octal digits. */ if (*str == '0') { str++; @@ -256,7 +256,7 @@ print_escape_str(const char *str) } else if (*str == 'c') { return 1; } else { - str--; + str--; str += print_escape(str); } } else { @@ -269,7 +269,7 @@ print_escape_str(const char *str) } /* - * Print "standard" escape characters + * Print "standard" escape characters */ static int print_escape(const char *str) @@ -368,7 +368,7 @@ mklong(const char *str, int ch) { static char *copy; static int copysize; - int len; + int len; len = strlen(str) + 2; if (copysize < len) { @@ -388,7 +388,7 @@ mklong(const char *str, int ch) copy[len - 3] = 'l'; copy[len - 2] = ch; copy[len - 1] = '\0'; - return (copy); + return (copy); } static int diff --git a/usr.bin/tmux/popup.c b/usr.bin/tmux/popup.c index ad2e1c8cd..cafbc168c 100644 --- a/usr.bin/tmux/popup.c +++ b/usr.bin/tmux/popup.c @@ -1,4 +1,4 @@ -/* $OpenBSD: popup.c,v 1.48 2023/03/15 19:23:22 nicm Exp $ */ +/* $OpenBSD: popup.c,v 1.49 2023/06/08 11:17:28 nicm Exp $ */ /* * Copyright (c) 2020 Nicholas Marriott @@ -637,7 +637,7 @@ int popup_display(int flags, enum box_lines lines, struct cmdq_item *item, u_int px, u_int py, u_int sx, u_int sy, struct environ *env, const char *shellcmd, int argc, char **argv, const char *cwd, const char *title, struct client *c, - struct session *s, const char* style, const char* border_style, + struct session *s, const char *style, const char *border_style, popup_close_cb cb, void *arg) { struct popup_data *pd; diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index ff4512e97..9f7a761f9 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1198 2023/05/08 10:03:39 tb Exp $ */ +/* $OpenBSD: tmux.h,v 1.1199 2023/06/08 11:17:29 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -2890,8 +2890,8 @@ void screen_write_hline(struct screen_write_ctx *, u_int, int, int); void screen_write_vline(struct screen_write_ctx *, u_int, int, int); void screen_write_menu(struct screen_write_ctx *, struct menu *, int, const struct grid_cell *); -void screen_write_box(struct screen_write_ctx *, u_int, u_int, int, - const struct grid_cell *, const char *); +void screen_write_box(struct screen_write_ctx *, u_int, u_int, + enum box_lines, const struct grid_cell *, const char *); void screen_write_preview(struct screen_write_ctx *, struct screen *, u_int, u_int); void screen_write_backspace(struct screen_write_ctx *); @@ -3316,11 +3316,11 @@ int menu_key_cb(struct client *, void *, struct key_event *); #define POPUP_INTERNAL 0x4 typedef void (*popup_close_cb)(int, void *); typedef void (*popup_finish_edit_cb)(char *, size_t, void *); -int popup_display(int, int, struct cmdq_item *, u_int, u_int, - u_int, u_int, struct environ *, const char *, int, char **, - const char *, const char *, struct client *, - struct session *, const char *, const char *, - popup_close_cb, void *); +int popup_display(int, enum box_lines, struct cmdq_item *, u_int, + u_int, u_int, u_int, struct environ *, const char *, int, + char **, const char *, const char *, struct client *, + struct session *, const char *, const char *, + popup_close_cb, void *); int popup_editor(struct client *, const char *, size_t, popup_finish_edit_cb, void *); diff --git a/usr.sbin/fw_update/fw_update.sh b/usr.sbin/fw_update/fw_update.sh index af14359b9..dce81286b 100644 --- a/usr.sbin/fw_update/fw_update.sh +++ b/usr.sbin/fw_update/fw_update.sh @@ -222,7 +222,7 @@ lock_db() { $|=1; lock_db(0); - + say $$; sleep; EOL diff --git a/usr.sbin/fw_update/patterns.c b/usr.sbin/fw_update/patterns.c index f5f30c4be..4287d38fe 100644 --- a/usr.sbin/fw_update/patterns.c +++ b/usr.sbin/fw_update/patterns.c @@ -90,7 +90,7 @@ main(void) printf("%s\n", "acx"); printf("%s\n", "amdgpu"); print_devices("amdgpu", amdgpu_devices, nitems(amdgpu_devices)); - printf("%s\n", "amdgpu ^vga*vendor \"ATI\", unknown product"); + printf("%s\n", "amdgpu ^vga*vendor \"ATI\", unknown product"); printf("%s\n", "amdgpu ^vendor \"ATI\", unknown product*class display"); printf("%s\n", "apple-boot ^cpu0*Apple"); printf("%s\n", "arm64-qcom-dtb ^qcgpio0"); diff --git a/usr.sbin/hostapd/parse.y b/usr.sbin/hostapd/parse.y index c368f3a62..5eb17f59a 100644 --- a/usr.sbin/hostapd/parse.y +++ b/usr.sbin/hostapd/parse.y @@ -1542,7 +1542,7 @@ top: if (next == '=') return (NE); lungetc(next); - break; + break; case '<': next = lgetc(0); if (next == '=') diff --git a/usr.sbin/httpd/patterns.c b/usr.sbin/httpd/patterns.c index c6910785b..f8986c9f9 100644 --- a/usr.sbin/httpd/patterns.c +++ b/usr.sbin/httpd/patterns.c @@ -446,7 +446,7 @@ match(struct match_state *ms, const char *s, const char *p) match(ms, s + 1, ep + 1)) != NULL) s = res; else { - /* + /* * else return * match(ms, s, ep + 1); */ diff --git a/usr.sbin/installboot/i386_installboot.c b/usr.sbin/installboot/i386_installboot.c index 110530186..277ef92f8 100644 --- a/usr.sbin/installboot/i386_installboot.c +++ b/usr.sbin/installboot/i386_installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i386_installboot.c,v 1.45 2023/04/26 18:04:21 kn Exp $ */ +/* $OpenBSD: i386_installboot.c,v 1.46 2023/06/11 14:00:04 krw Exp $ */ /* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* @@ -196,7 +196,7 @@ write_bootblocks(int devfd, char *dev, struct disklabel *dl) { struct stat sb; u_int8_t *secbuf; - u_int start = 0; + u_int start; /* Write patched proto bootblock(s) into the superblock. */ if (fstat(devfd, &sb) == -1) @@ -214,18 +214,15 @@ write_bootblocks(int devfd, char *dev, struct disklabel *dl) } /* - * Find OpenBSD partition. Floppies are special, getting an - * everything-in-one /boot starting at sector 0. + * Find bootstrap sector. */ - if (dl->d_type != DTYPE_FLOPPY) { - start = findopenbsd(devfd, dl); - if (start == (u_int)-1) - errx(1, "no OpenBSD partition"); - } - - if (verbose) + start = findopenbsd(devfd, dl); + if (verbose) { + if (start == 0) + fprintf(stderr, "no MBR, "); fprintf(stderr, "%s will be written at sector %u\n", stage1, start); + } if (start + (blksize / dl->d_secsize) > BOOTBIOS_MAXSEC) warnx("%s extends beyond sector %u. OpenBSD might not boot.", @@ -437,6 +434,12 @@ rmdir: exit(1); } +/* + * a) For media w/o an MBR use sector 0. + * b) For media with an MBR and an OpenBSD (A6) partition use the first + * sector of the OpenBSD partition. + * c) For media with an MBR and no OpenBSD partition error out. + */ u_int findopenbsd(int devfd, struct disklabel *dl) { @@ -453,7 +456,7 @@ again: if (verbose) fprintf(stderr, "Traversed more than %d Extended Boot " "Records (EBRs)\n", DOS_MAXEBR); - return ((u_int)-1); + goto done; } if (verbose) @@ -469,9 +472,12 @@ again: bcopy(secbuf, &mbr, sizeof(mbr)); free(secbuf); - if (mbr.dmbr_sign != DOSMBR_SIGNATURE) + if (mbr.dmbr_sign != DOSMBR_SIGNATURE) { + if (mbroff == DOSBBSECTOR) + return 0; errx(1, "invalid boot record signature (0x%04X) @ sector %u", mbr.dmbr_sign, mbroff); + } nextebr = 0; for (i = 0; i < NDOSPART; i++) { @@ -505,7 +511,8 @@ again: goto again; } - return ((u_int)-1); + done: + errx(1, "no OpenBSD partition"); } /* diff --git a/usr.sbin/pkg_add/OpenBSD/Delete.pm b/usr.sbin/pkg_add/OpenBSD/Delete.pm index 7ec46df78..05c4ca4c6 100644 --- a/usr.sbin/pkg_add/OpenBSD/Delete.pm +++ b/usr.sbin/pkg_add/OpenBSD/Delete.pm @@ -705,7 +705,7 @@ sub copy_old_stuff { my ($self, $plist, $state) = @_; - OpenBSD::PackingElement::Comment->add($plist, + OpenBSD::PackingElement::Comment->add($plist, "\@".$self->keyword." ".$self->stringize); } diff --git a/usr.sbin/pkg_add/OpenBSD/Getopt.pod b/usr.sbin/pkg_add/OpenBSD/Getopt.pod index a4f17fbbc..cde9d239e 100644 --- a/usr.sbin/pkg_add/OpenBSD/Getopt.pod +++ b/usr.sbin/pkg_add/OpenBSD/Getopt.pod @@ -8,7 +8,7 @@ OpenBSD::Getopt - Process single-characters switches use OpenBSD::Getopt; - my $h = { 'v' => + my $h = { 'v' => sub() { ++$opt_v; }; diff --git a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm index a1bd6989d..169c6edd6 100644 --- a/usr.sbin/pkg_add/OpenBSD/PackingElement.pm +++ b/usr.sbin/pkg_add/OpenBSD/PackingElement.pm @@ -2201,7 +2201,7 @@ sub new { my ($class, $fullpkgpath) = @_; my ($dir, @mandatory) = split(/\,/, $fullpkgpath); - my $o = + my $o = bless {dir => $dir, mandatory => {map {($_, 1)} @mandatory}, }, $class; diff --git a/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm b/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm index 94134a0f3..bff1a65fa 100644 --- a/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm +++ b/usr.sbin/pkg_add/OpenBSD/SharedLibs.pm @@ -66,7 +66,7 @@ sub register_libname($self, $name, $pkgname) if ($lib->is_valid) { $self->register_library($lib, $pkgname); } else { - $self->{state}->errsay("Bogus library in #1: #2", $pkgname, + $self->{state}->errsay("Bogus library in #1: #2", $pkgname, $name) unless $pkgname eq 'system'; } diff --git a/usr.sbin/pkg_add/OpenBSD/Ustar.pm b/usr.sbin/pkg_add/OpenBSD/Ustar.pm index bf1454c2a..e1f486031 100644 --- a/usr.sbin/pkg_add/OpenBSD/Ustar.pm +++ b/usr.sbin/pkg_add/OpenBSD/Ustar.pm @@ -901,7 +901,7 @@ sub write_contents my $filename = $self->{realname}; my $size = $self->{size}; my $out = $arc->{fh}; - open my $fh, "<", $filename or + open my $fh, "<", $filename or $self->_fatal("Can't read file #1: #2", $filename, $!); my $buffer; diff --git a/usr.sbin/relayd/ca.c b/usr.sbin/relayd/ca.c index dcb9d205e..2c5f7b6ce 100644 --- a/usr.sbin/relayd/ca.c +++ b/usr.sbin/relayd/ca.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ca.c,v 1.41 2023/03/26 18:04:47 tb Exp $ */ +/* $OpenBSD: ca.c,v 1.42 2023/06/11 10:30:26 op Exp $ */ /* * Copyright (c) 2014 Reyk Floeter @@ -95,7 +95,7 @@ hash_x509(X509 *cert, char *hash, size_t hashlen) fatalx("%s: X509_pubkey_digest failed", __func__); if (hashlen < 2 * dlen + sizeof("SHA256:")) - fatalx("%s: hash buffer to small", __func__); + fatalx("%s: hash buffer too small", __func__); off = strlcpy(hash, "SHA256:", hashlen); diff --git a/usr.sbin/sensorsd/sensorsd.c b/usr.sbin/sensorsd/sensorsd.c index bf04206a6..5d79e8251 100644 --- a/usr.sbin/sensorsd/sensorsd.c +++ b/usr.sbin/sensorsd/sensorsd.c @@ -731,7 +731,7 @@ parse_config_sdlim(struct sdlim_t *sdlim, char *cf) char *buf = NULL, *ebuf = NULL; char node[48]; char *cfa[2]; - + cfa[0] = cf; cfa[1] = NULL; diff --git a/usr.sbin/smtpd/ssl.c b/usr.sbin/smtpd/ssl.c index a7b8521dc..9802ee144 100644 --- a/usr.sbin/smtpd/ssl.c +++ b/usr.sbin/smtpd/ssl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssl.c,v 1.98 2022/02/18 16:57:36 millert Exp $ */ +/* $OpenBSD: ssl.c,v 1.99 2023/06/11 10:30:10 op Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard @@ -257,7 +257,7 @@ hash_x509(X509 *cert, char *hash, size_t hashlen) fatalx("%s: X509_pubkey_digest failed", __func__); if (hashlen < 2 * dlen + sizeof("SHA256:")) - fatalx("%s: hash buffer to small", __func__); + fatalx("%s: hash buffer too small", __func__); off = strlcpy(hash, "SHA256:", hashlen); diff --git a/usr.sbin/tcpdump/addrtoname.c b/usr.sbin/tcpdump/addrtoname.c index 9b19c3d23..f7bb92231 100644 --- a/usr.sbin/tcpdump/addrtoname.c +++ b/usr.sbin/tcpdump/addrtoname.c @@ -320,7 +320,7 @@ lookup_emem(const u_char *ep) } /* - * Find the hash node that corresponds to the bytestring 'bs' + * Find the hash node that corresponds to the bytestring 'bs' * with length 'nlen' */ @@ -470,7 +470,7 @@ linkaddr_string(const u_char *ep, const int len) if (len == 6) /* XXX not totally correct... */ return etheraddr_string(ep); - + tp = lookup_bytestring(ep, len); if (tp->e_name) return (tp->e_name); diff --git a/usr.sbin/tcpdump/bootp.h b/usr.sbin/tcpdump/bootp.h index 0f4e41642..432ce76f6 100644 --- a/usr.sbin/tcpdump/bootp.h +++ b/usr.sbin/tcpdump/bootp.h @@ -60,7 +60,6 @@ struct bootp { */ #define VM_RFC1048 { 99, 130, 83, 99 } - /* * RFC1048 tag values used to specify what information is being supplied in diff --git a/usr.sbin/tcpdump/decnet.h b/usr.sbin/tcpdump/decnet.h index 6c23f3bcd..4f64c54f1 100644 --- a/usr.sbin/tcpdump/decnet.h +++ b/usr.sbin/tcpdump/decnet.h @@ -243,7 +243,7 @@ union controlmsg /* Macros for decoding routing-info fields */ #define RI_COST(x) ((x)&0777) #define RI_HOPS(x) (((x)>>10)&037) - + /* * NSP protocol fields and values. */ diff --git a/usr.sbin/tcpdump/ethertype.h b/usr.sbin/tcpdump/ethertype.h index 6b9c899d4..8e6e1e654 100644 --- a/usr.sbin/tcpdump/ethertype.h +++ b/usr.sbin/tcpdump/ethertype.h @@ -139,7 +139,7 @@ #define ETHERTYPE_LOOPBACK 0x9000 #endif #ifndef ETHERTYPE_VMAN -#define ETHERTYPE_VMAN 0x9100 /* Extreme VMAN Protocol */ +#define ETHERTYPE_VMAN 0x9100 /* Extreme VMAN Protocol */ #endif #ifndef ETHERTYPE_ISO #define ETHERTYPE_ISO 0xfefe /* nonstandard - used in Cisco HDLC encapsulation */ diff --git a/usr.sbin/tcpdump/gtp.h b/usr.sbin/tcpdump/gtp.h index 629a61ccc..4699b4120 100644 --- a/usr.sbin/tcpdump/gtp.h +++ b/usr.sbin/tcpdump/gtp.h @@ -350,7 +350,7 @@ #define GTPV1_TLV_PDU_NUMBERS 175 #define GTPV1_TLV_BSSGP_CAUSE 176 #define GTPV1_TLV_REQUIRED_MBMS_BEARER_CAP 177 -#define GTPV1_TLV_RIM_ROUTING_ADDRESS_DISC 178 +#define GTPV1_TLV_RIM_ROUTING_ADDRESS_DISC 178 #define GTPV1_TLV_LIST_OF_SETUP_PFCS 179 #define GTPV1_TLV_PS_HANDOVER_XID_PARAMETERS 180 #define GTPV1_TLV_MS_INFO_CHANGE_REPORTING 181 diff --git a/usr.sbin/tcpdump/ike.h b/usr.sbin/tcpdump/ike.h index 9ba5ae365..7491b8255 100644 --- a/usr.sbin/tcpdump/ike.h +++ b/usr.sbin/tcpdump/ike.h @@ -201,7 +201,7 @@ "CP", /* 47 */ \ "EAP", /* 48 */ \ } - + /* Exchange types */ #define EXCHANGE_NONE 0 @@ -412,7 +412,7 @@ static struct tok ipsec_attr_encap[] = { }; /* - * IKE mode config. + * IKE mode config. */ #define IKE_CFG_ATTRIBUTE_TYPE_INITIALIZER \ @@ -475,7 +475,7 @@ static u_int16_t min_priv_payload_lengths[] = { 0, 0, ISAKMP_NAT_D_SZ, ISAKMP_NAT_OA_SZ }; -static const struct vendor_id +static const struct vendor_id { size_t len; char vid[16]; diff --git a/usr.sbin/tcpdump/install-sh b/usr.sbin/tcpdump/install-sh index 20161fb04..529704caf 100644 --- a/usr.sbin/tcpdump/install-sh +++ b/usr.sbin/tcpdump/install-sh @@ -117,7 +117,7 @@ fi if [ x"$dir_arg" != x ]; then dst=$src src="" - + if [ -d $dst ]; then instcmd=: else @@ -126,7 +126,7 @@ if [ x"$dir_arg" != x ]; then else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad +# might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] @@ -136,7 +136,7 @@ else echo "install: $src does not exist" exit 1 fi - + if [ x"$dst" = x ] then echo "install: no destination specified" @@ -203,17 +203,17 @@ else # If we're going to rename the final executable, determine the name now. - if [ x"$transformarg" = x ] + if [ x"$transformarg" = x ] then dstfile=`basename $dst` else - dstfile=`basename $dst $transformbasename | + dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename - if [ x"$dstfile" = x ] + if [ x"$dstfile" = x ] then dstfile=`basename $dst` else @@ -244,7 +244,7 @@ else # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile + $doit $mvcmd $dsttmp $dstdir/$dstfile fi && diff --git a/usr.sbin/tcpdump/ipx.h b/usr.sbin/tcpdump/ipx.h index 4851b8ee6..570924ef5 100644 --- a/usr.sbin/tcpdump/ipx.h +++ b/usr.sbin/tcpdump/ipx.h @@ -1,7 +1,7 @@ /* $OpenBSD: ipx.h,v 1.7 2007/10/07 16:41:05 deraadt Exp $ */ /* - * IPX protocol formats + * IPX protocol formats * * @(#) $Id: ipx.h,v 1.7 2007/10/07 16:41:05 deraadt Exp $ */ diff --git a/usr.sbin/tcpdump/l2tp.h b/usr.sbin/tcpdump/l2tp.h index d0df50a57..b46d88dfa 100644 --- a/usr.sbin/tcpdump/l2tp.h +++ b/usr.sbin/tcpdump/l2tp.h @@ -63,17 +63,17 @@ struct l2tp_avp_vec { const char *name; - void (*print)(const u_char *, u_int); + void (*print)(const u_char *, u_int); }; - + struct l2tp_call_errors { u_short reserved; u_int crc_errs; - u_int framing_errs; - u_int hardware_overruns; + u_int framing_errs; + u_int hardware_overruns; u_int buffer_overruns; - u_int timeout_errs; - u_int alignment_errs; + u_int timeout_errs; + u_int alignment_errs; }; struct l2tp_accm { diff --git a/usr.sbin/tcpdump/makemib b/usr.sbin/tcpdump/makemib index 023209b62..041704198 100644 --- a/usr.sbin/tcpdump/makemib +++ b/usr.sbin/tcpdump/makemib @@ -37,7 +37,7 @@ # This script needs to be run by "gawk" (GNU awk). "nawk" will work, but # dump will get a recursion error if you process LARGE mibs. While it would # by farily easy to rewrite this not to use recursion (and also easy to -# eliminate use of gsub and functions to use classic "awk"), you have to +# eliminate use of gsub and functions to use classic "awk"), you have to # order the structure declarations in defined-first order for the compiler # not to barf; too bad tsort doesn't take arguments. # @@ -47,7 +47,7 @@ cat << EOF * This file was generated by tcpdump/makemib on `date` * You probably don't want to edit this by hand! * - * struct mib somename = { desc, oid-octet, type, child-pointer, next-pointer + * struct mib somename = { desc, oid-octet, type, child-pointer, next-pointer }; */ @@ -108,7 +108,7 @@ $1 == "::=" && holddesc != "none" && NF == 5 { holddesc="none" } -# +# # End of the road - output the data. # diff --git a/usr.sbin/tcpdump/nameser.h b/usr.sbin/tcpdump/nameser.h index ddb5e065c..0af9aed2f 100644 --- a/usr.sbin/tcpdump/nameser.h +++ b/usr.sbin/tcpdump/nameser.h @@ -30,14 +30,14 @@ * @(#)nameser.h 8.2 (Berkeley) 2/16/94 * - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * + * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies, and that * the name of Digital Equipment Corporation not be used in advertising or * publicity pertaining to distribution of the document or software without * specific, written prior permission. - * + * * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT @@ -226,7 +226,7 @@ typedef struct { */ #define INDIR_MASK 0xc0 /* 11.... */ #define EDNS0_MASK 0x40 /* 01.... */ -# define EDNS0_ELT_BITLABEL 0x01 +# define EDNS0_ELT_BITLABEL 0x01 /* * Structure for passing resource records around. diff --git a/usr.sbin/tcpdump/pf_print_state.c b/usr.sbin/tcpdump/pf_print_state.c index eac1764f9..cd761bcb1 100644 --- a/usr.sbin/tcpdump/pf_print_state.c +++ b/usr.sbin/tcpdump/pf_print_state.c @@ -192,14 +192,14 @@ print_state(struct pfsync_state *s, int opts) dst = &s->dst; sk = &s->key[PF_SK_STACK]; nk = &s->key[PF_SK_WIRE]; - if (s->proto == IPPROTO_ICMP || s->proto == IPPROTO_ICMPV6) + if (s->proto == IPPROTO_ICMP || s->proto == IPPROTO_ICMPV6) sk->port[0] = nk->port[0]; } else { src = &s->dst; dst = &s->src; sk = &s->key[PF_SK_WIRE]; nk = &s->key[PF_SK_STACK]; - if (s->proto == IPPROTO_ICMP || s->proto == IPPROTO_ICMPV6) + if (s->proto == IPPROTO_ICMP || s->proto == IPPROTO_ICMPV6) sk->port[1] = nk->port[1]; } /* Treat s->ifname as untrusted input. */ diff --git a/usr.sbin/tcpdump/pfctl_osfp.c b/usr.sbin/tcpdump/pfctl_osfp.c index dcd39e6fe..f4d63ae75 100644 --- a/usr.sbin/tcpdump/pfctl_osfp.c +++ b/usr.sbin/tcpdump/pfctl_osfp.c @@ -96,11 +96,11 @@ pfctl_file_fingerprints(int dev, int opts, const char *fp_filename) struct pf_osfp_ioctl fp; pfctl_flush_my_fingerprints(&classes); - + fd = priv_open_pfosfp(); if (fd < 0) return (1); - + if ((in = fdopen(fd, "r")) == NULL) { warn("%s", fp_filename); return (1); diff --git a/usr.sbin/tcpdump/print-802_11.c b/usr.sbin/tcpdump/print-802_11.c index b6b7ade0f..d3ad001cd 100644 --- a/usr.sbin/tcpdump/print-802_11.c +++ b/usr.sbin/tcpdump/print-802_11.c @@ -47,13 +47,13 @@ const char *ieee80211_ctl_subtype_name[] = { "reserved#6", "wrapper", "block ack request", - "block ack", - "ps poll", - "rts", - "cts", - "ack", - "cf-end", - "cf-end-ack", + "block ack", + "ps poll", + "rts", + "cts", + "ack", + "cf-end", + "cf-end-ack", }; const char *ieee80211_mgt_subtype_name[] = { @@ -740,14 +740,14 @@ ieee80211_print_vhtcaps(u_int8_t *data, u_int len) /* Supported MCS set. */ rxmcs = (data[4] | (data[5] << 8)); printf(",RxMCS"); - print_vht_mcsmap(rxmcs); + print_vht_mcsmap(rxmcs); max_lgi = ((data[6] | (data[7] << 8)) & IEEE80211_VHT_MAX_LGI_MBIT_S_MASK); if (max_lgi) printf(",Rx max LGI rate %uMbit/s", max_lgi); txmcs = (data[8] | (data[9] << 8)); printf(",TxMCS"); - print_vht_mcsmap(txmcs); + print_vht_mcsmap(txmcs); max_lgi = ((data[6] | (data[7] << 8)) & IEEE80211_VHT_MAX_LGI_MBIT_S_MASK); if (max_lgi) @@ -1318,7 +1318,7 @@ ieee80211_frame(struct ieee80211_frame *wh, u_int len) subtype == IEEE80211_FC0_SUBTYPE_BA) { u_int16_t ctrl; - t += 6; + t += 6; TCHECK2(*t, 2); /* BAR/BA control */ ctrl = t[0] | (t[1] << 8); if (ctrl & IEEE80211_BA_ACK_POLICY) diff --git a/usr.sbin/tcpdump/print-bgp.c b/usr.sbin/tcpdump/print-bgp.c index bac67ea1b..ab203a460 100644 --- a/usr.sbin/tcpdump/print-bgp.c +++ b/usr.sbin/tcpdump/print-bgp.c @@ -3,7 +3,7 @@ /* * Copyright (C) 1999 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -15,7 +15,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 @@ -309,7 +309,7 @@ static const char *bgpattr_nlri_safi[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 64-66: MPLS BGP RFC3107 */ "Tunnel", "VPLS", "MDT", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -475,7 +475,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len) * segment value in bytes, with the path segment length from the * message (counted in # of AS) */ - + if (len % 2) { printf(" invalid len"); break; @@ -600,7 +600,7 @@ bgp_attr_print(const struct bgp_attr *attr, const u_char *dat, int len) break; case BGPTYPE_ONLY_TO_CUSTOMER: if (len != 4) { - printf(" invalid len"); + printf(" invalid len"); break; } TCHECK2(p[0], 4); @@ -890,7 +890,7 @@ bgp_open_print(const u_char *dat, int length) i += BGP_OPT_SIZE + bgpopt.bgpopt_len; } /* ( */ - printf(")"); + printf(")"); return; trunc: printf("[|BGP]"); @@ -966,7 +966,7 @@ bgp_update_print(const u_char *dat, int length) newline = 1; /* ( */ - printf(")"); + printf(")"); i += aoff + alen; } @@ -1026,7 +1026,7 @@ bgp_notification_print(const u_char *dat, int length) * RFC 4486: optional maxprefix subtype of 7 bytes * may contain AFI, SAFI and MAXPREFIXES */ - if(bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_MAXPRFX && + if(bgpn.bgpn_minor == BGP_NOTIFY_MINOR_CEASE_MAXPRFX && length >= BGP_NOTIFICATION_SIZE + 7) { p = dat + BGP_NOTIFICATION_SIZE; @@ -1042,7 +1042,7 @@ bgp_notification_print(const u_char *dat, int length) /* * RFC 8203 describes a method to send a message intended - * for human consumption regarding the Administrative + * for human consumption regarding the Administrative * Shutdown or Reset event. This is called the "Shutdown * Communication". The communication is UTF-8 encoded * and may be no longer than 128 bytes. @@ -1064,7 +1064,7 @@ bgp_notification_print(const u_char *dat, int length) BGP_NOTIFICATION_SIZE)) goto trunc; TCHECK2(*(p+1), shutdown_comm_length); - + /* a proper shutdown communication */ printf(", Shutdown Communication [len %zu]: \"", shutdown_comm_length); @@ -1147,8 +1147,8 @@ bgp_print(const u_char *dat, int length) const u_char *ep; const u_char *start; const u_char marker[] = { - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, }; struct bgp bgp; u_int16_t hlen; diff --git a/usr.sbin/tcpdump/print-cdp.c b/usr.sbin/tcpdump/print-cdp.c index 311870d43..790e93a26 100644 --- a/usr.sbin/tcpdump/print-cdp.c +++ b/usr.sbin/tcpdump/print-cdp.c @@ -136,7 +136,7 @@ error: printf("[!cdp]"); } -#define CDP_CHECK_ACCESS(p, s) if ((endp - (p)) < (s)) return 1 +#define CDP_CHECK_ACCESS(p, s) if ((endp - (p)) < (s)) return 1 int cdp_print_addr(const u_char * p, int l) diff --git a/usr.sbin/tcpdump/print-ether.c b/usr.sbin/tcpdump/print-ether.c index 6a803061b..e12954d4e 100644 --- a/usr.sbin/tcpdump/print-ether.c +++ b/usr.sbin/tcpdump/print-ether.c @@ -271,7 +271,7 @@ recurse: p += 4; length -= 4; caplen -= 4; - if (ethertype > ETHERMTU) + if (ethertype > ETHERMTU) goto recurse; extracted_ethertype = 0; diff --git a/usr.sbin/tcpdump/print-gtp.c b/usr.sbin/tcpdump/print-gtp.c index c21db86fe..3d3fe038d 100644 --- a/usr.sbin/tcpdump/print-gtp.c +++ b/usr.sbin/tcpdump/print-gtp.c @@ -465,7 +465,7 @@ gtp_print_apn(const u_char *cp, u_int len) if (len > 0) printf("."); - } + } } /* Print string from array. */ @@ -528,7 +528,7 @@ gtp_v0_print(const u_char *cp, u_int length, u_short sport, u_short dport) printf("Unknown IP version %u", version); printf(" }"); - } else + } else gtp_decode_ie(cp, GTP_VERSION_0, len); return; @@ -542,7 +542,7 @@ gtp_v0_print_prime(const u_char *cp) { struct gtp_v0_prime_hdr *gph = (struct gtp_v0_prime_hdr *)cp; int len; - + /* Decode GTP prime header. */ TCHECK(*gph); cp += sizeof(*gph); @@ -734,7 +734,7 @@ gtp_v0_print_tv(const u_char *cp, u_int value) cp[0]); ielen = GTPV0_TV_PACKET_XFER_CMD_LENGTH; break; - + case GTPV0_TV_CHARGING_ID: /* 09.60 7.9.17 - Charging ID. */ @@ -960,7 +960,7 @@ gtp_v1_print(const u_char *cp, u_int length, u_short sport, u_short dport) printf(" [Unknown Header %u]", nexthdr); } - p += hlen - 1; + p += hlen - 1; nexthdr = (int)p[0]; p++; } @@ -1035,7 +1035,7 @@ void gtp_v1_print_prime(const u_char *cp, struct gtp_v1_prime_hdr *gph) { int len; - + /* Decode GTP prime header. */ TCHECK(*gph); cp += sizeof(struct gtp_v1_prime_hdr); diff --git a/usr.sbin/tcpdump/print-icmp.c b/usr.sbin/tcpdump/print-icmp.c index 73b8110f3..169948746 100644 --- a/usr.sbin/tcpdump/print-icmp.c +++ b/usr.sbin/tcpdump/print-icmp.c @@ -181,7 +181,7 @@ icmp_print(const u_char *bp, u_int length, const u_char *bp2) ipaddr_string(&ip->ip_dst)); TCHECK(dp->icmp_code); - if (qflag) + if (qflag) (void) snprintf(buf, sizeof buf, "%u %u", dp->icmp_type, dp->icmp_code); else switch (dp->icmp_type) { diff --git a/usr.sbin/tcpdump/print-icmp6.c b/usr.sbin/tcpdump/print-icmp6.c index 6869159d6..0da68d10d 100644 --- a/usr.sbin/tcpdump/print-icmp6.c +++ b/usr.sbin/tcpdump/print-icmp6.c @@ -830,7 +830,7 @@ mldv2_query_print(const u_char *bp, u_int len) } if (vflag) { printf(" [max resp delay=%d]", mrd); - } + } TCHECK2(bp[8], sizeof(struct in6_addr)); printf(" [gaddr %s", ip6addr_string(&bp[8])); diff --git a/usr.sbin/tcpdump/print-ike.c b/usr.sbin/tcpdump/print-ike.c index 3a687bc92..16b9daf46 100644 --- a/usr.sbin/tcpdump/print-ike.c +++ b/usr.sbin/tcpdump/print-ike.c @@ -680,7 +680,7 @@ ike_pl_notification_print (u_int8_t *buf, int len) printf("seq %u", ntohl(*seq)); } break; - + default: printf("%d (unknown)", type); @@ -830,7 +830,7 @@ void ike_pl_print (u_int8_t type, u_int8_t *buf, u_int8_t doi) { static const char *pltypes[] = IKE_PAYLOAD_TYPES_INITIALIZER; - static const char *plprivtypes[] = + static const char *plprivtypes[] = IKE_PRIVATE_PAYLOAD_TYPES_INITIALIZER; static const char *plv2types[] = IKEV2_PAYLOAD_TYPES_INITIALIZER; u_int8_t next_type; @@ -864,7 +864,7 @@ ike_pl_print (u_int8_t type, u_int8_t *buf, u_int8_t doi) this_len < min_priv_payload_lengths[type - PAYLOAD_PRIVATE_MIN]) || this_len == 0) goto pltrunc; - + if (buf + this_len > snapend) goto pltrunc; diff --git a/usr.sbin/tcpdump/print-ip.c b/usr.sbin/tcpdump/print-ip.c index e7eb0fa1b..aa02e65cd 100644 --- a/usr.sbin/tcpdump/print-ip.c +++ b/usr.sbin/tcpdump/print-ip.c @@ -205,7 +205,7 @@ igmp_print(const u_char *bp, u_int len, const u_char *bp2) u_int32_t sum = 0; int count; const u_short *sp = (u_short *)bp; - + for (count = len / 2; --count >= 0; ) sum += *sp++; if (len & 1) @@ -517,7 +517,7 @@ ip_print(const u_char *bp, u_int length) ipcomp_print(cp, len, (const u_char *)ip); break; -#ifndef IPPROTO_CARP +#ifndef IPPROTO_CARP #define IPPROTO_CARP 112 #endif case IPPROTO_CARP: @@ -536,7 +536,7 @@ ip_print(const u_char *bp, u_int length) } break; -#ifndef IPPROTO_PFSYNC +#ifndef IPPROTO_PFSYNC #define IPPROTO_PFSYNC 240 #endif case IPPROTO_PFSYNC: @@ -571,7 +571,7 @@ ip_print(const u_char *bp, u_int length) ntohs(ip->ip_id), len, (off & 0x1fff) * 8, (off & IP_MF)? "+" : ""); - } + } if (off & IP_DF) printf(" (DF)"); @@ -585,7 +585,7 @@ ip_print(const u_char *bp, u_int length) } if (ip->ip_tos & IPTOS_CE) { /* _C_ongestion experienced (ECN) */ - putchar('C'); + putchar('C'); } printf(")"); } diff --git a/usr.sbin/tcpdump/print-ip6.c b/usr.sbin/tcpdump/print-ip6.c index 80d3bd3a5..bb2c3b27b 100644 --- a/usr.sbin/tcpdump/print-ip6.c +++ b/usr.sbin/tcpdump/print-ip6.c @@ -201,7 +201,7 @@ ip6_print(const u_char *bp, u_int length) etherip_print(cp, snapend - cp, len); goto end; -#ifndef IPPROTO_CARP +#ifndef IPPROTO_CARP #define IPPROTO_CARP 112 #endif case IPPROTO_CARP: diff --git a/usr.sbin/tcpdump/print-ip6opts.c b/usr.sbin/tcpdump/print-ip6opts.c index ec710eae7..454a18a4b 100644 --- a/usr.sbin/tcpdump/print-ip6opts.c +++ b/usr.sbin/tcpdump/print-ip6opts.c @@ -3,7 +3,7 @@ /* * Copyright (C) 1998 WIDE Project. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -15,7 +15,7 @@ * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE PROJECT 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 diff --git a/usr.sbin/tcpdump/print-ipsec.c b/usr.sbin/tcpdump/print-ipsec.c index 755c84fb4..2f2874a96 100644 --- a/usr.sbin/tcpdump/print-ipsec.c +++ b/usr.sbin/tcpdump/print-ipsec.c @@ -21,9 +21,9 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. * * Format and print IPsec (ESP/AH) packets. - * By Tero Kivinen , Tero Mononen , + * By Tero Kivinen , Tero Mononen , * Tatu Ylonen and Timo J. Rinne - * in co-operation with SSH Communications Security, Espoo, Finland + * in co-operation with SSH Communications Security, Espoo, Finland */ #include @@ -202,7 +202,7 @@ esp_decrypt (const u_char *bp, u_int len, const u_char *bp2) printf(" (esp)"); } -void +void esp_print (const u_char *bp, u_int len, const u_char *bp2) { const struct esp_hdr *esp; @@ -266,11 +266,11 @@ ah_print (const u_char *bp, u_int len, const u_char *bp2) printf("truncated"); goto out; } - - switch (ah->ah_nxt_hdr) { + + switch (ah->ah_nxt_hdr) { case IPPROTO_IPIP: /* Tunnel Mode, IP-in-IP */ - ip_print(bp + pl_len, len - pl_len); + ip_print(bp + pl_len, len - pl_len); break; case IPPROTO_ICMP: /* From here and down; Transport mode */ @@ -284,22 +284,22 @@ ah_print (const u_char *bp, u_int len, const u_char *bp2) break; case IPPROTO_TCP: - tcp_print(bp + pl_len, len - pl_len, + tcp_print(bp + pl_len, len - pl_len, (const u_char *) ip); break; case IPPROTO_UDP: - udp_print(bp + pl_len, len - pl_len, + udp_print(bp + pl_len, len - pl_len, (const u_char *) ip); break; case IPPROTO_ESP: - esp_print(bp + pl_len, len - pl_len, + esp_print(bp + pl_len, len - pl_len, (const u_char *) ip); break; case IPPROTO_AH: - ah_print(bp + pl_len, len - pl_len, + ah_print(bp + pl_len, len - pl_len, (const u_char *) ip); break; @@ -325,7 +325,7 @@ ipcomp_print (const u_char *bp, u_int len, const u_char *bp2) const struct ip *ip; const struct ipcomp_hdr *ipc; u_int plen = len; - + ip = (const struct ip *)bp2; printf("ipcomp %s > %s", diff --git a/usr.sbin/tcpdump/print-isoclns.c b/usr.sbin/tcpdump/print-isoclns.c index ea2edac3d..b96fbc844 100644 --- a/usr.sbin/tcpdump/print-isoclns.c +++ b/usr.sbin/tcpdump/print-isoclns.c @@ -311,7 +311,7 @@ osi_cksum(const u_char *p, u_int len, } /* skip cksum bytes */ - p += 2; + p += 2; c1 += c0; c1 += c0; for (; p < ep; p++) { diff --git a/usr.sbin/tcpdump/print-l2tp.c b/usr.sbin/tcpdump/print-l2tp.c index c72c31e36..aae76ca1e 100644 --- a/usr.sbin/tcpdump/print-l2tp.c +++ b/usr.sbin/tcpdump/print-l2tp.c @@ -199,7 +199,7 @@ static char *l2tp_error_code_general[] = { /******************************/ /* generic print out routines */ /******************************/ -static void +static void print_string(const u_char *dat, u_int length) { int i; @@ -208,7 +208,7 @@ print_string(const u_char *dat, u_int length) } } -static void +static void print_octets(const u_char *dat, u_int length) { int i; @@ -247,9 +247,9 @@ l2tp_result_code_print(const u_char *dat, u_int length) { /* we just print out the result and error code number */ u_short *ptr = (u_short *)dat; - + if (length == 2) { /* result code */ - printf("%d", ntohs(*ptr)); + printf("%d", ntohs(*ptr)); } else if (length == 4) { /* result & error code */ printf("%d/%d", ntohs(*ptr), ntohs(*(ptr+1))); } else if (length > 4) { /* result & error code & msg */ @@ -324,7 +324,7 @@ l2tp_assnd_tun_id_print(const u_char *dat, u_int length) static void l2tp_recv_win_size_print(const u_char *dat, u_int length) { - print_short((u_short *)dat); + print_short((u_short *)dat); } static void @@ -341,7 +341,7 @@ l2tp_q931_cc_print(const u_char *dat, u_int length) if (length > 3) { printf(" "); print_string(dat+3, length-3); - } + } } static void @@ -541,7 +541,7 @@ l2tp_random_vector_print(const u_char *dat, u_int length) static void l2tp_private_grp_id_print(const u_char *dat, u_int length) { - print_string(dat, length); + print_string(dat, length); /* XXX print_octets is more appropriate?? */ } @@ -621,7 +621,7 @@ l2tp_print(const u_char *dat, u_int length) flag_t = flag_l = flag_s = flag_o = flag_p = FALSE; - if (length < 6 || snapend - dat < 6) { + if (length < 6 || snapend - dat < 6) { /* flag/ver, tunnel_id, session_id must be present for this packet to be properly decoded */ printf("%s", tstr); @@ -665,7 +665,7 @@ l2tp_print(const u_char *dat, u_int length) dat += 2; cnt += 2; - + if (flag_l) { TCHECK2(*dat, sizeof(val)); memcpy(&val, dat, sizeof(val)); diff --git a/usr.sbin/tcpdump/print-mobile.c b/usr.sbin/tcpdump/print-mobile.c index 98cd51122..a0443a1dc 100644 --- a/usr.sbin/tcpdump/print-mobile.c +++ b/usr.sbin/tcpdump/print-mobile.c @@ -79,7 +79,7 @@ mobile_print(const u_char *bp, u_int length) if (proto & OSRC_PRES) { osp=1; } - + if (osp) { printf("[S] "); if (vflag) @@ -100,21 +100,21 @@ mobile_print(const u_char *bp, u_int length) static u_int16_t mob_in_cksum(u_short *p, int len) { - u_int32_t sum = 0; + u_int32_t sum = 0; int nwords = len >> 1; - + while (nwords-- != 0) sum += *p++; - + if (len & 1) { union { u_int16_t w; - u_int32_t c[2]; + u_int32_t c[2]; } u; u.c[0] = *(u_char *)p; u.c[1] = 0; sum += u.w; - } + } /* end-around-carry */ sum = (sum >> 16) + (sum & 0xffff); diff --git a/usr.sbin/tcpdump/print-nfs.c b/usr.sbin/tcpdump/print-nfs.c index d49505781..074802cbf 100644 --- a/usr.sbin/tcpdump/print-nfs.c +++ b/usr.sbin/tcpdump/print-nfs.c @@ -168,7 +168,7 @@ static struct tok type2str[] = { * * Assume that a system that has INT64_FORMAT defined, has a 64-bit * integer datatype and can print it. - */ + */ #define UNSIGNED 0 #define SIGNED 1 @@ -812,7 +812,7 @@ xid_map_find(const struct rpc_msg *rp, const u_char *bp, u_int32_t *proc, int cmp; /* Start searching from where we last left off */ - i = xid_map_hint; + i = xid_map_hint; do { xmep = &xid_map[i]; cmp = 1; diff --git a/usr.sbin/tcpdump/print-ospf6.c b/usr.sbin/tcpdump/print-ospf6.c index 9465c1378..134d4baa6 100644 --- a/usr.sbin/tcpdump/print-ospf6.c +++ b/usr.sbin/tcpdump/print-ospf6.c @@ -228,7 +228,7 @@ ospf6_print_lsaprefix(const struct lsa_prefix *lsapp) } memset(&prefix, 0, sizeof(prefix)); memcpy(&prefix, lsapp->lsa_p_prefix, k * 4); - printf(" %s/%d", ip6addr_string(&prefix), + printf(" %s/%d", ip6addr_string(&prefix), lsapp->lsa_p_len); if (lsapp->lsa_p_opt) printf("(opt=%x)", lsapp->lsa_p_opt); diff --git a/usr.sbin/tcpdump/print-ppp.c b/usr.sbin/tcpdump/print-ppp.c index 15bf91a7a..c80a42490 100644 --- a/usr.sbin/tcpdump/print-ppp.c +++ b/usr.sbin/tcpdump/print-ppp.c @@ -157,7 +157,7 @@ static char *lcpconfopts[] = { "Auth-Prot", "Quality-Prot", "Magic-Number", - "unassigned (6)", + "unassigned (6)", "Prot-Field-Compr", "Add-Ctrl-Field-Compr", "FCS-Alternatives", @@ -192,7 +192,7 @@ static const char *chapcode[] = { "Challenge", "Response", "Success", - "Failure", + "Failure", }; /* PAP */ @@ -234,7 +234,7 @@ static const char *eapcode[] = { "Challenge", "Response", "Success", - "Failure", + "Failure", }; static const char *eaptype[] = { @@ -457,7 +457,7 @@ handle_lcp(const u_char *p, int l) case LCP_CONF_REJ: while (l > 0) { int optlen; - + optlen = print_lcp_config_options(p, l); if (optlen == -1) goto trunc; @@ -563,7 +563,7 @@ print_lcp_config_options(const u_char *p, int l) p += sizeof(proto); l -= sizeof(proto); - + type = *p; switch (type) { case 0x05: @@ -844,7 +844,7 @@ handle_pap(const u_char *p, int l) p += sizeof(x); l -= sizeof(x); - + printf(" Peer-Id="); for (i = 0; i < x; i++) { if (l == 0) @@ -863,7 +863,7 @@ handle_pap(const u_char *p, int l) p += sizeof(x); l -= sizeof(x); - + printf(" Passwd="); for (i = 0; i < x; i++) { if (l == 0) @@ -885,7 +885,7 @@ handle_pap(const u_char *p, int l) p += sizeof(x); l -= sizeof(x); - + printf(" Message="); for (i = 0; i < x; i++) { if (l == 0) @@ -938,7 +938,7 @@ handle_ipcp(const u_char *p, int l) case IPCP_CODE_CFG_REJ: while (l > 0) { int optlen; - + optlen = print_ipcp_config_options(p, l); if (optlen == -1) goto trunc; @@ -1074,7 +1074,7 @@ handle_ipv6cp(const u_char *p, int l) case IPV6CP_CODE_CFG_REJ: while (l > 0) { int optlen; - + optlen = print_ipv6cp_config_options(p, l); if (optlen == -1) goto trunc; @@ -1133,7 +1133,7 @@ print_ipv6cp_config_options(const u_char *p, int l) return (-1); printf("=%04x:%04x:%04x:%04x", EXTRACT_16BITS(p + 0), - EXTRACT_16BITS(p + 2), EXTRACT_16BITS(p + 4), + EXTRACT_16BITS(p + 2), EXTRACT_16BITS(p + 4), EXTRACT_16BITS(p + 6)); break; default: diff --git a/usr.sbin/tcpdump/print-radius.c b/usr.sbin/tcpdump/print-radius.c index 47887f871..4a72caec0 100644 --- a/usr.sbin/tcpdump/print-radius.c +++ b/usr.sbin/tcpdump/print-radius.c @@ -74,7 +74,7 @@ static struct radius_ctable radius_codes[] = { /* --------------------------------------------------------------- */ -#define MAX_VALUES 20 +#define MAX_VALUES 20 struct radius_atable { int code; @@ -88,7 +88,7 @@ struct radius_atable { /* the right way to do this is probably to read these values out * of the actual RADIUS dictionary; this would require the machine * running tcpdump to have that file installed, and it's not my - * program, so I'm not going to introduce new dependencies. Oh well. + * program, so I'm not going to introduce new dependencies. Oh well. */ static struct radius_atable radius_atts[] = { @@ -99,10 +99,10 @@ static struct radius_atable radius_atts[] = { { RADIUS_ATT_NAS_IP, RD_ADDRESS, "NAS-IP", { NULL } }, { RADIUS_ATT_NAS_PORT, RD_INT, "NAS-Pt", { NULL } }, -{ RADIUS_ATT_USER_SERVICE, RD_INT, "USvc", +{ RADIUS_ATT_USER_SERVICE, RD_INT, "USvc", { "", "Login", "Framed", "DB-Lgn", "DB-Frm", "Out", "Shell", NULL } }, -{ RADIUS_ATT_PROTOCOL, RD_INT, "FProt", +{ RADIUS_ATT_PROTOCOL, RD_INT, "FProt", { "", "PPP", "SLIP", NULL } }, { RADIUS_ATT_FRAMED_ADDRESS, RD_ADDRESS, "F-IP", { NULL } }, @@ -113,7 +113,7 @@ static struct radius_atable radius_atts[] = { { RADIUS_ATT_COMPRESSION, RD_INT, "F-Comp", { NULL } }, { RADIUS_ATT_LOGIN_HOST, RD_ADDRESS, "L-Hst", { NULL } }, -{ RADIUS_ATT_LOGIN_SERVICE, RD_INT, "L-Svc", +{ RADIUS_ATT_LOGIN_SERVICE, RD_INT, "L-Svc", { "", "Telnt", "Rlog", "Clear", "PortM", NULL } }, { RADIUS_ATT_LOGIN_TCP_PORT, RD_INT, "L-Pt", { NULL } }, @@ -133,7 +133,7 @@ static struct radius_atable radius_atts[] = { { RADIUS_ATT_CALLED_ID, RD_STRING, "Callee", { NULL } }, { RADIUS_ATT_CALLER_ID, RD_STRING, "Caller", { NULL } }, -{ RADIUS_ATT_STATUS_TYPE, RD_INT, "Stat", +{ RADIUS_ATT_STATUS_TYPE, RD_INT, "Stat", { "", "Start", "Stop", NULL } }, { -1, -1, NULL, { NULL } } @@ -142,9 +142,9 @@ static struct radius_atable radius_atts[] = { typedef void (*aselector)(int code, int len, const u_char *data); aselector atselector[] = { - r_print_hex, - r_print_int, - r_print_int, + r_print_hex, + r_print_int, + r_print_int, r_print_address, r_print_string, r_print_hex @@ -154,7 +154,7 @@ static void r_print_att(int code, int len, const u_char *data) { struct radius_atable *atp; int i; - for(atp = radius_atts; atp->code != -1; atp++) + for(atp = radius_atts; atp->code != -1; atp++) if(atp->code == code) break; @@ -162,7 +162,7 @@ static void r_print_att(int code, int len, const u_char *data) { if(vflag > 1) { printf(" %d =", code); atselector[RD_HEX](code, len, data); - } else + } else printf(" %d", code); return; @@ -173,7 +173,7 @@ static void r_print_att(int code, int len, const u_char *data) { if(atp->encoding == RD_INT && *atp->values) { u_int32_t k = ntohl((*(int *)data)); - for(i = 0; atp->values[i] != NULL; i++) + for(i = 0; atp->values[i] != NULL; i++) /* SHOOT ME */ ; if(k < i) { @@ -181,9 +181,9 @@ static void r_print_att(int code, int len, const u_char *data) { atp->values[k]); return; } - } - - atselector[atp->encoding](code, len, data); + } + + atselector[atp->encoding](code, len, data); } static void r_print_int(int code, int len, const u_char *data) { @@ -223,12 +223,12 @@ static void r_print_string(int code, int len, const u_char *data) { } static void r_print_hex(int code, int len, const u_char *data) { - int i; + int i; /* excuse me */ printf(" ["); - + for(i = 0; i < len; i++) printf("%02x", data[i]); @@ -248,7 +248,7 @@ void radius_print(const u_char *data, u_int len) { rhp = (struct radius_header *) data; if(rhp->code > DEFINED_OPCODES || - rhp->code < 1) + rhp->code < 1) printf("Code:%d id:%x [%d]", rhp->code, rhp->id, ntohs(rhp->len)); else @@ -281,7 +281,7 @@ void radius_print(const u_char *data, u_int len) { printf(" [|radius]"); return; } - + al -= 2; r_print_att(ac, al, pp); diff --git a/usr.sbin/tcpdump/print-snmp.c b/usr.sbin/tcpdump/print-snmp.c index 01c2f9957..fe62607ca 100644 --- a/usr.sbin/tcpdump/print-snmp.c +++ b/usr.sbin/tcpdump/print-snmp.c @@ -350,7 +350,7 @@ struct snmp3_sm { {3, "USM", snmp3_print_usmparams}, {0, NULL, NULL} }; - + /* * constants for ASN.1 decoding */ @@ -431,7 +431,7 @@ asn1_parse(const u_char *p, u_int len, struct be *elem) if (len == 0 && *p & ASN_BIT8) { if (truncated) printf("[|snmp]"); - else + else printf("[Xtagfield?]"); return -1; } @@ -1339,7 +1339,7 @@ snmp3_print(const u_char *np, u_int length) } length -= count; np += count; - + if (SNMP3_PRIV(authpriv) != 0) { printf("[encrypted PDU]"); return; diff --git a/usr.sbin/tcpdump/print-tcp.c b/usr.sbin/tcpdump/print-tcp.c index ec6053e73..39ea46c57 100644 --- a/usr.sbin/tcpdump/print-tcp.c +++ b/usr.sbin/tcpdump/print-tcp.c @@ -276,7 +276,7 @@ tcp_print(const u_char *bp, u_int length, const u_char *bp2) dport == NFS_PORT) { nfsreq_print((u_char *)tp + hlen + 4, len, bp2); return; - } else if ((u_char *)tp + 4 + + } else if ((u_char *)tp + 4 + sizeof(struct rpc_msg) <= snapend && sport == NFS_PORT) { nfsreply_print((u_char *)tp + hlen + 4, len, bp2); return; diff --git a/usr.sbin/tcpdump/print-timed.c b/usr.sbin/tcpdump/print-timed.c index 9e4803d62..75d21c9af 100644 --- a/usr.sbin/tcpdump/print-timed.c +++ b/usr.sbin/tcpdump/print-timed.c @@ -22,7 +22,7 @@ * * from tcpdump.org: * Header: /tcpdump/master/tcpdump/print-timed.c,v 1.1 2000/10/06 05:35:37 guy Exp - * + * */ #ifdef HAVE_CONFIG_H diff --git a/usr.sbin/tcpdump/print-udp.c b/usr.sbin/tcpdump/print-udp.c index 2ec86df5e..bc9c5b69d 100644 --- a/usr.sbin/tcpdump/print-udp.c +++ b/usr.sbin/tcpdump/print-udp.c @@ -409,7 +409,7 @@ udp_print(const u_char *bp, u_int length, const void *iph) if (usum == 0) { if (ipv == 4) printf("[no udp cksum] "); - else + else printf("[invalid udp cksum 0] "); } else { cksum += htons(IPPROTO_UDP); diff --git a/usr.sbin/tcpdump/radius.h b/usr.sbin/tcpdump/radius.h index 3007898e6..ec4e0486b 100644 --- a/usr.sbin/tcpdump/radius.h +++ b/usr.sbin/tcpdump/radius.h @@ -93,8 +93,8 @@ #define RADIUS_ATT_STATUS_TYPE 40 -/* the accounting attributes change way too much - * for me to want to hardcode them in. +/* the accounting attributes change way too much + * for me to want to hardcode them in. */ /* ------------------------------------------------------------ */ diff --git a/usr.sbin/tcpdump/smbutil.c b/usr.sbin/tcpdump/smbutil.c index 48eff294a..c77634069 100644 --- a/usr.sbin/tcpdump/smbutil.c +++ b/usr.sbin/tcpdump/smbutil.c @@ -567,7 +567,7 @@ const uchar *fdata(const uchar *buf, const char *fmt, const uchar *maxbuf) if (!depth && buf